Support Erigon Caplin consensus client#297
Open
stakepeter wants to merge 1 commit into
Open
Conversation
Caplin emits several JSON fields with bare numbers where the beacon API spec requires quoted decimal strings, and serializes `previous_epoch_participation`/`current_epoch_participation` as a single 0x hex string instead of a JSON array. Soften the affected unmarshalers to accept both forms while keeping marshaling spec-strict, and recognize Caplin in the multi-client provider detection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Erigon's Caplin consensus client emits a few JSON fields in non-spec-compliant forms. This PR softens the affected unmarshalers to accept both spec and Caplin forms while keeping marshal output spec-strict. The fix is purely additive — public API, marshal output, and SSZ encoding are all unchanged.
Three classes of divergence are handled:
uint64fields inexecution_requestsandpending_*state queues. Caplin's struct definitions incl/cltypes/solid/{deposits,withdrawal,consolidation}.goomit the spec's,stringtag onamount,index,slot,validator_index, andwithdrawable_epoch. Softenphase0.{Gwei,Slot,Epoch,ValidatorIndex}.UnmarshalJSONandelectra.DepositRequest's JSON parsing to accept both"42"(spec) and42(Caplin). Marshal still emits"42".previous_epoch_participation/current_epoch_participationas a single hex string. Caplin'sParticipationBitList.MarshalJSONemits the raw SSZ encoding as"0x..."; the spec requires a JSON array of decimal-string flags. Addedaltair.ParseParticipationFlags/MarshalParticipationFlagshelpers and wired them into the altair / bellatrix / capella / deneb / electra / fulu BeaconState JSON paths. Accepts both forms; emits spec form.caplincase tomulti.Service's provider detection so the multi-client recognizes Caplin nodes.This makes downstream consumers work directly against Caplin without per-application JSON-rewriting shims.
Test plan
go test ./...— all packages greengo vet ./...clean;gofmt -lclean on touched filesphase0.{Gwei,Slot,Epoch,ValidatorIndex}, mixed/bare/missing/invalid cases forelectra.DepositRequest, hex/array/null/invalid cases foraltair.ParseParticipationFlagsTestBeaconBlockJSON/Good,TestSignedBeaconBlockYAML/Good,TestMarshalParticipationFlags_Roundtrip,TestDepositRequestUnmarshalJSONmarshal-after-parse) confirm wire output is byte-identical for spec-form inputsgithub.qkg1.top/erigontech/erigon'scl/package