Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions docs/migration_guide.rst
Original file line number Diff line number Diff line change
@@ -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 <https://docs.starknet.io/learn/cheatsheets/version-notes#starknet-v0-14-1-tbd>`_
- RPC - `0.10.0 <https://github.com/starkware-libs/starknet-specs/releases/tag/v0.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
****************************
Expand Down
2 changes: 1 addition & 1 deletion starknet_py/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion starknet_py/net/client_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions starknet_py/net/schemas/rpc/block.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions starknet_py/net/schemas/rpc/executables_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from marshmallow import ValidationError, fields, post_load, validate

from starknet_py.constants import FIELD_PRIME
from starknet_py.net.executable_models import (
AllocConstantSize,
AllocConstantSizeInner,
Expand Down
15 changes: 3 additions & 12 deletions starknet_py/tests/e2e/account/account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand Down
3 changes: 0 additions & 3 deletions starknet_py/tests/e2e/client/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 7 additions & 17 deletions starknet_py/tests/e2e/client/full_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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"],
Expand Down
6 changes: 2 additions & 4 deletions starknet_py/tests/e2e/client/websocket_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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


@pytest.mark.asyncio
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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading