Compare commits

..

1 Commits

Author SHA1 Message Date
Omar Abdulla d0cffd24c1 Increase eth-rpc cache size 2025-11-10 09:54:20 +03:00
16 changed files with 255 additions and 278 deletions
+176 -144
View File
@@ -18,95 +18,136 @@ env:
POLKADOT_VERSION: polkadot-stable2506-2 POLKADOT_VERSION: polkadot-stable2506-2
jobs: jobs:
machete: cache-polkadot:
name: Check for Unneeded Dependencies name: Build and cache Polkadot binaries on ${{ matrix.os }}
runs-on: ubuntu-24.04
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout This Repository
uses: actions/checkout@v4
with:
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 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:
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:
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 }} runs-on: ${{ matrix.os }}
needs: cache-polkadot
strategy: strategy:
matrix: matrix:
os: [ubuntu-24.04, macos-14] os: [ubuntu-24.04, macos-14]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
POLKADOT_SDK_COMMIT_HASH: "30cda2aad8612a10ff729d494acd9d5353294d63"
steps: steps:
- name: Checkout This Repository - name: Checkout repo and submodules
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: recursive submodules: recursive
- name: Run Sccache
uses: mozilla-actions/sccache-action@v0.0.9 - name: Install dependencies (Linux)
- name: Install the Rust Toolchain if: matrix.os == 'ubuntu-24.04'
uses: actions-rust-lang/setup-rust-toolchain@v1 run: |
with: sudo apt-get update
target: "wasm32-unknown-unknown" sudo apt-get install -y protobuf-compiler clang libclang-dev
components: "rust-src,rust-std" rustup target add wasm32-unknown-unknown
- name: Install the Cargo Make Binary rustup component add rust-src
uses: davidB/rust-cargo-make@v1
- name: Caching Step - name: Install dependencies (macOS)
uses: actions/cache@v4 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
with: with:
path: | path: |
~/.cargo/bin/eth-rpc
~/.cargo/bin/revive-dev-node ~/.cargo/bin/revive-dev-node
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}-${{ matrix.os }} ~/.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
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 }}
needs: cache-polkadot
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-14]
steps:
- name: Checkout repo
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
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
- name: Install Geth on Ubuntu - name: Install Geth on Ubuntu
if: matrix.os == 'ubuntu-24.04' if: matrix.os == 'ubuntu-24.04'
run: | run: |
@@ -120,7 +161,7 @@ jobs:
# Ubuntu. Eventually, we found out that the last version of geth that worked in our CI was # Ubuntu. Eventually, we found out that the last version of geth that worked in our CI was
# version 1.15.11. Thus, this is the version that we want to use in CI. The PPA sadly does # version 1.15.11. Thus, this is the version that we want to use in CI. The PPA sadly does
# not have historic versions of Geth and therefore we need to resort to downloading pre # not have historic versions of Geth and therefore we need to resort to downloading pre
# built binaries for Geth and the surrounding tools which is what the following parts of # built binaries for Geth and the surrounding tools which is what the following parts of
# the script do. # the script do.
sudo apt-get install -y wget ca-certificates tar sudo apt-get install -y wget ca-certificates tar
@@ -139,6 +180,7 @@ jobs:
curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-x86_64-unknown-linux-musl -o resolc curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-x86_64-unknown-linux-musl -o resolc
chmod +x resolc chmod +x resolc
sudo mv resolc /usr/local/bin sudo mv resolc /usr/local/bin
- name: Install Geth on macOS - name: Install Geth on macOS
if: matrix.os == 'macos-14' if: matrix.os == 'macos-14'
run: | run: |
@@ -150,79 +192,69 @@ jobs:
curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-universal-apple-darwin -o resolc curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-universal-apple-darwin -o resolc
chmod +x resolc chmod +x resolc
sudo mv resolc /usr/local/bin sudo mv resolc /usr/local/bin
- name: Install Kurtosis on macOS - name: Install Kurtosis on macOS
if: matrix.os == 'macos-14' if: matrix.os == 'macos-14'
run: brew install kurtosis-tech/tap/kurtosis-cli run: brew install kurtosis-tech/tap/kurtosis-cli
- name: Install Kurtosis on Ubuntu - name: Install Kurtosis on Ubuntu
if: matrix.os == 'ubuntu-24.04' if: matrix.os == 'ubuntu-24.04'
run: | run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update sudo apt update
sudo apt install kurtosis-cli sudo apt install kurtosis-cli
- 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:
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: Install dependencies (Linux) - name: Install cargo-machete
if: matrix.os == 'ubuntu-24.04' && steps.cache-step.outputs.cache-hit != 'true' uses: clechasseur/rs-cargo@v2
with:
command: install
args: cargo-machete@0.7.0
- name: Machete
run: cargo machete crates
- 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'
run: | run: |
sudo apt-get update cargo test --workspace -- --nocapture --skip lighthouse_geth::tests::
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/*
+4 -2
View File
@@ -3,7 +3,6 @@
.DS_Store .DS_Store
node_modules node_modules
/*.json /*.json
*.sh
# We do not want to commit any log files that we produce from running the code locally so this is # 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. # added to the .gitignore file.
@@ -14,4 +13,7 @@ workdir
!/schema.json !/schema.json
!/dev-genesis.json !/dev-genesis.json
!/scripts/*
# Ignore all shell scripts except for the `run_tests.sh` script
*.sh
!run_tests.sh
+3
View File
@@ -1,3 +1,6 @@
[submodule "polkadot-sdk"]
path = polkadot-sdk
url = https://github.com/paritytech/polkadot-sdk.git
[submodule "resolc-compiler-tests"] [submodule "resolc-compiler-tests"]
path = resolc-compiler-tests path = resolc-compiler-tests
url = https://github.com/paritytech/resolc-compiler-tests url = https://github.com/paritytech/resolc-compiler-tests
Generated
-1
View File
@@ -5657,7 +5657,6 @@ dependencies = [
"semver 1.0.26", "semver 1.0.26",
"serde", "serde",
"serde_json", "serde_json",
"subxt 0.44.0",
"tokio", "tokio",
"tracing", "tracing",
"tracing-appender", "tracing-appender",
+15
View File
@@ -0,0 +1,15 @@
.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
-21
View File
@@ -1,21 +0,0 @@
[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.
-1
View File
@@ -37,7 +37,6 @@ schemars = { workspace = true }
semver = { workspace = true } semver = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
subxt = { workspace = true }
[lints] [lints]
workspace = true workspace = true
@@ -127,8 +127,6 @@ where
.inspect_err(|err| error!(?err, "Pre-linking compilation failed")) .inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
.context("Failed to produce the pre-linking compiled contracts")?; .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 deployed_libraries = None::<HashMap<_, _>>;
let mut contract_sources = self let mut contract_sources = self
.test_definition .test_definition
@@ -161,6 +159,23 @@ where
let code = alloy::hex::decode(code)?; 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( let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
TransactionRequest::default().from(deployer_address), TransactionRequest::default().from(deployer_address),
code, code,
+19 -51
View File
@@ -8,7 +8,7 @@ use alloy::{
hex, hex,
json_abi::JsonAbi, json_abi::JsonAbi,
network::{Ethereum, TransactionBuilder}, network::{Ethereum, TransactionBuilder},
primitives::{Address, TxHash, U256, address}, primitives::{Address, TxHash, U256},
rpc::types::{ rpc::types::{
TransactionReceipt, TransactionRequest, TransactionReceipt, TransactionRequest,
trace::geth::{ trace::geth::{
@@ -18,9 +18,9 @@ use alloy::{
}, },
}; };
use anyhow::{Context as _, Result, bail}; use anyhow::{Context as _, Result, bail};
use futures::{TryStreamExt, future::try_join_all}; use futures::TryStreamExt;
use indexmap::IndexMap; use indexmap::IndexMap;
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator, VmIdentifier}; use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator};
use revive_dt_format::{ use revive_dt_format::{
metadata::{ContractInstance, ContractPathAndIdent}, metadata::{ContractInstance, ContractPathAndIdent},
steps::{ steps::{
@@ -30,7 +30,6 @@ use revive_dt_format::{
}, },
traits::ResolutionContext, traits::ResolutionContext,
}; };
use subxt::{ext::codec::Decode, metadata::Metadata, tx::Payload};
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tracing::{error, info, instrument}; use tracing::{error, info, instrument};
@@ -199,8 +198,6 @@ where
}) })
.context("Failed to produce the pre-linking compiled contracts")?; .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 deployed_libraries = None::<HashMap<_, _>>;
let mut contract_sources = test_definition let mut contract_sources = test_definition
.metadata .metadata
@@ -235,6 +232,22 @@ where
let code = alloy::hex::decode(code)?; 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( let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
TransactionRequest::default().from(deployer_address), TransactionRequest::default().from(deployer_address),
code, code,
@@ -282,51 +295,6 @@ where
}) })
.context("Failed to compile the post-link contracts")?; .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( Ok(ExecutionState::new(
compiler_output.contracts, compiler_output.contracts,
deployed_libraries.unwrap_or_default(), deployed_libraries.unwrap_or_default(),
-15
View File
@@ -1,4 +1,3 @@
use alloy::primitives::Address;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -108,20 +107,6 @@ impl Case {
None => Mode::all().cloned().collect(), 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!( define_wrapper_type!(
@@ -4,7 +4,7 @@ use std::{
pin::Pin, pin::Pin,
process::{Command, Stdio}, process::{Command, Stdio},
sync::{ sync::{
Arc, Mutex, Arc,
atomic::{AtomicU32, Ordering}, atomic::{AtomicU32, Ordering},
}, },
time::Duration, time::Duration,
@@ -32,7 +32,7 @@ use futures::{FutureExt, Stream, StreamExt};
use revive_common::EVMVersion; use revive_common::EVMVersion;
use revive_dt_common::fs::clear_directory; use revive_dt_common::fs::clear_directory;
use revive_dt_format::traits::ResolverApi; use revive_dt_format::traits::ResolverApi;
use serde_json::{Value, json}; use serde_json::json;
use sp_core::crypto::Ss58Codec; use sp_core::crypto::Ss58Codec;
use sp_runtime::AccountId32; use sp_runtime::AccountId32;
@@ -57,9 +57,6 @@ use crate::{
static NODE_COUNT: AtomicU32 = AtomicU32::new(0); 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 /// 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 /// or the revive-dev-node which is done by changing the path and some of the other arguments passed
/// to the command. /// to the command.
@@ -141,8 +138,6 @@ impl SubstrateNode {
} }
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> { fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
static CHAINSPEC_MUTEX: Mutex<Option<Value>> = Mutex::new(None);
if !self.rpc_url.is_empty() { if !self.rpc_url.is_empty() {
return Ok(self); return Ok(self);
} }
@@ -161,22 +156,12 @@ impl SubstrateNode {
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE); let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
trace!("Creating the node genesis"); trace!("Creating the node genesis");
let chainspec_json = { let chainspec_json = Self::node_genesis(
let mut chainspec_mutex = CHAINSPEC_MUTEX.lock().expect("Poisoned"); &self.node_binary,
match chainspec_mutex.as_ref() { &self.export_chainspec_command,
Some(chainspec_json) => chainspec_json.clone(), &self.wallet,
None => { )
let chainspec_json = Self::node_genesis( .context("Failed to prepare the chainspec command")?;
&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"); trace!("Writing the node genesis");
serde_json::to_writer_pretty( serde_json::to_writer_pretty(
@@ -227,8 +212,6 @@ impl SubstrateNode {
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--pool-kbytes") .arg("--pool-kbytes")
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--state-pruning")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV) .env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
.stdout(stdout_file) .stdout(stdout_file)
.stderr(stderr_file); .stderr(stderr_file);
@@ -269,9 +252,9 @@ impl SubstrateNode {
.arg("--rpc-max-connections") .arg("--rpc-max-connections")
.arg(u32::MAX.to_string()) .arg(u32::MAX.to_string())
.arg("--index-last-n-blocks") .arg("--index-last-n-blocks")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string()) .arg(1_000u32.to_string())
.arg("--cache-size") .arg("--cache-size")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string()) .arg(1_000u32.to_string())
.env("RUST_LOG", Self::PROXY_LOG_ENV) .env("RUST_LOG", Self::PROXY_LOG_ENV)
.stdout(stdout_file) .stdout(stdout_file)
.stderr(stderr_file); .stderr(stderr_file);
@@ -324,7 +307,7 @@ impl SubstrateNode {
.get_or_try_init(|| async move { .get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>( construct_concurrency_limited_provider::<Ethereum, _>(
self.rpc_url.as_str(), self.rpc_url.as_str(),
FallbackGasFiller::new(u64::MAX, 50_000_000_000, 1_000_000_000), FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
ChainIdFiller::new(Some(CHAIN_ID)), ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()), NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(), self.wallet.clone(),
@@ -856,7 +856,7 @@ mod tests {
use utils::{new_node, test_config}; use utils::{new_node, test_config};
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored for the time being"]
async fn test_transfer_transaction_should_return_receipt() { async fn test_transfer_transaction_should_return_receipt() {
// Arrange // Arrange
let (ctx, node) = new_node().await; let (ctx, node) = new_node().await;
@@ -882,7 +882,6 @@ mod tests {
} }
#[test] #[test]
#[ignore = "Ignored since CI doesn't have zombienet installed"]
fn print_eth_to_polkadot_mappings() { fn print_eth_to_polkadot_mappings() {
let eth_addresses = vec![ let eth_addresses = vec![
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
@@ -898,7 +897,6 @@ mod tests {
} }
#[test] #[test]
#[ignore = "Ignored since CI doesn't have zombienet installed"]
fn test_eth_to_polkadot_address() { fn test_eth_to_polkadot_address() {
let cases = vec![ let cases = vec![
( (
@@ -929,7 +927,6 @@ mod tests {
} }
#[test] #[test]
#[ignore = "Ignored since CI doesn't have zombienet installed"]
fn eth_rpc_version_works() { fn eth_rpc_version_works() {
// Arrange // Arrange
let context = test_config(); let context = test_config();
@@ -949,7 +946,6 @@ mod tests {
} }
#[test] #[test]
#[ignore = "Ignored since CI doesn't have zombienet installed"]
fn version_works() { fn version_works() {
// Arrange // Arrange
let context = test_config(); let context = test_config();
@@ -969,7 +965,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn get_chain_id_from_node_should_succeed() { async fn get_chain_id_from_node_should_succeed() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -988,7 +984,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_gas_limit_from_node() { async fn can_get_gas_limit_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1006,7 +1002,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_coinbase_from_node() { async fn can_get_coinbase_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1024,7 +1020,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_difficulty_from_node() { async fn can_get_block_difficulty_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1042,7 +1038,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_hash_from_node() { async fn can_get_block_hash_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1060,7 +1056,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_timestamp_from_node() { async fn can_get_block_timestamp_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1078,7 +1074,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since CI doesn't have zombienet installed"] #[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_number_from_node() { async fn can_get_block_number_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
Submodule
+1
Submodule polkadot-sdk added at 45a0ea734f