Skip to content

feat(firewood/syncer): implement change proof support#5385

Draft
rkuris wants to merge 1 commit into
masterfrom
rkuris/firewood-change-proofs
Draft

feat(firewood/syncer): implement change proof support#5385
rkuris wants to merge 1 commit into
masterfrom
rkuris/firewood-change-proofs

Conversation

@rkuris
Copy link
Copy Markdown
Member

@rkuris rkuris commented May 17, 2026

Why this should be merged

The firewood syncer backend previously stubbed out the change-proof side of the sync.DB interface (placeholder type struct{}, marshaler/methods returned "not implemented"). Range proofs were the only working path, so the syncer fell back to full range proofs whenever a change proof would have been more efficient. Firewood v0.5.0 exposes the full change-proof API ((*Database).ChangeProof, .VerifyChangeProof*Proposal, (*Proposal).CommitWithRebase, (*ChangeProof).FindNextKey), so this change lights up the real implementation end-to-end.

How this works

  • proof.go: add a ChangeProof wrapper around *ffi.ChangeProof that holds the *ffi.Proposal produced by VerifyChangeProof until commit time; replace the stub marshaler with the real one.
  • syncer.go: switch the type parameter from struct{} to *ChangeProof on *database and the New/newWithDB constructors; implement GetChangeProof (server side), VerifyChangeProof (client side, returns a Proposal), and CommitChangeProof (Proposal.CommitWithRebase + FindNextKey for the next-key continuation, matching the existing range-proof pattern).
  • evm_syncer.go: implement (*evmDB).CommitChangeProof to enqueue code hashes from the proof before committing, mirroring the range-proof flow. (*ffi.ChangeProof).CodeHashes() is currently a no-op in firewood; the iterator loop is kept so we pick up real hashes automatically once it is implemented.
  • handler.go: change-proof handler type params.
  • External callers (graft/evm/sync/evmstate/firewood_syncer.go, syncer_test.go) updated to the new *ChangeProof type parameter.

Firewood version bumped to v0.5.0 in `go.mod`. v0.5.0 contains several correctness fixes that this code depends on (no-op proposal handling, `FindNextKey` returning nil at trie right edge, range-proof boundary checks).

How this was tested

Ran the firewood syncer test suite against a local firewood build at the v0.5.0 source. All 11 sub-tests pass:

  • `Test_Firewood_Sync` (7 cases — range-proof sync from empty/non-empty client to various server sizes up to 100k keys)
  • `Test_Firewood_Sync_UpdateSyncTarget` (4 cases — sync target update mid-flight, exercising the real change-proof path including `partial_sync_*_then_update` scenarios)

CI will fail until firewood v0.5.0 is published; reviewers can validate locally by pointing the firewood dependency at a v0.5.0 build via `go mod edit -replace`.

Need to be documented in RELEASES.md?

No.

Why this should be merged

How this works

How this was tested

Need to be documented in RELEASES.md?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements real change-proof support in the firewood syncer backend, replacing the previous struct{} stub with a *ChangeProof type that wraps *ffi.ChangeProof and the verification *ffi.Proposal. Bumps the firewood FFI dependency to v0.5.0 which provides the required APIs.

Changes:

  • Add ChangeProof wrapper type with real marshal/unmarshal and implement GetChangeProof/VerifyChangeProof/CommitChangeProof on *database.
  • Switch the type parameter from struct{} to *ChangeProof across database, evmDB, handler constructors, and external callers; implement evmDB.CommitChangeProof to enqueue code hashes before commit.
  • Bump github.com/ava-labs/firewood-go-ethhash/ffi to v0.5.0.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
go.mod Bumps firewood FFI to v0.5.0 (required for change-proof APIs).
database/merkle/firewood/syncer/proof.go Adds ChangeProof wrapper and real marshaler implementation.
database/merkle/firewood/syncer/syncer.go Implements GetChangeProof/VerifyChangeProof/CommitChangeProof; switches generics to *ChangeProof.
database/merkle/firewood/syncer/evm_syncer.go Implements evmDB.CommitChangeProof (code-hash enqueue + commit) and updates generics.
database/merkle/firewood/syncer/handler.go Updates handler constructors to new type parameter.
database/merkle/firewood/syncer/syncer_test.go Updates syncer type parameter in test.
graft/evm/sync/evmstate/firewood_syncer.go Updates FirewoodSyncer.s type parameter to *ChangeProof.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Why this should be merged

The firewood syncer backend previously stubbed out the change-proof side of
the `sync.DB` interface (placeholder type `struct{}`, marshaler/methods
returned `"not implemented"`). Range proofs were the only working path, so
the syncer fell back to full range proofs whenever a change proof would
have been more efficient. Firewood v0.5.0 exposes the full change-proof
API (`(*Database).ChangeProof`, `.VerifyChangeProof` → `*Proposal`,
`(*Proposal).CommitWithRebase`, `(*ChangeProof).FindNextKey`), so this
change lights up the real implementation end-to-end.

## How this works

- `proof.go`: add a `ChangeProof` wrapper around `*ffi.ChangeProof` that
  holds the `*ffi.Proposal` produced by `VerifyChangeProof` until commit
  time; replace the stub marshaler with the real one.
- `syncer.go`: switch the type parameter from `struct{}` to `*ChangeProof`
  on `*database` and the `New`/`newWithDB` constructors; implement
  `GetChangeProof` (server side), `VerifyChangeProof` (client side, returns
  a Proposal), and `CommitChangeProof` (`Proposal.CommitWithRebase` +
  `FindNextKey` for the next-key continuation, matching the existing
  range-proof pattern).
- `evm_syncer.go`: implement `(*evmDB).CommitChangeProof` to enqueue code
  hashes from the proof before committing, mirroring the range-proof flow.
  `(*ffi.ChangeProof).CodeHashes()` is currently a no-op in firewood; the
  iterator loop is kept so we pick up real hashes automatically once it
  is implemented.
- `handler.go`: change-proof handler type params.
- External callers (`graft/evm/sync/evmstate/firewood_syncer.go`,
  `syncer_test.go`) updated to the new `*ChangeProof` type parameter.

Firewood version bumped to v0.5.0 in \`go.mod\`. v0.5.0 contains several
correctness fixes that this code depends on (no-op proposal handling,
\`FindNextKey\` returning nil at trie right edge, range-proof boundary
checks).

## How this was tested

Ran the firewood syncer test suite against a local firewood build at the
v0.5.0 source. All 11 sub-tests pass:

- \`Test_Firewood_Sync\` (7 cases — range-proof sync from empty/non-empty
  client to various server sizes up to 100k keys)
- \`Test_Firewood_Sync_UpdateSyncTarget\` (4 cases — sync target update
  mid-flight, exercising the real change-proof path including
  \`partial_sync_*_then_update\` scenarios)

CI will fail until firewood v0.5.0 is published; reviewers can validate
locally by pointing the firewood dependency at a v0.5.0 build via
\`go mod edit -replace\`.

## Need to be documented in RELEASES.md?

No.
@rkuris rkuris force-pushed the rkuris/firewood-change-proofs branch from 3c58984 to 9148af6 Compare May 23, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants