mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 06:13:07 +00:00
Updated eth_trie_utils to 0.4.0
This commit is contained in:
parent
2e7da17554
commit
8736435ea9
@ -7,7 +7,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
plonky2 = { path = "../plonky2", default-features = false, features = ["rand", "timing"] }
|
||||
plonky2_util = { path = "../util" }
|
||||
eth_trie_utils = "0.3.1"
|
||||
eth_trie_utils = "0.4.0"
|
||||
anyhow = "1.0.40"
|
||||
env_logger = "0.9.0"
|
||||
ethereum-types = "0.14.0"
|
||||
|
||||
@ -2,7 +2,6 @@ use anyhow::Result;
|
||||
use eth_trie_utils::partial_trie::PartialTrie;
|
||||
use ethereum_types::{BigEndianHash, H256};
|
||||
|
||||
use super::nibbles;
|
||||
use crate::cpu::kernel::aggregator::KERNEL;
|
||||
use crate::cpu::kernel::interpreter::Interpreter;
|
||||
use crate::cpu::kernel::tests::mpt::{extension_to_leaf, test_account_1_rlp, test_account_2_rlp};
|
||||
@ -55,7 +54,7 @@ fn mpt_hash_hash() -> Result<()> {
|
||||
#[test]
|
||||
fn mpt_hash_leaf() -> Result<()> {
|
||||
let state_trie = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
};
|
||||
let trie_inputs = TrieInputs {
|
||||
@ -82,7 +81,7 @@ fn mpt_hash_extension_to_leaf() -> Result<()> {
|
||||
#[test]
|
||||
fn mpt_hash_branch_to_leaf() -> Result<()> {
|
||||
let leaf = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
value: test_account_2_rlp(),
|
||||
}
|
||||
.into();
|
||||
|
||||
@ -2,7 +2,6 @@ use anyhow::Result;
|
||||
use eth_trie_utils::partial_trie::{Nibbles, PartialTrie};
|
||||
use ethereum_types::{BigEndianHash, H256};
|
||||
|
||||
use super::nibbles;
|
||||
use crate::cpu::kernel::aggregator::KERNEL;
|
||||
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
|
||||
use crate::cpu::kernel::interpreter::Interpreter;
|
||||
@ -49,7 +48,7 @@ fn mpt_insert_leaf_overlapping_keys() -> Result<()> {
|
||||
#[ignore] // TODO: Not valid for state trie, all keys have same len.
|
||||
fn mpt_insert_leaf_insert_key_extends_leaf_key() -> Result<()> {
|
||||
let state_trie = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
};
|
||||
test_state_trie(state_trie, nibbles_64(0xABCDE), test_account_2())
|
||||
@ -59,7 +58,7 @@ fn mpt_insert_leaf_insert_key_extends_leaf_key() -> Result<()> {
|
||||
#[ignore] // TODO: Not valid for state trie, all keys have same len.
|
||||
fn mpt_insert_leaf_leaf_key_extends_insert_key() -> Result<()> {
|
||||
let state_trie = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xABCDE),
|
||||
nibbles: 0xABCDE_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
};
|
||||
test_state_trie(state_trie, nibbles_64(0xABC), test_account_2())
|
||||
@ -84,12 +83,12 @@ fn mpt_insert_extension_nonoverlapping_keys() -> Result<()> {
|
||||
// Existing keys are 0xABC, 0xABCDEF; inserted key is 0x12345.
|
||||
let mut children = std::array::from_fn(|_| PartialTrie::Empty.into());
|
||||
children[0xD] = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xEF),
|
||||
nibbles: 0xEF_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
}
|
||||
.into();
|
||||
let state_trie = PartialTrie::Extension {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
child: PartialTrie::Branch {
|
||||
children,
|
||||
value: test_account_1_rlp(),
|
||||
@ -107,12 +106,12 @@ fn mpt_insert_extension_insert_key_extends_node_key() -> Result<()> {
|
||||
// Existing keys are 0xA, 0xABCD; inserted key is 0xABCDEF.
|
||||
let mut children = std::array::from_fn(|_| PartialTrie::Empty.into());
|
||||
children[0xB] = PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xCD),
|
||||
nibbles: 0xCD_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
}
|
||||
.into();
|
||||
let state_trie = PartialTrie::Extension {
|
||||
nibbles: nibbles(0xA),
|
||||
nibbles: 0xA_u64.into(),
|
||||
child: PartialTrie::Branch {
|
||||
children,
|
||||
value: test_account_1_rlp(),
|
||||
|
||||
@ -2,11 +2,11 @@ use anyhow::Result;
|
||||
use eth_trie_utils::partial_trie::PartialTrie;
|
||||
use ethereum_types::{BigEndianHash, H256, U256};
|
||||
|
||||
use crate::cpu::kernel::aggregator::KERNEL;
|
||||
use crate::cpu::kernel::constants::global_metadata::GlobalMetadata;
|
||||
use crate::cpu::kernel::constants::trie_type::PartialTrieType;
|
||||
use crate::cpu::kernel::interpreter::Interpreter;
|
||||
use crate::cpu::kernel::tests::mpt::{extension_to_leaf, test_account_1, test_account_1_rlp};
|
||||
use crate::cpu::kernel::{aggregator::KERNEL, tests::mpt::nibbles};
|
||||
use crate::generation::mpt::all_mpt_prover_inputs_reversed;
|
||||
use crate::generation::TrieInputs;
|
||||
|
||||
@ -49,7 +49,7 @@ fn load_all_mpts_empty() -> Result<()> {
|
||||
fn load_all_mpts_leaf() -> Result<()> {
|
||||
let trie_inputs = TrieInputs {
|
||||
state_trie: PartialTrie::Leaf {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
value: test_account_1_rlp(),
|
||||
},
|
||||
transactions_trie: Default::default(),
|
||||
|
||||
@ -9,16 +9,6 @@ mod insert;
|
||||
mod load;
|
||||
mod read;
|
||||
|
||||
/// Helper function to reduce code duplication.
|
||||
/// Note that this preserves all nibbles (eg. `0x123` is not interpreted as `0x0123`).
|
||||
pub(crate) fn nibbles<T: Into<U256>>(v: T) -> Nibbles {
|
||||
let packed = v.into();
|
||||
Nibbles {
|
||||
count: Nibbles::get_num_nibbles_in_key(&packed),
|
||||
packed,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn nibbles_64<T: Into<U256>>(v: T) -> Nibbles {
|
||||
let packed = v.into();
|
||||
Nibbles { count: 64, packed }
|
||||
@ -58,7 +48,7 @@ pub(crate) fn test_account_2_rlp() -> Vec<u8> {
|
||||
/// A `PartialTrie` where an extension node leads to a leaf node containing an account.
|
||||
pub(crate) fn extension_to_leaf(value: Vec<u8>) -> PartialTrie {
|
||||
PartialTrie::Extension {
|
||||
nibbles: nibbles(0xABC),
|
||||
nibbles: 0xABC_u64.into(),
|
||||
child: PartialTrie::Leaf {
|
||||
nibbles: Nibbles {
|
||||
count: 3,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user