Skip to content

Commit

Permalink
Add Badger DataVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
syjn99 committed Jan 15, 2025
1 parent 24c0995 commit cf19378
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 157 deletions.
4 changes: 2 additions & 2 deletions api/v1/payloadattributesevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func (e *PayloadAttributesEvent) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, errors.Wrap(err, "failed to marshal payload attributes v3")
}
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if e.Data.V4 == nil {
return nil, errors.New("no payload attributes v4 data")
}
Expand Down Expand Up @@ -592,7 +592,7 @@ func (e *PayloadAttributesEvent) unpack(data *payloadAttributesEventJSON) error
return err
}
e.Data.V3 = &payloadAttributes
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
var payloadAttributes PayloadAttributesV4
err = json.Unmarshal(data.Data.PayloadAttributes, &payloadAttributes)
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions api/versionedblindedbeaconblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (v *VersionedBlindedBeaconBlock) Slot() (phase0.Slot, error) {
}

return v.Deneb.Slot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return 0, ErrDataMissing
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func (v *VersionedBlindedBeaconBlock) ProposerIndex() (phase0.ValidatorIndex, er
}

return v.Deneb.ProposerIndex, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return 0, ErrDataMissing
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (v *VersionedBlindedBeaconBlock) RandaoReveal() (phase0.BLSSignature, error
}

