Skip to content

Commit

Permalink
refactor: organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaatif committed Jun 8, 2024
1 parent 4a5abfb commit 86899b4
Show file tree
Hide file tree
Showing 28 changed files with 21,853 additions and 22,063 deletions.
215 changes: 16 additions & 199 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ bitvec = "1.0.1"
[dev-dependencies]
hex = { workspace = true, features = ["serde"] }
insta = { version = "1.39.0", features = ["glob"] }
once_cell = "1.19.0"
pretty_env_logger = "0.5.0"
serde_json.workspace = true
winnow = { version = "0.6.11", features = ["debug"] }
35 changes: 32 additions & 3 deletions trace_decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,36 @@ pub fn type_1(
}

mod type1 {
pub use witness::{Instruction, V1Header, Witness};
mod witness;
mod witness2forest;
//! Based on [this specification](https://gist.github.com/mandrigin/ff7eccf30d0ef9c572bafcb0ab665cff#the-bytes-layout).
//! Deviations are commented with `BUG`.
/// Execution of [`Instruction`]s from the wire into a trie.
///
/// Use of a stack machine is amenable to streaming off the wire.
mod execution;
/// Parser combinators for the binary "wire" format.
///
/// Use of [`winnow`] is amenable to streaming off the wire.
mod wire;

#[test]
fn test() {
use insta::assert_debug_snapshot;
use serde::Deserialize;

#[derive(Deserialize)]
struct Case {
#[serde(with = "hex", rename = "hex")]
pub bytes: Vec<u8>,
}

for vector in
serde_json::from_str::<Vec<Case>>(include_str!("type1/witness_vectors.json")).unwrap()
{
let instructions = wire::parse(&vector.bytes).unwrap();
assert_debug_snapshot!(instructions);
let executed = execution::execute(instructions).unwrap();
assert_debug_snapshot!(executed);
}
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: trace_decoder/src/type1/witness.rs
expression: collapsed
source: trace_decoder/src/lib.rs
expression: executed
---
NonEmpty {
inner: [
Expand Down
Loading

0 comments on commit 86899b4

Please sign in to comment.