Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
0.11.1 adaptations (#472)
Browse files Browse the repository at this point in the history
* Install cairo-lang 0.11.1.1
-------
Co-authored-by: FabijanC <[email protected]>
  • Loading branch information
mikiw authored May 19, 2023
1 parent dd34fe0 commit eed2ecc
Show file tree
Hide file tree
Showing 18 changed files with 509 additions and 457 deletions.
2 changes: 1 addition & 1 deletion page/docs/guide/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ optional arguments:
--start-time START_TIME
Specify the start time of the genesis block in Unix time seconds
--gas-price GAS_PRICE, -g GAS_PRICE
Specify the gas price in wei per gas unit; defaults to 1e+11
Specify the gas price in wei per gas unit; defaults to 1e+8
--allow-max-fee-zero Allow transactions with max fee equal to zero
--timeout TIMEOUT, -t TIMEOUT
Specify the server timeout in seconds; defaults to 60
Expand Down
905 changes: 479 additions & 426 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["starknet", "cairo", "testnet", "local", "server"]
python = ">=3.9,<3.10"
Flask = {extras = ["async"], version = "~2.0.3"}
flask-cors = "~3.0.10"
cairo-lang = "0.11.0.2"
cairo-lang = "0.11.1.1"
Werkzeug = "~2.0.3"
cloudpickle = "~2.1.0"
crypto-cpp-py = "~1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_dev_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
if [ -z "$CAIRO_1_COMPILER_MANIFEST" ]; then
mkdir cairo-compiler
git clone [email protected]:starkware-libs/cairo.git cairo-compiler \
--branch v1.0.0-alpha.6 \
--branch v1.0.0-rc0 \
--single-branch
CAIRO_1_COMPILER_MANIFEST="cairo-compiler/Cargo.toml"

Expand Down
4 changes: 3 additions & 1 deletion starknet_devnet/cairo_rs_py_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
get_deprecated_contract_class_struct,
load_program,
)
from starkware.starknet.core.os.deprecated_syscall_handler import (
DeprecatedBlSyscallHandler,
)
from starkware.starknet.core.os.syscall_handler import (
BusinessLogicSyscallHandler,
DeprecatedBlSyscallHandler,
SyscallHandlerBase,
)
from starkware.starknet.definitions.error_codes import StarknetErrorCode
Expand Down
5 changes: 3 additions & 2 deletions starknet_devnet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

DEFAULT_ACCOUNTS = 10
DEFAULT_INITIAL_BALANCE = 10**21
DEFAULT_GAS_PRICE = 10**11
DEFAULT_GAS_PRICE = 10**8

SUPPORTED_TX_VERSION = 1
SUPPORTED_RPC_TX_VERSION = 1
Expand All @@ -22,6 +22,7 @@
DEPRECATED_RPC_DECLARE_TX_VERSION = 1

DUMMY_STATE_ROOT = bytes(32)
DUMMY_PENDING_BLOCK_HASH = 0

DEFAULT_TIMEOUT = 60 # seconds

Expand All @@ -31,7 +32,7 @@
# poetry run python scripts/compute_compiled_class_hash.py \
# ~/.cache/pypoetry/virtualenvs/<YOUR_VENV>/lib/python3.9/site-packages/starkware/starknet/third_party/open_zeppelin/account.json
STARKNET_CLI_ACCOUNT_CLASS_HASH = (
0x6EA5324F5D3F919A7FF007ACFAD6C421D724CF0CBCF0F6105945565518A572
0x1D28D8D8874CEA14193F70EDCDF501F9AE137BE2A41E258A29CBD05558D8EB6
)

# starkware.starknet.public.abi.get_selector_from_name("replace_class")
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/forked_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get_forked_starknet(
gas_price=gas_price,
),
state_reader=state_reader,
contract_class_cache={},
compiled_class_cache={},
),
general_config=build_devnet_general_config(chain_id),
)
Expand Down
2 changes: 0 additions & 2 deletions starknet_devnet/general_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
build_general_config,
)

from .constants import SUPPORTED_TX_VERSION
from .fee_token import FeeToken


Expand All @@ -34,7 +33,6 @@ def build_devnet_general_config(chain_id: StarknetChainId):
"chain_id": chain_id.value,
"fee_token_address": hex(FeeToken.ADDRESS),
},
"tx_version": SUPPORTED_TX_VERSION,
"tx_commitment_tree_height": constants.TRANSACTION_COMMITMENT_TREE_HEIGHT,
"validate_max_n_steps": DEFAULT_VALIDATE_MAX_STEPS,
}
Expand Down
2 changes: 0 additions & 2 deletions starknet_devnet/postman_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Tuple

