Repository navigation
fix: make addPayloadEnvelope idempotent on API path - #9504
markolazic01 wants to merge 11 commits into
Conversation
addPayloadEnvelope idempotent on API path
There was a problem hiding this comment.
Code Review
This pull request adds a check to prevent overwriting an existing execution payload envelope, logging a debug message when skipping a duplicate. The reviewer recommends verifying whether the incoming envelope matches the existing one by comparing their block hashes, and logging a warning instead of a debug message if they differ, as this could indicate a potential equivocation or software bug.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7ba49abf0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| seenTimestampSec, | ||
| peerIdStr: undefined, | ||
| }); | ||
| if (!payloadInput.hasPayloadEnvelope()) { |
There was a problem hiding this comment.
Handle known envelopes before validation
When the duplicate envelope is already in seenPayloadEnvelopeInputCache before this API call starts validation, the earlier validateApiExecutionPayloadEnvelope() call still throws ENVELOPE_ALREADY_KNOWN, so execution never reaches this new idempotency guard. This only fixes the narrow race where another path sets the envelope after validation but before addPayloadEnvelope(); VC retries or gossip-first arrivals still get an error instead of an idempotent success. Consider checking/returning success for the already-known case before validation, or mapping that validation result to the intended duplicate behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This one is still relevant. The current branch catches ENVELOPE_ALREADY_KNOWN before reaching the add, but that catch returns immediately, so it avoids the validation throw while also bypassing later publish/process side effects. After #9595 this should be reworked on top of the new signedEnvelopeOrContents / broadcastValidation flow rather than patched in place.
|
needs more work |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d40231371e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
fixed the typing in the test, the failing type check should now pass |
|
|
||
| await validateApiExecutionPayloadEnvelope(chain, signedExecutionPayloadEnvelope); | ||
| try { | ||
| await validateApiExecutionPayloadEnvelope(chain, signedExecutionPayloadEnvelope); |
There was a problem hiding this comment.
- this will conflict with feat: builder selection, broadcast validation, stateless flow for gloas block production #9595
There was a problem hiding this comment.
will follow up after it lands 👍
There was a problem hiding this comment.
Confirmed now that #9595 is merged: GitHub marks #9504 as DIRTY, and merge-tree conflicts in blocks/index.ts around this exact validation/add-envelope area. I posted the situation analysis and recommended rebasing/reworking on current unstable rather than stacking more changes onto this draft branch.
|
@lodekeeper now that #9595 is merged, can you write down a situation analysis? |
|
Situation after #9595:
Recommended next shape: rebase/rework this on current
No code pushed from me in this pass because the branch is conflicted with #9595 and needs a deliberate rework on top of the new endpoint shape. |
|
@markolazic01 @nflaig I agree with closing #9504 rather than reworking this draft. I rechecked current The only remaining value I see is the narrower observability/test follow-up Marko called out: when an envelope is already known, validation short-circuits before comparing an incoming duplicate payload block hash against the cached/bid hash, so an adapted warning plus focused tests could still be useful. I would do that as a fresh small PR on Concrete recommendation: close #9504, and track a clean follow-up only for the divergent-hash warning/test coverage if we still want that signal. |
ah yes I think so, I didn't wanna close your PR yet because I didn't double check your PR, but since you did that we can probably close it for now, can keep the issue open as a reminder |
|
sounds good @nflaig |
Motivation
addPayloadEnvelopethrows if called when an envelope is already set. This is reachable from the API handler when the envelope has already been set by another source before the call reaches addPayloadEnvelope, causing a 500 to the VC.Description
All call sites of addPayloadEnvelope were audited before applying the fix:
gossipHandlers.ts— unguarded, but all handler throws are caught by gossipValidatorFn and converted toTopicValidatorResult.Ignore, so safesync/unknownBlock.ts— guarded with!payloadInput.hasPayloadEnvelope()before callingsync/utils/downloadByRange.ts— same guard, safeapi/impl/beacon/blocks/index.ts— unguarded, the only path where the throw caused a user-visible errorAdds the same
hasPayloadEnvelope()guard to the API handler, matching the existing sync path pattern. A debug log is emitted when the envelope is already set to aid debugging.Closes #9071