Skip to content

Commit

Permalink
Updated deps to use 0xPolygonZero instead of mir-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
BGluth committed Oct 11, 2023
1 parent 1bc2069 commit e81ec6d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ resolver = "2"
[workspace.dependencies]
serde_json = "1.0.106"
log = "0.4.19"
plonky2_evm = { git = "https://github.com/mir-protocol/plonky2.git", rev = "762e6f07b834df04be8cd290f07465a28c392c6d" }
plonky2_evm = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "762e6f07b834df04be8cd290f07465a28c392c6d" }
rlp = "0.5.2"
hex = "0.4.3"

[patch.crates-io]
# TODO: Remove `eth_trie_utils` patch once version `0.7.0` is released...
eth_trie_utils = { git = "https://github.com/mir-protocol/eth_trie_utils.git", rev = "e9ec4ec2aa2ae976b7c699ef40c1ffc716d87ed5" }
eth_trie_utils = { git = "https://github.com/0xPolygonZero/eth_trie_utils.git", rev = "e9ec4ec2aa2ae976b7c699ef40c1ffc716d87ed5" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plonky Edge block trace parser

This is a simple library dedicated to parsing [Polygon Edge](https://github.com/0xPolygon/polygon-edge) block traces into a format usable for txn proof generation within [plonky2](https://github.com/mir-protocol/plonky2) (and later also [plonky3](https://github.com/Plonky3)).
This is a simple library dedicated to parsing [Polygon Edge](https://github.com/0xPolygon/polygon-edge) block traces into a format usable for txn proof generation within [plonky2](https://github.com/0xPolygonZero/plonky2) (and later also [plonky3](https://github.com/Plonky3)).

Note that at the time of writing support for Edge block traces are currently not stable and only available on the `feat/zero` branch.

Expand Down
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ eth_trie_utils = "0.6.0"
hex = { workspace = true }
keccak-hash = "0.10.0"
log = { workspace = true }
plonky_block_proof_gen = { git = "https://github.com/mir-protocol/plonky-block-proof-gen.git", rev = "73c3bcbaf3bfe913641c5b6817bc3ba5aa9859bc" }
plonky_block_proof_gen = { git = "https://github.com/0xPolygonZero/plonky-block-proof-gen.git", rev = "9951509f31c0099dca446b478bfb8a45cf8aaf97" }
plonky2_evm = { workspace = true }
rlp = { workspace = true }
rlp-derive = "0.1.0"
Expand Down
42 changes: 42 additions & 0 deletions parser/src/plonky2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ impl EdgeBlockTrace {
Self::decode_edge_rlp_state_trie_nodes(&rlped_storage_nodes, s_root);
assert_eq!(s_tree.hash(), s_root);

let s_addrs: Vec<_> = s_tree
.items()
.map(|(k, v_or_h)| {
let v_or_h_char = match v_or_h {
ValOrHash::Val(_) => 'L',
ValOrHash::Hash(_) => 'H',
};
format!("{} - {:x}", v_or_h_char, k)
})
.collect();
println!("Initial storage trie for {:x}: {:?}", addr, s_addrs);

(H256::from_slice(&addr.bytes_be()), s_tree)
})
.collect();
Expand Down Expand Up @@ -645,6 +657,19 @@ impl EdgeBlockTrace {
// The account may not have any storage until this txn.
let acc_storage_trie = trie_state.storage.entry(d.hashed_addr).or_default();

let s_addrs: Vec<_> = acc_storage_trie
.items()
.map(|(k, v_or_h)| {
let v_or_h_char = match v_or_h {
ValOrHash::Val(_) => 'L',
ValOrHash::Hash(_) => 'H',
};
format!("{} - {:x}", v_or_h_char, k)
})
.collect();

println!("APPLYING DELTA TO {:x} ({:?})", d.hashed_addr, s_addrs);

for (k, v) in new_storage_deltas {
let rlped_v: Vec<_> = rlp::encode(&v).into();
acc_storage_trie.insert(k, rlped_v);
Expand Down Expand Up @@ -719,3 +744,20 @@ fn string_to_nibbles_even_nibble_fixed(s: &str) -> Nibbles {

n
}

#[cfg(test)]
mod tests {
use std::str::FromStr;

use eth_trie_utils::nibbles::Nibbles;

use super::hash;

#[test]
fn cheese() {
let str = "0x0000000000000000000000000000000000000000000000000000000000000002";
let n = Nibbles::from_str(str).unwrap();

println!("{:x}", hash(&n.bytes_be()));
}
}

0 comments on commit e81ec6d

Please sign in to comment.