Skip to content

Commit c755e6b

Browse files
Support RPC 0.10.0 (#1683)
1 parent 75e6013 commit c755e6b

File tree

20 files changed

+104
-129
lines changed

20 files changed

+104
-129
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Checks
33
env:
44
CAIRO_LANG_VERSION: "0.13.1"
55
# TODO(#1611)
6-
DEVNET_SHA: e7ae78e59aaed289c081ab602328349d296ea4db # v0.5.1
6+
DEVNET_SHA: b761edef5b89a4faa7a972d7172a324cd646d612 # v0.7.0
77
LEDGER_APP_SHA: 768a7b47b0da681b28112342edd76e2c9b292c4e # v2.3.1
88
LEDGER_APP_DEV_TOOLS_SHA: a845b2ab0b5dd824133f73858f6f373edea85ec1bd828245bf50ce9700f33bcb # v4.5.0
99

docs/migration_guide.rst

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

4+
************************
5+
0.29.0-0 Migration guide
6+
************************
7+
8+
Version 0.29.0 of **starknet.py** comes with full support for RPC 0.10.0.
9+
10+
0.29.0 Targeted versions
11+
------------------------
12+
13+
- Starknet - `0.14.1 <https://docs.starknet.io/learn/cheatsheets/version-notes#starknet-v0-14-1-tbd>`_
14+
- RPC - `0.10.0 <https://github.com/starkware-libs/starknet-specs/releases/tag/v0.10.0>`_
15+
16+
.. py:currentmodule:: starknet_py.net.client_models
17+
18+
1. :class:`BlockHeader`: Added new fields: ``event_commitment``, ``transaction_commitment``, ``receipt_commitment``, ``state_diff_commitment``, ``event_count``, ``transaction_count``, ``state_diff_length``.
19+
420
****************************
521
0.29.0-rc.2 Migration guide
622
****************************

starknet_py/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class OutsideExecutionInterfaceID(IntEnum):
5353
V2 = 0x1D1144BB2138366FF28D8E9AB57456B1D332AC42196230C3A602003C89872
5454

5555

56-
EXPECTED_RPC_VERSION = "0.10.0-rc.1"
56+
EXPECTED_RPC_VERSION = "0.10.0"
5757

5858
ARGENT_V040_CLASS_HASH = (
5959
0x036078334509B514626504EDC9FB252328D1A240E4E948BEF8D0C08DFF45927F

starknet_py/net/client_models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,13 @@ class BlockHeader:
609609
l1_data_gas_price: ResourcePrice
610610
l1_da_mode: L1DAMode
611611
starknet_version: str
612+
event_commitment: int
613+
transaction_commitment: int
614+
receipt_commitment: int
615+
state_diff_commitment: int
616+
event_count: int
617+
transaction_count: int
618+
state_diff_length: int
612619

613620

614621
@dataclass
@@ -792,10 +799,10 @@ class StateDiff:
792799
storage_diffs: List[StorageDiffItem]
793800
deprecated_declared_classes: List[int]
794801
declared_classes: List[DeclaredContractHash]
795-
migrated_compiled_classes: List[MigratedClass]
796802
deployed_contracts: List[DeployedContract]
797803
replaced_classes: List[ReplacedClass]
798804
nonces: List[ContractsNonce]
805+
migrated_compiled_classes: Optional[List[MigratedClass]] = None
799806

800807

801808
@dataclass

starknet_py/net/schemas/rpc/block.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from marshmallow import fields, post_load
1+
from marshmallow import fields, post_load, validate
22

33
from starknet_py.net.client_models import (
44
BlockHashAndNumber,
@@ -78,6 +78,19 @@ class BlockHeaderSchema(Schema):
7878
)
7979
l1_da_mode = L1DAModeField(data_key="l1_da_mode", required=True)
8080
starknet_version = fields.String(data_key="starknet_version", required=True)
81+
event_commitment = Felt(data_key="event_commitment", required=True)
82+
transaction_commitment = Felt(data_key="transaction_commitment", required=True)
83+
receipt_commitment = Felt(data_key="receipt_commitment", required=True)
84+
state_diff_commitment = Felt(data_key="state_diff_commitment", required=True)
85+
event_count = fields.Integer(
86+
data_key="event_count", required=True, validate=validate.Range(min=0)
87+
)
88+
transaction_count = fields.Integer(
89+
data_key="transaction_count", required=True, validate=validate.Range(min=0)
90+
)
91+
state_diff_length = fields.Integer(
92+
data_key="state_diff_length", required=True, validate=validate.Range(min=0)
93+
)
8194

8295
@post_load
8396
def make_dataclass(self, data, **kwargs) -> BlockHeader:
@@ -170,7 +183,7 @@ class StateDiffSchema(Schema):
170183
migrated_compiled_classes = fields.List(
171184
fields.Nested(MigratedClassSchema()),
172185
data_key="migrated_compiled_classes",
173-
required=True,
186+
required=False,
174187
)
175188
deployed_contracts = fields.List(
176189
fields.Nested(DeployedContractSchema()),

starknet_py/tests/e2e/account/account_test.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from starknet_py.constants import ARGENT_V040_CLASS_HASH
99
from starknet_py.hash.address import compute_address
1010
from starknet_py.hash.casm_class_hash import compute_casm_class_hash
11-
from starknet_py.hash.hash_method import HashMethod
1211
from starknet_py.hash.selector import get_selector_from_name
1312
from starknet_py.net.account.account import Account
1413
from starknet_py.net.account.base_account import BaseAccount
@@ -164,7 +163,7 @@ async def test_sending_multicall(account, map_contract, key, val):
164163
async def test_rejection_reason_in_transaction_receipt(map_contract):
165164
with pytest.raises(
166165
ClientError,
167-
match="The transaction's resources don't cover validation or the minimal transaction fee",
166+
match="Client failed with code -1. Message: Resource bounds were not satisfied",
168167
):
169168
resource_bounds = ResourceBoundsMapping(
170169
l1_gas=ResourceBounds(max_amount=1, max_price_per_unit=1),
@@ -758,11 +757,7 @@ async def test_declare_v3_with_tip(account):
758757
tip = 12345
759758
signed_tx = await account.sign_declare_v3(
760759
compiled_contract["sierra"],
761-
compute_casm_class_hash(
762-
# TODO(#1659): Use blake
763-
create_casm_class(compiled_contract["casm"]),
764-
HashMethod.POSEIDON,
765-
),
760+
compute_casm_class_hash(create_casm_class(compiled_contract["casm"])),
766761
resource_bounds=MAX_RESOURCE_BOUNDS,
767762
tip=tip,
768763
)
@@ -785,11 +780,7 @@ async def test_declare_v3_auto_estimate_tip(
785780
mocked_block_with_txs.return_value = block_with_tips_mock
786781
signed_tx = await account.sign_declare_v3(
787782
compiled_contract["sierra"],
788-
compute_casm_class_hash(
789-
# TODO(#1659): Use blake
790-
create_casm_class(compiled_contract["casm"]),
791-
HashMethod.POSEIDON,
792-
),
783+
compute_casm_class_hash(create_casm_class(compiled_contract["casm"])),
793784
resource_bounds=MAX_RESOURCE_BOUNDS,
794785
auto_estimate_tip=True,
795786
)

starknet_py/tests/e2e/client/client_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,6 @@ async def test_state_update_declared_contract_hashes(
641641
assert class_hash in state_update.state_diff.deprecated_declared_classes
642642

643643

644-
@pytest.mark.skip(reason="TODO(#1659)")
645644
@pytest.mark.run_on_devnet
646645
@pytest.mark.asyncio
647646
async def test_state_update_storage_diffs(
@@ -659,7 +658,6 @@ async def test_state_update_storage_diffs(
659658
assert isinstance(state_update, BlockStateUpdate)
660659

661660

662-
@pytest.mark.skip(reason="TODO(#1659)")
663661
@pytest.mark.run_on_devnet
664662
@pytest.mark.asyncio
665663
async def test_state_update_deployed_contracts(
@@ -754,7 +752,6 @@ async def test_get_block_with_declare_v3(
754752

755753

756754
# TODO (#1219): add assert for replaced_class once it is fixed in devnet
757-
@pytest.mark.skip(reason="TODO(#1659)")
758755
@pytest.mark.asyncio
759756
async def test_get_new_state_update(
760757
client,

starknet_py/tests/e2e/client/full_node_test.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from starknet_py.contract import Contract
99
from starknet_py.hash.address import compute_address
1010
from starknet_py.hash.casm_class_hash import compute_casm_class_hash
11-
from starknet_py.hash.hash_method import HashMethod
1211
from starknet_py.hash.selector import get_selector_from_name
1312
from starknet_py.hash.storage import get_storage_var_address
1413
from starknet_py.net.account.account import Account
@@ -29,7 +28,6 @@
2928
from starknet_py.net.models import StarknetChainId
3029
from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS
3130
from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract
32-
from starknet_py.tests.e2e.utils import create_empty_block
3331

3432

3533
def _parse_event_name(event: str) -> str:
@@ -146,7 +144,6 @@ async def test_get_storage_at_incorrect_address_full_node_client(client):
146144
"--contract_dir=v1" in sys.argv,
147145
reason="Contract exists only in v2 directory",
148146
)
149-
@pytest.mark.skip("TODO(#1659)")
150147
@pytest.mark.run_on_devnet
151148
@pytest.mark.asyncio
152149
async def test_get_events_without_following_continuation_token(
@@ -176,7 +173,6 @@ async def test_get_events_without_following_continuation_token(
176173
"--contract_dir=v1" in sys.argv,
177174
reason="Contract exists only in v2 directory",
178175
)
179-
@pytest.mark.skip("TODO(#1659)")
180176
@pytest.mark.run_on_devnet
181177
@pytest.mark.asyncio
182178
async def test_get_events_follow_continuation_token(
@@ -233,7 +229,6 @@ async def test_get_events_nonexistent_event_name(
233229
"--contract_dir=v1" in sys.argv,
234230
reason="Contract exists only in v2 directory",
235231
)
236-
@pytest.mark.skip("TODO(#1659)")
237232
@pytest.mark.run_on_devnet
238233
@pytest.mark.asyncio
239234
async def test_get_events_with_two_events(
@@ -287,7 +282,6 @@ async def test_get_events_with_two_events(
287282
"--contract_dir=v1" in sys.argv,
288283
reason="Contract exists only in v2 directory",
289284
)
290-
@pytest.mark.skip("TODO(#1659)")
291285
@pytest.mark.run_on_devnet
292286
@pytest.mark.asyncio
293287
async def test_get_events_start_from_continuation_token(
@@ -319,7 +313,6 @@ async def test_get_events_start_from_continuation_token(
319313
"--contract_dir=v1" in sys.argv,
320314
reason="Contract exists only in v2 directory",
321315
)
322-
@pytest.mark.skip("TODO(#1659)")
323316
@pytest.mark.run_on_devnet
324317
@pytest.mark.asyncio
325318
async def test_get_events_no_params(
@@ -361,30 +354,30 @@ async def test_get_events_nonexistent_starting_block(
361354

362355

363356
@pytest.mark.asyncio
364-
async def test_get_block_number(client):
357+
async def test_get_block_number(client, devnet_client):
365358
# pylint: disable=protected-access
366-
await create_empty_block(client._client)
359+
await devnet_client.create_block()
367360

368361
block_number = await client.get_block_number()
369362

370363
# pylint: disable=protected-access
371-
await create_empty_block(client._client)
364+
await devnet_client.create_block()
372365

373366
new_block_number = await client.get_block_number()
374367
assert new_block_number == block_number + 1
375368

376369

377370
@pytest.mark.asyncio
378-
async def test_get_block_hash_and_number(client):
371+
async def test_get_block_hash_and_number(client, devnet_client):
379372
# pylint: disable=protected-access
380-
await create_empty_block(client._client)
373+
await devnet_client.create_block()
381374

382375
block_hash_and_number = await client.get_block_hash_and_number()
383376

384377
assert isinstance(block_hash_and_number, BlockHashAndNumber)
385378

386379
# pylint: disable=protected-access
387-
await create_empty_block(client._client)
380+
await devnet_client.create_block()
388381

389382
new_block_hash_and_number = await client.get_block_hash_and_number()
390383

@@ -476,7 +469,6 @@ async def test_simulate_transactions_skip_fee_charge(
476469
assert simulated_txs is not None
477470

478471

479-
@pytest.mark.skip(reason="TODO(#1659)")
480472
@pytest.mark.asyncio
481473
async def test_simulate_transactions_invoke(account, deployed_balance_contract):
482474
assert isinstance(deployed_balance_contract, Contract)
@@ -507,7 +499,6 @@ async def test_simulate_transactions_invoke(account, deployed_balance_contract):
507499
assert simulated_txs[0].transaction_trace.execution_resources is not None
508500

509501

510-
@pytest.mark.skip(reason="TODO(#1659)")
511502
@pytest.mark.asyncio
512503
async def test_simulate_transactions_two_txs(account, deployed_balance_contract):
513504
assert isinstance(deployed_balance_contract, Contract)
@@ -523,8 +514,7 @@ async def test_simulate_transactions_two_txs(account, deployed_balance_contract)
523514
)
524515

525516
casm_class = create_casm_class(contract["casm"])
526-
# TODO(#1659): Use blake
527-
casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON)
517+
casm_class_hash = compute_casm_class_hash(casm_class)
528518

529519
declare_v3_tx = await account.sign_declare_v3(
530520
compiled_contract=contract["sierra"],

starknet_py/tests/e2e/client/websocket_client_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def handler(new_heads_notification: NewHeadsNotification):
5252
)
5353

5454
new_block_hash = await devnet_client.create_block()
55+
await asyncio.sleep(5)
5556

5657
assert received_block is not None
5758
assert int(new_block_hash, 16) == received_block.block_hash
@@ -80,6 +81,7 @@ def handler(new_heads_notification: NewHeadsNotification):
8081
)
8182

8283
new_block_hash = await devnet_client.create_block()
84+
await asyncio.sleep(5)
8385

8486
assert received_block is not None
8587
assert int(new_block_hash, 16) == received_block.block_hash
@@ -131,7 +133,6 @@ async def test_unsubscribe_with_non_existing_id(
131133
assert unsubscribe_result is False
132134

133135

134-
@pytest.mark.skip(reason="TODO(#1659)")
135136
@pytest.mark.asyncio
136137
async def test_subscribe_events_with_finality_status(
137138
websocket_client: WebsocketClient,
@@ -174,7 +175,6 @@ def handler(new_events_notification: NewEventsNotification):
174175
assert unsubscribe_result is True
175176

176177

177-
@pytest.mark.skip(reason="TODO(#1659)")
178178
@pytest.mark.asyncio
179179
async def test_subscribe_new_transactions_with_finality_status(
180180
websocket_client: WebsocketClient,
@@ -214,7 +214,6 @@ def handler(new_tx_notification: NewTransactionNotification):
214214
assert unsubscribe_result is True
215215

216216

217-
@pytest.mark.skip(reason="TODO(#1659)")
218217
@pytest.mark.asyncio
219218
async def test_subscribe_new_transaction_receipts_with_finality_status(
220219
websocket_client: WebsocketClient,
@@ -254,7 +253,6 @@ def handler(new_tx_receipt: NewTransactionReceiptsNotification):
254253
assert unsubscribe_result is True
255254

256255

257-
@pytest.mark.skip("TODO(#1659)")
258256
@pytest.mark.asyncio
259257
async def test_subscribe_events_with_all_filters(
260258
client: FullNodeClient,

starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import pytest
22

3+
from starknet_py.devnet_utils.devnet_client import DevnetClient
34
from starknet_py.net.client import Client
4-
from starknet_py.net.client_models import PriceUnit
5-
from starknet_py.tests.e2e.fixtures.accounts import mint_token_on_devnet
65
from starknet_py.tests.e2e.utils import _get_random_private_key_unsafe
76

87

98
@pytest.mark.asyncio
109
async def test_deploy_prefunded_account(
1110
account_with_validate_deploy_class_hash: int,
1211
client: Client,
12+
devnet_client: DevnetClient,
1313
):
1414
# pylint: disable=import-outside-toplevel, too-many-locals, unused-variable
1515
full_node_client_fixture = client
@@ -47,8 +47,7 @@ async def test_deploy_prefunded_account(
4747
# docs: end
4848

4949
client = full_node_client_fixture
50-
client_url = client.url.replace("/rpc", "")
51-
await mint_token_on_devnet(client_url, address, int(1e24), PriceUnit.FRI.value)
50+
await devnet_client.mint(address, int(1e24))
5251

5352
# docs: start
5453

0 commit comments

Comments
 (0)