from starkware.eth.eth_test_utils import EthAccount, EthContract
from starkware.eth.web3_wrapper import web3_contract_create_filter_fix
from starkware.solidity.utils import load_nearby_contract
from starkware.starknet.business_logic.transaction.objects import InternalL1Handler
from starkware.starknet.definitions.error_codes import StarknetErrorCode
Expand Down Expand Up @@ -198,7 +197,6 @@ def __init__(

# Create a filter to collect LogMessageToL2 events.
w3_contract = self.mock_starknet_messaging_contract.w3_contract
web3_contract_create_filter_fix(w3_contract.events.LogMessageToL2)
self.message_to_l2_filter = w3_contract.events.LogMessageToL2.create_filter(
fromBlock=LATEST_BLOCK_ID
)
Expand Down
3 changes: 1 addition & 2 deletions starknet_devnet/predeployed_contract_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def deploy(self):
starknet: Starknet = self.starknet_wrapper.starknet

# declare
starknet.state.state.contract_classes[self.class_hash] = self.contract_class
starknet.state.state.compiled_classes[self.class_hash] = self.contract_class

# pylint: disable=protected-access
self.starknet_wrapper._contract_classes[self.class_hash] = self.contract_class
Expand All @@ -51,5 +51,4 @@ async def deploy(self):
state=starknet.state,
abi=self.contract_class.abi,
contract_address=self.address,
deploy_call_info=None,
)
7 changes: 4 additions & 3 deletions starknet_devnet/starknet_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
from .chargeable_account import ChargeableAccount
from .compiler import select_compiler
from .constants import (
DUMMY_PENDING_BLOCK_HASH,
DUMMY_STATE_ROOT,
LEGACY_TX_VERSION,
STARKNET_CLI_ACCOUNT_CLASS_HASH,
Expand Down Expand Up @@ -325,7 +326,7 @@ async def update_pending_state( # pylint: disable=too-many-arguments
)

return BlockStateUpdate(
block_hash=None,
block_hash=DUMMY_PENDING_BLOCK_HASH,
new_root=DUMMY_STATE_ROOT,
old_root=DUMMY_STATE_ROOT,
state_diff=state_diff,
Expand Down Expand Up @@ -396,7 +397,7 @@ async def declare(
compiled_class = external_tx.contract_class
tx_handler.explicitly_declared_old.append(class_hash)

state.state.contract_classes[compiled_class_hash] = compiled_class
state.state.compiled_classes[compiled_class_hash] = compiled_class
self._contract_classes[class_hash] = external_tx.contract_class

return class_hash, tx_handler.internal_tx.hash_value
Expand Down Expand Up @@ -928,7 +929,7 @@ async def get_nonce(
async def __predeclare_starknet_cli_account(self):
"""Predeclares the account class used by Starknet CLI"""
state = self.get_state().state
state.contract_classes[STARKNET_CLI_ACCOUNT_CLASS_HASH] = oz_account_class
state.compiled_classes[STARKNET_CLI_ACCOUNT_CLASS_HASH] = oz_account_class

async def __deploy_chargeable_account(self):
if await self.is_deployed(ChargeableAccount.ADDRESS):
Expand Down
4 changes: 2 additions & 2 deletions test/expected/deploy_function_invocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"0x5"
],
"caller_address": "0x0",
"class_hash": "0x2216379233d6f7c8890a730e164e069dafdd63edf0f0218dde8181b50fabd45",
"contract_address": "0x7f50463b43a30d3a60c004ab70bbf70f8ea2d16dbf802c952e94c8ef18646b2",
"class_hash": "0x4dd892c3bbcdbe25b6a4c77adb8363bfc02176c231f70f086970610bee84539",
"contract_address": "0x7c81e7744ed1745985c0d5947cf6c261a3d9fc95c309887649a975edd019945",
"entry_point_type": "CONSTRUCTOR",
"events": [],
"execution_resources": {
Expand Down
6 changes: 3 additions & 3 deletions test/expected/invoke_function_invocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"events": [],
"calldata": [
"0x1",
"0x7f50463b43a30d3a60c004ab70bbf70f8ea2d16dbf802c952e94c8ef18646b2",
"0x7c81e7744ed1745985c0d5947cf6c261a3d9fc95c309887649a975edd019945",
"0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"0x0",
"0x2",
Expand All @@ -34,7 +34,7 @@
},
"messages": [],
"call_type": "CALL",
"class_hash": "0x2216379233d6f7c8890a730e164e069dafdd63edf0f0218dde8181b50fabd45",
"class_hash": "0x4dd892c3bbcdbe25b6a4c77adb8363bfc02176c231f70f086970610bee84539",
"result": [],
"events": [],
"calldata": [
Expand All @@ -44,7 +44,7 @@
"caller_address": "0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"entry_point_type": "EXTERNAL",
"selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"contract_address": "0x7f50463b43a30d3a60c004ab70bbf70f8ea2d16dbf802c952e94c8ef18646b2",
"contract_address": "0x7c81e7744ed1745985c0d5947cf6c261a3d9fc95c309887649a975edd019945",
"internal_calls": []
}
]
Expand Down
4 changes: 2 additions & 2 deletions test/expected/invoke_receipt_account_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"0x0",
"0xa"
],
"from_address": "0x6c9b52d3297d731eaea82dbfa4d20424855d498b8594b9442a1d4d5d995a5bd",
"from_address": "0x2d3c5f33198cf54a030e316ab2d9532e1c401d3c5a8b8a3962aeda6c1dcd260",
"keys": [
"0x3db3da4221c078e78bd987e54e1cc24570d89a7002cefa33e548d6c72c73f9d"
]
},
{
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0xbebe7dec64b911aeffecc184afcefa6470e3b3652a1605e42d643e1ea9093d",
"0x4035e7e01f09b8bc746a549fdf1bafa8d975bdbc53d25646635d0ab58425f30",
"0x569ced8800",
"0x0"
],
Expand Down
6 changes: 3 additions & 3 deletions test/rpc/test_data/get_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ def parse_block_delimiter_parameter(


EVENT_FEE_ADDRESS = rpc_felt(
0xBEBE7DEC64B911AEFFECC184AFCEFA6470E3B3652A1605E42D643E1EA9093D
0x04035E7E01F09B8BC746A549FDF1BAFA8D975BDBC53D25646635D0AB58425F30
)
INVOKE_1_FEE_CHARGING_EVENT = [
rpc_felt(int(PREDEPLOYED_ACCOUNT_ADDRESS, 16)),
EVENT_FEE_ADDRESS,
rpc_felt(0x73B00ED0C000), # WEI
rpc_felt(0x01D9DB5F800), # WEI
rpc_felt(0),
]
INVOKE_2_FEE_CHARGING_EVENT = [
rpc_felt(int(PREDEPLOYED_ACCOUNT_ADDRESS, 16)),
EVENT_FEE_ADDRESS,
rpc_felt(0x015254FFDB4000), # WEI
rpc_felt(0x0569CED8800), # WEI
rpc_felt(0),
]

Expand Down
4 changes: 2 additions & 2 deletions test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
)

EXPECTED_CLASS_HASH = (
"0x2216379233d6f7c8890a730e164e069dafdd63edf0f0218dde8181b50fabd45"
"0x4dd892c3bbcdbe25b6a4c77adb8363bfc02176c231f70f086970610bee84539"
)
# hash of contract at CONTRACT_1_PATH
EXPECTED_CLASS_1_HASH = (
"0x7c93b555d40b18537ae7107aaa26dce3f8658337f5be3f563955fd24b623fec"
"0x21c6a99e1947cd3526da50ed29f66e46a41c8e9e31761326739c6f3f9c2c5f7"
)

NONEXISTENT_TX_HASH = "0x99"
Expand Down
4 changes: 2 additions & 2 deletions test/test_fork_feeder_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@

DEPLOYMENT_INPUT = "10"
EXPECTED_DEPLOYMENT_ADDRESS = (
"0x03f37e0679b8c295373f6452c5c68c2de5ee661b77e02af5fe1a416ce9be93f7"
"0x1377433bcc53c639d2203c164d2004ba2522c59f902eab2662199a2c78b8e3f"
)
EXPECTED_INVOKE_HASH = (
"0x54dd317f451041c1d4f138538ee665bff505dbeeec575902122014b60d0ce06"
"0x26f966f10eb28d442650fb6f3829d3d9298812e00ef60583a496ece0bb45082"
)


Expand Down
2 changes: 1 addition & 1 deletion test/test_general_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_salty_deploy():
"""Test deploying with salt"""

expected_address = (
"0x6c9b52d3297d731eaea82dbfa4d20424855d498b8594b9442a1d4d5d995a5bd"
"0x2d3c5f33198cf54a030e316ab2d9532e1c401d3c5a8b8a3962aeda6c1dcd260"
)
contract_path = EVENTS_CONTRACT_PATH
inputs = None
Expand Down

0 comments on commit eed2ecc

Please sign in to comment.