Skip to content

Commit 8783383

Browse files
committed
Merge branch 'development'
2 parents d56f105 + 1834b50 commit 8783383

File tree

19 files changed

+462
-146
lines changed

19 files changed

+462
-146
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Checks
22

33
env:
4-
STARKNET_VERSION: "0.13.0"
5-
RPC_SPEC_VERSION: "0.6.0"
6-
DEVNET_SHA: "1bd447d"
4+
DEVNET_SHA: "c6ffb99"
75

86
on:
97
push:

docs/development.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ Below is the command you can use to do this, designed for compatibility with the
2424

2525
.. code-block:: bash
2626
27-
STARKNET_VERSION="0.13.0" RPC_SPEC_VERSION="0.6.0" \
2827
cargo install \
2928
--locked \
3029
--git https://github.com/0xSpaceShard/starknet-devnet-rs.git \
31-
--rev 1bd447d
30+
--rev c6ffb99
3231
3332
If you choose to install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-rs>`_ using a different method, please make sure to add the executable ``starknet-devnet`` to your ``PATH`` environment variable.
3433

docs/guide/account_and_client.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ To enable auto estimation, set the ``auto_estimate`` parameter to ``True``.
2828
It is strongly discouraged to use automatic fee estimation in production code as it may lead to an unexpectedly high fee.
2929

3030
The returned estimated fee is multiplied by ``1.5`` for V1 and V2 transactions to mitigate fluctuations in price.
31-
For V3 transactions, ``max_amount`` and ``max_price_per_unit`` are scaled by ``1.1`` and ``1.5`` respectively.
32-
31+
For V3 transactions, ``max_amount`` and ``max_price_per_unit`` are scaled by ``1.5`` and ``1.5`` respectively.
3332

3433
.. note::
3534
It is possible to configure the value by which the estimated fee is multiplied,

docs/migration_guide.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
Migration guide
22
===============
33

4+
******************************
5+
0.21.0 (alpha) Migration guide
6+
******************************
7+
8+
Version 0.21.0 of **starknet.py** comes with support for RPC 0.7.0-rc2!
9+
10+
0.21.0 Targeted versions
11+
------------------------
12+
13+
- Starknet - `0.13.1 <https://docs.starknet.io/documentation/starknet_versions/version_notes/#version0.13.1>`_
14+
- RPC - `0.7.0-rc2 <https://github.com/starkware-libs/starknet-specs/releases/tag/v0.7.0-rc2>`_
15+
16+
0.21.0 Breaking changes
17+
-----------------------
18+
19+
.. currentmodule:: starknet_py.net.client_models
20+
21+
1. :class:`PendingStarknetBlock` and :class:`PendingStarknetBlockWithTxHashes` field ``parent_block_hash`` has been renamed to ``parent_hash``
22+
2. :class:`StarknetBlockCommon` has been renamed to :class:`BlockHeader`
23+
3. :class:`StarknetBlock` and :class:`StarknetBlockWithTxHashes` fields ``parent_block_hash`` and ``root`` have been renamed to ``parent_hash`` and ``new_root`` respectively
24+
4. :class:`FunctionInvocation` field ``execution_resources`` has been renamed to ``computation_resources``
25+
26+
0.21.0 Minor changes
27+
-----------------------
28+
29+
1. :class:`EventsChunk` field ``events`` is now a list of :class:`EmittedEvent` instead of :class:`Event`
30+
2. :class:`ExecutionResources` has a new required field ``data_availability``
31+
3. :class:`InvokeTransactionTrace`, :class:`DeclareTransactionTrace` and :class:`DeployAccountTransactionTrace` have a new required field ``execution_resources``
32+
4. :class:`EstimatedFee` has new required fields ``data_gas_consumed`` and ``data_gas_price``
33+
5. :class:`StarknetBlock`, :class:`PendingStarknetBlock`, :class:`StarknetBlockWithTxHashes`, :class:`PendingStarknetBlockWithTxHashes` have new required fields ``l1_data_gas_price`` and ``l1_da_mode``
34+
435
**********************
536
0.20.0 Migration guide
637
**********************

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "starknet-py"
3-
version = "0.20.0"
3+
version = "0.21.0-alpha"
44
description = "A python SDK for Starknet"
55
authors = ["Tomasz Rejowski <tomasz.rejowski@swmansion.com>", "Jakub Ptak <jakub.ptak@swmansion.com>"]
66
include = ["starknet_py", "starknet_py/utils/crypto/libcrypto_c_exports.*"]

