mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
beacon/light/api: fix version decoding
This commit is contained in:
parent
7db96f1a38
commit
b1ae3691f8
1 changed files with 13 additions and 14 deletions
|
|
@ -241,18 +241,28 @@ func (api *BeaconLightApi) GetFinalityUpdate() (types.FinalityUpdate, error) {
|
|||
|
||||
func decodeFinalityUpdate(enc []byte) (types.FinalityUpdate, error) {
|
||||
var data struct {
|
||||
Data struct {
|
||||
Version string `json:"version"`
|
||||
Version string
|
||||
Data struct {
|
||||
Attested jsonHeaderWithExecProof `json:"attested_header"`
|
||||
Finalized jsonHeaderWithExecProof `json:"finalized_header"`
|
||||
FinalityBranch merkle.Values `json:"finality_branch"`
|
||||
Aggregate types.SyncAggregate `json:"sync_aggregate"`
|
||||
SignatureSlot common.Decimal `json:"signature_slot"`
|
||||
} `json:"data"`
|
||||
}
|
||||
}
|
||||
if err := json.Unmarshal(enc, &data); err != nil {
|
||||
return types.FinalityUpdate{}, err
|
||||
}
|
||||
// Decode the execution payload headers.
|
||||
attestedExecHeader, err := types.ExecutionHeaderFromJSON(data.Version, data.Data.Attested.Execution)
|
||||
if err != nil {
|
||||
return types.FinalityUpdate{}, fmt.Errorf("invalid attested header: %v", err)
|
||||
}
|
||||
finalizedExecHeader, err := types.ExecutionHeaderFromJSON(data.Version, data.Data.Finalized.Execution)
|
||||
if err != nil {
|
||||
return types.FinalityUpdate{}, fmt.Errorf("invalid finalized header: %v", err)
|
||||
}
|
||||
// Perform sanity checks.
|
||||
if len(data.Data.Aggregate.Signers) != params.SyncCommitteeBitmaskSize {
|
||||
return types.FinalityUpdate{}, errors.New("invalid sync_committee_bits length")
|
||||
}
|
||||
|
|
@ -260,17 +270,6 @@ func decodeFinalityUpdate(enc []byte) (types.FinalityUpdate, error) {
|
|||
return types.FinalityUpdate{}, errors.New("invalid sync_committee_signature length")
|
||||
}
|
||||
|
||||
// Decode the execution payload headers.
|
||||
fork := data.Data.Version
|
||||
attestedExecHeader, err := types.ExecutionHeaderFromJSON(fork, data.Data.Attested.Execution)
|
||||
if err != nil {
|
||||
return types.FinalityUpdate{}, fmt.Errorf("invalid attested header: %v", err)
|
||||
}
|
||||
finalizedExecHeader, err := types.ExecutionHeaderFromJSON(fork, data.Data.Finalized.Execution)
|
||||
if err != nil {
|
||||
return types.FinalityUpdate{}, fmt.Errorf("invalid finalized header: %v", err)
|
||||
}
|
||||
|
||||
return types.FinalityUpdate{
|
||||
Attested: types.HeaderWithExecProof{
|
||||
Header: data.Data.Attested.Beacon,
|
||||
|
|
|
|||
Loading…
Reference in a new issue