Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 4bfc9fc

Browse files
committed
Improve FaultProofStatus serialization, options
1 parent 8880514 commit 4bfc9fc

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ exclude = ["**/target", "benches/"]
1515
# General
1616
serde = { version = "1", features = ["derive"] }
1717
serde_json = "1"
18+
serde_repr = "0.1"
1819
thiserror = "1"
1920
color-eyre = "0.6"
2021
lazy_static = "1"

crates/op-test-vectors/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ edition.workspace = true
1212
[dependencies]
1313
# Core
1414
serde.workspace = true
15+
serde_repr.workspace = true
1516
color-eyre.workspace = true
1617
hashbrown.workspace = true
1718

crates/op-test-vectors/src/faultproof.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Module containing the fault proof test fixture.
22
3-
use alloy_primitives::{BlockNumber, Bytes, ChainId, B256, U256};
3+
use alloy_primitives::{BlockHash, BlockNumber, Bytes, ChainId, B256, U256};
44
use serde::{Deserialize, Serialize};
5+
use serde_repr::{Deserialize_repr, Serialize_repr};
56
use hashbrown::HashMap;
67

78
/// The fault proof fixture is the top-level object that contains
@@ -22,9 +23,9 @@ pub struct FaultProofFixture {
2223
#[serde(rename_all = "camelCase")]
2324
pub struct FaultProofInputs {
2425
/// The L1 head block hash.
25-
pub l1_head: B256,
26+
pub l1_head: BlockHash,
2627
/// The L2 head block hash.
27-
pub l2_head: B256,
28+
pub l2_head: BlockHash,
2829
/// The claimed L2 output root to validate.
2930
pub l2_claim: B256,
3031
/// The agreed L2 output root to start derivation from.
@@ -36,15 +37,18 @@ pub struct FaultProofInputs {
3637
}
3738

3839
/// The fault proof status is the result of executing the fault proof program.
39-
#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
40+
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, PartialEq, Eq)]
41+
#[repr(u8)]
4042
pub enum FaultProofStatus {
4143
/// The claim is valid.
4244
#[default]
43-
Valid,
45+
Valid = 0,
4446
/// The claim is invalid.
45-
Invalid,
47+
Invalid = 1,
4648
/// Executing the program resulted in a panic.
47-
Panic,
49+
Panic = 2,
50+
/// The program has not exited.
51+
Unfinished = 3,
4852
/// The status is unknown.
4953
Unknown
5054
}
@@ -59,6 +63,7 @@ mod tests {
5963
FaultProofStatus::Valid,
6064
FaultProofStatus::Invalid,
6165
FaultProofStatus::Panic,
66+
FaultProofStatus::Unfinished,
6267
FaultProofStatus::Unknown,
6368
];
6469

0 commit comments

Comments
 (0)