mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-13 16:21:04 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 556f6c0501 |
@@ -1,105 +0,0 @@
|
|||||||
name: "Run Revive Differential Tests"
|
|
||||||
description: "Builds and runs revive-differential-tests (retester) from this repo against the caller's Polkadot SDK."
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
# Setup arguments & environment
|
|
||||||
polkadot-sdk-path:
|
|
||||||
description: "The path of the polkadot-sdk that should be compiled for the tests to run against."
|
|
||||||
required: false
|
|
||||||
default: "."
|
|
||||||
type: string
|
|
||||||
cargo-command:
|
|
||||||
description: "The cargo command to use in compilations and running of tests (e.g., forklift cargo)."
|
|
||||||
required: false
|
|
||||||
default: "cargo"
|
|
||||||
type: string
|
|
||||||
revive-differential-tests-ref:
|
|
||||||
description: "The branch, tag or SHA to checkout for the revive-differential-tests."
|
|
||||||
required: false
|
|
||||||
default: "main"
|
|
||||||
type: string
|
|
||||||
resolc-version:
|
|
||||||
description: "The version of resolc to install and use in tests."
|
|
||||||
required: false
|
|
||||||
default: "0.5.0"
|
|
||||||
type: string
|
|
||||||
use-compilation-caches:
|
|
||||||
description: "Controls if the compilation caches will be used for the test run or not."
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
type: boolean
|
|
||||||
# Test Execution Arguments
|
|
||||||
platform:
|
|
||||||
description: "The identifier of the platform to run the tests on (e.g., geth-evm-solc, revive-dev-node-revm-solc)"
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Checkout the Differential Tests Repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
with:
|
|
||||||
repository: paritytech/revive-differential-tests
|
|
||||||
ref: ${{ inputs['revive-differential-tests-ref'] }}
|
|
||||||
path: revive-differential-tests
|
|
||||||
submodules: recursive
|
|
||||||
- name: Installing the Latest Resolc
|
|
||||||
shell: bash
|
|
||||||
if: ${{ runner.os == 'Linux' && runner.arch == 'X64' }}
|
|
||||||
run: |
|
|
||||||
VERSION="${{ inputs['resolc-version'] }}"
|
|
||||||
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-x86_64-unknown-linux-musl"
|
|
||||||
echo "Downloading resolc v$VERSION from $ASSET_URL"
|
|
||||||
curl -Lsf --show-error -o resolc "$ASSET_URL"
|
|
||||||
chmod +x resolc
|
|
||||||
./resolc --version
|
|
||||||
- name: Installing Retester
|
|
||||||
shell: bash
|
|
||||||
run: ${{ inputs['cargo-command'] }} install --locked --path revive-differential-tests/crates/core
|
|
||||||
- name: Creating a workdir for retester
|
|
||||||
shell: bash
|
|
||||||
run: mkdir workdir
|
|
||||||
- name: Downloading & Initializing the compilation caches
|
|
||||||
shell: bash
|
|
||||||
if: ${{ inputs['use-compilation-caches'] == true }}
|
|
||||||
run: |
|
|
||||||
curl -fL --retry 3 --retry-all-errors --connect-timeout 10 -o cache.tar.gz "https://github.com/paritytech/revive-differential-tests/releases/download/compilation-caches-v1.1/cache.tar.gz"
|
|
||||||
tar -zxf cache.tar.gz -C ./workdir > /dev/null 2>&1
|
|
||||||
- name: Building the dependencies from the Polkadot SDK
|
|
||||||
shell: bash
|
|
||||||
run: ${{ inputs['cargo-command'] }} build --locked --profile release -p pallet-revive-eth-rpc -p revive-dev-node --manifest-path ${{ inputs['polkadot-sdk-path'] }}/Cargo.toml
|
|
||||||
- name: Running the Differential Tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
${{ inputs['cargo-command'] }} run --locked --manifest-path revive-differential-tests/Cargo.toml -- test \
|
|
||||||
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/simple \
|
|
||||||
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/complex \
|
|
||||||
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/translated_semantic_tests \
|
|
||||||
--platform ${{ inputs['platform'] }} \
|
|
||||||
--concurrency.number-of-nodes 10 \
|
|
||||||
--concurrency.number-of-threads 10 \
|
|
||||||
--concurrency.number-of-concurrent-tasks 100 \
|
|
||||||
--working-directory ./workdir \
|
|
||||||
--revive-dev-node.consensus manual-seal-200 \
|
|
||||||
--revive-dev-node.path ${{ inputs['polkadot-sdk-path'] }}/target/release/revive-dev-node \
|
|
||||||
--eth-rpc.path ${{ inputs['polkadot-sdk-path'] }}/target/release/eth-rpc \
|
|
||||||
--resolc.path ./resolc
|
|
||||||
- name: Creating a markdown report of the test execution
|
|
||||||
shell: bash
|
|
||||||
if: ${{ always() }}
|
|
||||||
run: |
|
|
||||||
mv ./workdir/*.json report.json
|
|
||||||
python3 revive-differential-tests/scripts/process-differential-tests-report.py report.json ${{ inputs['platform'] }}
|
|
||||||
- name: Upload the Report to the CI
|
|
||||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
|
|
||||||
if: ${{ always() }}
|
|
||||||
with:
|
|
||||||
name: report-${{ inputs['platform'] }}.md
|
|
||||||
path: report.md
|
|
||||||
- name: Posting the report as a comment on the PR
|
|
||||||
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
|
|
||||||
if: ${{ always() }}
|
|
||||||
with:
|
|
||||||
header: diff-tests-report-${{ inputs['platform'] }}
|
|
||||||
path: report.md
|
|
||||||
+6
-37
@@ -2,9 +2,9 @@ mod differential_benchmarks;
|
|||||||
mod differential_tests;
|
mod differential_tests;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use anyhow::{Context as _, bail};
|
use anyhow::Context as _;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use revive_dt_report::{ReportAggregator, TestCaseStatus};
|
use revive_dt_report::ReportAggregator;
|
||||||
use schemars::schema_for;
|
use schemars::schema_for;
|
||||||
use tracing::{info, level_filters::LevelFilter};
|
use tracing::{info, level_filters::LevelFilter};
|
||||||
use tracing_subscriber::{EnvFilter, FmtSubscriber};
|
use tracing_subscriber::{EnvFilter, FmtSubscriber};
|
||||||
@@ -57,22 +57,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let differential_tests_handling_task =
|
let differential_tests_handling_task =
|
||||||
handle_differential_tests(*context, reporter);
|
handle_differential_tests(*context, reporter);
|
||||||
|
|
||||||
let (_, report) = futures::future::try_join(
|
futures::future::try_join(differential_tests_handling_task, report_aggregator_task)
|
||||||
differential_tests_handling_task,
|
.await?;
|
||||||
report_aggregator_task,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let contains_failure = report
|
|
||||||
.execution_information
|
|
||||||
.values()
|
|
||||||
.flat_map(|values| values.case_reports.values())
|
|
||||||
.flat_map(|values| values.mode_execution_reports.values())
|
|
||||||
.any(|report| matches!(report.status, Some(TestCaseStatus::Failed { .. })));
|
|
||||||
|
|
||||||
if contains_failure {
|
|
||||||
bail!("Some tests failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
@@ -85,23 +71,12 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let differential_benchmarks_handling_task =
|
let differential_benchmarks_handling_task =
|
||||||
handle_differential_benchmarks(*context, reporter);
|
handle_differential_benchmarks(*context, reporter);
|
||||||
|
|
||||||
let (_, report) = futures::future::try_join(
|
futures::future::try_join(
|
||||||
differential_benchmarks_handling_task,
|
differential_benchmarks_handling_task,
|
||||||
report_aggregator_task,
|
report_aggregator_task,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let contains_failure = report
|
|
||||||
.execution_information
|
|
||||||
.values()
|
|
||||||
.flat_map(|values| values.case_reports.values())
|
|
||||||
.flat_map(|values| values.mode_execution_reports.values())
|
|
||||||
.any(|report| matches!(report.status, Some(TestCaseStatus::Failed { .. })));
|
|
||||||
|
|
||||||
if contains_failure {
|
|
||||||
bail!("Some benchmarks failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Context::ExportGenesis(ref export_genesis_context) => {
|
Context::ExportGenesis(ref export_genesis_context) => {
|
||||||
@@ -110,17 +85,11 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let genesis_json = serde_json::to_string_pretty(&genesis)
|
let genesis_json = serde_json::to_string_pretty(&genesis)
|
||||||
.context("Failed to serialize the genesis to JSON")?;
|
.context("Failed to serialize the genesis to JSON")?;
|
||||||
println!("{genesis_json}");
|
println!("{genesis_json}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Context::ExportJsonSchema => {
|
Context::ExportJsonSchema => {
|
||||||
let schema = schema_for!(Metadata);
|
let schema = schema_for!(Metadata);
|
||||||
println!(
|
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
"{}",
|
|
||||||
serde_json::to_string_pretty(&schema)
|
|
||||||
.context("Failed to export the JSON schema")?
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ impl GethNode {
|
|||||||
construct_concurrency_limited_provider::<Ethereum, _>(
|
construct_concurrency_limited_provider::<Ethereum, _>(
|
||||||
self.connection_string.as_str(),
|
self.connection_string.as_str(),
|
||||||
FallbackGasFiller::default()
|
FallbackGasFiller::default()
|
||||||
.with_fallback_mechanism(self.use_fallback_gas_filler),
|
.with_use_fallback_gas_filler(self.use_fallback_gas_filler),
|
||||||
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(),
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ impl LighthouseGethNode {
|
|||||||
construct_concurrency_limited_provider::<Ethereum, _>(
|
construct_concurrency_limited_provider::<Ethereum, _>(
|
||||||
self.ws_connection_string.as_str(),
|
self.ws_connection_string.as_str(),
|
||||||
FallbackGasFiller::default()
|
FallbackGasFiller::default()
|
||||||
.with_fallback_mechanism(self.use_fallback_gas_filler),
|
.with_use_fallback_gas_filler(self.use_fallback_gas_filler),
|
||||||
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(),
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ use tracing::{instrument, trace};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Node,
|
Node,
|
||||||
constants::INITIAL_BALANCE,
|
constants::{CHAIN_ID, INITIAL_BALANCE},
|
||||||
helpers::{Process, ProcessReadinessWaitBehavior},
|
helpers::{Process, ProcessReadinessWaitBehavior},
|
||||||
provider_utils::{
|
provider_utils::{
|
||||||
ConcreteProvider, FallbackGasFiller, construct_concurrency_limited_provider,
|
ConcreteProvider, FallbackGasFiller, construct_concurrency_limited_provider,
|
||||||
@@ -327,9 +327,13 @@ 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::default()
|
FallbackGasFiller::new(
|
||||||
.with_fallback_mechanism(self.use_fallback_gas_filler),
|
u64::MAX,
|
||||||
ChainIdFiller::default(),
|
50_000_000_000,
|
||||||
|
1_000_000_000,
|
||||||
|
self.use_fallback_gas_filler,
|
||||||
|
),
|
||||||
|
ChainIdFiller::new(Some(CHAIN_ID)),
|
||||||
NonceFiller::new(self.nonce_manager.clone()),
|
NonceFiller::new(self.nonce_manager.clone()),
|
||||||
self.wallet.clone(),
|
self.wallet.clone(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -334,8 +334,12 @@ impl ZombienetNode {
|
|||||||
.get_or_try_init(|| async move {
|
.get_or_try_init(|| async move {
|
||||||
construct_concurrency_limited_provider::<Ethereum, _>(
|
construct_concurrency_limited_provider::<Ethereum, _>(
|
||||||
self.connection_string.as_str(),
|
self.connection_string.as_str(),
|
||||||
FallbackGasFiller::default()
|
FallbackGasFiller::new(
|
||||||
.with_fallback_mechanism(self.use_fallback_gas_filler),
|
u64::MAX,
|
||||||
|
5_000_000_000,
|
||||||
|
1_000_000_000,
|
||||||
|
self.use_fallback_gas_filler,
|
||||||
|
),
|
||||||
ChainIdFiller::default(), // TODO: use CHAIN_ID constant
|
ChainIdFiller::default(), // TODO: use CHAIN_ID constant
|
||||||
NonceFiller::new(self.nonce_manager.clone()),
|
NonceFiller::new(self.nonce_manager.clone()),
|
||||||
self.wallet.clone(),
|
self.wallet.clone(),
|
||||||
|
|||||||
@@ -1,71 +1,65 @@
|
|||||||
use std::{borrow::Cow, fmt::Display};
|
|
||||||
|
|
||||||
use alloy::{
|
use alloy::{
|
||||||
eips::BlockNumberOrTag,
|
|
||||||
network::{Network, TransactionBuilder},
|
network::{Network, TransactionBuilder},
|
||||||
providers::{
|
providers::{
|
||||||
Provider, SendableTx,
|
Provider, SendableTx,
|
||||||
ext::DebugApi,
|
fillers::{GasFiller, TxFiller},
|
||||||
fillers::{GasFillable, GasFiller, TxFiller},
|
|
||||||
},
|
},
|
||||||
rpc::types::trace::geth::{
|
transports::{TransportError, TransportResult},
|
||||||
GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions,
|
|
||||||
GethDebugTracingOptions,
|
|
||||||
},
|
|
||||||
transports::{RpcError, TransportResult},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An implementation of [`GasFiller`] with a fallback mechanism for reverting transactions.
|
// Percentage padding applied to estimated gas (e.g. 120 = 20% padding)
|
||||||
///
|
const GAS_ESTIMATE_PADDING_NUMERATOR: u64 = 120;
|
||||||
/// This struct provides a fallback mechanism for alloy's [`GasFiller`] which kicks in when a
|
const GAS_ESTIMATE_PADDING_DENOMINATOR: u64 = 100;
|
||||||
/// transaction's dry run fails due to it reverting allowing us to get gas estimates even for
|
|
||||||
/// failing transactions. In this codebase, this is very important since the MatterLabs tests
|
|
||||||
/// expect some transactions in the test suite revert. Since we're expected to run a number of
|
|
||||||
/// assertions on these reverting transactions we must commit them to the ledger.
|
|
||||||
///
|
|
||||||
/// Therefore, this struct does the following:
|
|
||||||
///
|
|
||||||
/// 1. It first attempts to estimate the gas through the mechanism implemented in the [`GasFiller`].
|
|
||||||
/// 2. If it fails, then we perform a debug trace of the transaction to find out how much gas the
|
|
||||||
/// transaction needs until it reverts.
|
|
||||||
/// 3. We fill in these values (either the success or failure case) into the transaction.
|
|
||||||
///
|
|
||||||
/// The fallback mechanism of this filler can be completely disabled if we don't want it to be used.
|
|
||||||
/// In that case, this gas filler will act in an identical way to alloy's [`GasFiller`].
|
|
||||||
///
|
|
||||||
/// We then fill in these values into the transaction.
|
|
||||||
///
|
|
||||||
/// The previous implementation of this fallback gas filler relied on making use of default values
|
|
||||||
/// for the gas limit in order to be able to submit the reverting transactions to the network. But,
|
|
||||||
/// it introduced a number of issues that we weren't anticipating at the time when it was built.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct FallbackGasFiller {
|
|
||||||
/// The inner [`GasFiller`] which we pass all of the calls to in the happy path.
|
|
||||||
inner: GasFiller,
|
|
||||||
|
|
||||||
/// A [`bool`] that controls if the fallback mechanism is enabled or not.
|
#[derive(Clone, Debug)]
|
||||||
enable_fallback_mechanism: bool,
|
pub struct FallbackGasFiller {
|
||||||
|
inner: GasFiller,
|
||||||
|
default_gas_limit: u64,
|
||||||
|
default_max_fee_per_gas: u128,
|
||||||
|
default_priority_fee: u128,
|
||||||
|
use_fallback_gas_filler: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FallbackGasFiller {
|
impl FallbackGasFiller {
|
||||||
pub fn new() -> Self {
|
pub fn new(
|
||||||
|
default_gas_limit: u64,
|
||||||
|
default_max_fee_per_gas: u128,
|
||||||
|
default_priority_fee: u128,
|
||||||
|
use_fallback_gas_filler: bool,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: Default::default(),
|
inner: GasFiller,
|
||||||
enable_fallback_mechanism: true,
|
default_gas_limit,
|
||||||
|
default_max_fee_per_gas,
|
||||||
|
default_priority_fee,
|
||||||
|
use_fallback_gas_filler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_fallback_mechanism(mut self, enable: bool) -> Self {
|
pub fn with_default_gas_limit(mut self, default_gas_limit: u64) -> Self {
|
||||||
self.enable_fallback_mechanism = enable;
|
self.default_gas_limit = default_gas_limit;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_fallback_mechanism_enabled(self) -> Self {
|
pub fn with_default_max_fee_per_gas(mut self, default_max_fee_per_gas: u128) -> Self {
|
||||||
self.with_fallback_mechanism(true)
|
self.default_max_fee_per_gas = default_max_fee_per_gas;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_fallback_mechanism_disabled(self) -> Self {
|
pub fn with_default_priority_fee(mut self, default_priority_fee: u128) -> Self {
|
||||||
self.with_fallback_mechanism(false)
|
self.default_priority_fee = default_priority_fee;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_use_fallback_gas_filler(mut self, use_fallback_gas_filler: bool) -> Self {
|
||||||
|
self.use_fallback_gas_filler = use_fallback_gas_filler;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FallbackGasFiller {
|
||||||
|
fn default() -> Self {
|
||||||
|
FallbackGasFiller::new(25_000_000, 1_000_000_000, 1_000_000_000, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,89 +67,32 @@ impl<N> TxFiller<N> for FallbackGasFiller
|
|||||||
where
|
where
|
||||||
N: Network,
|
N: Network,
|
||||||
{
|
{
|
||||||
type Fillable = <GasFiller as TxFiller<N>>::Fillable;
|
type Fillable = Option<<GasFiller as TxFiller<N>>::Fillable>;
|
||||||
|
|
||||||
fn status(
|
fn status(
|
||||||
&self,
|
&self,
|
||||||
tx: &<N as Network>::TransactionRequest,
|
tx: &<N as Network>::TransactionRequest,
|
||||||
) -> alloy::providers::fillers::FillerControlFlow {
|
) -> alloy::providers::fillers::FillerControlFlow {
|
||||||
TxFiller::<N>::status(&self.inner, tx)
|
<GasFiller as TxFiller<N>>::status(&self.inner, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_sync(&self, _: &mut SendableTx<N>) {}
|
fn fill_sync(&self, _: &mut alloy::providers::SendableTx<N>) {}
|
||||||
|
|
||||||
async fn prepare<P: Provider<N>>(
|
async fn prepare<P: Provider<N>>(
|
||||||
&self,
|
&self,
|
||||||
provider: &P,
|
provider: &P,
|
||||||
tx: &<N as Network>::TransactionRequest,
|
tx: &<N as Network>::TransactionRequest,
|
||||||
) -> TransportResult<Self::Fillable> {
|
) -> TransportResult<Self::Fillable> {
|
||||||
match (
|
match self.inner.prepare(provider, tx).await {
|
||||||
self.inner.prepare(provider, tx).await,
|
Ok(fill) => Ok(Some(fill)),
|
||||||
self.enable_fallback_mechanism,
|
Err(err) => {
|
||||||
) {
|
tracing::debug!(error = ?err, "Gas Provider Estimation Failed, using fallback");
|
||||||
// Return the same thing if either this calls succeeds, or if the call falls and the
|
|
||||||
// fallback mechanism is disabled.
|
|
||||||
(rtn @ Ok(..), ..) | (rtn @ Err(..), false) => rtn,
|
|
||||||
(Err(..), true) => {
|
|
||||||
// Perform a trace of the transaction.
|
|
||||||
let trace = provider
|
|
||||||
.debug_trace_call(
|
|
||||||
tx.clone(),
|
|
||||||
BlockNumberOrTag::Latest.into(),
|
|
||||||
GethDebugTracingCallOptions {
|
|
||||||
tracing_options: GethDebugTracingOptions {
|
|
||||||
tracer: Some(GethDebugTracerType::BuiltInTracer(
|
|
||||||
GethDebugBuiltInTracerType::CallTracer,
|
|
||||||
)),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
state_overrides: Default::default(),
|
|
||||||
block_overrides: Default::default(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await?
|
|
||||||
.try_into_call_frame()
|
|
||||||
.map_err(|err| {
|
|
||||||
RpcError::LocalUsageError(
|
|
||||||
FallbackGasFillerError::new(format!(
|
|
||||||
"Expected a callframe trace, but got: {err:?}"
|
|
||||||
))
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let gas_used = u64::try_from(trace.gas_used).map_err(|_| {
|
if !self.use_fallback_gas_filler {
|
||||||
RpcError::LocalUsageError(
|
Err(err)
|
||||||
FallbackGasFillerError::new(
|
|
||||||
"Transaction trace returned a value of gas used that exceeds u64",
|
|
||||||
)
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
let gas_limit = gas_used.saturating_mul(120) / 100;
|
|
||||||
|
|
||||||
if let Some(gas_price) = tx.gas_price() {
|
|
||||||
return Ok(GasFillable::Legacy {
|
|
||||||
gas_limit,
|
|
||||||
gas_price,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let estimate = if let (Some(max_fee_per_gas), Some(max_priority_fee_per_gas)) =
|
|
||||||
(tx.max_fee_per_gas(), tx.max_priority_fee_per_gas())
|
|
||||||
{
|
|
||||||
alloy::eips::eip1559::Eip1559Estimation {
|
|
||||||
max_fee_per_gas,
|
|
||||||
max_priority_fee_per_gas,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
provider.estimate_eip1559_fees().await?
|
Ok(None)
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(GasFillable::Eip1559 {
|
|
||||||
gas_limit,
|
|
||||||
estimate,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,35 +100,31 @@ where
|
|||||||
async fn fill(
|
async fn fill(
|
||||||
&self,
|
&self,
|
||||||
fillable: Self::Fillable,
|
fillable: Self::Fillable,
|
||||||
tx: SendableTx<N>,
|
mut tx: alloy::providers::SendableTx<N>,
|
||||||
) -> TransportResult<SendableTx<N>> {
|
) -> TransportResult<SendableTx<N>> {
|
||||||
self.inner.fill(fillable, tx).await
|
if let Some(fill) = fillable {
|
||||||
|
let mut tx = self.inner.fill(fill, tx).await?;
|
||||||
|
if let Some(builder) = tx.as_mut_builder() {
|
||||||
|
if let Some(estimated) = builder.gas_limit() {
|
||||||
|
let padded = estimated
|
||||||
|
.checked_mul(GAS_ESTIMATE_PADDING_NUMERATOR)
|
||||||
|
.and_then(|v| v.checked_div(GAS_ESTIMATE_PADDING_DENOMINATOR))
|
||||||
|
.unwrap_or(u64::MAX);
|
||||||
|
builder.set_gas_limit(padded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(tx)
|
||||||
|
} else if self.use_fallback_gas_filler {
|
||||||
|
if let Some(builder) = tx.as_mut_builder() {
|
||||||
|
builder.set_gas_limit(self.default_gas_limit);
|
||||||
|
builder.set_max_fee_per_gas(self.default_max_fee_per_gas);
|
||||||
|
builder.set_max_priority_fee_per_gas(self.default_priority_fee);
|
||||||
|
}
|
||||||
|
Ok(tx)
|
||||||
|
} else {
|
||||||
|
Err(TransportError::UnsupportedFeature(
|
||||||
|
"Fallback gas filler is disabled and we're attempting to do a gas estimate on a failing transaction",
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FallbackGasFiller {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
struct FallbackGasFillerError(Cow<'static, str>);
|
|
||||||
|
|
||||||
impl FallbackGasFillerError {
|
|
||||||
pub fn new(string: impl Into<Cow<'static, str>>) -> Self {
|
|
||||||
Self(string.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn boxed(self) -> Box<Self> {
|
|
||||||
Box::new(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for FallbackGasFillerError {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
Display::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::error::Error for FallbackGasFillerError {}
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ impl ReportAggregator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_task(mut self) -> (Reporter, impl Future<Output = Result<Report>>) {
|
pub fn into_task(mut self) -> (Reporter, impl Future<Output = Result<()>>) {
|
||||||
let reporter = self
|
let reporter = self
|
||||||
.runner_tx
|
.runner_tx
|
||||||
.take()
|
.take()
|
||||||
@@ -60,7 +60,7 @@ impl ReportAggregator {
|
|||||||
(reporter, async move { self.aggregate().await })
|
(reporter, async move { self.aggregate().await })
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn aggregate(mut self) -> Result<Report> {
|
async fn aggregate(mut self) -> Result<()> {
|
||||||
debug!("Starting to aggregate report");
|
debug!("Starting to aggregate report");
|
||||||
|
|
||||||
while let Some(event) = self.runner_rx.recv().await {
|
while let Some(event) = self.runner_rx.recv().await {
|
||||||
@@ -152,7 +152,7 @@ impl ReportAggregator {
|
|||||||
format!("Failed to serialize report JSON to {}", file_path.display())
|
format!("Failed to serialize report JSON to {}", file_path.display())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(self.report)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_subscribe_to_events_event(&self, event: SubscribeToEventsEvent) {
|
fn handle_subscribe_to_events_event(&self, event: SubscribeToEventsEvent) {
|
||||||
|
|||||||
@@ -5,54 +5,51 @@ CI. The full models used in the JSON report can be found in the revive different
|
|||||||
the models used in this script are just a partial reproduction of the full report models.
|
the models used in this script are just a partial reproduction of the full report models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json, typing, io, sys
|
from typing import TypedDict, Literal, Union
|
||||||
|
|
||||||
|
import json, io
|
||||||
|
|
||||||
|
|
||||||
class Report(typing.TypedDict):
|
class Report(TypedDict):
|
||||||
context: "Context"
|
context: "Context"
|
||||||
execution_information: dict["MetadataFilePathString", "MetadataFileReport"]
|
execution_information: dict[
|
||||||
|
"MetadataFilePathString",
|
||||||
|
dict["ModeString", dict["CaseIdxString", "CaseReport"]],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class MetadataFileReport(typing.TypedDict):
|
class Context(TypedDict):
|
||||||
case_reports: dict["CaseIdxString", "CaseReport"]
|
|
||||||
|
|
||||||
|
|
||||||
class CaseReport(typing.TypedDict):
|
|
||||||
mode_execution_reports: dict["ModeString", "ExecutionReport"]
|
|
||||||
|
|
||||||
|
|
||||||
class ExecutionReport(typing.TypedDict):
|
|
||||||
status: "TestCaseStatus"
|
|
||||||
|
|
||||||
|
|
||||||
class Context(typing.TypedDict):
|
|
||||||
Test: "TestContext"
|
Test: "TestContext"
|
||||||
|
|
||||||
|
|
||||||
class TestContext(typing.TypedDict):
|
class TestContext(TypedDict):
|
||||||
corpus_configuration: "CorpusConfiguration"
|
corpus_configuration: "CorpusConfiguration"
|
||||||
|
|
||||||
|
|
||||||
class CorpusConfiguration(typing.TypedDict):
|
class CorpusConfiguration(TypedDict):
|
||||||
test_specifiers: list["TestSpecifier"]
|
test_specifiers: list["TestSpecifier"]
|
||||||
|
|
||||||
|
|
||||||
class CaseStatusSuccess(typing.TypedDict):
|
class CaseReport(TypedDict):
|
||||||
status: typing.Literal["Succeeded"]
|
status: "CaseStatus"
|
||||||
|
|
||||||
|
|
||||||
|
class CaseStatusSuccess(TypedDict):
|
||||||
|
status: Literal["Succeeded"]
|
||||||
steps_executed: int
|
steps_executed: int
|
||||||
|
|
||||||
|
|
||||||
class CaseStatusFailure(typing.TypedDict):
|
class CaseStatusFailure(TypedDict):
|
||||||
status: typing.Literal["Failed"]
|
status: Literal["Failed"]
|
||||||
reason: str
|
reason: str
|
||||||
|
|
||||||
|
|
||||||
class CaseStatusIgnored(typing.TypedDict):
|
class CaseStatusIgnored(TypedDict):
|
||||||
status: typing.Literal["Ignored"]
|
status: Literal["Ignored"]
|
||||||
reason: str
|
reason: str
|
||||||
|
|
||||||
|
|
||||||
TestCaseStatus = typing.Union[CaseStatusSuccess, CaseStatusFailure, CaseStatusIgnored]
|
CaseStatus = Union[CaseStatusSuccess, CaseStatusFailure, CaseStatusIgnored]
|
||||||
"""A union type of all of the possible statuses that could be reported for a case."""
|
"""A union type of all of the possible statuses that could be reported for a case."""
|
||||||
|
|
||||||
TestSpecifier = str
|
TestSpecifier = str
|
||||||
@@ -67,12 +64,6 @@ MetadataFilePathString = str
|
|||||||
CaseIdxString = str
|
CaseIdxString = str
|
||||||
"""The index of a case as a string. For example '0'"""
|
"""The index of a case as a string. For example '0'"""
|
||||||
|
|
||||||
PlatformString = typing.Union[
|
|
||||||
typing.Literal["revive-dev-node-revm-solc"],
|
|
||||||
typing.Literal["revive-dev-node-polkavm-resolc"],
|
|
||||||
]
|
|
||||||
"""A string of the platform on which the test was run"""
|
|
||||||
|
|
||||||
|
|
||||||
def path_relative_to_resolc_compiler_test_directory(path: str) -> str:
|
def path_relative_to_resolc_compiler_test_directory(path: str) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -87,22 +78,12 @@ def path_relative_to_resolc_compiler_test_directory(path: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
with open(sys.argv[1], "r") as file:
|
with open("report.json", "r") as file:
|
||||||
report: Report = json.load(file)
|
report: Report = json.load(file)
|
||||||
|
|
||||||
# Getting the platform string and resolving it into a simpler version of
|
|
||||||
# itself.
|
|
||||||
platform_identifier: PlatformString = typing.cast(PlatformString, sys.argv[2])
|
|
||||||
if platform_identifier == "revive-dev-node-polkavm-resolc":
|
|
||||||
platform: str = "PolkaVM"
|
|
||||||
elif platform_identifier == "revive-dev-node-revm-solc":
|
|
||||||
platform: str = "REVM"
|
|
||||||
else:
|
|
||||||
platform: str = platform_identifier
|
|
||||||
|
|
||||||
# Starting the markdown document and adding information to it as we go.
|
# Starting the markdown document and adding information to it as we go.
|
||||||
markdown_document: io.TextIOWrapper = open("report.md", "w")
|
markdown_document: io.TextIOWrapper = open("report.md", "w")
|
||||||
print(f"# Differential Tests Results ({platform})", file=markdown_document)
|
print("# Differential Tests Results", file=markdown_document)
|
||||||
|
|
||||||
# Getting all of the test specifiers from the report and making them relative to the tests dir.
|
# Getting all of the test specifiers from the report and making them relative to the tests dir.
|
||||||
test_specifiers: list[str] = list(
|
test_specifiers: list[str] = list(
|
||||||
@@ -113,7 +94,7 @@ def main() -> None:
|
|||||||
)
|
)
|
||||||
print("## Specified Tests", file=markdown_document)
|
print("## Specified Tests", file=markdown_document)
|
||||||
for test_specifier in test_specifiers:
|
for test_specifier in test_specifiers:
|
||||||
print(f"* ``{test_specifier}``", file=markdown_document)
|
print(f"* `{test_specifier}`", file=markdown_document)
|
||||||
|
|
||||||
# Counting the total number of test cases, successes, failures, and ignored tests
|
# Counting the total number of test cases, successes, failures, and ignored tests
|
||||||
total_number_of_cases: int = 0
|
total_number_of_cases: int = 0
|
||||||
@@ -121,13 +102,9 @@ def main() -> None:
|
|||||||
total_number_of_failures: int = 0
|
total_number_of_failures: int = 0
|
||||||
total_number_of_ignores: int = 0
|
total_number_of_ignores: int = 0
|
||||||
for _, mode_to_case_mapping in report["execution_information"].items():
|
for _, mode_to_case_mapping in report["execution_information"].items():
|
||||||
for _, case_idx_to_report_mapping in mode_to_case_mapping[
|
for _, case_idx_to_report_mapping in mode_to_case_mapping.items():
|
||||||
"case_reports"
|
for _, case_report in case_idx_to_report_mapping.items():
|
||||||
].items():
|
status: CaseStatus = case_report["status"]
|
||||||
for _, execution_report in case_idx_to_report_mapping[
|
|
||||||
"mode_execution_reports"
|
|
||||||
].items():
|
|
||||||
status: TestCaseStatus = execution_report["status"]
|
|
||||||
|
|
||||||
total_number_of_cases += 1
|
total_number_of_cases += 1
|
||||||
if status["status"] == "Succeeded":
|
if status["status"] == "Succeeded":
|
||||||
@@ -167,13 +144,9 @@ def main() -> None:
|
|||||||
for metadata_file_path, mode_to_case_mapping in report[
|
for metadata_file_path, mode_to_case_mapping in report[
|
||||||
"execution_information"
|
"execution_information"
|
||||||
].items():
|
].items():
|
||||||
for case_idx_string, case_idx_to_report_mapping in mode_to_case_mapping[
|
for mode_string, case_idx_to_report_mapping in mode_to_case_mapping.items():
|
||||||
"case_reports"
|
for case_idx_string, case_report in case_idx_to_report_mapping.items():
|
||||||
].items():
|
status: CaseStatus = case_report["status"]
|
||||||
for mode_string, execution_report in case_idx_to_report_mapping[
|
|
||||||
"mode_execution_reports"
|
|
||||||
].items():
|
|
||||||
status: TestCaseStatus = execution_report["status"]
|
|
||||||
metadata_file_path: str = (
|
metadata_file_path: str = (
|
||||||
path_relative_to_resolc_compiler_test_directory(metadata_file_path)
|
path_relative_to_resolc_compiler_test_directory(metadata_file_path)
|
||||||
)
|
)
|
||||||
@@ -210,13 +183,9 @@ def main() -> None:
|
|||||||
for metadata_file_path, mode_to_case_mapping in report[
|
for metadata_file_path, mode_to_case_mapping in report[
|
||||||
"execution_information"
|
"execution_information"
|
||||||
].items():
|
].items():
|
||||||
for case_idx_string, case_idx_to_report_mapping in mode_to_case_mapping[
|
for mode_string, case_idx_to_report_mapping in mode_to_case_mapping.items():
|
||||||
"case_reports"
|
for case_idx_string, case_report in case_idx_to_report_mapping.items():
|
||||||
].items():
|
status: CaseStatus = case_report["status"]
|
||||||
for mode_string, execution_report in case_idx_to_report_mapping[
|
|
||||||
"mode_execution_reports"
|
|
||||||
].items():
|
|
||||||
status: TestCaseStatus = execution_report["status"]
|
|
||||||
metadata_file_path: str = (
|
metadata_file_path: str = (
|
||||||
path_relative_to_resolc_compiler_test_directory(metadata_file_path)
|
path_relative_to_resolc_compiler_test_directory(metadata_file_path)
|
||||||
)
|
)
|
||||||
@@ -225,9 +194,7 @@ def main() -> None:
|
|||||||
if status["status"] != "Failed":
|
if status["status"] != "Failed":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
failure_reason: str = (
|
failure_reason: str = status["reason"].replace("\n", " ")
|
||||||
status["reason"].replace("\n", " ").replace("|", " ")
|
|
||||||
)
|
|
||||||
|
|
||||||
note: str = ""
|
note: str = ""
|
||||||
modes_where_this_case_succeeded: set[ModeString] = (
|
modes_where_this_case_succeeded: set[ModeString] = (
|
||||||
@@ -245,7 +212,7 @@ def main() -> None:
|
|||||||
f"{metadata_file_path}::{case_idx_string}::{mode_string}"
|
f"{metadata_file_path}::{case_idx_string}::{mode_string}"
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
f"| ``{test_specifier}`` | ``{failure_reason}`` | {note} |",
|
f"| `{test_specifier}` | `{failure_reason}` | {note} |",
|
||||||
file=markdown_document,
|
file=markdown_document,
|
||||||
)
|
)
|
||||||
print("\n\n</details>", file=markdown_document)
|
print("\n\n</details>", file=markdown_document)
|
||||||
|
|||||||
Reference in New Issue
Block a user