Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Inputs wiring #2604

Merged
merged 38 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2a40398
Support simpler capture and replay of ValidatorInputs
eljobe Aug 7, 2024
7113c52
Fix the deserialization of the UserWasm data
eljobe Aug 7, 2024
f424256
Print the End global state
eljobe Aug 7, 2024
3eed9bf
Remove two calls to recordBlock
eljobe Aug 7, 2024
0e49165
Merge branch 'master' into inputs-wiring
eljobe Aug 8, 2024
ec7a386
A few small changes bundled together in here.
eljobe Aug 8, 2024
e52eda4
Merge branch 'master' into inputs-wiring
eljobe Aug 9, 2024
457267e
Merge branch 'master' into inputs-wiring
eljobe Aug 12, 2024
2c540cf
Merge branch 'master' into inputs-wiring
eljobe Aug 14, 2024
95c6024
Merge branch 'master' into inputs-wiring
eljobe Aug 15, 2024
d379969
Merge branch 'master' into inputs-wiring
eljobe Aug 20, 2024
e9bf293
Use the strongly-typed rawdb.Target
eljobe Aug 20, 2024
e547683
Merge branch 'master' into inputs-wiring
eljobe Aug 22, 2024
39cd0a7
Finish wiring the json file writing everywhere.
eljobe Aug 22, 2024
20b6790
Merge branch 'master' into inputs-wiring
eljobe Aug 22, 2024
1a353b2
Add a hacky sleep
eljobe Aug 23, 2024
1056e22
Merge branch 'master' into inputs-wiring
eljobe Aug 29, 2024
25af47f
Ensure the inbox tracker has the desired message.
eljobe Aug 29, 2024
e0d70e6
Remove commented out code.
eljobe Aug 29, 2024
bc25dde
Separate the writer for validaiton inputs from the json.
eljobe Aug 29, 2024
62498a9
Merge branch 'master' into inputs-wiring
eljobe Aug 29, 2024
2f98f82
Merge branch 'master' into inputs-wiring
joshuacolvin0 Aug 30, 2024
9bca417
Merge branch 'master' into inputs-wiring
eljobe Aug 30, 2024
2f2c31c
Merge branch 'master' into inputs-wiring
eljobe Aug 31, 2024
37d4307
Merge branch 'master' into inputs-wiring
eljobe Sep 3, 2024
3042894
Merge branch 'master' into inputs-wiring
eljobe Sep 4, 2024
8faa8d3
Merge branch 'master' into inputs-wiring
eljobe Sep 6, 2024
984a7f1
Fix broken imports of ethdb and rawdb
eljobe Sep 18, 2024
646e6ad
Merge branch 'master' into inputs-wiring
eljobe Sep 18, 2024
c45d80f
Update Cargo.lock
eljobe Sep 18, 2024
f9e6eea
Address review feedback
eljobe Sep 18, 2024
9f0fff0
Merge branch 'master' into inputs-wiring
eljobe Sep 18, 2024
614d631
Remove commented out implementation.
eljobe Sep 18, 2024
f9bcefb
Merge branch 'master' into inputs-wiring
eljobe Sep 23, 2024
faed5a9
Merge branch 'master' into inputs-wiring
eljobe Sep 25, 2024
e20d793
Merge branch 'master' into inputs-wiring
eljobe Sep 28, 2024
c550c7e
Switch to funcional options for the inputs.Writer
eljobe Sep 28, 2024
ea47d46
Fix two last instances of system-specific paths
eljobe Sep 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 7 additions & 71 deletions arbitrator/Cargo.lock

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

101 changes: 101 additions & 0 deletions arbitrator/arbutil/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
borrow::Borrow,
fmt,
ops::{Deref, DerefMut},
str::FromStr,
};

// These values must be kept in sync with `arbutil/preimage_type.go`,
Expand Down Expand Up @@ -83,6 +84,32 @@ impl From<usize> for Bytes32 {
}
}

