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

Commit

Permalink
Adapt to 0.12.0 (stable) (#515)
Browse files Browse the repository at this point in the history
* [skip ci] - a commit follows with version bump
  • Loading branch information
FabijanC authored Jul 4, 2023
1 parent 9ac7b61 commit 5b66058
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 53 deletions.
6 changes: 4 additions & 2 deletions page/docs/guide/cairo1-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ sidebar_position: 18

Declaring, deploying and interacting with Cairo 1 contracts is supported in the latest version of starknet-devnet. Declaration body only includes the [Sierra](https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/cairo-1-and-sierra/) of your contract class, so Devnet needs to compile it to Casm.

Make sure your Devnet is using the same compiler version that you used for the compilation of the contract class being declared. To successfully declare a contract compiled with v2.0.0-rc5, if on an x86 machine, you don't have to do anything. On another architecture, or if you want to specify a custom version of the Cairo 1 compiler, you need to specify your local compiler. Use one of:
Make sure your Devnet is using the same compiler version that you used for the compilation of the contract class being declared. To successfully declare a contract compiled with v2.0.0, if on an x86 machine, you don't have to do anything. On another architecture, or if you want to specify a custom version of the Cairo 1 compiler, you need to specify your local compiler. Use one of:

- `--cairo-compiler-manifest <PATH_TO_CARGO_TOML>`
- `--sierra-compiler-path <PATH_TO_SIERRA_EXECUTABLE>`

## Compiler args

By default, Devnet runs the compiler with `--add-pythonic-hints`. Modify this with Devnet's `--compiler-args` CLI argument. You will probably want to use the same set of flags that you used when originally compiling. E.g. if in your development environment you ran `starknet-sierra-compile` with `--add-pythonic-hints` and `--allowed-libfuncs-list-file /my/path/to/lib_funcs.json`, you should start Devnet with (notice the quotes):

```
Expand All @@ -19,7 +21,7 @@ $ starknet-devnet --compiler-args "--add-pythonic-hints --allowed-libfuncs-list-

## Cairo 2 support

There is no difference in how Devnet treats Cairo 2 contracts, so the [paragraph on Cairo 1](#cairo-1-support) support should be applicable.
There is no difference in how Devnet treats Cairo 2 contracts, so the [paragraph on Cairo 1 support](#cairo-1-support) should be applicable.

## Compiler binaries

Expand Down
93 changes: 65 additions & 28 deletions page/docs/guide/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,101 @@ Installing the package adds the `starknet-devnet` command.
<!-- Developer note: the following section should be a copy-paste of `starknet-devnet --help` -->

```text
usage: starknet-devnet [-h] [-v] [--verbose] [--host HOST] [--port PORT] [--load-path LOAD_PATH] [--dump-path DUMP_PATH] [--dump-on DUMP_ON]
[--lite-mode] [--blocks-on-demand] [--accounts ACCOUNTS] [--initial-balance INITIAL_BALANCE] [--seed SEED]
[--hide-predeployed-contracts] [--start-time START_TIME] [--gas-price GAS_PRICE] [--allow-max-fee-zero]
[--timeout TIMEOUT] [--account-class ACCOUNT_CLASS] [--fork-network FORK_NETWORK] [--fork-block FORK_BLOCK]
[--fork-retries FORK_RETRIES] [--chain-id CHAIN_ID] [--disable-rpc-request-validation]
[--disable-rpc-response-validation] [--hide-server-logs]
usage: starknet-devnet [-h] [-v] [--verbose] [--hide-server-logs]
[--host HOST] [--port PORT] [--load-path LOAD_PATH]
[--dump-path DUMP_PATH] [--dump-on DUMP_ON]
[--lite-mode] [--blocks-on-demand]
[--accounts ACCOUNTS]
[--initial-balance INITIAL_BALANCE] [--seed SEED]
[--hide-predeployed-contracts]
[--start-time START_TIME] [--gas-price GAS_PRICE]
[--allow-max-fee-zero] [--timeout TIMEOUT]
[--account-class ACCOUNT_CLASS]
[--fork-network FORK_NETWORK] [--fork-block FORK_BLOCK]
[--fork-retries FORK_RETRIES] [--chain-id CHAIN_ID]
[--disable-rpc-request-validation]
[--disable-rpc-response-validation]
[--cairo-compiler-manifest CAIRO_COMPILER_MANIFEST]
[--sierra-compiler-path SIERRA_COMPILER_PATH]
[--compiler-args COMPILER_ARGS]
Run a local instance of Starknet Devnet
optional arguments:
-h, --help show this help message and exit
-v, --version Print the version
--verbose Show more verbose output. Has higher priority than --hide-server-logs and --hide-predeployed-contracts
--host HOST Specify the address to listen at; defaults to 127.0.0.1 (use the address the program outputs on start)
--verbose Show more verbose output. Has higher priority than
--hide-server-logs and --hide-predeployed-contracts
--hide-server-logs Hide server access logging
--host HOST Specify the address to listen at; defaults to
127.0.0.1 (use the address the program outputs on
start)
--port PORT, -p PORT Specify the port to listen at; defaults to 5050
--load-path LOAD_PATH
Specify the path from which the state is loaded on startup
Specify the path from which the state is loaded on
startup
--dump-path DUMP_PATH
Specify the path to dump to
--dump-on DUMP_ON Specify when to dump; can dump on: exit, transaction
--lite-mode Introduces speed-up by skipping block hash calculation - applies sequential numbering instead (0x0, 0x1, 0x2, ...).
--lite-mode Introduces speed-up by skipping block hash calculation
- applies sequential numbering instead (0x0, 0x1, 0x2,
...).
--blocks-on-demand Block generation on demand via an endpoint.
--accounts ACCOUNTS Specify the number of accounts to be predeployed; defaults to 10
--accounts ACCOUNTS Specify the number of accounts to be predeployed;
defaults to 10
--initial-balance INITIAL_BALANCE, -e INITIAL_BALANCE
Specify the initial balance of accounts to be predeployed; defaults to 1e+21
--seed SEED Specify the seed for randomness of accounts to be predeployed
Specify the initial balance of accounts to be
predeployed; defaults to 1e+21
--seed SEED Specify the seed for randomness of accounts to be
predeployed
--hide-predeployed-contracts, --hide-predeployed-accounts
Prevents from printing the predeployed contracts details. Argument --hide-predeployed-accounts is deprecated
Prevents from printing the predeployed contracts
details. Argument --hide-predeployed-accounts is
deprecated
--start-time START_TIME
Specify the start time of the genesis block in Unix time seconds
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+8
Specify the gas price in wei per gas unit; defaults to
1e+08
--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
--account-class ACCOUNT_CLASS
Specify the account implementation to be used for predeploying; should be a path to the compiled JSON artifact; defaults to OpenZeppelin v1
Specify the account implementation to be used for
predeploying; should be a path to the compiled JSON
artifact; defaults to OpenZeppelin v1
--fork-network FORK_NETWORK
Specify the network to fork: can be a URL (e.g. https://alpha-mainnet.starknet.io) or network name (valid names: alpha-goerli, alpha-goerli2, alpha-mainnet)
Specify the network to fork: can be a URL (e.g.
https://alpha-mainnet.starknet.io) or network name
(valid names: alpha-goerli, alpha-goerli2, alpha-
mainnet)
--fork-block FORK_BLOCK
Specify the block number where the --fork-network is forked; defaults to latest
Specify the block number where the --fork-network is
forked; defaults to latest
--fork-retries FORK_RETRIES
Specify the number of retries of failed HTTP requests sent to the network before giving up; defaults to 1
--chain-id CHAIN_ID Specify the chain id as one of: {MAINNET, TESTNET, TESTNET2}; defaults to TESTNET (0x534e5f474f45524c49)
Specify the number of retries of failed HTTP requests
sent to the network before giving up; defaults to 1
--chain-id CHAIN_ID Specify the chain id as one of: {MAINNET, TESTNET,
TESTNET2}; defaults to TESTNET (0x534e5f474f45524c49)
--disable-rpc-request-validation
Disable requests schema validation for RPC endpoints
--disable-rpc-response-validation
Disable RPC schema validation for devnet responses
--cairo-compiler-manifest CAIRO_COMPILER_MANIFEST
Specify the path to the manifest (Cargo.toml) of the Cairo 1.0 compiler to be used for contract recompilation; if omitted, the default x86-compatible compiler (from cairo-lang package) is used
Specify the path to the manifest (Cargo.toml) of the
Cairo 1.0 compiler to be used for contract
recompilation; if omitted, the default x86-compatible
compiler (from cairo-lang package) is used
--sierra-compiler-path SIERRA_COMPILER_PATH
Specify the path to the binary executable of starknet-sierra-compile
--hide-server-logs Hide server access logging
Specify the path to the binary executable of starknet-
sierra-compile
--compiler-args COMPILER_ARGS
Specify the CLI args used internally by the Cairo 1.0 compiler for recompiling.
Provide them as a single space-separated string.
No validation is done on the arguments on Devnet startup, only when they are put to use.
Defaults to '--add-pythonic-hints'
Specify the CLI args used internally by the Cairo 1.0
compiler for recompiling. Provide them as a single
space-separated string. No validation is done on the
arguments on Devnet startup, only when they are put to
use. Defaults to '--add-pythonic-hints'
```

<!-- Developer note: the previous section should be a copy-paste of `starknet-devnet --help` -->
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.12.0a0"
cairo-lang = "0.12.0"
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 @@ -26,7 +26,7 @@ if [ -z "$CAIRO_1_COMPILER_MANIFEST" ]; then
COMPILER_DIR="cairo-compiler"
mkdir -p "$COMPILER_DIR"
git clone [email protected]:starkware-libs/cairo.git "$COMPILER_DIR" \
--branch v2.0.0-rc5 \
--branch v2.0.0 \
--single-branch
echo "Downloaded compiler to subdirectory $COMPILER_DIR"
CAIRO_1_COMPILER_MANIFEST="$COMPILER_DIR/Cargo.toml"
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,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 = (
0x2AF01407D426B1FFF03A6982813EA9F3E9467B2B19EDCC9FB612C3B5B6FFCEB
0x646A72E2AAB2FCA75D713FBE4A58F2D12CBD64105621B89DC9CE7045B5BF02B
)

# starkware.starknet.public.abi.get_selector_from_name("replace_class")
Expand Down
1 change: 1 addition & 0 deletions starknet_devnet/general_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def build_devnet_general_config(chain_id: StarknetChainId):
"global_state_commitment_tree_height": constants.CONTRACT_ADDRESS_BITS,
"invoke_tx_max_n_steps": DEFAULT_MAX_STEPS,
"min_gas_price": DEFAULT_GAS_PRICE,
"constant_gas_price": True,
"sequencer_address": hex(DEFAULT_SEQUENCER_ADDRESS),
"starknet_os_config": {
"chain_id": chain_id.value,
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": "0x7b49a5a6481737fc9f23f93086f8b53acefba360546340e2324e1d1f01c2d02",
"contract_address": "0x19b5dc77673aea30561a037d26ed0867d0dd8b6b685db5bad41c55505af1719",
"class_hash": "0x30430b242f48e0d8eb590f1a2a114d7c3e49678d96f8a5f20664f29413d3154",
"contract_address": "0x2ef8c5645763df5a2604dbfd7e348e5353f7272b3a4a33de4c7b8b8044a3ce0",
"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",
"0x19b5dc77673aea30561a037d26ed0867d0dd8b6b685db5bad41c55505af1719",
"0x2ef8c5645763df5a2604dbfd7e348e5353f7272b3a4a33de4c7b8b8044a3ce0",
"0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"0x0",
"0x2",
Expand All @@ -34,7 +34,7 @@
},
"messages": [],
"call_type": "CALL",
"class_hash": "0x7b49a5a6481737fc9f23f93086f8b53acefba360546340e2324e1d1f01c2d02",
"class_hash": "0x30430b242f48e0d8eb590f1a2a114d7c3e49678d96f8a5f20664f29413d3154",
"result": [],
"events": [],
"calldata": [
Expand All @@ -44,7 +44,7 @@
"caller_address": "0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"entry_point_type": "EXTERNAL",
"selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"contract_address": "0x19b5dc77673aea30561a037d26ed0867d0dd8b6b685db5bad41c55505af1719",
"contract_address": "0x2ef8c5645763df5a2604dbfd7e348e5353f7272b3a4a33de4c7b8b8044a3ce0",
"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,7 +5,7 @@
"0x0",
"0xa"
],
"from_address": "0xdce8a572e7dbd21414eeb532f17b3569aafea209ce7b55f7649630bd953e4e",
"from_address": "0x759db555a5facc5bc1cdd838efaf9122be77b0a1373959995ffcbe569057b7e",
"keys": [
"0x3db3da4221c078e78bd987e54e1cc24570d89a7002cefa33e548d6c72c73f9d"
]
Expand All @@ -14,7 +14,7 @@
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x2d389df4ad1c4d382cb7751982ab7bf24ac40cbab4769667f108a7b93f9e987",
"0x56a2e36900",
"0x73227f3100",
"0x0"
],
"from_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
Expand Down
4 changes: 2 additions & 2 deletions test/rpc/test_data/get_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def parse_block_delimiter_parameter(
INVOKE_1_FEE_CHARGING_EVENT = [
rpc_felt(int(PREDEPLOYED_ACCOUNT_ADDRESS, 16)),
EVENT_FEE_ADDRESS,
rpc_felt(0x1DA3ABD900), # WEI
rpc_felt(0x3A2347A100), # WEI
rpc_felt(0),
]
INVOKE_2_FEE_CHARGING_EVENT = [
rpc_felt(int(PREDEPLOYED_ACCOUNT_ADDRESS, 16)),
EVENT_FEE_ADDRESS,
rpc_felt(0x56A2E36900), # WEI
rpc_felt(0x73227F3100), # 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 @@ -38,11 +38,11 @@
)

EXPECTED_CLASS_HASH = (
"0x7b49a5a6481737fc9f23f93086f8b53acefba360546340e2324e1d1f01c2d02"
"0x30430b242f48e0d8eb590f1a2a114d7c3e49678d96f8a5f20664f29413d3154"
)
# hash of contract at CONTRACT_1_PATH
EXPECTED_CLASS_1_HASH = (
"0x2dc84cbdfc63f980cc6f8b9054184d7e33f43fdc02b2baf40017ea88490212d"
"0x442d719a5a3418648fecbf8b67615cea8560e88d9e2a17c25fd5c263c9f9518"
)

NONEXISTENT_TX_HASH = "0x99"
Expand Down
5 changes: 2 additions & 3 deletions test/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def fixture_starknet_wrapper_args(request):

def test_predeclared_oz_account():
"""Test that precomputed class matches"""
assert STARKNET_CLI_ACCOUNT_CLASS_HASH == compute_deprecated_class_hash(
oz_account_class
)
actual_class_hash = compute_deprecated_class_hash(oz_account_class)
assert actual_class_hash == STARKNET_CLI_ACCOUNT_CLASS_HASH


@devnet_in_background()
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 @@ -56,10 +56,10 @@

DEPLOYMENT_INPUT = "10"
EXPECTED_DEPLOYMENT_ADDRESS = (
"0x4350ca31a23a51479a63b28c0c3b4ade03f86223f640914ce4d3667ff0978fb"
"0x36ab41c97eff7ee3ebafce13b5c15206121661bf3e1481c53d5e8a2ac6680e6"
)
EXPECTED_INVOKE_HASH = (
"0x5499d481a6e6c174a745629091f2387949ff11f2c9b2aaf436d2633002807ea"
"0x36d9b59c104647452ec410b1a429bd16f175af71fb0afbed839f30202e3f44c"
)


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 = (
"0xdce8a572e7dbd21414eeb532f17b3569aafea209ce7b55f7649630bd953e4e"
"0x759db555a5facc5bc1cdd838efaf9122be77b0a1373959995ffcbe569057b7e"
)
contract_path = EVENTS_CONTRACT_PATH
inputs = None
Expand Down

0 comments on commit 5b66058

Please sign in to comment.