Skip to content

Commit 52dc0db

Browse files
committed
refactor(fault-proof): use forge-generated bindings as ABI source of truth
- Replace hand-written sol! ABI definitions with forge-generated bindings from op-succinct-bindings for contract types used in fault-proof and host - Keep hand-written sol! only for enums (GameStatus, ProposalStatus) that need custom derives and proper Rust enum variants - Move shared L2Output struct to bindings crate, re-export from consumers - Commit generated codegen to git so forge-less environments (Docker, CI jobs without Foundry) can compile against the bindings - Restore graceful forge fallback in build.rs: skip regeneration when forge is not in PATH, bail only if forge is present but broken - Add --skip-extra-derives to forge bind: removes unused serde/Debug/Default derives from codegen, reducing compile time - Add .gitattributes to collapse generated code in GitHub PR diffs - Hoist ProposalStatus::try_from before match block in proposer.rs
1 parent 25a9fee commit 52dc0db

31 files changed

Lines changed: 107104 additions & 348 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bindings/src/codegen/** linguist-generated=true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ configs/
4949

5050
# Contract Bindings
5151
**/codegen
52+
!bindings/src/codegen/
5253
# Grafana alloy config
5354
config.alloy
5455

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.

bindings/build.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@ fn main() -> anyhow::Result<()> {
2121
println!("cargo:rerun-if-changed={}", contracts_package_path.join("remappings.txt"));
2222
println!("cargo:rerun-if-changed={}", contracts_package_path.join("foundry.toml"));
2323

24-
// Check if forge is available
25-
if Command::new("forge").arg("--version").output().is_err() {
26-
println!("cargo:warning=Forge not found in PATH. Skipping bindings generation.");
27-
return Ok(());
24+
// Check if forge is available; skip regeneration if not (e.g. Docker builds).
25+
// CI jobs with forge (cargo-tests, lint) will catch ABI drift.
26+
let forge_check = Command::new("forge").arg("--version").output();
27+
match forge_check {
28+
Err(_) => {
29+
println!("cargo:warning=Forge not found in PATH. Skipping bindings generation.");
30+
return Ok(());
31+
}
32+
Ok(output) if !output.status.success() => {
33+
anyhow::bail!(
34+
"Forge is installed but returned an error. Check your Foundry installation."
35+
);
36+
}
37+
Ok(_) => {} // forge available, continue
2838
}
2939

30-
// Use 'forge bind' to generate bindings for only the contracts we need for E2E tests
3140
let mut forge_command = Command::new("forge");
3241
forge_command.args([
3342
"bind",
@@ -38,8 +47,8 @@ fn main() -> anyhow::Result<()> {
3847
"--skip-extra-derives",
3948
]);
4049

41-
// Only generate bindings for the contracts we actually need for E2E testing
4250
let required_contracts = [
51+
// E2E test contracts
4352
"DisputeGameFactory",
4453
"SuperchainConfig",
4554
"MockOptimismPortal2",
@@ -49,10 +58,14 @@ fn main() -> anyhow::Result<()> {
4958
"OPSuccinctFaultDisputeGame",
5059
"ERC1967Proxy",
5160
"MockPermissionedDisputeGame",
52-
// Also include interfaces that we need
61+
// Interfaces
5362
"IDisputeGameFactory",
5463
"IDisputeGame",
5564
"IFaultDisputeGame",
65+
"IAnchorStateRegistry",
66+
// Production contracts (host utils)
67+
"OPSuccinctL2OutputOracle",
68+
"OPSuccinctDisputeGame",
5669
];
5770

5871
// Create a regex pattern that matches any of our required contracts

0 commit comments

Comments
 (0)