From 8f250596a09b8b3abbc4bdaf195ecbde2584bf9b Mon Sep 17 00:00:00 2001 From: Vid Kersic Date: Thu, 21 Sep 2023 11:49:35 +0200 Subject: [PATCH] fix: bundler spec tests --- .github/workflows/ci.yml | 8 +++---- Dockerfile | 2 +- README.md | 2 +- bin/silius/src/cli/args.rs | 2 +- bundler-spec-tests/docker-compose.yml | 29 +++++++++++++++++++++++--- bundler-spec-tests/geth-dev/Dockerfile | 19 ----------------- bundler-spec-tests/launcher.sh | 3 ++- crates/contracts/src/tracer.rs | 5 ++++- docker-compose.yml | 1 + 9 files changed, 40 insertions(+), 31 deletions(-) delete mode 100644 bundler-spec-tests/geth-dev/Dockerfile mode change 100644 => 100755 bundler-spec-tests/launcher.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8fc126a..d71ec2e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,9 @@ jobs: sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install solc - wget -c https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.11.6-ea9e62ca.tar.gz - tar -xf geth-linux-amd64-1.11.6-ea9e62ca.tar.gz - mv geth-linux-amd64-1.11.6-ea9e62ca/geth /usr/local/bin/ + wget -c https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.12.0-e501b3b0.tar.gz + tar -xf geth-linux-amd64-1.12.0-e501b3b0.tar.gz + mv geth-linux-amd64-1.12.0-e501b3b0/geth /usr/local/bin/ chmod a+x /usr/local/bin/geth - name: Build @@ -111,4 +111,4 @@ jobs: - run: npm install -g yarn - name: Run tests - run: pdm run test --launcher-script silius/bundler-spec-tests/launcher.sh --url http://localhost:3000 + run: pdm run test --launcher-script silius/bundler-spec-tests/launcher.sh --url http://127.0.0.1:3000 diff --git a/Dockerfile b/Dockerfile index 23750a8b..75259de0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN apk add openssl1.1-compat COPY --from=builder /silius/target/release/silius /usr/local/bin/silius -EXPOSE 3000 +EXPOSE 3000 3001 ENTRYPOINT ["usr/local/bin/silius"] diff --git a/README.md b/README.md index dd9b4e09..c6cf5b61 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ For more information: https://hackmd.io/@Vid201/aa-bundler-rust Rust version: 1.71.1 1. `libclang-dev`, `pkg-config` and `libssl-dev` on Debian/Ubuntu. -2. Ethereum execution client JSON-RPC API with enabled [`debug_traceCall`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_tracecall). For production, you can use [Geth](https://github.com/ethereum/go-ethereum) or [Erigon](https://github.com/ledgerwatch/erigon). For testing, we are using Geth dev mode (tested with [v1.11.6](https://github.com/ethereum/go-ethereum/releases/tag/v1.11.6)); so you need to install [Geth](https://geth.ethereum.org/docs/getting-started/installing-geth) for running tests. +2. Ethereum execution client JSON-RPC API with enabled [`debug_traceCall`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_tracecall). For production, you can use [Geth](https://github.com/ethereum/go-ethereum) or [Erigon](https://github.com/ledgerwatch/erigon). For testing, we are using Geth dev mode (tested with [v1.12.0](https://github.com/ethereum/go-ethereum/releases/tag/v1.12.0)); so you need to install [Geth](https://geth.ethereum.org/docs/getting-started/installing-geth) for running tests. 3. [`solc`](https://docs.soliditylang.org/en/v0.8.17/installing-solidity.html) >=0.8.12. 4. [`cargo-sort`](https://crates.io/crates/cargo-sort) and [`cargo-udeps`](https://crates.io/crates/cargo-udeps). diff --git a/bin/silius/src/cli/args.rs b/bin/silius/src/cli/args.rs index 336b1396..f411492a 100644 --- a/bin/silius/src/cli/args.rs +++ b/bin/silius/src/cli/args.rs @@ -70,7 +70,7 @@ pub struct UoPoolArgs { pub datadir: Option, /// Max allowed verification gas. - #[clap(long, default_value="3000000", value_parser=parse_u256)] + #[clap(long, default_value="5000000", value_parser=parse_u256)] pub max_verification_gas: U256, /// Minimum stake required for entities. diff --git a/bundler-spec-tests/docker-compose.yml b/bundler-spec-tests/docker-compose.yml index fa3b2bdd..fa25243c 100644 --- a/bundler-spec-tests/docker-compose.yml +++ b/bundler-spec-tests/docker-compose.yml @@ -1,13 +1,36 @@ -version: '2' +version: "3" services: geth-dev: - build: geth-dev + image: ethereum/client-go:release-1.12 + healthcheck: + test: [ "CMD-SHELL", "geth attach --exec eth.blockNumber" ] + interval: 10s + timeout: 5s + retries: 5 ports: - 8545:8545 - 8546:8546 + command: + - --miner.gaslimit=12000000 + - --http + - --http.api=personal,eth,net,web3,debug + - --allow-insecure-unlock + - --rpc.allow-unprotected-txs + - --http.vhosts=* + - --http.corsdomain=* + - --http.addr=0.0.0.0 + - --ws + - --ws.api=personal,eth,net,web3,debug + - --ws.origins=* + - --ws.addr=0.0.0.0 + - --dev + - --nodiscover + - --maxpeers=0 + - --mine + - --verbosity=2 fund-signer: - image: ethereum/client-go:release-1.10 + image: ethereum/client-go:release-1.12 entrypoint: 'geth --exec "eth.sendTransaction({from: eth.accounts[0], to: \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\", value: web3.toWei(10000, \"ether\")})" attach http://geth-dev:8545' depends_on: geth-dev: diff --git a/bundler-spec-tests/geth-dev/Dockerfile b/bundler-spec-tests/geth-dev/Dockerfile deleted file mode 100644 index 5db03fc3..00000000 --- a/bundler-spec-tests/geth-dev/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM ethereum/client-go:release-1.10 - -ENTRYPOINT geth \ - --verbosity 1 \ - --http.vhosts '*,localhost,host.docker.internal' \ - --http \ - --http.api personal,eth,net,web3,debug \ - --http.corsdomain '*' \ - --http.addr "0.0.0.0" \ - --ws \ - --ws.api personal,eth,net,web3,debug \ - --ws.origins '*' \ - --ws.addr "0.0.0.0" \ - --nodiscover --maxpeers 0 --mine \ - --networkid 1337 \ - --dev \ - --allow-insecure-unlock \ - --rpc.allow-unprotected-txs \ - --dev.gaslimit 20000000 \ No newline at end of file diff --git a/bundler-spec-tests/launcher.sh b/bundler-spec-tests/launcher.sh old mode 100644 new mode 100755 index af796c8c..d51e26e5 --- a/bundler-spec-tests/launcher.sh +++ b/bundler-spec-tests/launcher.sh @@ -10,9 +10,10 @@ case $1 in start) docker-compose up -d + sleep 2 silius bundler \ --verbosity 4 \ - --eth-client-address ws://localhost:8545 \ + --eth-client-address ws://127.0.0.1:8546 \ --mnemonic-file keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ --beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \ --entry-points 0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789 \ diff --git a/crates/contracts/src/tracer.rs b/crates/contracts/src/tracer.rs index 2f233831..fd441686 100644 --- a/crates/contracts/src/tracer.rs +++ b/crates/contracts/src/tracer.rs @@ -165,7 +165,10 @@ pub const JS_TRACER: &str = r#" this.lastThreeOpcodes.shift(); } // this.debug.push(this.lastOp + '-' + opcode + '-' + log.getDepth() + '-' + log.getGas() + '-' + log.getCost()) - if (log.getGas() < log.getCost()) { + if (log.getGas() < log.getCost() || ( + // special rule for SSTORE with gas metering + opcode === 'SSTORE' && log.getGas() < 2300) + ) { this.currentLevel.oog = true; } if (opcode === 'REVERT' || opcode === 'RETURN') { diff --git a/docker-compose.yml b/docker-compose.yml index 64bc8ec2..6549285a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,5 @@ version: "3" + services: silius: image: ghcr.io/vid201/silius:latest