From 795f6433c66add7fb5e6e4f5f54e72196f7fc5d6 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 11 Mar 2025 13:23:01 -0400 Subject: [PATCH] refactor: remove zenith, prep to invert dep relationship --- Cargo.toml | 4 +- src/fill/mod.rs | 2 - src/fill/zenith.rs | 95 -------------------------------------------- src/journal/coder.rs | 38 ------------------ 4 files changed, 1 insertion(+), 138 deletions(-) delete mode 100644 src/fill/zenith.rs diff --git a/Cargo.toml b/Cargo.toml index 0abd542..f2fa0f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trevm" -version = "0.19.11" +version = "0.19.12" rust-version = "1.83.0" edition = "2021" authors = ["init4"] @@ -31,8 +31,6 @@ alloy = { version = "=0.11.1", default-features = false, features = ["consensus" revm = { version = "19.5.0", default-features = false, features = ["std"] } -zenith-types = { version = "0.15" } - dashmap = { version = "6.1.0", optional = true } tracing = { version = "0.1.41", optional = true} thiserror = "2.0.11" diff --git a/src/fill/mod.rs b/src/fill/mod.rs index 50192c7..b9b5a91 100644 --- a/src/fill/mod.rs +++ b/src/fill/mod.rs @@ -8,5 +8,3 @@ pub use noop::{NoopBlock, NoopCfg}; mod traits; pub use traits::{Block, Cfg, Tx}; - -mod zenith; diff --git a/src/fill/zenith.rs b/src/fill/zenith.rs deleted file mode 100644 index 5ab053f..0000000 --- a/src/fill/zenith.rs +++ /dev/null @@ -1,95 +0,0 @@ -use crate::{Block, Tx}; -use alloy::{ - primitives::{Address, U256}, - sol_types::SolCall, -}; -use revm::primitives::{TransactTo, TxEnv}; -use zenith_types::{Passage::EnterToken, Transactor, ZenithCallBundle}; - -impl Tx for Transactor::Transact { - fn fill_tx_env(&self, tx_env: &mut revm::primitives::TxEnv) { - // destructuring here means that any changes to the fields will result - // in breaking changes here, ensuring that they never silently add new - // fields - let TxEnv { - caller, - gas_limit, - gas_price, - transact_to, - value, - data, - nonce, - chain_id, - access_list, - gas_priority_fee, - blob_hashes, - max_fee_per_blob_gas, - authorization_list, - } = tx_env; - - *caller = self.sender; - *gas_limit = self.gas.as_limbs()[0]; - *gas_price = self.maxFeePerGas; - *gas_priority_fee = Some(U256::ZERO); - *transact_to = TransactTo::Call(self.to); - *value = self.value; - *data = self.data.clone(); - *chain_id = Some(self.rollup_chain_id()); - // This causes nonce validation to be skipped. i.e. the Transact event - // will always use the next available nonce - *nonce = None; - *access_list = vec![]; - blob_hashes.clear(); - max_fee_per_blob_gas.take(); - authorization_list.take(); - } -} - -impl Tx for EnterToken { - fn fill_tx_env(&self, tx_env: &mut TxEnv) { - let TxEnv { - caller, - gas_limit, - gas_price, - transact_to, - value, - data, - nonce, - chain_id, - access_list, - gas_priority_fee, - blob_hashes, - max_fee_per_blob_gas, - authorization_list, - } = tx_env; - - *caller = zenith_types::MINTER_ADDRESS; - *gas_limit = 1_000_000; - *gas_price = U256::ZERO; - // This is deliberately not set, as it is not known by the event. - *transact_to = Address::ZERO.into(); - *value = U256::ZERO; - *data = zenith_types::mintCall { amount: self.amount(), to: self.rollupRecipient } - .abi_encode() - .into(); - *nonce = None; - *chain_id = Some(self.rollup_chain_id()); - *access_list = vec![]; - *gas_priority_fee = Some(U256::ZERO); - blob_hashes.clear(); - max_fee_per_blob_gas.take(); - authorization_list.take(); - } -} - -impl Block for ZenithCallBundle { - fn fill_block_env(&self, block_env: &mut revm::primitives::BlockEnv) { - block_env.number = - self.bundle.state_block_number.as_number().map(U256::from).unwrap_or(block_env.number); - block_env.timestamp = self.bundle.timestamp.map(U256::from).unwrap_or(block_env.timestamp); - block_env.gas_limit = self.bundle.gas_limit.map(U256::from).unwrap_or(block_env.gas_limit); - block_env.difficulty = - self.bundle.difficulty.map(U256::from).unwrap_or(block_env.difficulty); - block_env.basefee = self.bundle.base_fee.map(U256::from).unwrap_or(block_env.basefee); - } -} diff --git a/src/journal/coder.rs b/src/journal/coder.rs index 36cc03f..b5f9508 100644 --- a/src/journal/coder.rs +++ b/src/journal/coder.rs @@ -16,7 +16,6 @@ use std::{ sync::Arc, vec::Vec, }; -use zenith_types::Zenith; type Result = core::result::Result; @@ -41,7 +40,6 @@ const TAG_OPTION_NONE: u8 = 0; const TAG_OPTION_SOME: u8 = 1; // Sizes -const ZENITH_HEADER_BYTES: usize = 32 + 32 + 32 + 20 + 32; const ACCOUNT_INFO_BYTES: usize = 8 + 32 + 32; const INFO_OUTCOME_MIN_BYTES: usize = 1 + ACCOUNT_INFO_BYTES; const ACCT_DIFF_MIN_BYTES: usize = 4 + INFO_OUTCOME_MIN_BYTES; @@ -413,22 +411,6 @@ impl JournalEncode for BundleState { } } -impl JournalEncode for Zenith::BlockHeader { - fn serialized_size(&self) -> usize { - ZENITH_HEADER_BYTES - } - - fn encode(&self, buf: &mut dyn BufMut) { - let Self { rollupChainId, hostBlockNumber, gasLimit, rewardAddress, blockDataHash } = self; - - rollupChainId.encode(buf); - hostBlockNumber.encode(buf); - gasLimit.encode(buf); - rewardAddress.encode(buf); - blockDataHash.encode(buf); - } -} - /// Trait for decoding journal types from a buffer. pub trait JournalDecode: JournalEncode + Sized + 'static { /// Decode the type from the buffer. @@ -638,18 +620,6 @@ impl JournalDecode for BundleState { } } -impl JournalDecode for Zenith::BlockHeader { - fn decode(buf: &mut &[u8]) -> Result { - Ok(Self { - rollupChainId: JournalDecode::decode(buf)?, - hostBlockNumber: JournalDecode::decode(buf)?, - gasLimit: JournalDecode::decode(buf)?, - rewardAddress: JournalDecode::decode(buf)?, - blockDataHash: JournalDecode::decode(buf)?, - }) - } -} - #[cfg(test)] mod test { use super::*; @@ -748,13 +718,5 @@ mod test { .collect(), }; roundtrip(&bsi); - - roundtrip(&Zenith::BlockHeader { - rollupChainId: U256::from(1), - hostBlockNumber: U256::from(1), - gasLimit: U256::from(1), - rewardAddress: Address::repeat_byte(0xa), - blockDataHash: B256::repeat_byte(0xa), - }); } }