mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-24 04:17:55 +00:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a1f81fb6d | |||
| 51191013c1 | |||
| c81279fc8f | |||
| 0392b6b629 | |||
| ac94c972de | |||
| 5cc814b0e0 | |||
| 0722791a28 | |||
| 52042dfff5 | |||
| e3c717f4d9 | |||
| e7ebe4fa2f | |||
| 5c957e5ac1 | |||
| a0248b58f3 | |||
| 6a9acea748 | |||
| c31c7d94f9 | |||
| dcc43d4ea6 | |||
| cb13c3c2cd | |||
| 7cda3416f0 | |||
| d7bc4f1fab | |||
| b6db597a57 | |||
| d7136d9a3d | |||
| e5a3f0aee9 | |||
| 3cdf57f7c3 | |||
| dab8ffe520 | |||
| c913a8222f | |||
| c8cef4834f | |||
| ca59a1f6a9 | |||
| adc0c44cde | |||
| 811e17136b | |||
| ba32bad6b3 | |||
| bb754cba4f | |||
| c858bbe66d | |||
| 906878f06a | |||
| 9a71369e8a | |||
| 84ab873b46 | |||
| 2ef6f7ba63 | |||
| 38e6140a7c | |||
| ca6c5529e2 | |||
| 038a2db53c |
@@ -76,7 +76,7 @@ pub struct Arguments {
|
||||
/// This argument controls which private keys the nodes should have access to and be added to
|
||||
/// its wallet signers. With a value of N, private keys (0, N] will be added to the signer set
|
||||
/// of the node.
|
||||
#[arg(long = "private-keys-count", default_value_t = 30)]
|
||||
#[arg(short, long = "private-keys-count", default_value_t = 30)]
|
||||
pub private_keys_to_add: usize,
|
||||
|
||||
/// The differential testing leader node implementation.
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::marker::PhantomData;
|
||||
|
||||
use alloy::json_abi::JsonAbi;
|
||||
use alloy::network::{Ethereum, TransactionBuilder};
|
||||
use alloy::primitives::Bytes;
|
||||
use alloy::rpc::types::TransactionReceipt;
|
||||
use alloy::rpc::types::trace::geth::{
|
||||
CallFrame, GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingOptions, GethTrace,
|
||||
@@ -441,8 +442,9 @@ where
|
||||
// Additionally, what happens if the compiler filter doesn't match? Do we consider that the
|
||||
// transaction should succeed? Do we just ignore the expectation?
|
||||
|
||||
let deployed_contracts = self.deployed_contracts.entry(case_idx).or_default();
|
||||
let chain_state_provider = node;
|
||||
let error_span =
|
||||
tracing::error_span!("Exception failed", ?tracing_result, ?execution_receipt,);
|
||||
let _guard = error_span.enter();
|
||||
|
||||
// Handling the receipt state assertion.
|
||||
let expected = !expectation.exception;
|
||||
@@ -456,16 +458,17 @@ where
|
||||
|
||||
// Handling the calldata assertion
|
||||
if let Some(ref expected_calldata) = expectation.return_data {
|
||||
let expected = expected_calldata;
|
||||
let actual = &tracing_result.output.as_ref().unwrap_or_default();
|
||||
if !expected.is_equivalent(actual, deployed_contracts, chain_state_provider)? {
|
||||
let expected = expected_calldata
|
||||
.calldata(self.deployed_contracts.entry(case_idx).or_default(), node)
|
||||
.map(Bytes::from)?;
|
||||
let actual = tracing_result.output.clone().unwrap_or_default();
|
||||
if !expected.starts_with(&actual) {
|
||||
tracing::error!(
|
||||
?execution_receipt,
|
||||
?expected,
|
||||
%expected,
|
||||
%actual,
|
||||
"Calldata assertion failed"
|
||||
);
|
||||
anyhow::bail!("Calldata assertion failed - Expected {expected:?} but got {actual}",);
|
||||
anyhow::bail!("Calldata assertion failed - Expected {expected} but got {actual}",);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,24 +505,17 @@ where
|
||||
}
|
||||
|
||||
// Handling the topics assertion.
|
||||
for (expected, actual) in expected_event
|
||||
for (expected_topic, actual_topic) in expected_event
|
||||
.topics
|
||||
.as_slice()
|
||||
.iter()
|
||||
.zip(actual_event.topics())
|
||||
{
|
||||
let expected = Calldata::Compound(vec![expected.clone()]);
|
||||
if !expected.is_equivalent(
|
||||
&actual.0,
|
||||
deployed_contracts,
|
||||
chain_state_provider,
|
||||
)? {
|
||||
tracing::error!(
|
||||
?execution_receipt,
|
||||
?expected,
|
||||
?actual,
|
||||
"Event topics assertion failed",
|
||||
);
|
||||
let expected = Calldata::Compound(vec![expected_topic.clone()])
|
||||
.calldata(self.deployed_contracts.entry(case_idx).or_default(), node)?;
|
||||
let actual = actual_topic.to_vec();
|
||||
if actual != expected {
|
||||
tracing::error!(?expected, ?actual, "Event topics assertion failed",);
|
||||
anyhow::bail!(
|
||||
"Event topics assertion failed - Expected {expected:?} but got {actual:?}",
|
||||
);
|
||||
@@ -527,15 +523,13 @@ where
|
||||
}
|
||||
|
||||
// Handling the values assertion.
|
||||
let expected = &expected_event.values;
|
||||
let expected = &expected_event
|
||||
.values
|
||||
.calldata(self.deployed_contracts.entry(case_idx).or_default(), node)
|
||||
.map(Bytes::from)?;
|
||||
let actual = &actual_event.data().data;
|
||||
if !expected.is_equivalent(&actual.0, deployed_contracts, chain_state_provider)? {
|
||||
tracing::error!(
|
||||
?execution_receipt,
|
||||
?expected,
|
||||
?actual,
|
||||
"Event value assertion failed",
|
||||
);
|
||||
if !expected.starts_with(actual) {
|
||||
tracing::error!(?expected, ?actual, "Event value assertion failed",);
|
||||
anyhow::bail!(
|
||||
"Event value assertion failed - Expected {expected:?} but got {actual:?}",
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ pub struct Event {
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum Calldata {
|
||||
Single(Bytes),
|
||||
Single(String),
|
||||
Compound(Vec<String>),
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ impl Calldata {
|
||||
chain_state_provider: &impl EthereumNode,
|
||||
) -> anyhow::Result<()> {
|
||||
match self {
|
||||
Calldata::Single(bytes) => {
|
||||
buffer.extend_from_slice(bytes);
|
||||
Calldata::Single(string) => {
|
||||
alloy::hex::decode_to_slice(string, buffer)?;
|
||||
}
|
||||
Calldata::Compound(items) => {
|
||||
for (arg_idx, arg) in items.iter().enumerate() {
|
||||
@@ -190,48 +190,10 @@ impl Calldata {
|
||||
|
||||
pub fn size_requirement(&self) -> usize {
|
||||
match self {
|
||||
Calldata::Single(single) => single.len(),
|
||||
Calldata::Single(single) => (single.len() - 2) / 2,
|
||||
Calldata::Compound(items) => items.len() * 32,
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if this [`Calldata`] is equivalent to the passed calldata bytes.
|
||||
pub fn is_equivalent(
|
||||
&self,
|
||||
other: &[u8],
|
||||
deployed_contracts: &HashMap<ContractInstance, (Address, JsonAbi)>,
|
||||
chain_state_provider: &impl EthereumNode,
|
||||
) -> anyhow::Result<bool> {
|
||||
match self {
|
||||
Calldata::Single(calldata) => Ok(calldata == other),
|
||||
Calldata::Compound(items) => {
|
||||
// Chunking the "other" calldata into 32 byte chunks since each
|
||||
// one of the items in the compound calldata represents 32 bytes
|
||||
for (this, other) in items.iter().zip(other.chunks(32)) {
|
||||
// The matterlabs format supports wildcards and therefore we
|
||||
// also need to support them.
|
||||
if this == "*" {
|
||||
continue;
|
||||
}
|
||||
|
||||
let other = if other.len() < 32 {
|
||||
let mut vec = other.to_vec();
|
||||
vec.resize(32, 0);
|
||||
std::borrow::Cow::Owned(vec)
|
||||
} else {
|
||||
std::borrow::Cow::Borrowed(other)
|
||||
};
|
||||
|
||||
let this = resolve_argument(this, deployed_contracts, chain_state_provider)?;
|
||||
let other = U256::from_be_slice(&other);
|
||||
if this != other {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
/// This constant defines how much Wei accounts are pre-seeded with in genesis.
|
||||
///
|
||||
/// Note: After changing this number, check that the tests for kitchensink work as we encountered
|
||||
/// some issues with different values of the initial balance on Kitchensink.
|
||||
pub const INITIAL_BALANCE: u128 = 10u128.pow(37);
|
||||
@@ -29,7 +29,7 @@ use revive_dt_config::Arguments;
|
||||
use revive_dt_node_interaction::{BlockingExecutor, EthereumNode};
|
||||
use tracing::Level;
|
||||
|
||||
use crate::{Node, common::FallbackGasFiller, constants::INITIAL_BALANCE};
|
||||
use crate::{Node, common::FallbackGasFiller};
|
||||
|
||||
static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
@@ -84,12 +84,10 @@ impl Instance {
|
||||
for signer_address in
|
||||
<EthereumWallet as NetworkWallet<Ethereum>>::signer_addresses(&self.wallet)
|
||||
{
|
||||
// Note, the use of the entry API here means that we only modify the entries for any
|
||||
// account that is not in the `alloc` field of the genesis state.
|
||||
genesis
|
||||
.alloc
|
||||
.entry(signer_address)
|
||||
.or_insert(GenesisAccount::default().with_balance(U256::from(INITIAL_BALANCE)));
|
||||
genesis.alloc.entry(signer_address).or_insert(
|
||||
GenesisAccount::default()
|
||||
.with_balance(10000000000000000000000u128.try_into().unwrap()),
|
||||
);
|
||||
}
|
||||
let genesis_path = self.base_directory.join(Self::GENESIS_JSON_FILE);
|
||||
serde_json::to_writer(File::create(&genesis_path)?, &genesis)?;
|
||||
|
||||
@@ -39,7 +39,7 @@ use tracing::Level;
|
||||
use revive_dt_config::Arguments;
|
||||
use revive_dt_node_interaction::{BlockingExecutor, EthereumNode};
|
||||
|
||||
use crate::{Node, common::FallbackGasFiller, constants::INITIAL_BALANCE};
|
||||
use crate::{Node, common::FallbackGasFiller};
|
||||
|
||||
static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
@@ -131,12 +131,10 @@ impl KitchensinkNode {
|
||||
for signer_address in
|
||||
<EthereumWallet as NetworkWallet<Ethereum>>::signer_addresses(&self.wallet)
|
||||
{
|
||||
// Note, the use of the entry API here means that we only modify the entries for any
|
||||
// account that is not in the `alloc` field of the genesis state.
|
||||
genesis
|
||||
.alloc
|
||||
.entry(signer_address)
|
||||
.or_insert(GenesisAccount::default().with_balance(U256::from(INITIAL_BALANCE)));
|
||||
genesis.alloc.entry(signer_address).or_insert(
|
||||
GenesisAccount::default()
|
||||
.with_balance(10000000000000000000000u128.try_into().unwrap()),
|
||||
);
|
||||
}
|
||||
self.extract_balance_from_genesis_file(&genesis)?
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@ use revive_dt_config::Arguments;
|
||||
use revive_dt_node_interaction::EthereumNode;
|
||||
|
||||
pub mod common;
|
||||
pub mod constants;
|
||||
pub mod geth;
|
||||
pub mod kitchensink;
|
||||
pub mod pool;
|
||||
|
||||
+5
-1
@@ -33,5 +33,9 @@
|
||||
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"timestamp": "0x00",
|
||||
"alloc": {}
|
||||
"alloc": {
|
||||
"90F8bf6A479f320ead074411a4B0e7944Ea8c9C1": {
|
||||
"balance": "10000000000000000000000"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user