Check builder header kzg commitment (#13358)

This commit is contained in:
terence 2023-12-18 14:14:59 +08:00 committed by GitHub
parent b45a6664be
commit d57bca97a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 12 deletions

View File

@ -214,16 +214,28 @@ func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot primitiv
if err != nil {
return nil, nil, errors.Wrap(err, "could not get blob kzg commitments")
}
if len(kzgCommitments) > fieldparams.MaxBlobsPerBlock {
return nil, nil, fmt.Errorf("builder returned too many kzg commitments: %d", len(kzgCommitments))
}
for _, c := range kzgCommitments {
if len(c) != fieldparams.BLSPubkeyLength {
return nil, nil, fmt.Errorf("builder returned invalid kzg commitment lenth: %d", len(c))
}
}
}
log.WithFields(logrus.Fields{
l := log.WithFields(logrus.Fields{
"value": v.String(),
"builderPubKey": fmt.Sprintf("%#x", bid.Pubkey()),
"blockHash": fmt.Sprintf("%#x", header.BlockHash()),
"slot": slot,
"validator": idx,
"sinceSlotStartTime": time.Since(t),
}).Info("Received header with bid")
})
if len(kzgCommitments) > 0 {
l = l.WithField("kzgCommitmentCount", len(kzgCommitments))
}
l.Info("Received header with bid")
span.AddAttributes(
trace.StringAttribute("value", v.String()),

View File

@ -391,6 +391,7 @@ func TestServer_setExecutionData(t *testing.T) {
require.DeepEqual(t, bid.BlobKzgCommitments, got)
})
}
func TestServer_getPayloadHeader(t *testing.T) {
genesis := time.Now().Add(-time.Duration(params.BeaconConfig().SlotsPerEpoch) * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second)
params.SetupTestConfigCleanup(t)

View File

@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 80045ff1d2d5fb4ddf3cdb266ca12357a1138b370a8f30ac8ce19ddabd084b2b
// Hash: fce84268dbb58d0fa7f5405422df453060a5e79f4f9d465e471e02b7fc82e53b
package eth
import (
@ -3513,7 +3513,7 @@ func (b *BeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -4088,7 +4088,7 @@ func (b *BlindedBeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, er
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -4667,7 +4667,7 @@ func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -5306,7 +5306,7 @@ func (b *BeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error)
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {

View File

@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 17d610aa564b1ba39cb2e5e21c991cf209125aba08c7412f736b6f79e2b55a50
// Hash: 3f430aea0c076f79689535373e221ae26a7f8d581d9ab214f15d4fd3a761a82c
package eth
import (
@ -5476,7 +5476,7 @@ func (b *BeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error)
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -6375,7 +6375,7 @@ func (b *BeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -7214,7 +7214,7 @@ func (b *BlindedBeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, er
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {
@ -8057,7 +8057,7 @@ func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err
// Field (10) 'BlsToExecutionChanges'
if size := len(b.BlsToExecutionChanges); size > 16 {
err = ssz.ErrListTooBigFn("--.BLSToExecutionChanges", size, 16)
err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16)
return
}
for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ {