2022-09-27 10:49:13 -07:00
|
|
|
use eth_trie_utils::partial_trie::{Nibbles, PartialTrie};
|
2022-10-08 15:09:07 -07:00
|
|
|
use ethereum_types::{BigEndianHash, H256, U256};
|
|
|
|
|
|
|
|
|
|
use crate::generation::mpt::AccountRlp;
|
2022-09-27 10:49:13 -07:00
|
|
|
|
2022-10-01 21:55:47 -07:00
|
|
|
mod hash;
|
2022-09-30 13:04:16 -07:00
|
|
|
mod hex_prefix;
|
2022-10-08 15:09:07 -07:00
|
|
|
mod insert;
|
2022-09-22 20:09:48 -07:00
|
|
|
mod load;
|
2022-09-24 22:23:24 -07:00
|
|
|
mod read;
|
2022-09-27 10:49:13 -07:00
|
|
|
|
2022-10-17 23:12:03 -07:00
|
|
|
pub(crate) fn nibbles_64<T: Into<U256>>(v: T) -> Nibbles {
|
|
|
|
|
let packed = v.into();
|
|
|
|
|
Nibbles { count: 64, packed }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn nibbles_count<T: Into<U256>>(v: T, count: usize) -> Nibbles {
|
|
|
|
|
let packed = v.into();
|
|
|
|
|
Nibbles { count, packed }
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-08 15:09:07 -07:00
|
|
|
pub(crate) fn test_account_1() -> AccountRlp {
|
|
|
|
|
AccountRlp {
|
|
|
|
|
nonce: U256::from(1111),
|
|
|
|
|
balance: U256::from(2222),
|
|
|
|
|
storage_root: H256::from_uint(&U256::from(3333)),
|
|
|
|
|
code_hash: H256::from_uint(&U256::from(4444)),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn test_account_1_rlp() -> Vec<u8> {
|
|
|
|
|
rlp::encode(&test_account_1()).to_vec()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn test_account_2() -> AccountRlp {
|
|
|
|
|
AccountRlp {
|
|
|
|
|
nonce: U256::from(5555),
|
|
|
|
|
balance: U256::from(6666),
|
|
|
|
|
storage_root: H256::from_uint(&U256::from(7777)),
|
|
|
|
|
code_hash: H256::from_uint(&U256::from(8888)),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn test_account_2_rlp() -> Vec<u8> {
|
|
|
|
|
rlp::encode(&test_account_2()).to_vec()
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-27 10:49:13 -07:00
|
|
|
/// A `PartialTrie` where an extension node leads to a leaf node containing an account.
|
2022-10-06 20:50:32 -07:00
|
|
|
pub(crate) fn extension_to_leaf(value: Vec<u8>) -> PartialTrie {
|
2022-09-27 10:49:13 -07:00
|
|
|
PartialTrie::Extension {
|
2022-10-31 15:15:10 -06:00
|
|
|
nibbles: 0xABC_u64.into(),
|
2022-10-11 20:15:33 -06:00
|
|
|
child: PartialTrie::Leaf {
|
2022-09-27 10:49:13 -07:00
|
|
|
nibbles: Nibbles {
|
|
|
|
|
count: 3,
|
|
|
|
|
packed: 0xDEF.into(),
|
|
|
|
|
},
|
|
|
|
|
value,
|
2022-10-11 20:15:33 -06:00
|
|
|
}
|
|
|
|
|
.into(),
|
2022-09-27 10:49:13 -07:00
|
|
|
}
|
|
|
|
|
}
|