Add fork-agnostic api/v1 types (api/v1/all)#37
Open
pk910 wants to merge 7 commits into
Open
Conversation
New api/v1/all package with fork-agnostic BlockContents, SignedBlockContents, BlindedBeaconBlockBody, BlindedBeaconBlock and SignedBlindedBeaconBlock, following the spec/all conventions: dynamic-ssz view codecs, JSON/YAML delegation to the per-fork wire types, ToView/FromView conversion and ToVersioned/FromVersioned bridging to the api Versioned* containers. Block contents cover Deneb/Electra/Fulu; blinded blocks cover Bellatrix..Electra with Fulu mapped to the Electra schema.
Strengthen the ToVersioned tests: the plain (unblinded) per-fork field of api.VersionedSignedProposal/VersionedProposal must carry the exact per-fork view (byte-identical JSON and SSZ — the body the http client submits after AssertPresent), the Blinded flag and *Blinded fields must stay untouched, and FromVersioned must reject blinded proposals.
The ExecutionPayloadHeader multiplexer only matched Bellatrix/Capella/Deneb, so an Electra- or Fulu-versioned agnostic header (e.g. seeded by the version cascade of a blinded beacon block) failed to encode with "unsupported version". Electra and Fulu do not redefine the container; map them to the Deneb view, matching the ExecutionPayload multiplexer.
Add SignedExecutionPayloadEnvelopeContents (per-fork api/v1/gloas view + fork-agnostic api/v1/all union) per the beacon-APIs envelope_post schema, and wire it into a new ExecutionPayloadEnvelopeSubmitter service interface (versioned SubmitExecutionPayloadEnvelope + fork-agnostic SubmitAgnosticExecutionPayloadEnvelope, mirroring the fetch pair). POST /eth/v1/beacon/execution_payload_envelopes sends the stateless contents body (Eth-Execution-Payload-Blinded: false) with the consensus version header from the envelope, as SSZ or JSON per client negotiation.
d3542f1 to
9d24dac
Compare
Add ExecutionPayloadBidSubmitter (versioned SubmitExecutionPayloadBid + fork-agnostic SubmitAgnosticExecutionPayloadBid) posting the bare signed bid to /eth/v1/beacon/execution_payload_bids as SSZ or JSON with the consensus version header, per the beacon-APIs bid schema. Add NodeIdentityProvider for GET /eth/v1/node/identity.
Bellatrix and capella proposals are plain signed beacon blocks — blobs only enter the proposal wrapper at Deneb. The helper previously handled only the post-Gloas bare-block forks, leaving no way to build a versioned proposal for an unblinded pre-Deneb block (SignedBlockContents is Deneb+ and its ToVersioned rejects earlier versions). Deneb through Fulu remain rejected with a pointer to SignedBlockContents.ToVersioned.
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.
Add fork-agnostic api/v1 types (
api/v1/all)Motivation
The
spec/allpackage provides fork-agnostic union types for consensus speccontainers, but the
api/v1wire types (block contents, blinded blocks) onlyexist as per-fork packages. Consumers that handle multiple forks — builders,
relays, tooling — have to hardcode a fork package (
apiv1fulu,apiv1electra, ...) and duplicate a version switch at every call site.This PR adds
api/v1/all: fork-agnostic counterparts for the api/v1 wiretypes, following the
spec/allconventions (version-multiplexed views,dynamic-ssz codecs, JSON/YAML delegation to the per-fork wire shapes).
Types
BlockContents/SignedBlockContentsBlindedBeaconBlockBody/BlindedBeaconBlock/SignedBlindedBeaconBlockspec/all's Electra/Fulu schema sharingEach type carries a
Versionfield andspec/allcomponent fields(
*all.SignedBeaconBlock,*all.ExecutionPayloadHeader, ...), and implementsthe full
spec/allcodec surface:MarshalSSZDyn/UnmarshalSSZDyn/SizeSSZDyn/HashTreeRootWithDyn) plus the fastssz-compatible wrappers,generated via
dynssz-gen(view-only mode, likespec/all)are identical to the fork-specific packages'
ToView/FromViewfor converting to/from the per-fork typesToVersioned/FromVersionedbridging toapi.VersionedProposal,api.VersionedSignedProposal,api.VersionedBlindedBeaconBlock,api.VersionedSignedBlindedBeaconBlockAdditionally,
ProposalFromSignedBlock(*all.SignedBeaconBlock)maps apost-Gloas bare block into
api.VersionedSignedProposal(Gloas/Heze). FromGloas onwards blocks are submitted without a block-contents wrapper — EIP-7732
separates the execution payload and blobs from the block — so the bare-block
mapping lives here as a helper rather than as a
SignedBlockContentsversion.Fix included
spec/all.ExecutionPayloadHeader.viewTypeonly acceptedBellatrix/Capella/Deneb, while
ExecutionPayloadalready mappedElectra/Fulu → Deneb. An Electra- or Fulu-versioned agnostic header failed to
encode. The multiplexers now match.
Wire compatibility
JSON/SSZ marshaling delegates to the same per-fork view the concrete types
use, so compatibility holds by construction — and is pinned by tests:
Test*JSONWireCompat/Test*SSZWireCompat: byte-identical JSON and SSZ(and equal hash tree roots) versus the fork-specific type built from the
same data, per version
Test*ToVersioned: the populatedVersioned*field is the exact per-forkview; for proposals additionally
Blinded == falseand byte-identicalencoding of the field the HTTP client actually submits
TestSignedBlockContentsFromVersionedBlinded: blinded proposals arerejected rather than misread
Test*ViewRoundtrip,Test*UnsupportedVersion, version-propagation checksNotes
propagateVersion) re-implementsspec/all's unexportedpopulateVersioncascade via reflection, since it is unreachablecross-package; behavior is asserted by the round-trip tests.
*_ssz.gofiles are not gofmt-formatted, matching the existinggenerated files in
spec/all.