mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 21:57:58 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ad3084fe1 | |||
| 66feb36b4e | |||
| cc753a1a2c | |||
| 31dfd67569 | |||
| a6e4932a08 | |||
| 06c2e023a9 | |||
| 347dcb4488 |
+137
-169
@@ -18,136 +18,95 @@ env:
|
||||
POLKADOT_VERSION: polkadot-stable2506-2
|
||||
|
||||
jobs:
|
||||
cache-polkadot:
|
||||
name: Build and cache Polkadot binaries on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-24.04, macos-14]
|
||||
|
||||
machete:
|
||||
name: Check for Unneeded Dependencies
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
RUSTC_WRAPPER: "sccache"
|
||||
steps:
|
||||
- name: Checkout repo and submodules
|
||||
- name: Checkout This Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install dependencies (Linux)
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y protobuf-compiler clang libclang-dev
|
||||
rustup target add wasm32-unknown-unknown
|
||||
rustup component add rust-src
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
if: matrix.os == 'macos-14'
|
||||
run: |
|
||||
brew install protobuf
|
||||
rustup target add wasm32-unknown-unknown
|
||||
rustup component add rust-src
|
||||
|
||||
- name: Cache binaries
|
||||
id: cache
|
||||
uses: actions/cache@v3
|
||||
- name: Run Sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
- name: Install the Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Install the Cargo Make Binary
|
||||
uses: davidB/rust-cargo-make@v1
|
||||
- name: Run Cargo Machete
|
||||
run: cargo make machete
|
||||
check-fmt:
|
||||
name: Check Formatting
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
RUSTC_WRAPPER: "sccache"
|
||||
steps:
|
||||
- name: Checkout This Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/revive-dev-node
|
||||
~/.cargo/bin/eth-rpc
|
||||
key: polkadot-binaries-${{ matrix.os }}-${{ hashFiles('polkadot-sdk/.git') }}-with-dev-node
|
||||
|
||||
- name: Build revive-dev-node
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd polkadot-sdk
|
||||
cargo install --locked --force --profile=production --path substrate/frame/revive/dev-node/node --bin revive-dev-node
|
||||
|
||||
- name: Build eth-rpc
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd polkadot-sdk
|
||||
cargo install --path substrate/frame/revive/rpc --bin eth-rpc
|
||||
|
||||
- name: Cache downloaded Polkadot binaries
|
||||
id: cache-polkadot
|
||||
uses: actions/cache@v3
|
||||
submodules: recursive
|
||||
- name: Run Sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
- name: Install the Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Install the Cargo Make Binary
|
||||
uses: davidB/rust-cargo-make@v1
|
||||
- name: Run Cargo Formatter
|
||||
run: cargo make fmt-check
|
||||
check-clippy:
|
||||
name: Check Clippy Lints
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
RUSTC_WRAPPER: "sccache"
|
||||
steps:
|
||||
- name: Checkout This Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: |
|
||||
~/polkadot-cache/polkadot
|
||||
~/polkadot-cache/polkadot-execute-worker
|
||||
~/polkadot-cache/polkadot-prepare-worker
|
||||
~/polkadot-cache/polkadot-parachain
|
||||
key: polkadot-downloaded-${{ matrix.os }}-${{ env.POLKADOT_VERSION }}
|
||||
|
||||
- name: Download Polkadot binaries on macOS
|
||||
if: matrix.os == 'macos-14' && steps.cache-polkadot.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
mkdir -p ~/polkadot-cache
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-aarch64-apple-darwin -o ~/polkadot-cache/polkadot
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-execute-worker-aarch64-apple-darwin -o ~/polkadot-cache/polkadot-execute-worker
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-prepare-worker-aarch64-apple-darwin -o ~/polkadot-cache/polkadot-prepare-worker
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-parachain-aarch64-apple-darwin -o ~/polkadot-cache/polkadot-parachain
|
||||
chmod +x ~/polkadot-cache/*
|
||||
|
||||
- name: Download Polkadot binaries on Ubuntu
|
||||
if: matrix.os == 'ubuntu-24.04' && steps.cache-polkadot.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
mkdir -p ~/polkadot-cache
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot -o ~/polkadot-cache/polkadot
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-execute-worker -o ~/polkadot-cache/polkadot-execute-worker
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-prepare-worker -o ~/polkadot-cache/polkadot-prepare-worker
|
||||
curl -sL https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-parachain -o ~/polkadot-cache/polkadot-parachain
|
||||
chmod +x ~/polkadot-cache/*
|
||||
|
||||
ci:
|
||||
name: CI on ${{ matrix.os }}
|
||||
submodules: recursive
|
||||
- name: Run Sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
- name: Install the Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Install the Cargo Make Binary
|
||||
uses: davidB/rust-cargo-make@v1
|
||||
- name: Run Cargo Clippy
|
||||
run: cargo make clippy
|
||||
test:
|
||||
name: Unit Tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: cache-polkadot
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-24.04, macos-14]
|
||||
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
RUSTC_WRAPPER: "sccache"
|
||||
POLKADOT_SDK_COMMIT_HASH: "30cda2aad8612a10ff729d494acd9d5353294d63"
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
- name: Checkout This Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Restore binaries from cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/revive-dev-node
|
||||
~/.cargo/bin/eth-rpc
|
||||
key: polkadot-binaries-${{ matrix.os }}-${{ hashFiles('polkadot-sdk/.git') }}-with-dev-node
|
||||
|
||||
- name: Restore downloaded Polkadot binaries from cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/polkadot-cache/polkadot
|
||||
~/polkadot-cache/polkadot-execute-worker
|
||||
~/polkadot-cache/polkadot-prepare-worker
|
||||
~/polkadot-cache/polkadot-parachain
|
||||
key: polkadot-downloaded-${{ matrix.os }}-${{ env.POLKADOT_VERSION }}
|
||||
|
||||
- name: Install Polkadot binaries
|
||||
run: |
|
||||
sudo cp ~/polkadot-cache/polkadot /usr/local/bin/
|
||||
sudo cp ~/polkadot-cache/polkadot-execute-worker /usr/local/bin/
|
||||
sudo cp ~/polkadot-cache/polkadot-prepare-worker /usr/local/bin/
|
||||
sudo cp ~/polkadot-cache/polkadot-parachain /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/polkadot*
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
- name: Run Sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
- name: Install the Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
rustflags: ""
|
||||
|
||||
- name: Add wasm32 target and formatting
|
||||
run: |
|
||||
rustup target add wasm32-unknown-unknown
|
||||
rustup component add rust-src rustfmt clippy
|
||||
|
||||
target: "wasm32-unknown-unknown"
|
||||
components: "rust-src,rust-std"
|
||||
- name: Install the Cargo Make Binary
|
||||
uses: davidB/rust-cargo-make@v1
|
||||
- name: Caching Step
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/eth-rpc
|
||||
~/.cargo/bin/revive-dev-node
|
||||
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}-${{ matrix.os }}
|
||||
- name: Install Geth on Ubuntu
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
@@ -180,7 +139,6 @@ jobs:
|
||||
curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-x86_64-unknown-linux-musl -o resolc
|
||||
chmod +x resolc
|
||||
sudo mv resolc /usr/local/bin
|
||||
|
||||
- name: Install Geth on macOS
|
||||
if: matrix.os == 'macos-14'
|
||||
run: |
|
||||
@@ -192,69 +150,79 @@ jobs:
|
||||
curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-universal-apple-darwin -o resolc
|
||||
chmod +x resolc
|
||||
sudo mv resolc /usr/local/bin
|
||||
|
||||
- name: Install Kurtosis on macOS
|
||||
if: matrix.os == 'macos-14'
|
||||
run: brew install kurtosis-tech/tap/kurtosis-cli
|
||||
|
||||
- name: Install Kurtosis on Ubuntu
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: |
|
||||
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
|
||||
sudo apt update
|
||||
sudo apt install kurtosis-cli
|
||||
|
||||
- name: Install cargo-machete
|
||||
uses: clechasseur/rs-cargo@v2
|
||||
- name: Run Tests
|
||||
run: cargo make test
|
||||
cache-polkadot:
|
||||
name: Build and Cache Polkadot Binaries on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-24.04, macos-14]
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
RUSTC_WRAPPER: "sccache"
|
||||
RUSTFLAGS: "-Awarnings"
|
||||
POLKADOT_SDK_COMMIT_HASH: "30cda2aad8612a10ff729d494acd9d5353294d63"
|
||||
steps:
|
||||
- name: Caching Step
|
||||
id: cache-step
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
command: install
|
||||
args: cargo-machete@0.7.0
|
||||
- name: Machete
|
||||
run: cargo machete crates
|
||||
path: |
|
||||
~/.cargo/bin/eth-rpc
|
||||
~/.cargo/bin/revive-dev-node
|
||||
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}-${{ matrix.os }}
|
||||
- name: Checkout the Polkadot SDK Repository
|
||||
uses: actions/checkout@v4
|
||||
if: steps.cache-step.outputs.cache-hit != 'true'
|
||||
with:
|
||||
repository: paritytech/polkadot-sdk
|
||||
ref: ${{ env.POLKADOT_SDK_COMMIT_HASH }}
|
||||
submodules: recursive
|
||||
- name: Run Sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
if: steps.cache-step.outputs.cache-hit != 'true'
|
||||
- name: Install the Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
if: steps.cache-step.outputs.cache-hit != 'true'
|
||||
with:
|
||||
target: "wasm32-unknown-unknown"
|
||||
components: "rust-src"
|
||||
toolchain: "1.90.0"
|
||||
|
||||
- name: Format
|
||||
run: make format
|
||||
|
||||
- name: Clippy
|
||||
run: make clippy
|
||||
|
||||
- name: Check revive-dev-node version
|
||||
run: revive-dev-node --version
|
||||
|
||||
- name: Check eth-rpc version
|
||||
run: eth-rpc --version
|
||||
|
||||
- name: Check resolc version
|
||||
run: resolc --version
|
||||
|
||||
- name: Check polkadot version
|
||||
run: polkadot --version
|
||||
|
||||
- name: Check polkadot-parachain version
|
||||
run: polkadot-parachain --version
|
||||
|
||||
- name: Check polkadot-execute-worker version
|
||||
run: polkadot-execute-worker --version
|
||||
|
||||
- name: Check polkadot-prepare-worker version
|
||||
run: polkadot-prepare-worker --version
|
||||
|
||||
- name: Test Formatting
|
||||
run: make format
|
||||
|
||||
- name: Test Clippy
|
||||
run: make clippy
|
||||
|
||||
- name: Test Machete
|
||||
run: make machete
|
||||
|
||||
- name: Unit Tests
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
run: cargo test --workspace -- --nocapture
|
||||
|
||||
# We can't install docker in the MacOS image used in CI and therefore we need to skip the
|
||||
# Kurtosis and lighthouse related tests when running the CI on MacOS.
|
||||
- name: Unit Tests
|
||||
if: matrix.os == 'macos-14'
|
||||
- name: Install dependencies (Linux)
|
||||
if: matrix.os == 'ubuntu-24.04' && steps.cache-step.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cargo test --workspace -- --nocapture --skip lighthouse_geth::tests::
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y protobuf-compiler clang libclang-dev
|
||||
- name: Install dependencies (macOS)
|
||||
if: matrix.os == 'macos-14' && steps.cache-step.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
brew install protobuf llvm
|
||||
LLVM_PREFIX="$(brew --prefix llvm)"
|
||||
echo "LDFLAGS=-L${LLVM_PREFIX}/lib" >> "$GITHUB_ENV"
|
||||
echo "CPPFLAGS=-I${LLVM_PREFIX}/include" >> "$GITHUB_ENV"
|
||||
echo "CMAKE_PREFIX_PATH=${LLVM_PREFIX}" >> "$GITHUB_ENV"
|
||||
echo "LIBCLANG_PATH=${LLVM_PREFIX}/lib" >> "$GITHUB_ENV"
|
||||
echo "DYLD_FALLBACK_LIBRARY_PATH=${LLVM_PREFIX}/lib" >> "$GITHUB_ENV"
|
||||
echo "${LLVM_PREFIX}/bin" >> "$GITHUB_PATH"
|
||||
- name: Build Polkadot Dependencies
|
||||
if: steps.cache-step.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cargo build \
|
||||
--locked \
|
||||
--profile production \
|
||||
--package revive-dev-node \
|
||||
--package pallet-revive-eth-rpc;
|
||||
mv ./target/production/revive-dev-node ~/.cargo/bin
|
||||
mv ./target/production/eth-rpc ~/.cargo/bin
|
||||
chmod +x ~/.cargo/bin/*
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/*.json
|
||||
*.sh
|
||||
|
||||
# We do not want to commit any log files that we produce from running the code locally so this is
|
||||
# added to the .gitignore file.
|
||||
@@ -13,3 +14,4 @@ workdir
|
||||
|
||||
!/schema.json
|
||||
!/dev-genesis.json
|
||||
!/scripts/*
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
[submodule "polkadot-sdk"]
|
||||
path = polkadot-sdk
|
||||
url = https://github.com/paritytech/polkadot-sdk.git
|
||||
[submodule "resolc-compiler-tests"]
|
||||
path = resolc-compiler-tests
|
||||
url = https://github.com/paritytech/resolc-compiler-tests
|
||||
|
||||
Generated
+1
@@ -5657,6 +5657,7 @@ dependencies = [
|
||||
"semver 1.0.26",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"subxt 0.44.0",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
.PHONY: format clippy test machete
|
||||
|
||||
format:
|
||||
cargo fmt --all -- --check
|
||||
|
||||
clippy:
|
||||
cargo clippy --all-features --workspace -- --deny warnings
|
||||
|
||||
machete:
|
||||
cargo install cargo-machete
|
||||
cargo machete crates
|
||||
|
||||
test: format clippy machete
|
||||
cargo test --workspace -- --nocapture
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[config]
|
||||
default_to_workspace = false
|
||||
|
||||
[tasks.machete]
|
||||
command = "cargo"
|
||||
args = ["machete", "crates"]
|
||||
install_crate = "cargo-machete"
|
||||
|
||||
[tasks.fmt-check]
|
||||
command = "cargo"
|
||||
args = ["fmt", "--all", "--", "--check"]
|
||||
install_crate = "rustfmt"
|
||||
|
||||
[tasks.clippy]
|
||||
command = "cargo"
|
||||
args = ["clippy", "--all-features", "--workspace", "--", "--deny", "warnings"]
|
||||
install_crate = "clippy"
|
||||
|
||||
[tasks.test]
|
||||
command = "cargo"
|
||||
args = ["test", "--workspace", "--", "--nocapture"]
|
||||
Binary file not shown.
@@ -37,6 +37,7 @@ schemars = { workspace = true }
|
||||
semver = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
subxt = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -127,6 +127,8 @@ where
|
||||
.inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
|
||||
.context("Failed to produce the pre-linking compiled contracts")?;
|
||||
|
||||
let deployer_address = self.test_definition.case.deployer_address();
|
||||
|
||||
let mut deployed_libraries = None::<HashMap<_, _>>;
|
||||
let mut contract_sources = self
|
||||
.test_definition
|
||||
@@ -159,23 +161,6 @@ where
|
||||
|
||||
let code = alloy::hex::decode(code)?;
|
||||
|
||||
// Getting the deployer address from the cases themselves. This is to ensure
|
||||
// that we're doing the deployments from different accounts and therefore we're
|
||||
// not slowed down by the nonce.
|
||||
let deployer_address = self
|
||||
.test_definition
|
||||
.case
|
||||
.steps
|
||||
.iter()
|
||||
.filter_map(|step| match step {
|
||||
Step::FunctionCall(input) => input.caller.as_address().copied(),
|
||||
Step::BalanceAssertion(..) => None,
|
||||
Step::StorageEmptyAssertion(..) => None,
|
||||
Step::Repeat(..) => None,
|
||||
Step::AllocateAccount(..) => None,
|
||||
})
|
||||
.next()
|
||||
.unwrap_or(FunctionCallStep::default_caller_address());
|
||||
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
|
||||
TransactionRequest::default().from(deployer_address),
|
||||
code,
|
||||
|
||||
@@ -8,7 +8,7 @@ use alloy::{
|
||||
hex,
|
||||
json_abi::JsonAbi,
|
||||
network::{Ethereum, TransactionBuilder},
|
||||
primitives::{Address, TxHash, U256},
|
||||
primitives::{Address, TxHash, U256, address},
|
||||
rpc::types::{
|
||||
TransactionReceipt, TransactionRequest,
|
||||
trace::geth::{
|
||||
@@ -18,9 +18,9 @@ use alloy::{
|
||||
},
|
||||
};
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
use futures::TryStreamExt;
|
||||
use futures::{TryStreamExt, future::try_join_all};
|
||||
use indexmap::IndexMap;
|
||||
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator};
|
||||
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator, VmIdentifier};
|
||||
use revive_dt_format::{
|
||||
metadata::{ContractInstance, ContractPathAndIdent},
|
||||
steps::{
|
||||
@@ -30,6 +30,7 @@ use revive_dt_format::{
|
||||
},
|
||||
traits::ResolutionContext,
|
||||
};
|
||||
use subxt::{ext::codec::Decode, metadata::Metadata, tx::Payload};
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
@@ -198,6 +199,8 @@ where
|
||||
})
|
||||
.context("Failed to produce the pre-linking compiled contracts")?;
|
||||
|
||||
let deployer_address = test_definition.case.deployer_address();
|
||||
|
||||
let mut deployed_libraries = None::<HashMap<_, _>>;
|
||||
let mut contract_sources = test_definition
|
||||
.metadata
|
||||
@@ -232,22 +235,6 @@ where
|
||||
|
||||
let code = alloy::hex::decode(code)?;
|
||||
|
||||
// Getting the deployer address from the cases themselves. This is to ensure
|
||||
// that we're doing the deployments from different accounts and therefore we're
|
||||
// not slowed down by the nonce.
|
||||
let deployer_address = test_definition
|
||||
.case
|
||||
.steps
|
||||
.iter()
|
||||
.filter_map(|step| match step {
|
||||
Step::FunctionCall(input) => input.caller.as_address().copied(),
|
||||
Step::BalanceAssertion(..) => None,
|
||||
Step::StorageEmptyAssertion(..) => None,
|
||||
Step::Repeat(..) => None,
|
||||
Step::AllocateAccount(..) => None,
|
||||
})
|
||||
.next()
|
||||
.unwrap_or(FunctionCallStep::default_caller_address());
|
||||
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
|
||||
TransactionRequest::default().from(deployer_address),
|
||||
code,
|
||||
@@ -295,6 +282,51 @@ where
|
||||
})
|
||||
.context("Failed to compile the post-link contracts")?;
|
||||
|
||||
// Factory contracts on the PVM refer to the code that they're instantiating by hash rather
|
||||
// than including the actual bytecode. This creates a problem where a factory contract could
|
||||
// be deployed but the code it's supposed to create is not on chain. Therefore, we upload
|
||||
// all the code to the chain prior to running any transactions on the driver.
|
||||
if platform_information.platform.vm_identifier() == VmIdentifier::PolkaVM {
|
||||
#[subxt::subxt(runtime_metadata_path = "../../assets/revive_metadata.scale")]
|
||||
pub mod revive {}
|
||||
|
||||
let metadata_bytes = include_bytes!("../../../../assets/revive_metadata.scale");
|
||||
let metadata = Metadata::decode(&mut &metadata_bytes[..])
|
||||
.context("Failed to decode the revive metadata")?;
|
||||
|
||||
const RUNTIME_PALLET_ADDRESS: Address =
|
||||
address!("0x6d6f646c70792f70616464720000000000000000");
|
||||
|
||||
let code_upload_tasks = compiler_output
|
||||
.contracts
|
||||
.values()
|
||||
.flat_map(|item| item.values())
|
||||
.map(|(code_string, _)| {
|
||||
let metadata = metadata.clone();
|
||||
async move {
|
||||
let code = alloy::hex::decode(code_string)
|
||||
.context("Failed to hex-decode the post-link code. This is a bug")?;
|
||||
let payload = revive::tx().revive().upload_code(code, u128::MAX);
|
||||
let encoded_payload = payload
|
||||
.encode_call_data(&metadata)
|
||||
.context("Failed to encode the upload code payload")?;
|
||||
|
||||
let tx_request = TransactionRequest::default()
|
||||
.from(deployer_address)
|
||||
.to(RUNTIME_PALLET_ADDRESS)
|
||||
.input(encoded_payload.into());
|
||||
platform_information
|
||||
.node
|
||||
.execute_transaction(tx_request)
|
||||
.await
|
||||
.context("Failed to execute transaction")
|
||||
}
|
||||
});
|
||||
try_join_all(code_upload_tasks)
|
||||
.await
|
||||
.context("Code upload failed")?;
|
||||
}
|
||||
|
||||
Ok(ExecutionState::new(
|
||||
compiler_output.contracts,
|
||||
deployed_libraries.unwrap_or_default(),
|
||||
@@ -359,7 +391,11 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument(level = "info", skip_all)]
|
||||
#[instrument(
|
||||
level = "info",
|
||||
skip_all,
|
||||
fields(block_number = tracing::field::Empty)
|
||||
)]
|
||||
pub async fn execute_function_call(
|
||||
&mut self,
|
||||
_: &StepPath,
|
||||
@@ -373,6 +409,7 @@ where
|
||||
.handle_function_call_execution(step, deployment_receipts)
|
||||
.await
|
||||
.context("Failed to handle the function call execution")?;
|
||||
tracing::Span::current().record("block_number", execution_receipt.block_number);
|
||||
let tracing_result = self
|
||||
.handle_function_call_call_frame_tracing(execution_receipt.transaction_hash)
|
||||
.await
|
||||
@@ -616,8 +653,8 @@ where
|
||||
}
|
||||
|
||||
// Handling the calldata assertion
|
||||
if let Some(ref expected_calldata) = assertion.return_data {
|
||||
let expected = expected_calldata;
|
||||
if let Some(ref expected_output) = assertion.return_data {
|
||||
let expected = expected_output;
|
||||
let actual = &tracing_result.output.as_ref().unwrap_or_default();
|
||||
if !expected
|
||||
.is_equivalent(actual, resolver.as_ref(), resolution_context)
|
||||
@@ -628,9 +665,9 @@ where
|
||||
?receipt,
|
||||
?expected,
|
||||
%actual,
|
||||
"Calldata assertion failed"
|
||||
"Output assertion failed"
|
||||
);
|
||||
anyhow::bail!("Calldata assertion failed - Expected {expected:?} but got {actual}",);
|
||||
anyhow::bail!("Output assertion failed - Expected {expected:?} but got {actual}",);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use alloy::primitives::Address;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -107,6 +108,20 @@ impl Case {
|
||||
None => Mode::all().cloned().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deployer_address(&self) -> Address {
|
||||
self.steps
|
||||
.iter()
|
||||
.filter_map(|step| match step {
|
||||
Step::FunctionCall(input) => input.caller.as_address().copied(),
|
||||
Step::BalanceAssertion(..) => None,
|
||||
Step::StorageEmptyAssertion(..) => None,
|
||||
Step::Repeat(..) => None,
|
||||
Step::AllocateAccount(..) => None,
|
||||
})
|
||||
.next()
|
||||
.unwrap_or(FunctionCallStep::default_caller_address())
|
||||
}
|
||||
}
|
||||
|
||||
define_wrapper_type!(
|
||||
|
||||
@@ -706,6 +706,7 @@ impl Calldata {
|
||||
.await
|
||||
.context("Failed to resolve calldata item during equivalence check")?;
|
||||
let other = U256::from_be_slice(&other);
|
||||
|
||||
Ok(this == other)
|
||||
})
|
||||
.buffered(0xFF)
|
||||
@@ -718,7 +719,7 @@ impl Calldata {
|
||||
}
|
||||
|
||||
impl CalldataItem {
|
||||
#[instrument(level = "info", skip_all, err)]
|
||||
#[instrument(level = "info", skip_all, err(Debug))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
resolver: &(impl ResolverApi + ?Sized),
|
||||
@@ -906,7 +907,7 @@ impl<T: AsRef<str>> CalldataToken<T> {
|
||||
let block_hash = resolver
|
||||
.block_hash(desired_block_number.into())
|
||||
.await
|
||||
.context("Failed to resolve block hash for desired block number")?;
|
||||
.context(format!("Failed to resolve the block hash of block number {desired_block_number}"))?;
|
||||
|
||||
Ok(U256::from_be_bytes(block_hash.0))
|
||||
} else if item == Self::BLOCK_NUMBER_VARIABLE {
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
pin::Pin,
|
||||
process::{Command, Stdio},
|
||||
sync::{
|
||||
Arc,
|
||||
Arc, Mutex,
|
||||
atomic::{AtomicU32, Ordering},
|
||||
},
|
||||
time::Duration,
|
||||
@@ -32,7 +32,7 @@ use futures::{FutureExt, Stream, StreamExt};
|
||||
use revive_common::EVMVersion;
|
||||
use revive_dt_common::fs::clear_directory;
|
||||
use revive_dt_format::traits::ResolverApi;
|
||||
use serde_json::json;
|
||||
use serde_json::{Value, json};
|
||||
use sp_core::crypto::Ss58Codec;
|
||||
use sp_runtime::AccountId32;
|
||||
|
||||
@@ -57,6 +57,9 @@ use crate::{
|
||||
|
||||
static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
/// The number of blocks that should be cached by the revive-dev-node and the eth-rpc.
|
||||
const NUMBER_OF_CACHED_BLOCKS: u32 = 100_000;
|
||||
|
||||
/// A node implementation for Substrate based chains. Currently, this supports either substrate
|
||||
/// or the revive-dev-node which is done by changing the path and some of the other arguments passed
|
||||
/// to the command.
|
||||
@@ -138,6 +141,8 @@ impl SubstrateNode {
|
||||
}
|
||||
|
||||
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
|
||||
static CHAINSPEC_MUTEX: Mutex<Option<Value>> = Mutex::new(None);
|
||||
|
||||
if !self.rpc_url.is_empty() {
|
||||
return Ok(self);
|
||||
}
|
||||
@@ -156,12 +161,22 @@ impl SubstrateNode {
|
||||
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
|
||||
|
||||
trace!("Creating the node genesis");
|
||||
let chainspec_json = Self::node_genesis(
|
||||
&self.node_binary,
|
||||
&self.export_chainspec_command,
|
||||
&self.wallet,
|
||||
)
|
||||
.context("Failed to prepare the chainspec command")?;
|
||||
let chainspec_json = {
|
||||
let mut chainspec_mutex = CHAINSPEC_MUTEX.lock().expect("Poisoned");
|
||||
match chainspec_mutex.as_ref() {
|
||||
Some(chainspec_json) => chainspec_json.clone(),
|
||||
None => {
|
||||
let chainspec_json = Self::node_genesis(
|
||||
&self.node_binary,
|
||||
&self.export_chainspec_command,
|
||||
&self.wallet,
|
||||
)
|
||||
.context("Failed to prepare the chainspec command")?;
|
||||
*chainspec_mutex = Some(chainspec_json.clone());
|
||||
chainspec_json
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
trace!("Writing the node genesis");
|
||||
serde_json::to_writer_pretty(
|
||||
@@ -212,6 +227,8 @@ impl SubstrateNode {
|
||||
.arg(u32::MAX.to_string())
|
||||
.arg("--pool-kbytes")
|
||||
.arg(u32::MAX.to_string())
|
||||
.arg("--state-pruning")
|
||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
||||
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
|
||||
.stdout(stdout_file)
|
||||
.stderr(stderr_file);
|
||||
@@ -251,6 +268,10 @@ impl SubstrateNode {
|
||||
.arg(format!("ws://127.0.0.1:{substrate_rpc_port}"))
|
||||
.arg("--rpc-max-connections")
|
||||
.arg(u32::MAX.to_string())
|
||||
.arg("--index-last-n-blocks")
|
||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
||||
.arg("--cache-size")
|
||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
||||
.env("RUST_LOG", Self::PROXY_LOG_ENV)
|
||||
.stdout(stdout_file)
|
||||
.stderr(stderr_file);
|
||||
@@ -303,7 +324,7 @@ impl SubstrateNode {
|
||||
.get_or_try_init(|| async move {
|
||||
construct_concurrency_limited_provider::<Ethereum, _>(
|
||||
self.rpc_url.as_str(),
|
||||
FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
|
||||
FallbackGasFiller::new(u64::MAX, 50_000_000_000, 1_000_000_000),
|
||||
ChainIdFiller::new(Some(CHAIN_ID)),
|
||||
NonceFiller::new(self.nonce_manager.clone()),
|
||||
self.wallet.clone(),
|
||||
|
||||
@@ -856,7 +856,7 @@ mod tests {
|
||||
use utils::{new_node, test_config};
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored for the time being"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn test_transfer_transaction_should_return_receipt() {
|
||||
// Arrange
|
||||
let (ctx, node) = new_node().await;
|
||||
@@ -882,6 +882,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
fn print_eth_to_polkadot_mappings() {
|
||||
let eth_addresses = vec![
|
||||
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
|
||||
@@ -897,6 +898,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
fn test_eth_to_polkadot_address() {
|
||||
let cases = vec![
|
||||
(
|
||||
@@ -927,6 +929,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
fn eth_rpc_version_works() {
|
||||
// Arrange
|
||||
let context = test_config();
|
||||
@@ -946,6 +949,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
fn version_works() {
|
||||
// Arrange
|
||||
let context = test_config();
|
||||
@@ -965,7 +969,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn get_chain_id_from_node_should_succeed() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -984,7 +988,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_gas_limit_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -1002,7 +1006,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_coinbase_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -1020,7 +1024,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_block_difficulty_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -1038,7 +1042,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_block_hash_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -1056,7 +1060,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_block_timestamp_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
@@ -1074,7 +1078,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "Ignored since they take a long time to run"]
|
||||
#[ignore = "Ignored since CI doesn't have zombienet installed"]
|
||||
async fn can_get_block_number_from_node() {
|
||||
// Arrange
|
||||
let node = shared_node().await;
|
||||
|
||||
-1
Submodule polkadot-sdk deleted from 45a0ea734f
+1
-1
Submodule resolc-compiler-tests updated: 40ffa2b839...7bc445491e
Reference in New Issue
Block a user