Skip to content

Commit

Permalink
rm KethSimplePointer and use KethPointer (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Dec 1, 2024
1 parent a143261 commit 14e3cf2
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 101 deletions.
3 changes: 2 additions & 1 deletion crates/exex/src/model/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ mod tests {
// Assert that the buffer length matches the length in the Keth RLP structure
assert_eq!(
buffer.len(),
usize::try_from(keth_tx.rlp.len.to_u64()).expect("Invalid length conversion")
usize::try_from(keth_tx.rlp.len.clone().unwrap().to_u64())
.expect("Invalid length conversion")
);

// Assert that the type size is 1
Expand Down
12 changes: 5 additions & 7 deletions crates/exex/src/model/header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use super::primitives::{
KethMaybeRelocatable, KethOption, KethPointer, KethSimplePointer, KethU256,
};
use super::primitives::{KethMaybeRelocatable, KethOption, KethPointer, KethU256};
use alloy_consensus::Header;
use serde::{Deserialize, Serialize};

Expand All @@ -22,9 +20,9 @@ pub struct KethBlockHeader {
/// Root of the trie that contains the block's transaction receipts.
pub receipt_root: KethU256,
/// Root of the trie that contains withdrawals in the block.
pub withdrawals_root: KethOption<KethSimplePointer>,
pub withdrawals_root: KethOption<KethPointer>,
/// Logs bloom filter for efficient log search.
pub bloom: KethSimplePointer,
pub bloom: KethPointer,
/// Block difficulty value, which defines how difficult it is to mine the block.
pub difficulty: KethU256,
/// Block number, i.e., the height of the block in the chain.
Expand All @@ -46,9 +44,9 @@ pub struct KethBlockHeader {
/// Excess blob gas for rollups.
pub excess_blob_gas: KethOption<KethMaybeRelocatable>,
/// Root of the parent beacon block in the proof-of-stake chain.
pub parent_beacon_block_root: KethOption<KethSimplePointer>,
pub parent_beacon_block_root: KethOption<KethPointer>,
/// Root of the trie containing request receipts.
pub requests_root: KethOption<KethSimplePointer>,
pub requests_root: KethOption<KethPointer>,
/// Extra data provided within the block, usually for protocol-specific purposes.
pub extra_data: KethPointer,
}
Expand Down
22 changes: 10 additions & 12 deletions crates/exex/src/model/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ impl From<KethBlock> for KethPayload {
#[cfg(test)]
mod tests {
use super::*;
use crate::model::primitives::{
KethMaybeRelocatable, KethOption, KethPointer, KethSimplePointer, KethU256,
};
use crate::model::primitives::{KethMaybeRelocatable, KethOption, KethPointer, KethU256};
use alloy_consensus::{Header, TxLegacy};
use alloy_primitives::{
hex, Address, Bloom, Bytes, Parity, PrimitiveSignature, B256, B64, U256,
Expand Down Expand Up @@ -255,8 +253,8 @@ mod tests {
KethU256::from(state_root).encode(),
KethU256::from(transactions_root).encode(),
KethU256::from(receipt_root).encode(),
KethOption::<KethSimplePointer>::from(withdrawals_root).encode(),
KethSimplePointer::from(bloom).encode(),
KethOption::<KethPointer>::from(withdrawals_root).encode(),
KethPointer::from(bloom).encode(),
KethU256::from(difficulty).encode(),
KethMaybeRelocatable::from(number).encode(),
KethMaybeRelocatable::from(gas_limit).encode(),
Expand All @@ -267,8 +265,8 @@ mod tests {
KethOption::<KethMaybeRelocatable>::from(base_fee_per_gas).encode(),
KethOption::<KethMaybeRelocatable>::from(blob_gas_used).encode(),
KethOption::<KethMaybeRelocatable>::from(excess_blob_gas).encode(),
KethOption::<KethSimplePointer>::from(parent_beacon_block_root).encode(),
KethOption::<KethSimplePointer>::from(requests_root).encode(),
KethOption::<KethPointer>::from(parent_beacon_block_root).encode(),
KethOption::<KethPointer>::from(requests_root).encode(),
KethPointer::from(extra_data).encode(),
];

Expand Down Expand Up @@ -980,7 +978,7 @@ mod tests {
// - Address
assert_eq!(
vm.get_maybe(&(header_ptr + 33usize).unwrap()),
Some(keth_block.block_header.extra_data.len.0)
Some(keth_block.block_header.extra_data.len.unwrap().0)
);
let extra_data_ptr =
vm.get_maybe(&(header_ptr + 34usize).unwrap()).unwrap().get_relocatable().unwrap();
Expand All @@ -1002,7 +1000,7 @@ mod tests {
// - Address
assert_eq!(
vm.get_maybe(&transaction_ptr),
Some(keth_block.transactions[0].rlp.len.0.clone())
Some(keth_block.transactions[0].rlp.len.clone().unwrap().0)
);
let transaction1_rlp_ptr =
vm.get_maybe(&(transaction_ptr + 1usize).unwrap()).unwrap().get_relocatable().unwrap();
Expand All @@ -1022,7 +1020,7 @@ mod tests {
// - Address
assert_eq!(
vm.get_maybe(&(transaction_ptr + 2usize).unwrap()),
Some(keth_block.transactions[0].signature.len.0.clone())
Some(keth_block.transactions[0].signature.len.clone().unwrap().0)
);
let transaction1_signature_ptr =
vm.get_maybe(&(transaction_ptr + 3usize).unwrap()).unwrap().get_relocatable().unwrap();
Expand All @@ -1049,7 +1047,7 @@ mod tests {
// - Address
assert_eq!(
vm.get_maybe(&(transaction_ptr + 5usize).unwrap()),
Some(keth_block.transactions[1].rlp.len.0.clone())
Some(keth_block.transactions[1].rlp.len.clone().unwrap().0)
);
let transaction2_rlp_ptr =
vm.get_maybe(&(transaction_ptr + 6usize).unwrap()).unwrap().get_relocatable().unwrap();
Expand All @@ -1069,7 +1067,7 @@ mod tests {
// - Address
assert_eq!(
vm.get_maybe(&(transaction_ptr + 7usize).unwrap()),
Some(keth_block.transactions[1].signature.len.0.clone())
Some(keth_block.transactions[1].signature.len.clone().unwrap().0)
);
let transaction2_signature_ptr =
vm.get_maybe(&(transaction_ptr + 8usize).unwrap()).unwrap().get_relocatable().unwrap();
Expand Down
Loading

0 comments on commit 14e3cf2

Please sign in to comment.