impl FromStr for Bytes32 {
type Err = &'static str;

fn from_str(s: &str) -> Result<Self, Self::Err> {
// Remove the "0x" prefix if present
let s = s.strip_prefix("0x").unwrap_or(s);

// Pad with leading zeros if the string is shorter than 64 characters (32 bytes)
let padded = format!("{:0>64}", s);

// Decode the hex string using the hex crate
let decoded_bytes = hex::decode(padded).map_err(|_| "Invalid hex string")?;

// Ensure the decoded bytes is exactly 32 bytes
if decoded_bytes.len() != 32 {
return Err("Hex string too long for Bytes32");
}

// Create a 32-byte array and fill it with the decoded bytes.
let mut b = [0u8; 32];
b.copy_from_slice(&decoded_bytes);

Ok(Bytes32(b))
}
}

impl TryFrom<&[u8]> for Bytes32 {
type Error = std::array::TryFromSliceError;

Expand Down Expand Up @@ -249,3 +276,77 @@ impl From<GenericBytes20> for Bytes20 {
<[u8; 20]>::from(x).into()
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_bytes32() {
let b = Bytes32::from(0x12345678u32);
let expected = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x12, 0x34, 0x56, 0x78,
];
assert_eq!(b, Bytes32(expected));
}

#[test]
fn test_from_str_short() {
// Short hex string
let b = Bytes32::from_str("0x12345678").unwrap();
let expected = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x12, 0x34, 0x56, 0x78,
];
assert_eq!(b, Bytes32(expected));
}

#[test]
fn test_from_str_very_short() {
// Short hex string
let b = Bytes32::from_str("0x1").unwrap();
let expected = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0x1,
];
assert_eq!(b, Bytes32(expected));
}

#[test]
fn test_from_str_no_prefix() {
// Short hex string
let b = Bytes32::from_str("12345678").unwrap();
let expected = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x12, 0x34, 0x56, 0x78,
];
assert_eq!(b, Bytes32(expected));
}

#[test]
fn test_from_str_full() {
// Full-length hex string
let b =
Bytes32::from_str("0x0000000000000000000000000000000000000000000000000000000012345678")
.unwrap();
let expected = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x12, 0x34, 0x56, 0x78,
];
assert_eq!(b, Bytes32(expected));
}

#[test]
fn test_from_str_invalid_non_hex() {
let s = "0x123g5678"; // Invalid character 'g'
assert!(Bytes32::from_str(s).is_err());
}

#[test]
fn test_from_str_too_big() {
let s =
"0123456789ABCDEF0123456789ABCDEF01234567890123456789ABCDEF01234567890123456789ABCDEF0"; // 65 characters
assert!(Bytes32::from_str(s).is_err());
}
}
5 changes: 0 additions & 5 deletions arbitrator/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "bench"
version = "0.1.0"
edition = "2021"

[lib]
name = "bench"
path = "src/lib.rs"

[[bin]]
name = "benchbin"
path = "src/bin.rs"
Expand All @@ -20,7 +16,6 @@ clap = { version = "4.4.8", features = ["derive"] }
gperftools = { version = "0.2.0", optional = true }
serde = { version = "1.0.130", features = ["derive", "rc"] }
serde_json = "1.0.67"
serde_with = { version = "3.8.1", features = ["base64"] }

[features]
counters = []
Expand Down
6 changes: 3 additions & 3 deletions arbitrator/bench/src/bin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{path::PathBuf, time::Duration};

use bench::prepare::*;
use clap::Parser;
use eyre::bail;

Expand All @@ -10,11 +9,12 @@ use gperftools::profiler::PROFILER;
#[cfg(feature = "heapprof")]
use gperftools::heap_profiler::HEAP_PROFILER;

use prover::machine::MachineStatus;

#[cfg(feature = "counters")]
use prover::{machine, memory, merkle};

use prover::machine::MachineStatus;
use prover::prepare::prepare_machine;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
Expand Down
2 changes: 0 additions & 2 deletions arbitrator/bench/src/lib.rs

This file was deleted.

76 changes: 0 additions & 76 deletions arbitrator/bench/src/parse_input.rs

This file was deleted.

Loading
Loading