Skip to content

Commit bdc374a

Browse files
Temporarily disable braavos integration (#1583) [skip ci]
* Fix devnet installation action - use `devnet_sha` input * Trgigger CI * Remove `install_devnet.yml` workflow * Add todo in `checks.yml` * Remove temporary step for showing dirs * Move `parsed_abi_v2` into `test_event_serialization_v2` * Fix formatting * Add echo for displaying contracts v2 directory contents * Fix displaying contents of contracts v2 directory * Temporary change for displaying directory contents * Temporarily list contract v2 directory * Temporarily display owd * Revert "Temporarily display owd" This reverts commit 2ad7fe7. * Include Python 3.9 in `Setup Tests` job * Remove CI changes apart from modified devnet installation * Temporarily display directory with compiled contracts * Fix ls * Fix ls * Unconditionally compile contracts v1 and v2 * Use asdf action * Implement `test_get_transaction_status_with_failure_reason`; Code cleanup * Fix linting; Tests cleanup * Update regex in `test_rejection_reason_in_transaction_receipt` * Skip `test_compute_deploy_account_v3_transaction_hash` * Format * Skip `test_block_with_receipts_latest` * Fix failing docs tests * Fix linting * Remove contracts conditional compilation on CI * Add contracts compilation steps in docs tests * Skip `test_get_transaction_by_block_id`; Add todo * Skip `test_get_transaction_by_block_id`; Add todo * Skip `test_using_full_node_client`; Add todo * Skip `test_get_transaction_by_block_id`; Add todo * Add todos * Add todos in workflow * Update resource bounds params * Minor refactor of resource bounds params usage * Apply code review suggestion * Add `storage_root` field to `ContractLeafData` * Rename `block` to `block_id` param in ws methods * Add `is_reverted` field to `FunctionInvocation` * Add todo * Remove `block_id` param from `starknet_subscribeTransactionStatus` endpoint * Remove `contracts_storage_proof` field from `ContractsProof` * Fix `storage_root` data key * Implement `test_get_messages_status` * Fix `test_latest_resource_bounds_take_precedence` * Fix `test_deploy_prefunded_account` * Remove mocks from full node client * Add `l1_data_gas` to `ExecutionResources` * Update `CommonTransactionV3Fields.compute_resource_bounds_for_fee` * Add `l1_data_gas` to ExecutionResourcesSchema` * Fix `FullNodeClient.estimate_fee` * Fix contract tests * Temporarily skip some tests; Fix other tests * Update devnet sha * Remove code, tests and docs for old txs * Fix lint and typecheck * Fix formatting * Fix lint and typecheck * Remove old txs usages, adjust tests and docs * Fix tests * Remove todos * Remove `test_account_get_balance_eth` * Fix other tests * Skip test * Adjust devnet * Fix skip mark * Remove skip marks; Fix tests * Update ledger app sha * Refactor assertion in test * Restore original `test_ci_v2` * Remove `ResourceBounds.init_with_l1_gas_only` * Add todos * Formatting * Adjust todos and fixmes * Use `argent_account_class_hash` in `test_deploy_account_and_transfer` * Fix `test_deploy_account_and_transfer` * Revert "Fix `test_deploy_account_and_transfer`" This reverts commit d4c2eed. * Revert "Use `argent_account_class_hash` in `test_deploy_account_and_transfer`" This reverts commit 240c8ad. * Skip and add todo for `test_deploy_account_and_transfer` * Update skip message for `test_get_transaction_by_block_id` * Update todo * Remove `--initial-balance` flag for devnet start * Revert "Remove `--initial-balance` flag for devnet start" This reverts commit d9a2091. * Fix models and schemas for `get_storage_proof`; Add tests * Add storage proof response json * Restore values in storage proof response json * Use shorter example response for `get_storage_proof` test * Adjust storage proof tests * Remove helper function * Update migration guide * Update migration guide * Fix linting * Fix formatting * Remove unused imports * Add file with `ContractsStorageKeysSchema` * Fix `test_get_storage_proof` * Remove multipliers from `EstimatedFee.to_resource_bounds` * update todo * Fix and update network tests * Fix devnet client tests * Fix CI * Use asdf action * Restore `Download contracts` step in CI * Temporarily list contracts dir * Update listing dirs * Update listing dirs * Temporary CI change * Display compiled contracts path * Compile contract before running tests in CI * Partially implement `test_get_compiled_casm` * Fix params in `FullNodeClient.get_compiled_casm` * Update dependencies * Restore read api for txs other than v3 * Refactor broadcasted txn schemas * Add todo as skip reason * Add `test_sign_invoke_v3_auto_estimate` * Run `poetry lock` * Restore test values in `test_get_transaction_by_block_id_and_index` * Fix docs * Docstrings formatting * Add todos * Remove old transactions (#1557) * Fix `test_transaction_not_received_max_fee_too_big` * Fix and update network tests (#1563) * Add rust toolchain installation * Add `HintSchema`; Rename fields * Update field names in models * Add tests for `get_compiled_casm` * Move models and schema from executables api to separate files * Add docs * Fix migration guide * Rename file * Fix `test_get_compiled_casm` for devnet * Remove unused import * Add `STARKNET_PY_MARSHMALLOW_UNKNOWN_EXCLUDE` to CI * Change `index_delta_minus_1` to `index_delta_minus1` * Add fixes in executables schemas and models * Use schema with excluding unknown fields for `CasmClassSchema` * Update todos * Support `starknet_getCompiledCasm` (#1514) * Add todos * Add missing websocket API methods; Add tests * Fix formatting * Remove composite action * Format and lint * Add more tests * Further improvements of websocket client * Remove api docs (will be added in subsequent PR) * Run `poetry lock` * Update docstrings * Add `WebsocketClientError` * Fix `pytest_plugins` * Remove unused schemas; Refactor passing block number and block hash params * Remove unused `WSClient` * Add `devnet_ws` fixture * Add `test_new_heads_subscription_block_not_found` * Remove prints * Fix passing block id * Update websocket schemas * Add devnet websocket fixture * Remove `test_new_heads_subscription_block_not_found` * Restructure files; Add new tests * Remove unused model * Add missing docstrings * Update subscription id type to `str` (RPC 0.8.1) * Fix formatting * Remove unused schema * Add `is_connected` property; Add connection test * Little comments cleanup * Add websockets docs; Add code examples * Add api and guide docs files * Remove unneeded file * Rename `reorg_notification_handler` to `on_chain_reorg` * Fix formatting * Trigger CI * Format docstrings of `subscribe_pending_transactions` * Fix docs * Update `transaction_details` param description * Increase sleep time in `test_subscribe_transaction_status` * Fix serialize method in `PendingTransactionsNotificationResultField` * Temporarily disable braavos integration * Fix migration guide * Update docs * Code refactor * Apply code review suggestions * Apply code review suggestions * Change subscription id type to int * Use sepolia client in `test_account_execute_v3_braavos` * Update migration guide * Update migration guide * Refactor braavos tests * Temporarily disable running tests in parallel * Revert "Temporarily disable running tests in parallel" This reverts commit 54e86a4. * Refactor braavos tests * Fix formatting * Restore gas amount multiplier params * Update migration guide * Fix linting * Add missing envs * Remove try/except from unnecessary places * Fix test * Formatting * Trigger CI
1 parent e79cdf2 commit bdc374a

File tree

6 files changed

+120
-34
lines changed

6 files changed

+120
-34
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ jobs:
262262
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
263263
SEPOLIA_ACCOUNT_ADDRESS: ${{ secrets.SEPOLIA_ACCOUNT_ADDRESS }}
264264
SEPOLIA_ACCOUNT_PRIVATE_KEY: ${{ secrets.SEPOLIA_ACCOUNT_PRIVATE_KEY }}
265+
# TODO(#1582): Remove braavos envs once integration is restored
266+
SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS: ${{ secrets.SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS }}
267+
SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY: ${{ secrets.SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY }}
265268
steps:
266269
- uses: actions/checkout@v4
267270

docs/migration_guide.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Migration guide
99
1010
1. Restored ``amount_multiplier`` and ``unit_price_multiplier`` params in :meth:`EstimatedFee.to_resource_bounds()`
1111

12+
2. Using Braavos accounts is temporarily disabled because they don't work with starknet 0.13.5. Please read the `official post <https://community.starknet.io/t/starknet-devtools-for-0-13-5/115495#p-2359168-braavos-compatibility-issues-3>`_ for more details.
13+
1214
0.26.1 Bugfixes
1315
---------------
1416

starknet_py/net/account/account.py

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
StructSerializer,
5353
UintSerializer,
5454
)
55+
from starknet_py.utils.account import _raise_error_for_braavos_account
5556
from starknet_py.utils.iterable import ensure_iterable
5657
from starknet_py.utils.sync import add_sync_methods
5758
from starknet_py.utils.typed_data import TypedData
@@ -471,13 +472,19 @@ async def execute_v3(
471472
nonce: Optional[int] = None,
472473
auto_estimate: bool = False,
473474
) -> SentTransactionResponse:
474-
execute_transaction = await self.sign_invoke_v3(
475-
calls,
476-
resource_bounds=resource_bounds,
477-
nonce=nonce,
478-
auto_estimate=auto_estimate,
479-
)
480-
return await self._client.send_transaction(execute_transaction)
475+
# TODO(#1582): Remove below adjustment when braavos integration is restored
476+
try:
477+
execute_transaction = await self.sign_invoke_v3(
478+
calls,
479+
resource_bounds=resource_bounds,
480+
nonce=nonce,
481+
auto_estimate=auto_estimate,
482+
)
483+
return await self._client.send_transaction(execute_transaction)
484+
485+
except Exception as exception:
486+
await _raise_error_for_braavos_account(exception, self.address, self.client)
487+
raise exception
481488

