Skip to content

Commit

Permalink
wibble: order
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaatif committed Aug 7, 2024
1 parent bab2363 commit f65fbd0
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions trace_decoder/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,6 @@ use crate::{
OtherBlockData, PartialTriePreImages,
};

// This is just `rlp(0)`.
const ZERO_STORAGE_SLOT_VAL_RLPED: [u8; 1] = [128];

/// Formatting aid for error context.
struct WithHash(U512);

impl fmt::Display for WithHash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut buf = [0u8; 64];
self.0.to_big_endian(&mut buf);
f.write_fmt(format_args!("{} (hashed: 0x{:064X})", self.0, hash(buf)))
}
}

/// Aid for error context.
/// Covers all Ethereum trie types (see <https://ethereum.github.io/yellowpaper/paper.pdf> for details).
#[derive(Debug, strum::Display)]
#[allow(missing_docs)]
pub enum TrieType {
State,
Storage,
Receipt,
Txn,
}

/// The current state of all tries as we process txn deltas. These are mutated
/// after every txn we process in the trace.
#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -686,3 +661,28 @@ fn eth_to_gwei(eth: U256) -> U256 {
// 1 ether = 10^9 gwei.
eth * U256::from(10).pow(9.into())
}

// This is just `rlp(0)`.
const ZERO_STORAGE_SLOT_VAL_RLPED: [u8; 1] = [128];

/// Formatting aid for error context.
struct WithHash(U512);

impl fmt::Display for WithHash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut buf = [0u8; 64];
self.0.to_big_endian(&mut buf);
f.write_fmt(format_args!("{} (hashed: 0x{:064X})", self.0, hash(buf)))
}
}

/// Aid for error context.
/// Covers all Ethereum trie types (see <https://ethereum.github.io/yellowpaper/paper.pdf> for details).
#[derive(Debug, strum::Display)]
#[allow(missing_docs)]
pub enum TrieType {
State,
Storage,
Receipt,
Txn,
}

0 comments on commit f65fbd0

Please sign in to comment.