From 8b1a1b459d215361965fe7a8569209468d4c22d0 Mon Sep 17 00:00:00 2001 From: 0xaatif Date: Tue, 16 Jul 2024 17:25:33 +0100 Subject: [PATCH] refactor!: remove Node::new --- evm_arithmetization/src/generation/mpt.rs | 2 +- mpt_trie/src/partial_trie.rs | 4 ---- mpt_trie/src/trie_hashing.rs | 4 ++-- mpt_trie/src/trie_subsets.rs | 2 +- trace_decoder/src/decoding.rs | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/evm_arithmetization/src/generation/mpt.rs b/evm_arithmetization/src/generation/mpt.rs index baefeb479..a2c1d1a01 100644 --- a/evm_arithmetization/src/generation/mpt.rs +++ b/evm_arithmetization/src/generation/mpt.rs @@ -273,7 +273,7 @@ fn load_state_trie( code_hash, } = account; - let storage_hash_only = Node::new(Node::Hash(storage_root)).freeze(); + let storage_hash_only = Node::Hash(storage_root).freeze(); let merged_key = key.merge_nibbles(nibbles); let storage_trie: &Node = storage_tries_by_state_key .get(&merged_key) diff --git a/mpt_trie/src/partial_trie.rs b/mpt_trie/src/partial_trie.rs index 352849791..9d91bbf4e 100644 --- a/mpt_trie/src/partial_trie.rs +++ b/mpt_trie/src/partial_trie.rs @@ -123,10 +123,6 @@ impl Node { node: self, } } - /// Creates a new partial trie from a node. - pub fn new(node: Node) -> Self { - node - } /// Inserts a node into the trie. pub fn insert(&mut self, k: K, v: V) -> TrieOpResult<()> where diff --git a/mpt_trie/src/trie_hashing.rs b/mpt_trie/src/trie_hashing.rs index d3353ddc4..65fe1903b 100644 --- a/mpt_trie/src/trie_hashing.rs +++ b/mpt_trie/src/trie_hashing.rs @@ -227,7 +227,7 @@ mod tests { fn get_root_hashes_for_our_trie_after_each_insert( entries: impl Iterator, ) -> impl Iterator { - let mut trie = Node::new(Node::Empty); + let mut trie = Node::Empty; entries.map(move |(k, v)| { trie.insert(k, v).unwrap(); @@ -250,7 +250,7 @@ mod tests { fn empty_hash_is_correct() { common_setup(); - let trie = Node::new(Node::Empty); + let trie = Node::Empty; assert_eq!(keccak_hash::KECCAK_NULL_RLP, trie.get_hash()); } diff --git a/mpt_trie/src/trie_subsets.rs b/mpt_trie/src/trie_subsets.rs index d02c0d19c..34d24f6bc 100644 --- a/mpt_trie/src/trie_subsets.rs +++ b/mpt_trie/src/trie_subsets.rs @@ -436,7 +436,7 @@ mod tests { fn encountering_a_hash_node_returns_err() { common_setup(); - let trie = TrieType::new(Node::Hash(H256::zero())); + let trie = Node::Hash(H256::zero()); let res = create_trie_subset(&trie, once(0x1234)); assert!(res.is_err()) diff --git a/trace_decoder/src/decoding.rs b/trace_decoder/src/decoding.rs index f8f8792f8..7430c5138 100644 --- a/trace_decoder/src/decoding.rs +++ b/trace_decoder/src/decoding.rs @@ -417,7 +417,7 @@ impl ProcessedBlockTrace { if !storage_tries.contains_key(h_addr) { let trie = state_accounts_with_no_accesses_but_storage_tries .get(h_addr) - .map(|s_root| Node::new(Node::Hash(*s_root))) + .map(|s_root| Node::Hash(*s_root)) .unwrap_or_default(); storage_tries.insert(*h_addr, trie);