Skip to content

Commit

Permalink
feat: Add tracing dependency and enable tracing in payload validator
Browse files Browse the repository at this point in the history
  • Loading branch information
johntaiko committed Aug 26, 2024
1 parent be27561 commit 91d9a39
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 51 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ impl ChainSpec {
id >= 167000 && id <= 168000
}

/// Returns `true` if ontake fork is active at the given block number.
#[inline]
pub fn is_ontake_fork(&self, block_number: u64) -> bool {
self.is_fork_active_at_block(Hardfork::Ontake, block_number)
}

/// Returns `true` if this chain is Optimism mainnet.
#[inline]
pub fn is_optimism_mainnet(&self) -> bool {
Expand Down
34 changes: 17 additions & 17 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ where
transaction_gas_limit: transaction.gas_limit(),
block_available_gas,
}
.into())
.into());
}

EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender);
Expand Down Expand Up @@ -542,7 +542,7 @@ mod tests {
.executor(StateProviderDatabase::new(&db))
.execute(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand Down Expand Up @@ -573,7 +573,7 @@ mod tests {
// Now execute a block with the fixed header, ensure that it does not fail
executor
.execute_without_verification(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand Down Expand Up @@ -639,7 +639,7 @@ mod tests {
.batch_executor(StateProviderDatabase::new(&db), PruneModes::none())
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -693,7 +693,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -738,7 +738,7 @@ mod tests {
let _err = executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand All @@ -765,7 +765,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -825,7 +825,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand Down Expand Up @@ -896,7 +896,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -947,7 +947,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1005,7 +1005,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1124,7 +1124,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1163,7 +1163,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1205,7 +1205,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1295,7 +1295,7 @@ mod tests {
let BlockExecutionOutput { receipts, requests, .. } = executor
.execute(
(
&Block {
&mut Block {
header,
body: vec![tx],
ommers: vec![],
Expand Down Expand Up @@ -1383,7 +1383,7 @@ mod tests {
// Execute the block and capture the result
let exec_result = executor.execute(
(
&Block {
&mut Block {
header,
body: vec![tx],
ommers: vec![],
Expand Down
39 changes: 20 additions & 19 deletions crates/taiko/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ where
)?;

let treasury = self.chain_spec.treasury();
let basefee_ratio = decode_ontake_extra_data(&block.extra_data);

// execute transactions
let mut cumulative_gas_used = 0;
Expand Down Expand Up @@ -234,8 +233,10 @@ where
evm.tx_mut().taiko.is_anchor = is_anchor;
// set the treasury address
evm.tx_mut().taiko.treasury = treasury;
// set the basefee ratio
evm.tx_mut().taiko.basefee_ratio = basefee_ratio;
if self.chain_spec.is_ontake_fork(block.number) {
// set the basefee ratio
evm.tx_mut().taiko.basefee_ratio = decode_ontake_extra_data(&block.extra_data);
}

// Execute transaction.
let ResultAndState { result, state } = match evm.transact().map_err(move |err| {
Expand Down Expand Up @@ -540,7 +541,7 @@ mod tests {
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS},
eip7002::{WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, WITHDRAWAL_REQUEST_PREDEPLOY_CODE},
};
use reth_chainspec::{ChainSpecBuilder, ForkCondition};
use reth_chainspec::{ChainSpecBuilder, ForkCondition, MAINNET};
use reth_primitives::{
constants::{EMPTY_ROOT_HASH, ETH_TO_WEI},
keccak256, public_key_to_address, Account, Block, Transaction, TxKind, TxLegacy, B256,
Expand Down Expand Up @@ -616,7 +617,7 @@ mod tests {
.executor(StateProviderDatabase::new(&db))
.execute(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand Down Expand Up @@ -713,7 +714,7 @@ mod tests {
.batch_executor(StateProviderDatabase::new(&db), PruneModes::none())
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -767,7 +768,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -812,7 +813,7 @@ mod tests {
let _err = executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand All @@ -839,7 +840,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -899,7 +900,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header: header.clone(),
body: vec![],
Expand Down Expand Up @@ -970,7 +971,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1021,7 +1022,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1079,7 +1080,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1143,7 +1144,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1198,7 +1199,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1237,7 +1238,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1279,7 +1280,7 @@ mod tests {
executor
.execute_and_verify_one(
(
&BlockWithSenders {
&mut BlockWithSenders {
block: Block {
header,
body: vec![],
Expand Down Expand Up @@ -1369,7 +1370,7 @@ mod tests {
let BlockExecutionOutput { receipts, requests, .. } = executor
.execute(
(
&Block {
&mut Block {
header,
body: vec![tx],
ommers: vec![],
Expand Down Expand Up @@ -1457,7 +1458,7 @@ mod tests {
// Execute the block and capture the result
let exec_result = executor.execute(
(
&Block {
&mut Block {
header,
body: vec![tx],
ommers: vec![],
Expand Down
7 changes: 4 additions & 3 deletions crates/taiko/payload/builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ where
alloy_rlp::Decodable::decode(&mut attributes.block_metadata.tx_list.as_ref())
.map_err(|_| PayloadBuilderError::other(TaikoPayloadBuilderError::FailedToDecodeTx))?;

let basefee_ratio = decode_ontake_extra_data(&attributes.block_metadata.extra_data);

let mut receipts = Vec::new();
for (idx, tx) in transactions.into_iter().enumerate() {
let is_anchor = idx == 0;
Expand Down Expand Up @@ -302,7 +300,10 @@ where
let mut tx_env = tx_env_with_recovered(tx);
tx_env.taiko.is_anchor = is_anchor;
tx_env.taiko.treasury = chain_spec.treasury();
tx_env.taiko.basefee_ratio = basefee_ratio;
if chain_spec.is_ontake_fork(block_number) {
tx_env.taiko.basefee_ratio =
decode_ontake_extra_data(&attributes.block_metadata.extra_data);
}
tx_env
};
let env = EnvWithHandlerCfg::new_with_cfg_env(
Expand Down
3 changes: 3 additions & 0 deletions crates/taiko/payload/validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ reth-primitives = { workspace = true, features = ["taiko"] }
reth-rpc-types.workspace = true
reth-rpc-types-compat.workspace = true
taiko-reth-engine-primitives.workspace = true

# misc
tracing.workspace = true
Loading

0 comments on commit 91d9a39

Please sign in to comment.