Skip to content

Commit

Permalink
Improve FaultProofStatus serialization, options
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianBland committed Aug 26, 2024
1 parent 8880514 commit 4bfc9fc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exclude = ["**/target", "benches/"]
# General
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_repr = "0.1"
thiserror = "1"
color-eyre = "0.6"
lazy_static = "1"
Expand Down
1 change: 1 addition & 0 deletions crates/op-test-vectors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ edition.workspace = true
[dependencies]
# Core
serde.workspace = true
serde_repr.workspace = true
color-eyre.workspace = true
hashbrown.workspace = true

Expand Down
19 changes: 12 additions & 7 deletions crates/op-test-vectors/src/faultproof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Module containing the fault proof test fixture.

use alloy_primitives::{BlockNumber, Bytes, ChainId, B256, U256};
use alloy_primitives::{BlockHash, BlockNumber, Bytes, ChainId, B256, U256};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use hashbrown::HashMap;

/// The fault proof fixture is the top-level object that contains
Expand All @@ -22,9 +23,9 @@ pub struct FaultProofFixture {
#[serde(rename_all = "camelCase")]
pub struct FaultProofInputs {
/// The L1 head block hash.
pub l1_head: B256,
pub l1_head: BlockHash,
/// The L2 head block hash.
pub l2_head: B256,
pub l2_head: BlockHash,
/// The claimed L2 output root to validate.
pub l2_claim: B256,
/// The agreed L2 output root to start derivation from.
Expand All @@ -36,15 +37,18 @@ pub struct FaultProofInputs {
}

/// The fault proof status is the result of executing the fault proof program.
#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, PartialEq, Eq)]
#[repr(u8)]
pub enum FaultProofStatus {
/// The claim is valid.
#[default]
Valid,
Valid = 0,
/// The claim is invalid.
Invalid,
Invalid = 1,
/// Executing the program resulted in a panic.
Panic,
Panic = 2,
/// The program has not exited.
Unfinished = 3,
/// The status is unknown.
Unknown
}
Expand All @@ -59,6 +63,7 @@ mod tests {
FaultProofStatus::Valid,
FaultProofStatus::Invalid,
FaultProofStatus::Panic,
FaultProofStatus::Unfinished,
FaultProofStatus::Unknown,
];

Expand Down

0 comments on commit 4bfc9fc

Please sign in to comment.