Skip to content

Commit

Permalink
Merge pull request #21 from taikoxyz/changeset
Browse files Browse the repository at this point in the history
Fix state delta reverts
  • Loading branch information
Brechtpd authored Jan 14, 2025
2 parents f2810ee + 46dc01e commit 073fe2b
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 151 deletions.
221 changes: 111 additions & 110 deletions Cargo.lock

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,32 @@ bincode = "1.3"
# revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "v43-gwyneth" }
# revm-interpreter = { git = "https://github.com/taikoxyz/revm.git", branch = "v43-gwyneth" }
# revm-precompile = { git = "https://github.com/taikoxyz/revm.git", branch = "v43-gwyneth" }
revm = { git = "https://github.com/taikoxyz/revm.git", branch = "gwyneth-debug-shit" }
revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "gwyneth-debug-shit" }
revm-interpreter = { git = "https://github.com/taikoxyz/revm.git", branch = "gwyneth-debug-shit" }
revm-precompile = { git = "https://github.com/taikoxyz/revm.git", branch = "gwyneth-debug-shit" }
revm = { git = "https://github.com/taikoxyz/revm.git", branch = "changeset" }
revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "changeset" }
revm-interpreter = { git = "https://github.com/taikoxyz/revm.git", branch = "changeset" }
revm-precompile = { git = "https://github.com/taikoxyz/revm.git", branch = "changeset" }
revm-inspectors = { git = "https://github.com/taikoxyz/revm-inspectors.git", branch = "main-rbuilder" }