starknet_py/net/account/account.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Account(BaseAccount):
6060
ESTIMATED_FEE_MULTIPLIER: float = 1.5
6161
"""Amount by which each estimated fee is multiplied when using `auto_estimate`."""
6262

63-
ESTIMATED_AMOUNT_MULTIPLIER: float = 1.1
63+
ESTIMATED_AMOUNT_MULTIPLIER: float = 1.5
6464
ESTIMATED_UNIT_PRICE_MULTIPLIER: float = 1.5
6565
"""Values by which each estimated `max_amount` and `max_price_per_unit` are multiplied when using
6666
`auto_estimate`. Used only for V3 transactions"""
@@ -165,7 +165,10 @@ async def _get_resource_bounds(
165165

166166
l1_resource_bounds = ResourceBounds(
167167
max_amount=int(
168-
estimated_fee.gas_consumed * Account.ESTIMATED_AMOUNT_MULTIPLIER
168+
(estimated_fee.overall_fee / estimated_fee.gas_price)
169+
* Account.ESTIMATED_AMOUNT_MULTIPLIER
170+
if estimated_fee.gas_price != 0
171+
else 0
169172
),
170173
max_price_per_unit=int(
171174
estimated_fee.gas_price * Account.ESTIMATED_UNIT_PRICE_MULTIPLIER

starknet_py/net/client_models.py

Lines changed: 103 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,32 @@ class Call:
3333
@dataclass
3434
class Event:
3535
"""
36-
Dataclass representing an event emitted by transaction.
36+
Dataclass representing a Starknet event.
3737
"""
3838

3939
from_address: int
4040
keys: List[int]
4141
data: List[int]
4242

4343

44+
@dataclass
45+
class EmittedEvent(Event):
46+
"""
47+
Dataclass representing an event emitted by transaction.
48+
"""
49+
50+
transaction_hash: int
51+
block_hash: Optional[int] = None
52+
block_number: Optional[int] = None
53+
54+
4455
@dataclass
4556
class EventsChunk:
4657
"""
4758
Dataclass representing events returned by FullNodeClient.get_events method.
4859
"""
4960

50-
events: List[Event]
61+
events: List[EmittedEvent]
5162
continuation_token: Optional[str] = None
5263

5364

@@ -131,6 +142,11 @@ class DAMode(Enum):
131142
L2 = 1
132143

133144

145+
class L1DAMode(Enum):
146+
BLOB = "BLOB"
147+
CALLDATA = "CALLDATA"
148+
149+
134150
class TransactionType(Enum):
135151
"""
136152
Enum representing transaction types.
@@ -347,23 +363,42 @@ class TransactionFinalityStatus(Enum):
347363

348364

349365
@dataclass
350-
class ExecutionResources:
366+
class DataResources:
351367
"""
352-
Dataclass representing the resources consumed by the transaction.
368+
Dataclass representing the data-availability resources of the transaction
369+
"""
370+
371+
l1_gas: int
372+
l1_data_gas: int
373+
374+
375+
@dataclass
376+
class ComputationResources:
377+
"""
378+
Dataclass representing the resources consumed by the VM.
353379
"""
354380

355381
# pylint: disable=too-many-instance-attributes
356382

357383
steps: int
358-
range_check_builtin_applications: Optional[int] = None
359-
pedersen_builtin_applications: Optional[int] = None
360-
poseidon_builtin_applications: Optional[int] = None
361-
ec_op_builtin_applications: Optional[int] = None
362-
ecdsa_builtin_applications: Optional[int] = None
363-
bitwise_builtin_applications: Optional[int] = None
364-
keccak_builtin_applications: Optional[int] = None
365-
memory_holes: Optional[int] = None
366-
segment_arena_builtin: Optional[int] = None
384+
memory_holes: Optional[int]
385+
range_check_builtin_applications: Optional[int]
386+
pedersen_builtin_applications: Optional[int]
387+
poseidon_builtin_applications: Optional[int]
388+
ec_op_builtin_applications: Optional[int]
389+
ecdsa_builtin_applications: Optional[int]
390+
bitwise_builtin_applications: Optional[int]
391+
keccak_builtin_applications: Optional[int]
392+
segment_arena_builtin: Optional[int]
393+
394+
395+
@dataclass
396+
class ExecutionResources(ComputationResources):
397+
"""
398+
Dataclass representing the resources consumed by the transaction, includes both computation and data.
399+
"""
400+
401+
data_availability: DataResources
367402

368403

369404
# TODO (#1219): split into PendingTransactionReceipt and TransactionReceipt
@@ -385,16 +420,21 @@ class TransactionReceipt:
385420
events: List[Event] = field(default_factory=list)
386421
messages_sent: List[L2toL1Message] = field(default_factory=list)
387422

388-
contract_address: Optional[int] = None
389-
390423
block_number: Optional[int] = None
391424
block_hash: Optional[int] = None
392425

393-
message_hash: Optional[int] = None # L1_HANDLER_TXN_RECEIPT-only
426+
contract_address: Optional[int] = None # DEPLOY_ACCOUNT_TXN_RECEIPT only
427+
message_hash: Optional[int] = None # L1_HANDLER_TXN_RECEIPT only
394428

395429
revert_reason: Optional[str] = None
396430

397431

432+
@dataclass
433+
class TransactionWithReceipt:
434+
transaction: Transaction
435+
receipt: TransactionReceipt
436+
437+
398438
@dataclass
399439
class SentTransactionResponse:
400440
"""
@@ -432,58 +472,68 @@ class BlockStatus(Enum):
432472
REJECTED = "REJECTED"
433473
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2"
434474
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1"
435-
PROVEN = "PROVEN"
436475

437476

438477
@dataclass
439-
class PendingStarknetBlock:
478+
class PendingBlockHeader:
479+
parent_hash: int
480+
timestamp: int
481+
sequencer_address: int
482+
l1_gas_price: ResourcePrice
483+
l1_data_gas_price: ResourcePrice
484+
l1_da_mode: L1DAMode
485+
starknet_version: str
486+
487+
488+
@dataclass
489+
class PendingStarknetBlock(PendingBlockHeader):
440490
"""
441491
Dataclass representing a pending block on Starknet.
442492
"""
443493

444494
transactions: List[Transaction]
445-
parent_block_hash: int
446-
timestamp: int
447-
sequencer_address: int
448-
l1_gas_price: ResourcePrice
449-
starknet_version: str
450495

451496

452497
@dataclass
453-
class PendingStarknetBlockWithTxHashes:
498+
class PendingStarknetBlockWithTxHashes(PendingBlockHeader):
454499
"""
455500
Dataclass representing a pending block on Starknet containing transaction hashes.
456501
"""
457502

458503
transactions: List[int]
459-
parent_block_hash: int
460-
timestamp: int
461-
sequencer_address: int
462-
l1_gas_price: ResourcePrice
463-
starknet_version: str
464504

465505

466506
@dataclass
467-
class StarknetBlockCommon:
507+
class PendingStarknetBlockWithReceipts(PendingBlockHeader):
508+
"""
509+
Dataclass representing a pending block on Starknet with txs and receipts result
510+
"""
511+
512+
transactions: List[TransactionWithReceipt]
513+
514+
515+
@dataclass
516+
class BlockHeader:
468517
"""
469518
Dataclass representing a block header.
470519
"""
471520

472-
# TODO (#1219): change that into composition
473521
# pylint: disable=too-many-instance-attributes
474522

475523
block_hash: int
476-
parent_block_hash: int
524+
parent_hash: int
477525
block_number: int
478-
root: int
526+
new_root: int
479527
timestamp: int
480528
sequencer_address: int
481529
l1_gas_price: ResourcePrice
530+
l1_data_gas_price: ResourcePrice
531+
l1_da_mode: L1DAMode
482532
starknet_version: str
483533

484534

485535
@dataclass
486-
class StarknetBlock(StarknetBlockCommon):
536+
class StarknetBlock(BlockHeader):
487537
"""
488538
Dataclass representing a block on Starknet.
489539
"""
@@ -493,7 +543,7 @@ class StarknetBlock(StarknetBlockCommon):
493543

494544

495545
@dataclass
496-
class StarknetBlockWithTxHashes(StarknetBlockCommon):
546+
class StarknetBlockWithTxHashes(BlockHeader):
497547
"""
498548
Dataclass representing a block on Starknet containing transaction hashes.
499549
"""
@@ -502,6 +552,16 @@ class StarknetBlockWithTxHashes(StarknetBlockCommon):
502552
transactions: List[int]
503553

504554

555+
@dataclass
556+
class StarknetBlockWithReceipts(BlockHeader):
557+
"""
558+
Dataclass representing a block on Starknet with txs and receipts result
559+
"""
560+
561+
status: BlockStatus
562+
transactions: List[TransactionWithReceipt]
563+
564+
505565
@dataclass
506566
class BlockHashAndNumber:
507567
block_hash: int
@@ -544,9 +604,11 @@ class EstimatedFee:
544604
Dataclass representing estimated fee.
545605
"""
546606

547-
overall_fee: int
548-
gas_price: int
549607
gas_consumed: int
608+
gas_price: int
609+
data_gas_consumed: int
610+
data_gas_price: int
611+
overall_fee: int
550612
unit: PriceUnit
551613

552614

@@ -831,7 +893,7 @@ class FunctionInvocation:
831893
calls: List["FunctionInvocation"]
832894
events: List[OrderedEvent]
833895
messages: List[OrderedMessage]
834-
execution_resources: ExecutionResources
896+
computation_resources: ComputationResources
835897

836898

837899
@dataclass
@@ -850,6 +912,7 @@ class InvokeTransactionTrace:
850912
"""
851913

852914
execute_invocation: Union[FunctionInvocation, RevertedFunctionInvocation]
915+
execution_resources: ExecutionResources
853916
validate_invocation: Optional[FunctionInvocation] = None
854917
fee_transfer_invocation: Optional[FunctionInvocation] = None
855918
state_diff: Optional[StateDiff] = None
@@ -861,6 +924,7 @@ class DeclareTransactionTrace:
861924
Dataclass representing a transaction trace of an DECLARE transaction.
862925
"""
863926

927+
execution_resources: ExecutionResources
864928
validate_invocation: Optional[FunctionInvocation] = None
865929
fee_transfer_invocation: Optional[FunctionInvocation] = None
866930
state_diff: Optional[StateDiff] = None
@@ -873,6 +937,7 @@ class DeployAccountTransactionTrace:
873937
"""
874938

875939
constructor_invocation: FunctionInvocation
940+
execution_resources: ExecutionResources
876941
validate_invocation: Optional[FunctionInvocation] = None
877942
fee_transfer_invocation: Optional[FunctionInvocation] = None
878943
state_diff: Optional[StateDiff] = None

0 commit comments

Comments
 (0)