Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Feb 5, 2025
1 parent 2445938 commit cbfb470
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
7 changes: 5 additions & 2 deletions world-chain-builder/crates/world/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use reth_provider::{
use reth_transaction_pool::error::InvalidPoolTransactionError;
use reth_transaction_pool::{BestTransactions, ValidPoolTransaction};
use revm::Database;
use revm_primitives::{Bytes, EVMError, InvalidTransaction, ResultAndState, B256, U256};
use revm_primitives::{Address, Bytes, EVMError, InvalidTransaction, ResultAndState, B256, U256};
use tracing::{debug, trace, warn};
use world_chain_builder_pool::noop::NoopWorldChainTransactionPool;
use world_chain_builder_pool::tx::{WorldChainPoolTransaction, WorldChainPoolTransactionError};
Expand Down Expand Up @@ -744,10 +744,13 @@ where
let tx_da_limit = self.inner.da_config.max_da_tx_size();
let base_fee = self.base_fee();

// TODO:
let pbh_entry_point = Address::default();
let mut pbh_call_tracer = PBHCallTracer::new(pbh_entry_point);
let mut evm = self.inner.evm_config.evm_with_env_and_inspector(
&mut *db,
self.inner.evm_env.clone(),
PBHCallTracer::new(),
&mut pbh_call_tracer,
);

let mut invalid_txs = vec![];
Expand Down
23 changes: 13 additions & 10 deletions world-chain-builder/crates/world/payload/src/inspector.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use reth::revm::{Database, Inspector};
use revm::interpreter::CallOutcome;
use revm_primitives::Address;

/// Simple inspector that keeps track of the call stack
pub struct PBHCallTracer {
/// A vector of addresses across the call stack.
pub stack: Vec<Address>,
pub pbh_entry_point: Address,
pub invalid: bool,
}

impl PBHCallTracer {
/// Creates a new instance [`CallTracer`]
pub fn new() -> Self {
Self { stack: Vec::new() }
pub fn new(pbh_entry_point: Address) -> Self {
Self {
pbh_entry_point,
invalid: false,
}
}

/// Checks whether the `pbh_entrypoint` exists within the call stack.
// TODO: fix this
pub fn is_valid(&self, pbh_entrypoint: Address) -> bool {
self.stack[1..].iter().all(|&addr| addr != pbh_entrypoint)
pub fn reset(&mut self) {
self.invalid = false;
}
}

Expand All @@ -26,7 +27,9 @@ impl<DB: Database> Inspector<DB> for PBHCallTracer {
_context: &mut reth::revm::EvmContext<DB>,
inputs: &mut reth::revm::interpreter::CallInputs,
) -> Option<reth::revm::interpreter::CallOutcome> {
self.stack.push(inputs.target_address);
if inputs.target_address == self.pbh_entry_point {
self.invalid = true;
}

None
}
Expand Down

0 comments on commit cbfb470

Please sign in to comment.