Skip to content

Commit

Permalink
deneb block contents adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
olegshmuelov committed Jan 15, 2024
1 parent 6cb678b commit 0bd249d
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 284 deletions.
4 changes: 2 additions & 2 deletions ssv/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ type ProposerCalls interface {
// GetBlindedBeaconBlock returns blinded beacon block by the given slot, graffiti, and randao.
GetBlindedBeaconBlock(slot phase0.Slot, graffiti, randao []byte) (ssz.Marshaler, spec.DataVersion, error)
// SubmitBeaconBlock submit the block to the node
SubmitBeaconBlock(block *spec.VersionedBeaconBlock, sig phase0.BLSSignature) error
SubmitBeaconBlock(block *api.VersionedProposal, sig phase0.BLSSignature) error
// SubmitBlindedBeaconBlock submit the blinded block to the node
SubmitBlindedBeaconBlock(block *api.VersionedBlindedBeaconBlock, sig phase0.BLSSignature) error
SubmitBlindedBeaconBlock(block *api.VersionedBlindedProposal, sig phase0.BLSSignature) error
}

// AggregatorCalls interface has all attestation aggregator duty specific calls
Expand Down
15 changes: 7 additions & 8 deletions types/consensus_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
Expand Down Expand Up @@ -186,40 +185,40 @@ func (ci *ConsensusData) GetAttestationData() (*phase0.AttestationData, error) {
}

// GetBlockData ISSUE 221: GetBlockData/GetBlindedBlockData return versioned block only
func (ci *ConsensusData) GetBlockData() (*spec.VersionedBeaconBlock, ssz.HashRoot, error) {
func (ci *ConsensusData) GetBlockData() (*api.VersionedProposal, ssz.HashRoot, error) {
switch ci.Version {
case spec.DataVersionCapella:
ret := &capella.BeaconBlock{}
if err := ret.UnmarshalSSZ(ci.DataSSZ); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal ssz")
}
return &spec.VersionedBeaconBlock{Capella: ret, Version: ci.Version}, ret, nil
return &api.VersionedProposal{Capella: ret, Version: ci.Version}, ret, nil
case spec.DataVersionDeneb:
ret := &deneb.BeaconBlock{}
ret := &apiv1deneb.BlockContents{}
if err := ret.UnmarshalSSZ(ci.DataSSZ); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal ssz")
}
return &spec.VersionedBeaconBlock{Deneb: ret, Version: ci.Version}, ret, nil
return &api.VersionedProposal{Deneb: ret, Version: ci.Version}, ret, nil
default:
return nil, nil, errors.Errorf("unknown block version %s", ci.Version.String())
}
}

// GetBlindedBlockData ISSUE 221: GetBlockData/GetBlindedBlockData return versioned block only
func (ci *ConsensusData) GetBlindedBlockData() (*api.VersionedBlindedBeaconBlock, ssz.HashRoot, error) {
func (ci *ConsensusData) GetBlindedBlockData() (*api.VersionedBlindedProposal, ssz.HashRoot, error) {
switch ci.Version {
case spec.DataVersionCapella:
ret := &apiv1capella.BlindedBeaconBlock{}
if err := ret.UnmarshalSSZ(ci.DataSSZ); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal ssz")
}
return &api.VersionedBlindedBeaconBlock{Capella: ret, Version: ci.Version}, ret, nil
return &api.VersionedBlindedProposal{Capella: ret, Version: ci.Version}, ret, nil
case spec.DataVersionDeneb:
ret := &apiv1deneb.BlindedBeaconBlock{}
if err := ret.UnmarshalSSZ(ci.DataSSZ); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal ssz")
}
return &api.VersionedBlindedBeaconBlock{Deneb: ret, Version: ci.Version}, ret, nil
return &api.VersionedBlindedProposal{Deneb: ret, Version: ci.Version}, ret, nil
default:
return nil, nil, errors.Errorf("unknown blinded block version %s", ci.Version.String())
}
Expand Down
2 changes: 1 addition & 1 deletion types/spectest/generate/tests.json

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions types/testingutils/beacon_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (bn *TestingBeaconNode) GetBeaconBlock(slot phase0.Slot, graffiti, randao [
}

// SubmitBeaconBlock submit the block to the node
func (bn *TestingBeaconNode) SubmitBeaconBlock(block *spec.VersionedBeaconBlock, sig phase0.BLSSignature) error {
func (bn *TestingBeaconNode) SubmitBeaconBlock(block *api.VersionedProposal, sig phase0.BLSSignature) error {
var r [32]byte

switch block.Version {
Expand All @@ -567,11 +567,18 @@ func (bn *TestingBeaconNode) SubmitBeaconBlock(block *spec.VersionedBeaconBlock,
r, _ = sb.HashTreeRoot()
case spec.DataVersionDeneb:
if block.Deneb == nil {
return errors.Errorf("%s block contents is nil", block.Version.String())
}
if block.Deneb.Block == nil {
return errors.Errorf("%s block is nil", block.Version.String())
}
sb := &deneb.SignedBeaconBlock{
Message: block.Deneb,
Signature: sig,
sb := &apiv1deneb.SignedBlockContents{
SignedBlock: &deneb.SignedBeaconBlock{
Message: block.Deneb.Block,
Signature: sig,
},
KZGProofs: block.Deneb.KZGProofs,
Blobs: block.Deneb.Blobs,
}
r, _ = sb.HashTreeRoot()
default:
Expand All @@ -598,7 +605,7 @@ func (bn *TestingBeaconNode) GetBlindedBeaconBlock(slot phase0.Slot, graffiti, r
}

// SubmitBlindedBeaconBlock submit the blinded block to the node
func (bn *TestingBeaconNode) SubmitBlindedBeaconBlock(block *api.VersionedBlindedBeaconBlock, sig phase0.BLSSignature) error {
func (bn *TestingBeaconNode) SubmitBlindedBeaconBlock(block *api.VersionedBlindedProposal, sig phase0.BLSSignature) error {
var r [32]byte

switch block.Version {
Expand Down
Loading

0 comments on commit 0bd249d

Please sign in to comment.