Capella beacon block (#11566)

* in progress

* done, no tests yet

* fix ToBlinded()

* Revert "Auxiliary commit to revert individual files from 2e356b6f5b15d409ac15e825c744528591c13739"

This reverts commit 081ab74e88fb7d0e3f6a81e00fe5e89483b41f90.

* tests

* fix tests

* one more fix

* and one more

* review

* fix proto_test

* another fix

* do not return error when nil object is wrapped

* allow nil payload in body.Proto()

* correctly assert error

* nil checks in body.Execution()

* simplify PR

* Revert "Auxiliary commit to revert individual files from 5736c1f22f2d2f309b9303c13d0fb6b1679c6ecb"

This reverts commit 1ff3a4c864923f5c180aa015aa087a2814498b42.

* fix slice sizes in cloner tests

* better payload tests

* review

Co-authored-by: terencechain <terence@prysmaticlabs.com>
This commit is contained in:
Radosław Kapka
2022-10-31 12:58:30 -05:00
committed by GitHub
parent 26b46301d2
commit ffac232d89
16 changed files with 1801 additions and 158 deletions

View File

@@ -22,6 +22,10 @@ func NewSignedBeaconBlockFromGeneric(gb *eth.GenericSignedBeaconBlock) (interfac
return blocks.NewSignedBeaconBlock(bb.Bellatrix)
case *eth.GenericSignedBeaconBlock_BlindedBellatrix:
return blocks.NewSignedBeaconBlock(bb.BlindedBellatrix)
case *eth.GenericSignedBeaconBlock_Capella:
return blocks.NewSignedBeaconBlock(bb.Capella)
case *eth.GenericSignedBeaconBlock_BlindedCapella:
return blocks.NewSignedBeaconBlock(bb.BlindedCapella)
default:
return nil, errors.Wrapf(blocks.ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", gb)
}

View File

@@ -12,6 +12,7 @@ type blockMutator struct {
Phase0 func(beaconBlock *eth.SignedBeaconBlock)
Altair func(beaconBlock *eth.SignedBeaconBlockAltair)
Bellatrix func(beaconBlock *eth.SignedBeaconBlockBellatrix)
Capella func(beaconBlock *eth.SignedBeaconBlockCapella)
}
func (m blockMutator) apply(b interfaces.SignedBeaconBlock) (interfaces.SignedBeaconBlock, error) {
@@ -37,6 +38,13 @@ func (m blockMutator) apply(b interfaces.SignedBeaconBlock) (interfaces.SignedBe
}
m.Bellatrix(bb)
return blocks.NewSignedBeaconBlock(bb)
case version.Capella:
bb, err := b.PbCapellaBlock()
if err != nil {
return nil, err
}
m.Capella(bb)
return blocks.NewSignedBeaconBlock(bb)
default:
return nil, blocks.ErrUnsupportedSignedBeaconBlock
}
@@ -48,6 +56,7 @@ func SetBlockStateRoot(b interfaces.SignedBeaconBlock, sr [32]byte) (interfaces.
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.StateRoot = sr[:] },
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.StateRoot = sr[:] },
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.StateRoot = sr[:] },
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.StateRoot = sr[:] },
}.apply(b)
}
@@ -57,6 +66,7 @@ func SetBlockParentRoot(b interfaces.SignedBeaconBlock, pr [32]byte) (interfaces
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.ParentRoot = pr[:] },
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.ParentRoot = pr[:] },
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.ParentRoot = pr[:] },
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.ParentRoot = pr[:] },
}.apply(b)
}
@@ -66,6 +76,7 @@ func SetBlockSlot(b interfaces.SignedBeaconBlock, s types.Slot) (interfaces.Sign
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.Slot = s },
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.Slot = s },
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.Slot = s },
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.Slot = s },
}.apply(b)
}
@@ -75,5 +86,6 @@ func SetProposerIndex(b interfaces.SignedBeaconBlock, idx types.ValidatorIndex)
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.ProposerIndex = idx },
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.ProposerIndex = idx },
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.ProposerIndex = idx },
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.ProposerIndex = idx },
}.apply(b)
}