-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impled building account trie entries
Cleaned up and finished account parsing Initial (buggy!) impl of trie insertion Initial work on trie tests Filled in trie `todo!()`s First trie test now passes Leaf splitting now works - Just realized that I'm reading the keys backwards, so I'll need to deal with that.
- Loading branch information
0 parents
commit c9eedc9
Showing
8 changed files
with
757 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Cargo.lock | ||
/**/target | ||
/target | ||
**/*.rs.bk | ||
*.iml | ||
.idea/ | ||
.vscode |
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,17 @@ | ||
[package] | ||
name = "zero_eth_trie_utils" | ||
description = "Types and utility functions for building/working with partial Ethereum tries." | ||
version = "0.1.0" | ||
authors = ["Polygon Zero <[email protected]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0.64" | ||
ethereum-types = "0.13.1" | ||
itertools = "0.10.3" | ||
log = "0.4.17" | ||
num-traits = "0.2.15" | ||
hex = "0.4.3" | ||
|
||
[dev-dependencies] | ||
pretty_env_logger = "0.4.0" |
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,3 @@ | ||
unstable_features = true | ||
group_imports = "StdExternalCrate" | ||
wrap_comments = true |
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,4 @@ | ||
pub mod partial_trie; | ||
pub mod trie_builder; | ||
mod types; | ||
mod utils; |
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,34 @@ | ||
use ethereum_types::U256; | ||
|
||
#[derive(Clone, Debug)] | ||
/// A partial trie, or a sub-trie thereof. This mimics the structure of an Ethereum trie, except | ||
/// with an additional `Hash` node type, representing a node whose data is not needed to process | ||
/// our transaction. | ||
pub enum PartialTrie { | ||
/// An empty trie. | ||
Empty, | ||
/// The digest of trie whose data does not need to be stored. | ||
Hash(U256), | ||
/// A branch node, which consists of 16 children and an optional value. | ||
Branch { | ||
children: [Box<PartialTrie>; 16], | ||
value: Option<U256>, | ||
}, | ||
/// An extension node, which consists of a list of nibbles and a single child. | ||
Extension { | ||
nibbles: Nibbles, | ||
child: Box<PartialTrie>, | ||
}, | ||
/// A leaf node, which consists of a list of nibbles and a value. | ||
Leaf { nibbles: Nibbles, value: Vec<u8> }, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] | ||
/// A sequence of nibbles. | ||
pub struct Nibbles { | ||
/// The number of nibbles in this sequence. | ||
pub count: usize, | ||
/// A packed encoding of these nibbles. Only the first (least significant) `4 * count` bits are | ||
/// used. The rest are unused and should be zero. | ||
pub packed: U256, | ||
} |
Oops, something went wrong.