diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3c8c657f8..43230fc1b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -3,7 +3,7 @@ name: Checks env: CAIRO_LANG_VERSION: "0.13.1" # TODO(#1611) - DEVNET_SHA: e7ae78e59aaed289c081ab602328349d296ea4db # v0.5.1 + DEVNET_SHA: b761edef5b89a4faa7a972d7172a324cd646d612 # v0.7.0 LEDGER_APP_SHA: 768a7b47b0da681b28112342edd76e2c9b292c4e # v2.3.1 LEDGER_APP_DEV_TOOLS_SHA: a845b2ab0b5dd824133f73858f6f373edea85ec1bd828245bf50ce9700f33bcb # v4.5.0 diff --git a/docs/migration_guide.rst b/docs/migration_guide.rst index ab3f503c1..b5ed2b2fc 100644 --- a/docs/migration_guide.rst +++ b/docs/migration_guide.rst @@ -1,6 +1,22 @@ Migration guide =============== +************************ +0.29.0-0 Migration guide +************************ + +Version 0.29.0 of **starknet.py** comes with full support for RPC 0.10.0. + +0.29.0 Targeted versions +------------------------ + +- Starknet - `0.14.1 `_ +- RPC - `0.10.0 `_ + +.. py:currentmodule:: starknet_py.net.client_models + +1. :class:`BlockHeader`: Added new fields: ``event_commitment``, ``transaction_commitment``, ``receipt_commitment``, ``state_diff_commitment``, ``event_count``, ``transaction_count``, ``state_diff_length``. + **************************** 0.29.0-rc.2 Migration guide **************************** diff --git a/starknet_py/constants.py b/starknet_py/constants.py index 9de318e89..e6656606c 100644 --- a/starknet_py/constants.py +++ b/starknet_py/constants.py @@ -53,7 +53,7 @@ class OutsideExecutionInterfaceID(IntEnum): V2 = 0x1D1144BB2138366FF28D8E9AB57456B1D332AC42196230C3A602003C89872 -EXPECTED_RPC_VERSION = "0.10.0-rc.1" +EXPECTED_RPC_VERSION = "0.10.0" ARGENT_V040_CLASS_HASH = ( 0x036078334509B514626504EDC9FB252328D1A240E4E948BEF8D0C08DFF45927F diff --git a/starknet_py/net/client_models.py b/starknet_py/net/client_models.py index daa9f1b9f..f15d6413e 100644 --- a/starknet_py/net/client_models.py +++ b/starknet_py/net/client_models.py @@ -609,6 +609,13 @@ class BlockHeader: l1_data_gas_price: ResourcePrice l1_da_mode: L1DAMode starknet_version: str + event_commitment: int + transaction_commitment: int + receipt_commitment: int + state_diff_commitment: int + event_count: int + transaction_count: int + state_diff_length: int @dataclass @@ -792,10 +799,10 @@ class StateDiff: storage_diffs: List[StorageDiffItem] deprecated_declared_classes: List[int] declared_classes: List[DeclaredContractHash] - migrated_compiled_classes: List[MigratedClass] deployed_contracts: List[DeployedContract] replaced_classes: List[ReplacedClass] nonces: List[ContractsNonce] + migrated_compiled_classes: Optional[List[MigratedClass]] = None @dataclass diff --git a/starknet_py/net/schemas/rpc/block.py b/starknet_py/net/schemas/rpc/block.py index 8dd134e92..0cf29e23b 100644 --- a/starknet_py/net/schemas/rpc/block.py +++ b/starknet_py/net/schemas/rpc/block.py @@ -1,4 +1,4 @@ -from marshmallow import fields, post_load +from marshmallow import fields, post_load, validate from starknet_py.net.client_models import ( BlockHashAndNumber, @@ -78,6 +78,19 @@ class BlockHeaderSchema(Schema): ) l1_da_mode = L1DAModeField(data_key="l1_da_mode", required=True) starknet_version = fields.String(data_key="starknet_version", required=True) + event_commitment = Felt(data_key="event_commitment", required=True) + transaction_commitment = Felt(data_key="transaction_commitment", required=True) + receipt_commitment = Felt(data_key="receipt_commitment", required=True) + state_diff_commitment = Felt(data_key="state_diff_commitment", required=True) + event_count = fields.Integer( + data_key="event_count", required=True, validate=validate.Range(min=0) + ) + transaction_count = fields.Integer( + data_key="transaction_count", required=True, validate=validate.Range(min=0) + ) + state_diff_length = fields.Integer( + data_key="state_diff_length", required=True, validate=validate.Range(min=0) + ) @post_load def make_dataclass(self, data, **kwargs) -> BlockHeader: @@ -170,7 +183,7 @@ class StateDiffSchema(Schema): migrated_compiled_classes = fields.List( fields.Nested(MigratedClassSchema()), data_key="migrated_compiled_classes", - required=True, + required=False, ) deployed_contracts = fields.List( fields.Nested(DeployedContractSchema()), diff --git a/starknet_py/tests/e2e/account/account_test.py b/starknet_py/tests/e2e/account/account_test.py index b07f9b60b..1e019fc60 100644 --- a/starknet_py/tests/e2e/account/account_test.py +++ b/starknet_py/tests/e2e/account/account_test.py @@ -8,7 +8,6 @@ from starknet_py.constants import ARGENT_V040_CLASS_HASH from starknet_py.hash.address import compute_address from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.hash.selector import get_selector_from_name from starknet_py.net.account.account import Account from starknet_py.net.account.base_account import BaseAccount @@ -164,7 +163,7 @@ async def test_sending_multicall(account, map_contract, key, val): async def test_rejection_reason_in_transaction_receipt(map_contract): with pytest.raises( ClientError, - match="The transaction's resources don't cover validation or the minimal transaction fee", + match="Client failed with code -1. Message: Resource bounds were not satisfied", ): resource_bounds = ResourceBoundsMapping( l1_gas=ResourceBounds(max_amount=1, max_price_per_unit=1), @@ -758,11 +757,7 @@ async def test_declare_v3_with_tip(account): tip = 12345 signed_tx = await account.sign_declare_v3( compiled_contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(compiled_contract["casm"])), resource_bounds=MAX_RESOURCE_BOUNDS, tip=tip, ) @@ -785,11 +780,7 @@ async def test_declare_v3_auto_estimate_tip( mocked_block_with_txs.return_value = block_with_tips_mock signed_tx = await account.sign_declare_v3( compiled_contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(compiled_contract["casm"])), resource_bounds=MAX_RESOURCE_BOUNDS, auto_estimate_tip=True, ) diff --git a/starknet_py/tests/e2e/client/client_test.py b/starknet_py/tests/e2e/client/client_test.py index e5b0f5f0c..e725f2732 100644 --- a/starknet_py/tests/e2e/client/client_test.py +++ b/starknet_py/tests/e2e/client/client_test.py @@ -641,7 +641,6 @@ async def test_state_update_declared_contract_hashes( assert class_hash in state_update.state_diff.deprecated_declared_classes -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_state_update_storage_diffs( @@ -659,7 +658,6 @@ async def test_state_update_storage_diffs( assert isinstance(state_update, BlockStateUpdate) -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_state_update_deployed_contracts( @@ -754,7 +752,6 @@ async def test_get_block_with_declare_v3( # TODO (#1219): add assert for replaced_class once it is fixed in devnet -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_get_new_state_update( client, diff --git a/starknet_py/tests/e2e/client/full_node_test.py b/starknet_py/tests/e2e/client/full_node_test.py index 44e71f7ef..d1631590f 100644 --- a/starknet_py/tests/e2e/client/full_node_test.py +++ b/starknet_py/tests/e2e/client/full_node_test.py @@ -8,7 +8,6 @@ from starknet_py.contract import Contract from starknet_py.hash.address import compute_address from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.hash.selector import get_selector_from_name from starknet_py.hash.storage import get_storage_var_address from starknet_py.net.account.account import Account @@ -29,7 +28,6 @@ from starknet_py.net.models import StarknetChainId from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract -from starknet_py.tests.e2e.utils import create_empty_block def _parse_event_name(event: str) -> str: @@ -146,7 +144,6 @@ async def test_get_storage_at_incorrect_address_full_node_client(client): "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_without_following_continuation_token( @@ -176,7 +173,6 @@ async def test_get_events_without_following_continuation_token( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_follow_continuation_token( @@ -233,7 +229,6 @@ async def test_get_events_nonexistent_event_name( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_with_two_events( @@ -287,7 +282,6 @@ async def test_get_events_with_two_events( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_start_from_continuation_token( @@ -319,7 +313,6 @@ async def test_get_events_start_from_continuation_token( "--contract_dir=v1" in sys.argv, reason="Contract exists only in v2 directory", ) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.run_on_devnet @pytest.mark.asyncio async def test_get_events_no_params( @@ -361,30 +354,30 @@ async def test_get_events_nonexistent_starting_block( @pytest.mark.asyncio -async def test_get_block_number(client): +async def test_get_block_number(client, devnet_client): # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() block_number = await client.get_block_number() # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() new_block_number = await client.get_block_number() assert new_block_number == block_number + 1 @pytest.mark.asyncio -async def test_get_block_hash_and_number(client): +async def test_get_block_hash_and_number(client, devnet_client): # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() block_hash_and_number = await client.get_block_hash_and_number() assert isinstance(block_hash_and_number, BlockHashAndNumber) # pylint: disable=protected-access - await create_empty_block(client._client) + await devnet_client.create_block() new_block_hash_and_number = await client.get_block_hash_and_number() @@ -476,7 +469,6 @@ async def test_simulate_transactions_skip_fee_charge( assert simulated_txs is not None -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_simulate_transactions_invoke(account, deployed_balance_contract): assert isinstance(deployed_balance_contract, Contract) @@ -507,7 +499,6 @@ async def test_simulate_transactions_invoke(account, deployed_balance_contract): assert simulated_txs[0].transaction_trace.execution_resources is not None -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_simulate_transactions_two_txs(account, deployed_balance_contract): assert isinstance(deployed_balance_contract, Contract) @@ -523,8 +514,7 @@ async def test_simulate_transactions_two_txs(account, deployed_balance_contract) ) casm_class = create_casm_class(contract["casm"]) - # TODO(#1659): Use blake - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) declare_v3_tx = await account.sign_declare_v3( compiled_contract=contract["sierra"], diff --git a/starknet_py/tests/e2e/client/websocket_client_test.py b/starknet_py/tests/e2e/client/websocket_client_test.py index 328cc78e5..a926ccbc2 100644 --- a/starknet_py/tests/e2e/client/websocket_client_test.py +++ b/starknet_py/tests/e2e/client/websocket_client_test.py @@ -52,6 +52,7 @@ def handler(new_heads_notification: NewHeadsNotification): ) new_block_hash = await devnet_client.create_block() + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash @@ -80,6 +81,7 @@ def handler(new_heads_notification: NewHeadsNotification): ) new_block_hash = await devnet_client.create_block() + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash @@ -131,7 +133,6 @@ async def test_unsubscribe_with_non_existing_id( assert unsubscribe_result is False -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events_with_finality_status( websocket_client: WebsocketClient, @@ -174,7 +175,6 @@ def handler(new_events_notification: NewEventsNotification): assert unsubscribe_result is True -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transactions_with_finality_status( websocket_client: WebsocketClient, @@ -214,7 +214,6 @@ def handler(new_tx_notification: NewTransactionNotification): assert unsubscribe_result is True -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transaction_receipts_with_finality_status( websocket_client: WebsocketClient, @@ -254,7 +253,6 @@ def handler(new_tx_receipt: NewTransactionReceiptsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events_with_all_filters( client: FullNodeClient, diff --git a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py index 6e9324ac5..2260f5f40 100644 --- a/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py +++ b/starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py @@ -1,8 +1,7 @@ import pytest +from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.net.client import Client -from starknet_py.net.client_models import PriceUnit -from starknet_py.tests.e2e.fixtures.accounts import mint_token_on_devnet from starknet_py.tests.e2e.utils import _get_random_private_key_unsafe @@ -10,6 +9,7 @@ async def test_deploy_prefunded_account( account_with_validate_deploy_class_hash: int, client: Client, + devnet_client: DevnetClient, ): # pylint: disable=import-outside-toplevel, too-many-locals, unused-variable full_node_client_fixture = client @@ -47,8 +47,7 @@ async def test_deploy_prefunded_account( # docs: end client = full_node_client_fixture - client_url = client.url.replace("/rpc", "") - await mint_token_on_devnet(client_url, address, int(1e24), PriceUnit.FRI.value) + await devnet_client.mint(address, int(1e24)) # docs: start diff --git a/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py b/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py index 3ed913820..624d92299 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_full_node_client.py @@ -42,7 +42,6 @@ async def test_get_block(client, block_with_declare_hash): # docs-end: get_block -@pytest.mark.skip(reason="TODO(#1659)") @pytest.mark.asyncio async def test_get_state_update( client, declare_transaction_hash diff --git a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py index 3fea01785..b524cbb90 100644 --- a/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py +++ b/starknet_py/tests/e2e/docs/code_examples/test_websocket_client.py @@ -74,7 +74,7 @@ def handler(new_heads_notification: NewHeadsNotification): # ... # docs-end: subscribe_new_heads new_block_hash = await devnet_client.create_block() - + await asyncio.sleep(5) assert received_block is not None assert int(new_block_hash, 16) == received_block.block_hash # docs-start: subscribe_new_heads @@ -85,7 +85,6 @@ def handler(new_heads_notification: NewHeadsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_events( websocket_client: WebsocketClient, @@ -139,7 +138,6 @@ def handler(new_events_notification: NewEventsNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_transaction_status( websocket_client: WebsocketClient, @@ -204,7 +202,6 @@ def handler(transaction_status_notification: TransactionStatusNotification): assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_subscribe_new_transaction_receipts( websocket_client: WebsocketClient, @@ -268,7 +265,6 @@ def handler( assert unsubscribe_result is True -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_on_chain_reorg( websocket_client: WebsocketClient, diff --git a/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py b/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py index 148669a46..cf3bece38 100644 --- a/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py +++ b/starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py @@ -2,7 +2,6 @@ import pytest -from starknet_py.hash.hash_method import HashMethod from starknet_py.net.client_models import SierraContractClass from starknet_py.net.udc_deployer.deployer import _get_random_salt from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS @@ -31,9 +30,8 @@ async def test_cairo1_contract( # contract_compiled_casm is a string containing the content of the starknet-sierra-compile (.casm file) casm_class = create_casm_class(contract_compiled_casm) - # TODO(#1659): Use blake # Compute Casm class hash - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) # docs: end assert casm_class_hash == compiled_class_hash diff --git a/starknet_py/tests/e2e/fixtures/accounts.py b/starknet_py/tests/e2e/fixtures/accounts.py index 6a258420a..03d1bca36 100644 --- a/starknet_py/tests/e2e/fixtures/accounts.py +++ b/starknet_py/tests/e2e/fixtures/accounts.py @@ -7,12 +7,12 @@ from starknet_py.constants import ARGENT_V040_CLASS_HASH from starknet_py.contract import Contract +from starknet_py.devnet_utils.devnet_client import DevnetClient from starknet_py.hash.address import compute_address from starknet_py.net.account.account import Account from starknet_py.net.account.base_account import BaseAccount from starknet_py.net.client_models import PriceUnit from starknet_py.net.full_node_client import FullNodeClient -from starknet_py.net.http_client import HttpMethod, RpcHttpClient from starknet_py.net.models import AddressRepresentation, StarknetChainId from starknet_py.net.signer.eth_signer import EthSigner from starknet_py.net.signer.key_pair import KeyPair @@ -42,7 +42,7 @@ class AccountPrerequisites: async def devnet_account_details( client: FullNodeClient, class_hash: int, - devnet, + devnet_client: DevnetClient, ) -> Tuple[str, str]: """ Deploys an Account and adds fee tokens to its balance (only on devnet). @@ -59,8 +59,8 @@ async def devnet_account_details( deployer_address=0, ) - await mint_token_on_devnet(devnet, address, int(1e30), PriceUnit.WEI.value) - await mint_token_on_devnet(devnet, address, int(1e30), PriceUnit.FRI.value) + await devnet_client.mint(address, int(1e30), PriceUnit.WEI) + await devnet_client.mint(address, int(1e30), PriceUnit.FRI) deploy_account_tx = await get_deploy_account_transaction( address=address, @@ -82,15 +82,6 @@ async def devnet_account_details( return hex(address), hex(key_pair.private_key) -async def mint_token_on_devnet(url: str, address: int, amount: int, unit: str): - http_client = RpcHttpClient(url) - await http_client.request( - http_method=HttpMethod.POST, - address=f"{url}/mint", - payload={"address": hex(address), "amount": amount, "unit": unit}, - ) - - @pytest.fixture(name="account", scope="package") def full_node_account(client: FullNodeClient) -> BaseAccount: """ diff --git a/starknet_py/tests/e2e/fixtures/contracts_v1.py b/starknet_py/tests/e2e/fixtures/contracts_v1.py index 0d6bc5d4a..fc7abb0f0 100644 --- a/starknet_py/tests/e2e/fixtures/contracts_v1.py +++ b/starknet_py/tests/e2e/fixtures/contracts_v1.py @@ -8,7 +8,6 @@ from starknet_py.common import create_casm_class, create_sierra_compiled_contract from starknet_py.contract import Contract from starknet_py.hash.casm_class_hash import compute_casm_class_hash -from starknet_py.hash.hash_method import HashMethod from starknet_py.net.account.base_account import BaseAccount from starknet_py.net.models import DeclareV3 from starknet_py.net.udc_deployer.deployer import Deployer @@ -19,11 +18,7 @@ async def declare_contract( account: BaseAccount, compiled_contract: str, compiled_contract_casm: str ) -> Tuple[int, int]: - casm_class_hash = compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(compiled_contract_casm), - HashMethod.POSEIDON, - ) + casm_class_hash = compute_casm_class_hash(create_casm_class(compiled_contract_casm)) declare_tx = await account.sign_declare_v3( compiled_contract=compiled_contract, @@ -71,11 +66,7 @@ def constructor_with_arguments_abi() -> List: @pytest_asyncio.fixture(scope="package") async def declare_v3_hello_starknet(account: BaseAccount) -> DeclareV3: contract = load_contract("HelloStarknet") - casm_class_hash = compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ) + casm_class_hash = compute_casm_class_hash(create_casm_class(contract["casm"])) declare_tx = await account.sign_declare_v3( contract["sierra"], casm_class_hash, resource_bounds=MAX_RESOURCE_BOUNDS @@ -241,11 +232,7 @@ def map_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -255,11 +242,7 @@ def map_compiled_contract_and_class_hash_copy_1() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -269,11 +252,7 @@ def map_compiled_contract_and_class_hash_copy_2() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -325,11 +304,7 @@ def sierra_minimal_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -342,11 +317,7 @@ def abi_types_compiled_contract_and_class_hash() -> Tuple[str, int]: return ( contract["sierra"], - compute_casm_class_hash( - # TODO(#1659): Use blake - create_casm_class(contract["casm"]), - HashMethod.POSEIDON, - ), + compute_casm_class_hash(create_casm_class(contract["casm"])), ) @@ -378,8 +349,7 @@ async def account_declare_class_hash( """ casm_class = create_casm_class(compiled_account_contract_casm) - # TODO(#1659): Use blake - casm_class_hash = compute_casm_class_hash(casm_class, HashMethod.POSEIDON) + casm_class_hash = compute_casm_class_hash(casm_class) declare_v3_transaction = await account.sign_declare_v3( compiled_contract=compiled_account_contract, compiled_class_hash=casm_class_hash, @@ -395,9 +365,7 @@ async def account_with_validate_deploy_class_hash( pre_deployed_account_with_validate_deploy: BaseAccount, ) -> int: contract = load_contract("Account") - casm_class_hash = compute_casm_class_hash( - create_casm_class(contract["casm"]), HashMethod.POSEIDON - ) + casm_class_hash = compute_casm_class_hash(create_casm_class(contract["casm"])) return await declare_account( pre_deployed_account_with_validate_deploy, contract["sierra"], casm_class_hash diff --git a/starknet_py/tests/e2e/fixtures/misc.py b/starknet_py/tests/e2e/fixtures/misc.py index af17c8303..309301473 100644 --- a/starknet_py/tests/e2e/fixtures/misc.py +++ b/starknet_py/tests/e2e/fixtures/misc.py @@ -124,6 +124,13 @@ def starknet_block_mock() -> StarknetBlock: starknet_version="0.14.0", status=BlockStatus.ACCEPTED_ON_L2, transactions=[], + event_commitment=0, + transaction_commitment=0, + receipt_commitment=0, + state_diff_commitment=0, + event_count=0, + transaction_count=0, + state_diff_length=0, ) diff --git a/starknet_py/tests/e2e/tests_on_networks/client_test.py b/starknet_py/tests/e2e/tests_on_networks/client_test.py index f3c186c48..8a2928a6a 100644 --- a/starknet_py/tests/e2e/tests_on_networks/client_test.py +++ b/starknet_py/tests/e2e/tests_on_networks/client_test.py @@ -403,6 +403,16 @@ async def test_get_block_new_header_fields(client_sepolia_testnet): assert block.starknet_version is not None assert block.l1_gas_price is not None assert block.l1_gas_price.price_in_wei > 0 + assert block.event_commitment is not None + assert block.transaction_commitment is not None + assert block.receipt_commitment is not None + assert block.state_diff_commitment is not None + assert block.event_count is not None + assert block.transaction_count is not None + assert block.state_diff_length is not None + assert block.event_count >= 0 + assert block.transaction_count >= 0 + assert block.state_diff_length >= 0 pre_confirmed_block = await client_sepolia_testnet.get_block_with_txs( block_number="pre_confirmed" @@ -422,6 +432,16 @@ async def test_get_block_with_tx_hashes_new_header_fields(client_sepolia_testnet assert block.starknet_version is not None assert block.l1_gas_price is not None assert block.l1_gas_price.price_in_wei > 0 + assert block.event_commitment is not None + assert block.transaction_commitment is not None + assert block.receipt_commitment is not None + assert block.state_diff_commitment is not None + assert block.event_count is not None + assert block.transaction_count is not None + assert block.state_diff_length is not None + assert block.event_count >= 0 + assert block.transaction_count >= 0 + assert block.state_diff_length >= 0 pre_confirmed_block = await client_sepolia_testnet.get_block_with_tx_hashes( block_number="pre_confirmed" @@ -468,7 +488,6 @@ async def test_get_chain_id_sepolia_testnet(client_sepolia_testnet): assert chain_id == hex(StarknetChainId.SEPOLIA.value) -@pytest.mark.skip("TODO(#1659)") @pytest.mark.asyncio async def test_get_events_sepolia_testnet(client_sepolia_testnet): events_chunk = await client_sepolia_testnet.get_events( @@ -576,7 +595,7 @@ async def test_get_compiled_casm(client_sepolia_testnet): @pytest.mark.asyncio async def test_warning_on_incompatible_node_spec_version(client_sepolia_testnet): - old_rpc_url = client_sepolia_testnet.url.replace("v0_9", "v0_8") + old_rpc_url = client_sepolia_testnet.url.replace("v0_10", "v0_8") node = FullNodeClient(old_rpc_url) pattern = ( diff --git a/starknet_py/tests/e2e/utils.py b/starknet_py/tests/e2e/utils.py index c0a86433e..c6ea220e5 100644 --- a/starknet_py/tests/e2e/utils.py +++ b/starknet_py/tests/e2e/utils.py @@ -6,7 +6,6 @@ from starknet_py.hash.address import compute_address from starknet_py.net.account.account import Account from starknet_py.net.client import Client -from starknet_py.net.http_client import HttpClient, HttpMethod from starknet_py.net.models import DeployAccountV3, StarknetChainId from starknet_py.net.signer.key_pair import KeyPair from starknet_py.net.udc_deployer.deployer import _get_random_salt @@ -82,11 +81,3 @@ def _get_random_private_key_unsafe() -> int: This is not a safe way of generating private keys and should be used only in tests. """ return random.randint(1, EC_ORDER - 1) - - -async def create_empty_block(http_client: HttpClient) -> None: - url = http_client.url[:-4] if http_client.url.endswith("/rpc") else http_client.url - await http_client.request( - address=f"{url}/create_block", - http_method=HttpMethod.POST, - ) diff --git a/starknet_py/tests/install_devnet.sh b/starknet_py/tests/install_devnet.sh index b20ebaaaa..db9298a0c 100755 --- a/starknet_py/tests/install_devnet.sh +++ b/starknet_py/tests/install_devnet.sh @@ -2,8 +2,8 @@ set -e DEVNET_INSTALL_DIR="$(git rev-parse --show-toplevel)/starknet_py/tests/e2e/devnet/bin" -DEVNET_REPO="https://github.com/0xSpaceShard/starknet-devnet-rs" -DEVNET_VERSION="v0.5.1" +DEVNET_REPO="https://github.com/0xSpaceShard/starknet-devnet" +DEVNET_VERSION="v0.7.0" require_cmd() { if ! command -v "$1" >/dev/null 2>&1; then diff --git a/starknet_py/tests/unit/signer/test_ledger_signer.py b/starknet_py/tests/unit/signer/test_ledger_signer.py index c7d15a6e7..1b295d289 100644 --- a/starknet_py/tests/unit/signer/test_ledger_signer.py +++ b/starknet_py/tests/unit/signer/test_ledger_signer.py @@ -9,7 +9,6 @@ from starknet_py.net.full_node_client import FullNodeClient from starknet_py.net.models import DeclareV3, DeployAccountV3, InvokeV3, StarknetChainId from starknet_py.net.signer.ledger_signer import BlindSigningModeWarning -from starknet_py.tests.e2e.fixtures.accounts import mint_token_on_devnet from starknet_py.tests.e2e.fixtures.constants import MAX_RESOURCE_BOUNDS_SEPOLIA LEDGER_ACCOUNT_ADDRESS_SEPOLIA = ( @@ -197,7 +196,7 @@ async def _get_account_balance_strk(client: FullNodeClient, address: int): platform == "win32", reason="Testing Ledger is skipped on Windows due to different Speculos setup.", ) -async def test_deploy_account_and_transfer(client): +async def test_deploy_account_and_transfer(client, devnet_client): # pylint: disable=import-outside-toplevel, reimported, redefined-outer-name, too-many-locals # docs-deploy-account-and-transfer: start from starknet_py.contract import Contract @@ -232,12 +231,8 @@ async def test_deploy_account_and_transfer(client): # Remember to prefund the account # docs-deploy-account-and-transfer: end # Here we prefund the devnet account for test purposes - await mint_token_on_devnet( - url=rpc_client.url.replace("/rpc", ""), - address=address, - amount=5000000000000000000000, - unit="FRI", - ) + + await devnet_client.mint(address, int(1e24)) # docs-deploy-account-and-transfer: start signed_tx = await account.sign_deploy_account_v3( class_hash=class_hash,