-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trie): introduce
TRIE_ACCOUNT_RLP_MAX_SIZE
constant (#12638)
- Loading branch information
Showing
7 changed files
with
38 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// The maximum size of RLP encoded trie account in bytes. | ||
/// 2 (header) + 4 * 1 (field lens) + 8 (nonce) + 32 * 3 (balance, storage root, code hash) | ||
pub const TRIE_ACCOUNT_RLP_MAX_SIZE: usize = 110; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use alloy_primitives::{B256, U256}; | ||
use alloy_rlp::Encodable; | ||
use reth_trie_common::TrieAccount; | ||
|
||
#[test] | ||
fn account_rlp_max_size() { | ||
let account = TrieAccount { | ||
nonce: u64::MAX, | ||
balance: U256::MAX, | ||
storage_root: B256::from_slice(&[u8::MAX; 32]), | ||
code_hash: B256::from_slice(&[u8::MAX; 32]), | ||
}; | ||
let mut encoded = Vec::new(); | ||
account.encode(&mut encoded); | ||
assert_eq!(encoded.len(), TRIE_ACCOUNT_RLP_MAX_SIZE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters