Skip to content

Commit

Permalink
implement version command for all zero bin binaries (#451)
Browse files Browse the repository at this point in the history
* implement version command for all zero bin binaries

* fix clippy issues

* fix review comments

* Update zero_bin/README.md

Co-authored-by: Robin Salen <[email protected]>

* review fixes

* fix cliipy issues in develop

* Revert "fix cliipy issues in develop"

This reverts commit 4615cb5.

* added removed code

---------

Co-authored-by: Robin Salen <[email protected]>
  • Loading branch information
temaniarpit27 and Nashtare authored Aug 6, 2024
1 parent f6a3386 commit 52ab1aa
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 16 deletions.
130 changes: 130 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ axum = "0.7.5"
bitflags = "2.5.0"
bitvec = "1.0.1"
bytes = "1.6.0"
cargo_metadata = "0.18.1"
ciborium = "0.2.2"
ciborium-io = "0.2.2"
clap = { version = "4.5.7", features = ["derive", "env"] }
Expand Down Expand Up @@ -104,6 +105,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
u4 = "0.1.0"
uint = "0.9.5"
url = "2.5.2"
vergen = { version = "9.0.0", features = ["build", "rustc"] }
winnow = "0.6.13"

# local dependencies
Expand Down
8 changes: 7 additions & 1 deletion trace_decoder/src/typed_mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl TriePath {
pub fn from_hash(H256(bytes): H256) -> Self {
Self::new(AsNibbles(bytes)).expect("32 bytes is 64 nibbles, which fits")
}
#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
fn from_txn_ix(txn_ix: usize) -> Self {
TriePath::new(AsNibbles(rlp::encode(&txn_ix))).expect(
"\
Expand Down Expand Up @@ -163,6 +164,7 @@ impl TriePath {
}
}

#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
/// Per-block, `txn_ix -> [u8]`.
///
/// See <https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#receipts-trie>
Expand All @@ -171,6 +173,7 @@ pub struct TransactionTrie {
untyped: HashedPartialTrie,
}

#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
impl TransactionTrie {
pub fn insert(&mut self, txn_ix: usize, val: Vec<u8>) -> Result<Option<Vec<u8>>, Error> {
let prev = self
Expand All @@ -190,6 +193,7 @@ impl TransactionTrie {
}
}

#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
/// Per-block, `txn_ix -> [u8]`.
///
/// See <https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#transaction-trie>
Expand All @@ -198,6 +202,7 @@ pub struct ReceiptTrie {
untyped: HashedPartialTrie,
}

#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
impl ReceiptTrie {
pub fn insert(&mut self, txn_ix: usize, val: Vec<u8>) -> Result<Option<Vec<u8>>, Error> {
let prev = self
Expand Down Expand Up @@ -300,6 +305,7 @@ impl StorageTrie {
pub fn root(&self) -> H256 {
self.untyped.hash()
}
#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
pub fn remove(&mut self, path: TriePath) -> Result<Option<Vec<u8>>, Error> {
self.untyped
.delete(path.into_nibbles())
Expand All @@ -308,7 +314,7 @@ impl StorageTrie {
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}

#[allow(unused)] // TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
pub fn as_mut_hashed_partial_trie_unchecked(&mut self) -> &mut HashedPartialTrie {
&mut self.untyped
}
Expand Down
16 changes: 13 additions & 3 deletions zero_bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ Usage: leader [OPTIONS] <COMMAND>
Commands:
stdio Reads input from stdin and writes output to stdout
jerigon Reads input from a Jerigon node and writes output to stdout
native Reads input from a native node and writes output to stdout
native Reads input from a native node and writes output to stdout
http Reads input from HTTP and writes output to a directory
help Print this message or the help of the given subcommand(s)
Options:
-h, --help
Print help (see a summary with '-h')
--version
Fetch the `evm_arithmetization` package version, build commit hash and build timestamp
Paladin options:
-t, --task-bus-routing-key <TASK_BUS_ROUTING_KEY>
Expand Down Expand Up @@ -366,6 +368,7 @@ cargo r --bin verifier -- --help
Usage: verifier --file-path <FILE_PATH>
Options:
--version Fetch the `evm_arithmetization` package version, build commit hash and build timestamp
-f, --file-path <FILE_PATH> The file containing the proof to verify
-h, --help Print help
```
Expand All @@ -386,11 +389,13 @@ cargo r --bin rpc -- --help
Usage: rpc <COMMAND>
Commands:
fetch Fetch and generate prover input from the RPC endpoint
help Print this message or the help of the given subcommand(s)
fetch Fetch and generate prover input from the RPC endpoint
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
--version
Fetch the `evm_arithmetization` package version, build commit hash and build timestamp
```

Example:
Expand Down Expand Up @@ -457,15 +462,20 @@ Finally, note that both of these testing scripts force proof generation to be se

The trace decoder module has some basic regression tests, using the json witness data from the `trace_decoder/tests/data/witnesses` subdirectories.
When needed (e.g. some block with corner-case discovered), additional input witness data should be generated using the following procedure:

1. Run the `rpc` tool to fetch the block (or multiple blocks) witness:

```sh
cargo run --bin rpc fetch --rpc-url <node_rpc_endpoint> --start-block <start> --end-block <end> > ./b<number>_<network>.json
```

2. Download the header file for the block (or range of blocks), making the json array of headers:

```sh
file_name = "b<number>_<network>_header.json"
echo "[" > $file_name && cast rpc eth_getBlockByNumber "0x<block_number>" 'false' --rpc-url <node_rpc_endpoint> >> $file_name && echo "]" >> $file_name
```

Move the generated files to the appropriate subdirectory, and they will be automatically included in the test run.

## License
Expand Down
7 changes: 7 additions & 0 deletions zero_bin/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ futures = { workspace = true }
tokio = { workspace = true }
alloy = { workspace = true }
async-stream = { workspace = true }
cargo_metadata = { workspace = true }
vergen = { workspace = true }

[build-dependencies]
cargo_metadata = { workspace = true }
vergen = { workspace = true }
anyhow = { workspace = true }
Loading

0 comments on commit 52ab1aa

Please sign in to comment.