Skip to content

Commit

Permalink
Update to cairo-lang 0.10.3 (0xSpaceShard#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabijanC committed Dec 5, 2022
1 parent bf1ba8d commit a76cc16
Show file tree
Hide file tree
Showing 23 changed files with 141 additions and 110 deletions.
13 changes: 13 additions & 0 deletions page/docs/guide/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ All calls will first try Devnet's state and then fall back to the forking block.

If you are forking another Devnet instance, keep in mind that it doesn't support polling specific blocks, but will always fall back to the currently latest block.

## Chain ID

Devnet defaults to using the `TESTNET` chain ID (the one corresponding to Alpha Goerli). If you want Devnet to use another chain ID, you can provide it using:

```
starknet-devnet --chain-id [MAINNET | TESTNET | TESTNET2]
```

where `MAINNET` refers to Alpha Mainnet, `TESTNET` refers to Alpha Goerli and `TESTNET2` refers to Alpha Goerli2.

## Get fork status

```
GET /fork_status
```

Response when in fork mode:

```
{
"url": "https://alpha4.starknet.io",
Expand All @@ -32,6 +44,7 @@ Response when in fork mode:
```

Response when not in fork mode:

```
{}
```
6 changes: 3 additions & 3 deletions page/docs/guide/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Installing the package adds the `starknet-devnet` command.
usage: starknet-devnet [-h] [-v] [--host HOST] [--port PORT] [--load-path LOAD_PATH] [--dump-path DUMP_PATH] [--dump-on DUMP_ON] [--lite-mode] [--accounts ACCOUNTS]
[--initial-balance INITIAL_BALANCE] [--seed SEED] [--hide-predeployed-accounts] [--start-time START_TIME] [--gas-price GAS_PRICE] [--timeout TIMEOUT]
[--account-class ACCOUNT_CLASS] [--fork-network FORK_NETWORK] [--fork-block FORK_BLOCK]
[--chain_id CHAIN_ID]
[--chain-id CHAIN_ID]
Run a local instance of StarkNet Devnet
Expand Down Expand Up @@ -43,8 +43,8 @@ optional arguments:
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
--chain_id CHAIN_ID
Specify the chain id as string: ['MAINNET', 'TESTNET']
--chain-id CHAIN_ID
Specify the chain id as string: {MAINNET, TESTNET, TESTNET2}
```

You can run `starknet-devnet` in a separate shell, or you can run it in background with `starknet-devnet &`.
Expand Down
17 changes: 14 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.8,<3.10"
Flask = {extras = ["async"], version = "~2.0.3"}
flask-cors = "~3.0.10"
cairo-lang = "0.10.2"
cairo-lang = "0.10.3"
Werkzeug = "~2.0.3"
cloudpickle = "~2.1.0"
crypto-cpp-py = "~1.0.4"
Expand Down
17 changes: 17 additions & 0 deletions scripts/check_starknet_artifacts_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -eu
set -o pipefail

echo "Checking if starknet contracts are compiled using the latest compiler..."

# Use contract.cairo to test
COMPILED=$(jq -r ".program.compiler_version" test/artifacts/contracts/cairo/contract.cairo/contract.json)
echo "Compiled with: $COMPILED"
INSTALLED=$(poetry run starknet-compile --version | sed -rn "s/^starknet-compile (.*)$/\1/p")
echo "Installed: $INSTALLED"

if [ "$COMPILED" != "$INSTALLED" ]; then
echo "Error: Compiled with version: $COMPILED, installed version: $INSTALLED"
exit 1
fi
4 changes: 3 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -e
set -eu

./scripts/check_starknet_artifacts_version.sh

CMD="poetry run pytest -n auto --dist loadscope -v ${1:-test/}"
echo $CMD
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# account used by StarkNet CLI
OZ_ACCOUNT_CLASS_HASH = (
0x68CB33B3AB73EE34D2084CFCB7D07B24DB48095AD0907C10B6FDB7B0E91EF0A
0x6F500F527355DFDB8093C7FE46E6F73C96A867392B49FA4157A757538928539
)

LEGACY_RPC_TX_VERSION = 0
2 changes: 1 addition & 1 deletion starknet_devnet/devnet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _chain_id(chain_id: str):
chain_id = StarknetChainId[chain_id]
except KeyError:
sys.exit(
f"Error: The value of --chain_id must be in {{{CHAIN_IDS}}}, got: {chain_id}"
f"Error: The value of --chain-id must be in {{{CHAIN_IDS}}}, got: {chain_id}"
)

return chain_id
Expand Down
31 changes: 31 additions & 0 deletions test/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,37 @@ def _get_transaction_hash(
)


def get_estimate_fee_request_dict(
calls: List[AccountCall],
account_address: str,
private_key: str,
nonce: int = None,
):
"""Create a mock tx to request fee estimation of an invoke"""
if nonce is None:
nonce = get_nonce(account_address)

max_fee = 0
signature, execute_calldata = _get_execute_args(
calls=calls,
account_address=account_address,
private_key=private_key,
nonce=nonce,
max_fee=max_fee,
version=QUERY_VERSION,
)

return {
"contract_address": account_address,
"max_fee": hex(max_fee),
"calldata": [str(element) for element in execute_calldata],
"version": hex(QUERY_VERSION),
"nonce": hex(nonce),
"signature": signature,
"type": "INVOKE_FUNCTION",
}


def get_estimated_fee(
calls: List[AccountCall],
account_address: str,
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 @@ -2,8 +2,8 @@
"call_type": "CALL",
"calldata": ["0x0"],
"caller_address": "0x0",
"class_hash": "0x75dc4457c66bfb3808c67a918047b8f0973ea8b876056b72e99f651b91298ca",
"contract_address": "0x333c17a58a5e9d3e8f745d354fee89f83196e8fd0ded1c9766c24425276093f",
"class_hash": "0x71df7c871d389943e24aaaf85d41594266d12f2f9b580a9f92ba4a0bf763d67",
"contract_address": "0x6f47c70cfad7e0865af23e60e596e4926d557bc3fc26ce96a234d55bfb04857",
"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",
"0x333c17a58a5e9d3e8f745d354fee89f83196e8fd0ded1c9766c24425276093f",
"0x6f47c70cfad7e0865af23e60e596e4926d557bc3fc26ce96a234d55bfb04857",
"0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"0x0",
"0x2",
Expand All @@ -34,7 +34,7 @@
},
"messages": [],
"call_type": "CALL",
"class_hash": "0x75dc4457c66bfb3808c67a918047b8f0973ea8b876056b72e99f651b91298ca",
"class_hash": "0x71df7c871d389943e24aaaf85d41594266d12f2f9b580a9f92ba4a0bf763d67",
"result": [],
"events": [],
"calldata": [
Expand All @@ -44,7 +44,7 @@
"caller_address": "0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"entry_point_type": "EXTERNAL",
"selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320",
"contract_address": "0x333c17a58a5e9d3e8f745d354fee89f83196e8fd0ded1c9766c24425276093f",
"contract_address": "0x6f47c70cfad7e0865af23e60e596e4926d557bc3fc26ce96a234d55bfb04857",
"internal_calls": []
}
]
Expand Down
2 changes: 1 addition & 1 deletion test/expected/invoke_receipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x416017615e785233a2ec6b6a16058eef596a40171b2517add5167bd5ba1ab88",
"0x3711666a3506c99c9d78c4d4013409a87a962b7a0880a1c24af9fe193dafc01",
"0x16010bdfe1800",
"0x0"
],
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": "0x1fbcb39359c1d204c9fa13318451c208026c01b77513d4eac72b13798184372",
"from_address": "0x5b5c8722ce893e19fc813996e610f0699fbe9b6c685ce175e60d7cbdbb87fa1",
"keys": [
"0x3db3da4221c078e78bd987e54e1cc24570d89a7002cefa33e548d6c72c73f9d"
]
},
{
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x416017615e785233a2ec6b6a16058eef596a40171b2517add5167bd5ba1ab88",
"0x3711666a3506c99c9d78c4d4013409a87a962b7a0880a1c24af9fe193dafc01",
"0x5a5c900900",
"0x0"
],
Expand Down
4 changes: 2 additions & 2 deletions test/expected/invoke_receipt_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"0x0",
"0xa"
],
"from_address": "0x1fbcb39359c1d204c9fa13318451c208026c01b77513d4eac72b13798184372",
"from_address": "0x5b5c8722ce893e19fc813996e610f0699fbe9b6c685ce175e60d7cbdbb87fa1",
"keys": [
"0x3db3da4221c078e78bd987e54e1cc24570d89a7002cefa33e548d6c72c73f9d"
]
},
{
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x416017615e785233a2ec6b6a16058eef596a40171b2517add5167bd5ba1ab88",
"0x3711666a3506c99c9d78c4d4013409a87a962b7a0880a1c24af9fe193dafc01",
"0x160f992a32800",
"0x0"
],
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/test_data/get_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
INCREASE_BALANCE_BY_0_EVENT = [0, 0]
INCREASE_BALANCE_BY_1_EVENT = [0, 1]
EVENT_FEE_ADDRESS = (
1848132115085043480193496279185058626650378119257763769763822937432943340424
1556746869602934183907209817909870193193832701883543897870108478262537288705
)
FEE_CHARGING_IN_BLOCK_2_EVENT = [
int(PREDEPLOYED_ACCOUNT_ADDRESS, 16),
Expand Down
62 changes: 0 additions & 62 deletions test/sample_tx_objects.py

This file was deleted.

11 changes: 3 additions & 8 deletions test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,15 @@
"916907772491729262376534102982219947830828984996257231353398618781993312401"
)

SIGNATURE = [
"1225578735933442828068102633747590437426782890965066746429241472187377583468",
"3568809569741913715045370357918125425757114920266578211811626257903121825123",
]

EXPECTED_SALTY_DEPLOY_ADDRESS = (
"0x01fbcb39359c1d204c9fa13318451c208026c01b77513d4eac72b13798184372"
"0x05b5c8722ce893e19fc813996e610f0699fbe9b6c685ce175e60d7cbdbb87fa1"
)
EXPECTED_SALTY_DEPLOY_HASH = (
"0x799357c54a299cfdc53cf56951cd6f80f8881bdf7fc1d220b92c0af45bf1302"
"0x2e750343e63dc7ddf543c196c54018b4e5989acd413e6acafdae62ef2c3146d"
)

EXPECTED_CLASS_HASH = (
"0x75dc4457c66bfb3808c67a918047b8f0973ea8b876056b72e99f651b91298ca"
"0x71df7c871d389943e24aaaf85d41594266d12f2f9b580a9f92ba4a0bf763d67"
)

NONEXISTENT_TX_HASH = "0x1"
Expand Down
2 changes: 1 addition & 1 deletion test/test_block_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def my_get_block_number(address: str):
)


EXPECTED_TX_HASH = "0x4b366dbf9260f983daa608139943a8baa059668ef2df07b1f7b9ebbcb9240df"
EXPECTED_TX_HASH = "0x2a80a6c3878fb0b68b2da38b4a488276c014d955d1bf17933aefab6cb722121"


@pytest.mark.usefixtures("run_devnet_in_background")
Expand Down
Loading

0 comments on commit a76cc16

Please sign in to comment.