482489
def sign_message(self, typed_data: Union[TypedData, TypedDataDict]) -> List[int]:
483490
if isinstance(typed_data, TypedData):
@@ -525,38 +532,44 @@ async def deploy_account_v3(
525532
:param resource_bounds: Resource limits (L1 and L2) used when executing this transaction.
526533
:param auto_estimate: Use automatic fee estimation, not recommend as it may lead to high costs.
527534
"""
528-
calldata = (
529-
constructor_calldata
530-
if constructor_calldata is not None
531-
else [key_pair.public_key]
532-
)
535+
# TODO(#1582): Remove below adjustment when braavos integration is restored
536+
try:
537+
calldata = (
538+
constructor_calldata
539+
if constructor_calldata is not None
540+
else [key_pair.public_key]
541+
)
533542

534-
chain = await client.get_chain_id()
543+
chain = await client.get_chain_id()
535544

536-
account = _prepare_account_to_deploy(
537-
address=address,
538-
class_hash=class_hash,
539-
salt=salt,
540-
key_pair=key_pair,
541-
client=client,
542-
chain=chain,
543-
calldata=calldata,
544-
)
545+
account = _prepare_account_to_deploy(
546+
address=address,
547+
class_hash=class_hash,
548+
salt=salt,
549+
key_pair=key_pair,
550+
client=client,
551+
chain=chain,
552+
calldata=calldata,
553+
)
545554

546-
deploy_account_tx = await account.sign_deploy_account_v3(
547-
class_hash=class_hash,
548-
contract_address_salt=salt,
549-
constructor_calldata=calldata,
550-
nonce=nonce,
551-
resource_bounds=resource_bounds,
552-
auto_estimate=auto_estimate,
553-
)
555+
deploy_account_tx = await account.sign_deploy_account_v3(
556+
class_hash=class_hash,
557+
contract_address_salt=salt,
558+
constructor_calldata=calldata,
559+
nonce=nonce,
560+
resource_bounds=resource_bounds,
561+
auto_estimate=auto_estimate,
562+
)
554563

555-
result = await client.deploy_account(deploy_account_tx)
564+
result = await client.deploy_account(deploy_account_tx)
556565

557-
return AccountDeploymentResult(
558-
hash=result.transaction_hash, account=account, _client=account.client
559-
)
566+
return AccountDeploymentResult(
567+
hash=result.transaction_hash, account=account, _client=account.client
568+
)
569+
except Exception as exception:
570+
address = parse_address(address)
571+
await _raise_error_for_braavos_account(exception, address, client)
572+
raise exception
560573

561574
async def _get_chain_id(self) -> int:
562575
if self._chain_id is None:

starknet_py/tests/e2e/fixtures/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ def _get_env_lambda(env_name):
2929

3030
SEPOLIA_ACCOUNT_ADDRESS = _get_env_lambda("SEPOLIA_ACCOUNT_ADDRESS")
3131

32+
# TODO(#1582): Remove braavos envs once integration is restored
33+
SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY = _get_env_lambda(
34+
"SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY"
35+
)
36+
37+
SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS = _get_env_lambda("SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS")
38+
3239
SEPOLIA_RPC_URL = _get_env_lambda("SEPOLIA_RPC_URL")
3340

3441
EMPTY_CONTRACT_ADDRESS_SEPOLIA = (
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# TODO(#1582): Remove this test once braavos integration is restored
2+
import pytest
3+
4+
from starknet_py.hash.selector import get_selector_from_name
5+
from starknet_py.net.account.account import Account
6+
from starknet_py.net.client_models import Call
7+
from starknet_py.net.full_node_client import FullNodeClient
8+
from starknet_py.net.models import StarknetChainId
9+
from starknet_py.net.signer.key_pair import KeyPair
10+
from starknet_py.tests.e2e.fixtures.constants import (
11+
SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS,
12+
SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY,
13+
)
14+
from starknet_py.utils.account import BraavosAccountDisabledError
15+
16+
17+
@pytest.mark.asyncio
18+
async def test_account_execute_v3_braavos(client_sepolia_testnet: FullNodeClient):
19+
braavos_account = Account(
20+
address=SEPOLIA_BRAAVOS_ACCOUNT_ADDRESS(),
21+
client=client_sepolia_testnet,
22+
chain=StarknetChainId.SEPOLIA,
23+
key_pair=KeyPair.from_private_key(SEPOLIA_BRAAVOS_ACCOUNT_PRIVATE_KEY()),
24+
)
25+
with pytest.raises(BraavosAccountDisabledError):
26+
await braavos_account.execute_v3(
27+
calls=[
28+
Call(
29+
to_addr=0x0589A8B8BF819B7820CB699EA1F6C409BC012C9B9160106DDC3DACD6A89653CF,
30+
selector=get_selector_from_name("get_balance"),
31+
calldata=[],
32+
)
33+
],
34+
auto_estimate=True,
35+
)

starknet_py/utils/account.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# TODO(#1582): Remove braavos-related code once braavos integration is restored
2+
from starknet_py.net.client import Client
3+
from starknet_py.net.client_errors import ClientError
4+
5+
_BRAAVOS_CLASS_HASHES = [
6+
0x02C8C7E6FBCFB3E8E15A46648E8914C6AA1FC506FC1E7FB3D1E19630716174BC,
7+
0x00816DD0297EFC55DC1E7559020A3A825E81EF734B558F03C83325D4DA7E6253,
8+
0x041BF1E71792AECB9DF3E9D04E1540091C5E13122A731E02BEC588F71DC1A5C3,
9+
]
10+
11+
12+
class BraavosAccountDisabledError(ValueError):
13+
"""Raised when a Braavos account is used but is disabled for compatibility reasons."""
14+
15+
16+
async def _raise_error_for_braavos_account(
17+
exception: Exception, address: int, client: Client
18+
):
19+
if isinstance(exception, ClientError) and "INVALID_TX" in exception.message:
20+
class_hash = await client.get_class_hash_at(address)
21+
if class_hash in _BRAAVOS_CLASS_HASHES:
22+
# pylint: disable=line-too-long
23+
raise BraavosAccountDisabledError(
24+
"Using Braavos accounts is temporarily disabled because they don't yet work with starknet 0.13.5."
25+
"Visit this link to read more: https://community.starknet.io/t/starknet-devtools-for-0-13-5/115495#p-2359168-braavos-compatibility-issues-3"
26+
)

0 commit comments

Comments
 (0)