return v.Deneb.Body.RANDAOReveal, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil {
return phase0.BLSSignature{}, ErrDataMissing
Expand Down Expand Up @@ -161,7 +161,7 @@ func (v *VersionedBlindedBeaconBlock) Graffiti() ([32]byte, error) {
}

return v.Deneb.Body.Graffiti, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil {
return [32]byte{}, ErrDataMissing
Expand Down Expand Up @@ -218,7 +218,7 @@ func (v *VersionedBlindedBeaconBlock) Attestations() ([]spec.VersionedAttestatio
}

return versionedAttestations, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil || v.Electra.Body == nil {
return nil, ErrDataMissing
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (v *VersionedBlindedBeaconBlock) Root() (phase0.Root, error) {
}

return v.Deneb.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -290,7 +290,7 @@ func (v *VersionedBlindedBeaconBlock) BodyRoot() (phase0.Root, error) {
}

return v.Deneb.Body.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -322,7 +322,7 @@ func (v *VersionedBlindedBeaconBlock) ParentRoot() (phase0.Root, error) {
}

return v.Deneb.ParentRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func (v *VersionedBlindedBeaconBlock) StateRoot() (phase0.Root, error) {
}

return v.Deneb.StateRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -392,7 +392,7 @@ func (v *VersionedBlindedBeaconBlock) TransactionsRoot() (phase0.Root, error) {
}

return v.Deneb.Body.ExecutionPayloadHeader.TransactionsRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -432,7 +432,7 @@ func (v *VersionedBlindedBeaconBlock) FeeRecipient() (bellatrix.ExecutionAddress
}

return v.Deneb.Body.ExecutionPayloadHeader.FeeRecipient, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -472,7 +472,7 @@ func (v *VersionedBlindedBeaconBlock) Timestamp() (uint64, error) {
}

return v.Deneb.Body.ExecutionPayloadHeader.Timestamp, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -506,7 +506,7 @@ func (v *VersionedBlindedBeaconBlock) String() string {
}

return v.Deneb.String()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return ""
}
Expand Down
26 changes: 13 additions & 13 deletions api/versionedblindedproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (v *VersionedBlindedProposal) Slot() (phase0.Slot, error) {
}

return v.Deneb.Slot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return 0, ErrDataMissing
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func (v *VersionedBlindedProposal) ProposerIndex() (phase0.ValidatorIndex, error
}

return v.Deneb.ProposerIndex, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return 0, ErrDataMissing
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (v *VersionedBlindedProposal) RandaoReveal() (phase0.BLSSignature, error) {
}

return v.Deneb.Body.RANDAOReveal, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil {
return phase0.BLSSignature{}, ErrDataMissing
Expand Down Expand Up @@ -161,7 +161,7 @@ func (v *VersionedBlindedProposal) Graffiti() ([32]byte, error) {
}

return v.Deneb.Body.Graffiti, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil {
return [32]byte{}, ErrDataMissing
Expand Down Expand Up @@ -218,7 +218,7 @@ func (v *VersionedBlindedProposal) Attestations() ([]spec.VersionedAttestation,
}

return versionedAttestations, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil || v.Electra.Body == nil {
return nil, ErrDataMissing
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (v *VersionedBlindedProposal) Root() (phase0.Root, error) {
}

return v.Deneb.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -293,7 +293,7 @@ func (v *VersionedBlindedProposal) BodyRoot() (phase0.Root, error) {
}

return v.Deneb.Body.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil {
return phase0.Root{}, ErrDataMissing
Expand Down Expand Up @@ -326,7 +326,7 @@ func (v *VersionedBlindedProposal) ParentRoot() (phase0.Root, error) {
}

return v.Deneb.ParentRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -358,7 +358,7 @@ func (v *VersionedBlindedProposal) StateRoot() (phase0.Root, error) {
}

return v.Deneb.StateRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return phase0.Root{}, ErrDataMissing
}
Expand Down Expand Up @@ -396,7 +396,7 @@ func (v *VersionedBlindedProposal) TransactionsRoot() (phase0.Root, error) {
}

return v.Deneb.Body.ExecutionPayloadHeader.TransactionsRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -436,7 +436,7 @@ func (v *VersionedBlindedProposal) FeeRecipient() (bellatrix.ExecutionAddress, e
}

return v.Deneb.Body.ExecutionPayloadHeader.FeeRecipient, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -476,7 +476,7 @@ func (v *VersionedBlindedProposal) Timestamp() (uint64, error) {
}

return v.Deneb.Body.ExecutionPayloadHeader.Timestamp, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Body == nil ||
v.Electra.Body.ExecutionPayloadHeader == nil {
Expand Down Expand Up @@ -510,7 +510,7 @@ func (v *VersionedBlindedProposal) String() string {
}

return v.Deneb.String()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return ""
}
Expand Down
20 changes: 10 additions & 10 deletions api/versionedblockrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (v *VersionedBlockRequest) Slot() (phase0.Slot, error) {
}

return v.Deneb.Message.Slot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil {
return 0, ErrDataMissing
Expand Down Expand Up @@ -97,7 +97,7 @@ func (v *VersionedBlockRequest) ExecutionBlockHash() (phase0.Hash32, error) {
}

return v.Deneb.Message.Body.ExecutionPayload.BlockHash, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil ||
Expand Down Expand Up @@ -162,7 +162,7 @@ func (v *VersionedBlockRequest) Attestations() ([]spec.VersionedAttestation, err
}

return versionedAttestations, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil {
Expand Down Expand Up @@ -207,7 +207,7 @@ func (v *VersionedBlockRequest) Root() (phase0.Root, error) {
}

return v.Deneb.Message.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil {
return phase0.Root{}, ErrDataMissing
Expand Down Expand Up @@ -246,7 +246,7 @@ func (v *VersionedBlockRequest) BodyRoot() (phase0.Root, error) {
}

return v.Deneb.Message.Body.HashTreeRoot()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil {
Expand Down Expand Up @@ -283,7 +283,7 @@ func (v *VersionedBlockRequest) ParentRoot() (phase0.Root, error) {
}

return v.Deneb.Message.ParentRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil {
return phase0.Root{}, ErrDataMissing
Expand Down Expand Up @@ -319,7 +319,7 @@ func (v *VersionedBlockRequest) StateRoot() (phase0.Root, error) {
}

return v.Deneb.Message.StateRoot, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil {
return phase0.Root{}, ErrDataMissing
Expand Down Expand Up @@ -382,7 +382,7 @@ func (v *VersionedBlockRequest) AttesterSlashings() ([]spec.VersionedAttesterSla
}

return versionedAttesterSlashings, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil {
Expand Down Expand Up @@ -430,7 +430,7 @@ func (v *VersionedBlockRequest) ProposerSlashings() ([]*phase0.ProposerSlashing,
}

return v.Deneb.Message.Body.ProposerSlashings, nil
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil ||
v.Electra.Message == nil ||
v.Electra.Message.Body == nil {
Expand Down Expand Up @@ -464,7 +464,7 @@ func (v *VersionedBlockRequest) String() string {
}

return v.Deneb.String()
case spec.DataVersionAlpaca:
case spec.DataVersionAlpaca, spec.DataVersionBadger:
if v.Electra == nil {
return ""
}
Expand Down
Loading

0 comments on commit cf19378

Please sign in to comment.