From 8ba43cb7477007a10c3f82e926845d0f2adebdae Mon Sep 17 00:00:00 2001 From: FabijanC Date: Wed, 15 Dec 2021 16:41:57 +0100 Subject: [PATCH] Adapt to work with cairo-lang v0.6.2 (#19) * Adapt to work with cairo-lang v0.6.2 * Set plugin-test no_output_timeout to 1m * Use settings.ini in test-plugin.sh * Install plugin from source --- .circleci/config.yml | 1 + poetry.lock | 6 +++--- pyproject.toml | 2 +- scripts/setup-example.sh | 11 ++++++++++- scripts/test-cli-auth.sh | 4 ++-- scripts/test-cli.sh | 4 ++-- scripts/test-plugin.sh | 6 ++++-- starknet_devnet/server.py | 2 +- starknet_devnet/util.py | 11 +++++++---- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d0069fd05..97a0022e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,6 +34,7 @@ jobs: - run: name: Test plugin command: ./scripts/test-plugin.sh + no_output_timeout: 1m package_build_and_publish: docker: - image: cimg/python:3.7 diff --git a/poetry.lock b/poetry.lock index f0bfa3caa..f5e5e6e4a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -115,7 +115,7 @@ python-versions = "~=3.5" [[package]] name = "cairo-lang" -version = "0.6.1" +version = "0.6.2" description = "Compiler and runner for the Cairo language" category = "main" optional = false @@ -1027,7 +1027,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "89b0bf80957b90db52c443da252c6a6b9ac6aed37f22b2fd21b6482cf24cffb2" +content-hash = "6c61ecdadb44e5150281d9fbc4e3cc8ec9c76c34ae71f0bd5fc7a717df98bedd" [metadata.files] aiohttp = [ @@ -1140,7 +1140,7 @@ cachetools = [ {file = "cachetools-4.2.4.tar.gz", hash = "sha256:89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693"}, ] cairo-lang = [ - {file = "cairo-lang-0.6.1.zip", hash = "sha256:84e61ae768eee8df9b9c29b31224564d0a21349eb7d6ef0b77e61dca85d985d6"}, + {file = "cairo-lang-0.6.2.zip", hash = "sha256:ff3cf5fd4c92e861f22c853ccb22ec384abdcb6c7fa042b93e16d5c6ace6b9a4"}, ] certifi = [ {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"}, diff --git a/pyproject.toml b/pyproject.toml index 804cb591b..758375045 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ keywords = ["starknet", "cairo", "testnet", "local", "server"] python = "^3.7" Flask = {extras = ["async"], version = "^2.0.2"} flask-cors = "^3.0.10" -cairo-lang = "0.6.1" +cairo-lang = "0.6.2" [tool.poetry.dev-dependencies] diff --git a/scripts/setup-example.sh b/scripts/setup-example.sh index 21925adee..00f9d8e64 100755 --- a/scripts/setup-example.sh +++ b/scripts/setup-example.sh @@ -1,10 +1,19 @@ #!/bin/bash set -e -echo "Cloning branch 'devnet'" +echo "Installing starknet-hardhat-plugin from source" +git clone -b master --single-branch git@github.com:Shard-Labs/starknet-hardhat-plugin.git +cd starknet-hardhat-plugin +npm ci +npm run build +npm link +cd .. + +echo "Cloning starknet-hardhat-example branch 'devnet'" git clone -b devnet --single-branch git@github.com:Shard-Labs/starknet-hardhat-example.git cd starknet-hardhat-example npm ci +npm link @shardlabs/starknet-hardhat-plugin # generate artifacts npx hardhat starknet-compile diff --git a/scripts/test-cli-auth.sh b/scripts/test-cli-auth.sh index a64f79c42..a3e4ddd27 100755 --- a/scripts/test-cli-auth.sh +++ b/scripts/test-cli-auth.sh @@ -27,14 +27,14 @@ echo "tx_hash: $deploy_tx_hash" # inspects status from tx_status object deploy_tx_status=$(starknet tx_status --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".tx_status" -r) -if [ "$deploy_tx_status" != "PENDING" ]; then +if [ "$deploy_tx_status" != "ACCEPTED_ON_L2" ]; then echo "Wrong tx_status: $deploy_tx_status" exit 2 fi # inspects status from tx object deploy_tx_status2=$(starknet get_transaction --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".status" -r) -if [ "$deploy_tx_status2" != "PENDING" ]; then +if [ "$deploy_tx_status2" != "ACCEPTED_ON_L2" ]; then echo "Wrong status in tx: $deploy_tx_status2" exit 2 fi diff --git a/scripts/test-cli.sh b/scripts/test-cli.sh index e79852767..0e8bbeefd 100755 --- a/scripts/test-cli.sh +++ b/scripts/test-cli.sh @@ -25,14 +25,14 @@ echo "tx_hash: $deploy_tx_hash" # inspects status from tx_status object deploy_tx_status=$(starknet tx_status --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".tx_status" -r) -if [ "$deploy_tx_status" != "PENDING" ]; then +if [ "$deploy_tx_status" != "ACCEPTED_ON_L2" ]; then echo "Wrong tx_status: $deploy_tx_status" exit 2 fi # inspects status from tx object deploy_tx_status2=$(starknet get_transaction --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".status" -r) -if [ "$deploy_tx_status2" != "PENDING" ]; then +if [ "$deploy_tx_status2" != "ACCEPTED_ON_L2" ]; then echo "Wrong status in tx: $deploy_tx_status2" exit 2 fi diff --git a/scripts/test-plugin.sh b/scripts/test-plugin.sh index 6c82eda36..465f0182d 100755 --- a/scripts/test-plugin.sh +++ b/scripts/test-plugin.sh @@ -1,10 +1,12 @@ #!/bin/bash set -e +source scripts/settings.ini +[ -f .env ] && source .env + trap 'kill $(jobs -p)' EXIT -poetry run starknet-devnet --host=localhost --port=5000 & -GATEWAY_URL=http://localhost:5000 +poetry run starknet-devnet --host="$host" --port="$port" & sleep 1 # give the server some time to get up function extract_address () { diff --git a/starknet_devnet/server.py b/starknet_devnet/server.py index 2258ba1f4..69610b2a2 100644 --- a/starknet_devnet/server.py +++ b/starknet_devnet/server.py @@ -38,7 +38,7 @@ async def add_transaction(): tx_type = transaction.tx_type.name result_dict = {} - status = TxStatus.PENDING + status = TxStatus.ACCEPTED_ON_L2 error_message = None if tx_type == TransactionType.DEPLOY.name: diff --git a/starknet_devnet/util.py b/starknet_devnet/util.py index 331e73c42..b6140013f 100644 --- a/starknet_devnet/util.py +++ b/starknet_devnet/util.py @@ -10,19 +10,22 @@ class TxStatus(Enum): According to: https://www.cairo-lang.org/docs/hello_starknet/intro.html#interact-with-the-contract """ - PENDING = auto() - """The transaction passed the validation and is waiting to be sent on-chain.""" - NOT_RECEIVED = auto() """The transaction has not been received yet (i.e., not written to storage""" RECEIVED = auto() """The transaction was received by the operator.""" + PENDING = auto() + """The transaction passed the validation and entered the pending block.""" + REJECTED = auto() """The transaction failed validation and thus was skipped.""" - ACCEPTED_ONCHAIN = auto() + ACCEPTED_ON_L2 = auto() + """The transaction passed the validation and entered an actual created block.""" + + ACCEPTED_ON_L1 = auto() """The transaction was accepted on-chain.""" def custom_int(arg: str) -> str: