Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions crates/core/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use alloy::{
primitives::{Address, map::HashMap},
rpc::types::trace::geth::GethTrace,
rpc::types::trace::geth::{AccountState, DiffMode, GethTrace},
};
use revive_dt_compiler::{Compiler, CompilerInput, SolidityCompiler};
use revive_dt_config::Arguments;
Expand Down Expand Up @@ -94,15 +94,22 @@ where
&mut self,
input: &Input,
node: &T::Blockchain,
) -> anyhow::Result<GethTrace> {
) -> anyhow::Result<(GethTrace, DiffMode)> {
let receipt = node.execute_transaction(input.legacy_transaction(
self.config.network_id,
0,
&self.deployed_contracts,
)?)?;
dbg!(&receipt);
//node.trace_transaction(receipt)
todo!()

log::debug!("Transaction receipt: {:?}", receipt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!("Transaction receipt: {:?}", receipt);
log::trace!("Transaction receipt: {:?}", receipt);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in the new revision


let trace = node.trace_transaction(receipt.clone())?;

log::debug!("Trace result: {:?}", trace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!("Trace result: {:?}", trace);
log::trace!("Trace result: {:?}", trace);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in the new revision


let diff = node.state_diff(receipt)?;

Ok((trace, diff))
}
}

Expand Down Expand Up @@ -132,6 +139,32 @@ where
}
}

pub fn print_diff_mode(label: &str, diff: &DiffMode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should emit trace logs instead of println! to the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in the new revision

println!("🔍 {} - PRE STATE:", label);
for (addr, state) in &diff.pre {
Self::print_account_state(" [pre]", addr, state);
}

println!("🔍 {} - POST STATE:", label);
for (addr, state) in &diff.post {
Self::print_account_state(" [post]", addr, state);
}
}

fn print_account_state(prefix: &str, addr: &Address, state: &AccountState) {
println!("{} 0x{:x}", prefix, addr);

if let Some(balance) = &state.balance {
println!("{} balance: {}", prefix, balance);
}
if let Some(nonce) = &state.nonce {
println!("{} nonce: {}", prefix, nonce);
}
if let Some(code) = &state.code {
println!("{} code: {}", prefix, code);
}
}

pub fn execute(&mut self, span: Span) -> anyhow::Result<()> {
for mode in self.metadata.solc_modes() {
let mut leader_state = State::<L>::new(self.config, span);
Expand All @@ -142,8 +175,17 @@ where

for case in &self.metadata.cases {
for input in &case.inputs {
let _ = leader_state.execute_input(input, self.leader_node)?;
let _ = follower_state.execute_input(input, self.follower_node)?;
let (_, leader_diff) = leader_state.execute_input(input, self.leader_node)?;
let (_, follower_diff) =
follower_state.execute_input(input, self.follower_node)?;

if leader_diff == follower_diff {
log::info!("State diffs match between leader and follower.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::info!("State diffs match between leader and follower.");
log::debug!("State diffs match between leader and follower.");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in the new revision

} else {
log::warn!("State diffs mismatch between leader and follower.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::warn!("State diffs mismatch between leader and follower.");
log::debug!("State diffs mismatch between leader and follower.");

This is expected and not indicating a problem per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right

Self::print_diff_mode("Leader", &leader_diff);
Self::print_diff_mode("Follower", &follower_diff);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use revive_dt_compiler::{SolidityCompiler, revive_resolc, solc};
use revive_dt_config::TestingPlatform;
use revive_dt_node::geth;
use revive_dt_node::{geth, kitchensink::KitchensinkNode};
use revive_dt_node_interaction::EthereumNode;

pub mod driver;
Expand Down Expand Up @@ -37,7 +37,7 @@ impl Platform for Geth {
pub struct Kitchensink;

impl Platform for Kitchensink {
type Blockchain = geth::Instance;
type Blockchain = KitchensinkNode;
type Compiler = revive_resolc::Resolc;

fn config_id() -> TestingPlatform {
Expand Down