Compare commits

..

1 Commits

Author SHA1 Message Date
Omar Abdulla b8f63321e2 Implement storage empty assertion 2025-08-11 15:24:26 +03:00
13 changed files with 60 additions and 306 deletions
Generated
-3
View File
@@ -4081,7 +4081,6 @@ dependencies = [
"revive-dt-node-interaction",
"revive-dt-report",
"semver 1.0.26",
"serde_json",
"temp-dir",
"tokio",
"tracing",
@@ -4096,7 +4095,6 @@ dependencies = [
"alloy-primitives",
"alloy-sol-types",
"anyhow",
"revive-common",
"revive-dt-common",
"semver 1.0.26",
"serde",
@@ -4111,7 +4109,6 @@ version = "0.1.0"
dependencies = [
"alloy",
"anyhow",
"revive-common",
"revive-dt-common",
"revive-dt-config",
"revive-dt-format",
+1 -2
View File
@@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT/Apache-2.0"
edition = "2024"
repository = "https://github.com/paritytech/revive-differential-testing.git"
rust-version = "1.87.0"
rust-version = "1.85.0"
[workspace.dependencies]
revive-dt-common = { version = "0.1.0", path = "crates/common" }
@@ -36,7 +36,6 @@ serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, features = [
"arbitrary_precision",
"std",
"unbounded_depth",
] }
sha2 = { version = "0.10.9" }
sp-core = "36.1.0"
-1
View File
@@ -30,5 +30,4 @@ tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
semver = { workspace = true }
serde_json = { workspace = true }
temp-dir = { workspace = true }
+4 -11
View File
@@ -11,8 +11,8 @@ use alloy::network::{Ethereum, TransactionBuilder};
use alloy::primitives::U256;
use alloy::rpc::types::TransactionReceipt;
use alloy::rpc::types::trace::geth::{
CallFrame, GethDebugBuiltInTracerType, GethDebugTracerConfig, GethDebugTracerType,
GethDebugTracingOptions, GethTrace, PreStateConfig,
CallFrame, GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingOptions, GethTrace,
PreStateConfig,
};
use alloy::{
primitives::Address,
@@ -263,11 +263,6 @@ where
tracer: Some(GethDebugTracerType::BuiltInTracer(
GethDebugBuiltInTracerType::CallTracer,
)),
tracer_config: GethDebugTracerConfig(serde_json::json! {{
"onlyTopCall": true,
"withLog": false,
"withReturnData": false
}}),
..Default::default()
},
)
@@ -533,7 +528,7 @@ where
) -> anyhow::Result<()> {
let Some(instance) = balance_assertion
.address
.strip_suffix(".address")
.strip_prefix(".address")
.map(ContractInstance::new)
else {
return Ok(());
@@ -555,7 +550,6 @@ where
BalanceAssertion {
address: address_string,
expected_balance: amount,
..
}: &BalanceAssertion,
node: &T::Blockchain,
) -> anyhow::Result<()> {
@@ -593,7 +587,7 @@ where
) -> anyhow::Result<()> {
let Some(instance) = storage_empty_assertion
.address
.strip_suffix(".address")
.strip_prefix(".address")
.map(ContractInstance::new)
else {
return Ok(());
@@ -615,7 +609,6 @@ where
StorageEmptyAssertion {
address: address_string,
is_storage_empty,
..
}: &StorageEmptyAssertion,
node: &T::Blockchain,
) -> anyhow::Result<()> {
-21
View File
@@ -177,27 +177,6 @@ where
Some(false) | None => true,
},
)
.filter(|(metadata_file_path, metadata, ..)| match metadata.required_evm_version {
Some(evm_version_requirement) => {
let is_allowed = evm_version_requirement
.matches(&<L::Blockchain as revive_dt_node::Node>::evm_version())
&& evm_version_requirement
.matches(&<F::Blockchain as revive_dt_node::Node>::evm_version());
if !is_allowed {
tracing::warn!(
metadata_file_path = %metadata_file_path.display(),
leader_evm_version = %<L::Blockchain as revive_dt_node::Node>::evm_version(),
follower_evm_version = %<F::Blockchain as revive_dt_node::Node>::evm_version(),
version_requirement = %evm_version_requirement,
"Skipped test since the EVM version requirement was not fulfilled."
);
}
is_allowed
}
None => true,
})
.collect::<Vec<_>>();
let metadata_case_status = Arc::new(RwLock::new(test_cases.iter().fold(
-2
View File
@@ -11,8 +11,6 @@ rust-version.workspace = true
[dependencies]
revive-dt-common = { workspace = true }
revive-common = { workspace = true }
alloy = { workspace = true }
alloy-primitives = { workspace = true }
alloy-sol-types = { workspace = true }
-12
View File
@@ -9,25 +9,13 @@ use crate::{
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Case {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modes: Option<Vec<Mode>>,
#[serde(rename = "inputs")]
pub steps: Vec<Step>,
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expected: Option<Expected>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
}
+11 -47
View File
@@ -3,7 +3,6 @@ use std::collections::HashMap;
use alloy::{
eips::BlockNumberOrTag,
hex::ToHexExt,
json_abi::Function,
network::TransactionBuilder,
primitives::{Address, Bytes, U256},
rpc::types::TransactionRequest,
@@ -37,37 +36,20 @@ pub enum Step {
pub struct Input {
#[serde(default = "Input::default_caller")]
pub caller: Address,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(default = "Input::default_instance")]
pub instance: ContractInstance,
pub method: Method,
#[serde(default)]
pub calldata: Calldata,
#[serde(skip_serializing_if = "Option::is_none")]
pub expected: Option<Expected>,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<EtherValue>,
#[serde(skip_serializing_if = "Option::is_none")]
pub storage: Option<HashMap<String, Calldata>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub variable_assignments: Option<VariableAssignments>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct BalanceAssertion {
/// An optional comment on the balance assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
/// The address that the balance assertion should be done on.
///
/// This is a string which will be resolved into an address when being processed. Therefore,
@@ -82,10 +64,6 @@ pub struct BalanceAssertion {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct StorageEmptyAssertion {
/// An optional comment on the storage empty assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
/// The address that the balance assertion should be done on.
///
/// This is a string which will be resolved into an address when being processed. Therefore,
@@ -108,11 +86,8 @@ pub enum Expected {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct ExpectedOutput {
#[serde(skip_serializing_if = "Option::is_none")]
pub compiler_version: Option<VersionReq>,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_data: Option<Calldata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[serde(default)]
pub exception: bool,
@@ -120,7 +95,6 @@ pub struct ExpectedOutput {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct Event {
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
pub topics: Vec<String>,
pub values: Calldata,
@@ -280,27 +254,17 @@ impl Input {
// We follow the same logic that's implemented in the matter-labs-tester where they resolve
// the function name into a function selector and they assume that he function doesn't have
// any existing overloads.
// Overloads are handled by providing the full function signature in the "function
// name".
// https://github.com/matter-labs/era-compiler-tester/blob/1dfa7d07cba0734ca97e24704f12dd57f6990c2c/compiler_tester/src/test/case/input/mod.rs#L158-L190
let selector = if function_name.contains('(') && function_name.contains(')') {
Function::parse(function_name)
.context(
"Failed to parse the provided function name into a function signature",
)?
.selector()
} else {
abi.functions()
.find(|function| function.signature().starts_with(function_name))
.ok_or_else(|| {
anyhow::anyhow!(
"Function with name {:?} not found in ABI for the instance {:?}",
function_name,
&self.instance
)
})?
.selector()
};
let function = abi
.functions()
.find(|function| function.signature().starts_with(function_name))
.ok_or_else(|| {
anyhow::anyhow!(
"Function with name {:?} not found in ABI for the instance {:?}",
function_name,
&self.instance
)
})?;
tracing::trace!("Functions found for instance: {}", self.instance.as_ref());
@@ -316,7 +280,7 @@ impl Input {
// We're using indices in the following code in order to avoid the need for us to allocate
// a new buffer for each one of the resolved arguments.
let mut calldata = Vec::<u8>::with_capacity(4 + self.calldata.size_requirement());
calldata.extend(selector.0);
calldata.extend(function.selector().0);
self.calldata
.calldata_into_slice(&mut calldata, resolver, context)
.await?;
+1 -149
View File
@@ -1,5 +1,4 @@
use std::{
cmp::Ordering,
collections::BTreeMap,
fmt::Display,
fs::{File, read_to_string},
@@ -10,7 +9,6 @@ use std::{
use serde::{Deserialize, Serialize};
use revive_common::EVMVersion;
use revive_dt_common::{iterators::FilesWithExtensionIterator, macros::define_wrapper_type};
use crate::{
@@ -47,34 +45,13 @@ impl Deref for MetadataFile {
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Metadata {
/// A comment on the test case that's added for human-readability.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub targets: Option<Vec<String>>,
pub cases: Vec<Case>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contracts: Option<BTreeMap<ContractInstance, ContractPathAndIdent>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub libraries: Option<BTreeMap<PathBuf, BTreeMap<ContractIdent, ContractInstance>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
pub modes: Option<Vec<Mode>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub file_path: Option<PathBuf>,
/// This field specifies an EVM version requirement that the test case has where the test might
/// be run of the evm version of the nodes match the evm version specified here.
#[serde(skip_serializing_if = "Option::is_none")]
pub required_evm_version: Option<EvmVersionRequirement>,
}
impl Metadata {
@@ -365,131 +342,6 @@ impl From<ContractPathAndIdent> for String {
}
}
/// An EVM version requirement that the test case has. This gets serialized and
/// deserialized from and into [`String`].
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub struct EvmVersionRequirement {
ordering: Ordering,
or_equal: bool,
evm_version: EVMVersion,
}
impl EvmVersionRequirement {
pub fn new_greater_than_or_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Greater,
or_equal: true,
evm_version: version,
}
}
pub fn new_greater_than(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Greater,
or_equal: false,
evm_version: version,
}
}
pub fn new_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Equal,
or_equal: false,
evm_version: version,
}
}
pub fn new_less_than(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Less,
or_equal: false,
evm_version: version,
}
}
pub fn new_less_than_or_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Less,
or_equal: true,
evm_version: version,
}
}
pub fn matches(&self, other: &EVMVersion) -> bool {
let ordering = other.cmp(&self.evm_version);
ordering == self.ordering || (self.or_equal && matches!(ordering, Ordering::Equal))
}
}
impl Display for EvmVersionRequirement {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self {
ordering,
or_equal,
evm_version,
} = self;
match ordering {
Ordering::Less => write!(f, "<")?,
Ordering::Equal => write!(f, "=")?,
Ordering::Greater => write!(f, ">")?,
}
if *or_equal && !matches!(ordering, Ordering::Equal) {
write!(f, "=")?;
}
write!(f, "{evm_version}")
}
}
impl FromStr for EvmVersionRequirement {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.as_bytes() {
[b'>', b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Greater,
or_equal: true,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'>', remaining @ ..] => Ok(Self {
ordering: Ordering::Greater,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'<', b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Less,
or_equal: true,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'<', remaining @ ..] => Ok(Self {
ordering: Ordering::Less,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Equal,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
_ => anyhow::bail!("Invalid EVM version requirement {s}"),
}
}
}
impl TryFrom<String> for EvmVersionRequirement {
type Error = anyhow::Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
value.parse()
}
}
impl From<EvmVersionRequirement> for String {
fn from(value: EvmVersionRequirement) -> Self {
value.to_string()
}
}
#[cfg(test)]
mod test {
use super::*;
-1
View File
@@ -14,7 +14,6 @@ alloy = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true }
revive-common = { workspace = true }
revive-dt-common = { workspace = true }
revive-dt-config = { workspace = true }
revive-dt-format = { workspace = true }
+23 -28
View File
@@ -32,7 +32,6 @@ use alloy::{
signers::local::PrivateKeySigner,
};
use anyhow::Context;
use revive_common::EVMVersion;
use tracing::{Instrument, Level};
use revive_dt_common::{fs::clear_directory, futures::poll};
@@ -92,7 +91,7 @@ impl GethNode {
const TRACE_POLLING_DURATION: Duration = Duration::from_secs(60);
/// Create the node directory and call `geth init` to configure the genesis.
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn init(&mut self, genesis: String) -> anyhow::Result<&mut Self> {
let _ = clear_directory(&self.base_directory);
let _ = clear_directory(&self.logs_directory);
@@ -142,7 +141,7 @@ impl GethNode {
/// Spawn the go-ethereum node child process.
///
/// [Instance::init] must be called prior.
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn spawn_process(&mut self) -> anyhow::Result<&mut Self> {
// This is the `OpenOptions` that we wish to use for all of the log files that we will be
// opening in this method. We need to construct it in this way to:
@@ -200,7 +199,7 @@ impl GethNode {
/// Wait for the g-ethereum node child process getting ready.
///
/// [Instance::spawn_process] must be called priorly.
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn wait_ready(&mut self) -> anyhow::Result<&mut Self> {
let start_time = Instant::now();
@@ -269,7 +268,7 @@ impl GethNode {
}
impl EthereumNode for GethNode {
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
async fn execute_transaction(
&self,
transaction: TransactionRequest,
@@ -325,7 +324,7 @@ impl EthereumNode for GethNode {
.await
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
async fn trace_transaction(
&self,
transaction: &TransactionReceipt,
@@ -358,7 +357,7 @@ impl EthereumNode for GethNode {
.await
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn state_diff(&self, transaction: &TransactionReceipt) -> anyhow::Result<DiffMode> {
let trace_options = GethDebugTracingOptions::prestate_tracer(PreStateConfig {
diff_mode: Some(true),
@@ -375,7 +374,7 @@ impl EthereumNode for GethNode {
}
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn balance_of(&self, address: Address) -> anyhow::Result<U256> {
self.provider()
.await?
@@ -384,7 +383,7 @@ impl EthereumNode for GethNode {
.map_err(Into::into)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn latest_state_proof(
&self,
address: Address,
@@ -400,7 +399,7 @@ impl EthereumNode for GethNode {
}
impl ResolverApi for GethNode {
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn chain_id(&self) -> anyhow::Result<alloy::primitives::ChainId> {
self.provider()
.await?
@@ -409,7 +408,7 @@ impl ResolverApi for GethNode {
.map_err(Into::into)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn transaction_gas_price(&self, tx_hash: &TxHash) -> anyhow::Result<u128> {
self.provider()
.await?
@@ -419,7 +418,7 @@ impl ResolverApi for GethNode {
.map(|receipt| receipt.effective_gas_price)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_gas_limit(&self, number: BlockNumberOrTag) -> anyhow::Result<u128> {
self.provider()
.await?
@@ -429,7 +428,7 @@ impl ResolverApi for GethNode {
.map(|block| block.header.gas_limit as _)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_coinbase(&self, number: BlockNumberOrTag) -> anyhow::Result<Address> {
self.provider()
.await?
@@ -439,7 +438,7 @@ impl ResolverApi for GethNode {
.map(|block| block.header.beneficiary)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_difficulty(&self, number: BlockNumberOrTag) -> anyhow::Result<U256> {
self.provider()
.await?
@@ -449,7 +448,7 @@ impl ResolverApi for GethNode {
.map(|block| U256::from_be_bytes(block.header.mix_hash.0))
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_base_fee(&self, number: BlockNumberOrTag) -> anyhow::Result<u64> {
self.provider()
.await?
@@ -464,7 +463,7 @@ impl ResolverApi for GethNode {
})
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_hash(&self, number: BlockNumberOrTag) -> anyhow::Result<BlockHash> {
self.provider()
.await?
@@ -474,7 +473,7 @@ impl ResolverApi for GethNode {
.map(|block| block.header.hash)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn block_timestamp(&self, number: BlockNumberOrTag) -> anyhow::Result<BlockTimestamp> {
self.provider()
.await?
@@ -484,7 +483,7 @@ impl ResolverApi for GethNode {
.map(|block| block.header.timestamp)
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
async fn last_block_number(&self) -> anyhow::Result<BlockNumber> {
self.provider()
.await?
@@ -527,12 +526,12 @@ impl Node for GethNode {
}
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn connection_string(&self) -> String {
self.connection_string.clone()
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn shutdown(&mut self) -> anyhow::Result<()> {
// Terminate the processes in a graceful manner to allow for the output to be flushed.
if let Some(mut child) = self.handle.take() {
@@ -554,13 +553,13 @@ impl Node for GethNode {
Ok(())
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn spawn(&mut self, genesis: String) -> anyhow::Result<()> {
self.init(genesis)?.spawn_process()?;
Ok(())
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn version(&self) -> anyhow::Result<String> {
let output = Command::new(&self.geth)
.arg("--version")
@@ -573,21 +572,17 @@ impl Node for GethNode {
Ok(String::from_utf8_lossy(&output).into())
}
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn matches_target(&self, targets: Option<&[String]>) -> bool {
match targets {
None => true,
Some(targets) => targets.iter().any(|str| str.as_str() == "evm"),
}
}
fn evm_version() -> EVMVersion {
EVMVersion::Cancun
}
}
impl Drop for GethNode {
#[tracing::instrument(level = "info", skip_all, fields(geth_node_id = self.id))]
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
fn drop(&mut self) {
self.shutdown().expect("Failed to shutdown")
}
+20 -25
View File
@@ -32,7 +32,6 @@ use alloy::{
signers::local::PrivateKeySigner,
};
use anyhow::Context;
use revive_common::EVMVersion;
use revive_dt_common::fs::clear_directory;
use revive_dt_format::traits::ResolverApi;
use serde::{Deserialize, Serialize};
@@ -160,7 +159,7 @@ impl KitchensinkNode {
Ok(self)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
fn spawn_process(&mut self) -> anyhow::Result<()> {
let substrate_rpc_port = Self::BASE_SUBSTRATE_RPC_PORT + self.id as u16;
let proxy_rpc_port = Self::BASE_PROXY_RPC_PORT + self.id as u16;
@@ -258,7 +257,7 @@ impl KitchensinkNode {
Ok(())
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
fn extract_balance_from_genesis_file(
&self,
genesis: &Genesis,
@@ -307,7 +306,7 @@ impl KitchensinkNode {
}
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
pub fn eth_rpc_version(&self) -> anyhow::Result<String> {
let output = Command::new(&self.eth_proxy_binary)
.arg("--version")
@@ -382,7 +381,7 @@ impl KitchensinkNode {
}
impl EthereumNode for KitchensinkNode {
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn execute_transaction(
&self,
transaction: alloy::rpc::types::TransactionRequest,
@@ -399,7 +398,7 @@ impl EthereumNode for KitchensinkNode {
Ok(receipt)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn trace_transaction(
&self,
transaction: &TransactionReceipt,
@@ -413,7 +412,7 @@ impl EthereumNode for KitchensinkNode {
.await?)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn state_diff(&self, transaction: &TransactionReceipt) -> anyhow::Result<DiffMode> {
let trace_options = GethDebugTracingOptions::prestate_tracer(PreStateConfig {
diff_mode: Some(true),
@@ -430,7 +429,7 @@ impl EthereumNode for KitchensinkNode {
}
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn balance_of(&self, address: Address) -> anyhow::Result<U256> {
self.provider()
.await?
@@ -439,7 +438,7 @@ impl EthereumNode for KitchensinkNode {
.map_err(Into::into)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn latest_state_proof(
&self,
address: Address,
@@ -455,7 +454,7 @@ impl EthereumNode for KitchensinkNode {
}
impl ResolverApi for KitchensinkNode {
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn chain_id(&self) -> anyhow::Result<alloy::primitives::ChainId> {
self.provider()
.await?
@@ -464,7 +463,7 @@ impl ResolverApi for KitchensinkNode {
.map_err(Into::into)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn transaction_gas_price(&self, tx_hash: &TxHash) -> anyhow::Result<u128> {
self.provider()
.await?
@@ -474,7 +473,7 @@ impl ResolverApi for KitchensinkNode {
.map(|receipt| receipt.effective_gas_price)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_gas_limit(&self, number: BlockNumberOrTag) -> anyhow::Result<u128> {
self.provider()
.await?
@@ -484,7 +483,7 @@ impl ResolverApi for KitchensinkNode {
.map(|block| block.header.gas_limit as _)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_coinbase(&self, number: BlockNumberOrTag) -> anyhow::Result<Address> {
self.provider()
.await?
@@ -494,7 +493,7 @@ impl ResolverApi for KitchensinkNode {
.map(|block| block.header.beneficiary)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_difficulty(&self, number: BlockNumberOrTag) -> anyhow::Result<U256> {
self.provider()
.await?
@@ -504,7 +503,7 @@ impl ResolverApi for KitchensinkNode {
.map(|block| U256::from_be_bytes(block.header.mix_hash.0))
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_base_fee(&self, number: BlockNumberOrTag) -> anyhow::Result<u64> {
self.provider()
.await?
@@ -519,7 +518,7 @@ impl ResolverApi for KitchensinkNode {
})
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_hash(&self, number: BlockNumberOrTag) -> anyhow::Result<BlockHash> {
self.provider()
.await?
@@ -529,7 +528,7 @@ impl ResolverApi for KitchensinkNode {
.map(|block| block.header.hash)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn block_timestamp(&self, number: BlockNumberOrTag) -> anyhow::Result<BlockTimestamp> {
self.provider()
.await?
@@ -539,7 +538,7 @@ impl ResolverApi for KitchensinkNode {
.map(|block| block.header.timestamp)
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
async fn last_block_number(&self) -> anyhow::Result<BlockNumber> {
self.provider()
.await?
@@ -587,7 +586,7 @@ impl Node for KitchensinkNode {
self.rpc_url.clone()
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
fn shutdown(&mut self) -> anyhow::Result<()> {
// Terminate the processes in a graceful manner to allow for the output to be flushed.
if let Some(mut child) = self.process_proxy.take() {
@@ -614,12 +613,12 @@ impl Node for KitchensinkNode {
Ok(())
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
fn spawn(&mut self, genesis: String) -> anyhow::Result<()> {
self.init(&genesis)?.spawn_process()
}
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id), err)]
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
fn version(&self) -> anyhow::Result<String> {
let output = Command::new(&self.substrate_binary)
.arg("--version")
@@ -639,10 +638,6 @@ impl Node for KitchensinkNode {
Some(targets) => targets.iter().any(|str| str.as_str() == "pvm"),
}
}
fn evm_version() -> EVMVersion {
EVMVersion::Cancun
}
}
impl Drop for KitchensinkNode {
-4
View File
@@ -1,6 +1,5 @@
//! This crate implements the testing nodes.
use revive_common::EVMVersion;
use revive_dt_config::Arguments;
use revive_dt_node_interaction::EthereumNode;
@@ -37,7 +36,4 @@ pub trait Node: EthereumNode {
/// Given a list of targets from the metadata file, this function determines if the metadata
/// file can be ran on this node or not.
fn matches_target(&self, targets: Option<&[String]>) -> bool;
/// Returns the EVM version of the node.
fn evm_version() -> EVMVersion;
}