Repository navigation
perf(payments): in-memory vouchers with periodic + pre-redeem durable flush (#1672) - #1706
Merged
Merged
Conversation
…s default, reject 0)
…reason Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ubmitting on-chain
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Copilot stopped reviewing on behalf of
alpergundogdu due to an error
August 17, 2026 15:12
…y-fsync-15073f # Conflicts: # crates/node/src/handlers/client/mod.rs # crates/node/src/handlers/client/serve_leg.rs # crates/node/src/handlers/client/voucher.rs # crates/node/src/payment_settlement.rs # crates/node/tests/anvil_settlement_e2e.rs
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…y-fsync-15073f # Conflicts: # crates/node/src/handlers/client/voucher.rs # crates/node/tests/client_loopback.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #1672. Moves seller-side voucher persistence off the per-voucher fsync hot path (~3.18 ms/voucher, ~313 MiB/s lane ceiling). The per-lane voucher watermark now lives in memory and is mirrored to disk on a background timer, with a durable flush before every on-chain redeem.
The durability model
Lane state splits into two halves with different needs:
max(local, client)only advances), and a replay of un-redeemed vouchers is still on-chain-redeemable, so re-serving pays the node.owed ≥ submitted— the node never re-serves already-redeemed bytes for free.Worst case on an unclean restart is one flush interval of frontier (safe) and zero already-redeemed replay.
Changes
PoolStateStoregainsflush()(default no-op); the redb impl buffersrecord/forgetin an in-memory map hydrated atopen()and fsyncs the dirty set in one transaction onflush().payment.voucher_commit_interval_ms(repurposed from a 5 ms group-commit gather-wait to a 5 s flush period;0now rejected), plus a final flush on shutdown. Newlane_flush_failuresmetric.VoucherAckon the wire — acceptance is implicit); vouchers advance the lane watermark in memory one at a time viacommit_one_voucher.RetryLaterreject reason is removed (a store fault aborts the stream;RetrySignalstays as an internal marker).Net +738 / −1359 across 24 files.
Testing
cargo clippy --workspace --all-targetsclean;cargo fmt --checkclean.cargo nextest run -p decdn-node860/860;-p decdn-protocol -p decdn-incentive -p decdn-node1239/1239.cargo test --no-run -p decdn-e2e --features anvil-e2ecompile gate clean. Theanvil_settlement_e2eredeem path was adapted (2 s redeem interval) but not executed against a live chain in this environment — please run the anvil-e2e settlement suite on CI.Review notes
Every commit was reviewed individually; a whole-branch review caught and fixed one money-path bug (commit
613e2cc1): the redeemer originally flushed before reading/submitting the buffer, so a submitted cumulative could exceed the durable watermark and re-open the free-replay window on a crash. The flush now happens after planning and before the on-chain send, guaranteeing on-diskowed ≥ submitted.🤖 Generated with Claude Code