[patch."https://github.com/paradigmxyz/reth"]
reth = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-db = {git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-db-common = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-errors = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-libmdbx = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-payload-builder = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-node-api = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-trie = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-trie-parallel = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-basic-payload-builder = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-node-core = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-primitives = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-provider = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-chainspec = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-evm = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-evm-ethereum = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-db-api = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-execution-errors = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth-trie-db = { git = "https://github.com/taikoxyz/gwyneth", branch = "gwyneth_with_debug_shit_revm_and_inspector" }
reth = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-db = {git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-db-common = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-errors = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-libmdbx = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-payload-builder = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-node-api = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-trie = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-trie-parallel = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-basic-payload-builder = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-node-core = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-primitives = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-provider = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-chainspec = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-evm = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-evm-ethereum = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-db-api = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-execution-errors = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }
reth-trie-db = { git = "https://github.com/taikoxyz/gwyneth", branch = "changeset" }

#reth = { path = "../../revm-dani/gwyneth/bin/reth" }
#reth-db = { path = "../../revm-dani/gwyneth/crates/storage/db" }
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/building/builders/ordering_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn run_ordering_builder<DB: Database + Clone + 'static>(
let mut removed_orders = Vec::new();
let mut use_suggested_fee_recipient_as_coinbase = config.coinbase_payment;
'building: loop {
sleep(Duration::from_millis(1000));
//sleep(Duration::from_millis(1000));

if input.cancel.is_cancelled() {
break 'building;
Expand Down
19 changes: 9 additions & 10 deletions crates/rbuilder/src/building/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ use reth_evm_ethereum::{eip6110::parse_deposits_from_receipts, revm_spec, EthEvm
use reth_node_api::PayloadBuilderAttributes;
use reth_payload_builder::{database::SyncCachedReads as CachedReads, EthPayloadBuilderAttributes};
use revm::{
db::states::bundle_state::BundleRetention::{self, PlainState},
primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnvWithHandlerCfg, SpecId},
db::states::{bundle_state::BundleRetention::{self, PlainState}, reverts::Reverts},
primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnvWithHandlerCfg, SpecId}, TransitionState,
};
use serde::Deserialize;
use std::{hash::Hash, str::FromStr, sync::Arc};
Expand Down Expand Up @@ -187,7 +187,6 @@ impl ChainBlockBuildingContext {
extra_data: Vec<u8>,
spec_id: Option<SpecId>,
) -> ChainBlockBuildingContext {
println!("from_attributes");
let attributes = EthPayloadBuilderAttributes::try_new(
attributes.data.parent_block_hash,
attributes.data.payload_attributes.clone(),
Expand Down Expand Up @@ -742,13 +741,12 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
let requests_root = calculate_requests_root(&requests);
(Some(requests.into()), Some(requests_root))
} else {
println!("prague not active");
(None, None)
};

let (cached_reads, bundle) = state.clone_bundle_and_cache();
let execution_outcome = ExecutionOutcome::new(
Some(ctx.chain_spec.chain.id()),
ctx.chain_spec.chain.id(),
bundle,
Receipts::from(vec![self
.receipts
Expand All @@ -769,8 +767,7 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {

// Brecht: state root calculation
// TODO Brecht: Fix
let mut root_hash_config = root_hash_config.clone();
//root_hash_config.mode = RootHashMode::IgnoreParentHash;
let root_hash_config = root_hash_config.clone();
let state_root = calculate_state_root(
provider_factories.get(&chain_id).unwrap().clone(),
ctx.attributes.parent,
Expand Down Expand Up @@ -831,9 +828,11 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
}

if chain_id == super_ctx.parent_chain_id {
// The reverts will still contain the address but that's fine, we're never going to use that on L1 anyway
execution_outcome.bundle.state = execution_outcome.bundle.state.into_iter().filter(|account| account.0.1 != ctx.block_env.coinbase.1).collect();
}

// Only make a block for chains that have changes
if !state_diff.accounts.is_empty() {
let ctx = &super_ctx.chains[&chain_id];

Expand All @@ -848,11 +847,11 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
)?;

state_diff.state_root = state_root;
state_diff.transactions_root = transactions_root;
state_diff.bundle.reverts = reth_provider::merge_reverts(&state_diff.bundle.reverts);

//let extra_data = Bytes::from(serde_json::to_string(&state_diff).unwrap().into_bytes());
let extra_data = Bytes::from(bincode::serialize(&state_diff).unwrap());

println!("extra_data: {}", extra_data);
// println!("extra_data: {}", extra_data);

let header = Header {
parent_hash: ctx.attributes.parent,
Expand Down
4 changes: 2 additions & 2 deletions crates/rbuilder/src/live_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ impl<DB: Database + Clone + 'static, BuilderSourceType: SlotSource>
);

// TODO(Brecht): hack to wait until latest L2 block is also created, which is later then when we get the payload build event
sleep(Duration::from_millis(4000));
//sleep(Duration::from_millis(4000));

println!("payload: {:?}", payload);
//println!("payload: {:?}", payload);

// TODO: Brecht
let mut chains = HashMap::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn subscribe_to_txpool_with_blobs(
let mut stream = pin!(stream);

while let Some(tx_hash) = stream.next().await {
println!("Dani debug: Some txn arrived on {:?}", config.ipc_path);
println!("New tx arrived on {:?}!", config.ipc_path);

// TODO: Skip L1 transactions for now because circular
if config.ipc_path.to_str().unwrap() == "/tmp/reth.ipc" {
Expand Down Expand Up @@ -77,7 +77,7 @@ pub async fn subscribe_to_txpool_with_blobs(
trace!(order = ?order.id(), parse_duration_mus = parse_duration.as_micros(), "Mempool transaction received with blobs");

add_txfetcher_time_to_query(parse_duration);
println!("Dani debug: About to send order to results channel. Order ID: {:?}", order_id);
println!("About to send order to results channel. Order ID: {:?}", order_id);
match results
.send_timeout(
ReplaceableOrderPoolCommand::Order(order),
Expand All @@ -90,10 +90,11 @@ pub async fn subscribe_to_txpool_with_blobs(
error!("Failed to send txpool tx to results channel, timeout");
}
Err(SendTimeoutError::Closed(_)) => {
println!("Send timeout error: closed");
break;
}
}
println!("Dani debug: Successfully sent order to results channel. Order ID: {:?}", order_id);
println!("Successfully sent order to results channel. Order ID: {:?}", order_id);
}

// stream is closed, cancelling token because builder can't work without this stream
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/live_builder/simulation/sim_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn run_sim_worker<DB: Database + Clone + Send + 'static>(
// contexts are created for a duration of the slot so this is not a problem
sleep(Duration::from_millis(50));
}
sleep(Duration::from_millis(500));
//sleep(Duration::from_millis(500));
};

println!("Brecht: simming 3");
Expand Down
3 changes: 2 additions & 1 deletion crates/rbuilder/src/utils/provider_factory_reopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ pub fn check_provider_factory_health<DB: Database>(
let num = current_block_number - i;
let hash = provider_factory.block_hash(num)?;
if hash.is_none() {
eyre::bail!(
println!(
"Missing historical block hash for block {}, current block: {}",
current_block_number - i,
current_block_number
);
break;
}

if num == 0 {
Expand Down

0 comments on commit 073fe2b

Please sign in to comment.