mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-11 14:28:09 -05:00
Compare commits
23 Commits
init-build
...
more-build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33a0ac4472 | ||
|
|
b890559a18 | ||
|
|
e9d5e99f33 | ||
|
|
dc2b349b97 | ||
|
|
0d6bf081e3 | ||
|
|
481d15c474 | ||
|
|
e49da95350 | ||
|
|
85c784a1c4 | ||
|
|
494a6e409a | ||
|
|
a2c2a420c0 | ||
|
|
4bd93a7ebb | ||
|
|
668462667f | ||
|
|
9b7241caa8 | ||
|
|
0967613361 | ||
|
|
22f2de16af | ||
|
|
5f51670d3b | ||
|
|
e7d8485f3d | ||
|
|
c49297f037 | ||
|
|
fc4bd8e114 | ||
|
|
83a283d2ba | ||
|
|
a28ae83653 | ||
|
|
9e16ad6b62 | ||
|
|
3a1dec82a5 |
@@ -35,7 +35,7 @@ func TestReportEpochMetrics_SlashedValidatorOutOfBound(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
v.Slashed = true
|
||||
require.NoError(t, h.UpdateValidatorAtIndex(0, v))
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 1, Data: util.NewAttestationUtil().HydrateAttestationData(ð.AttestationData{})}))
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(ð.PendingAttestation{InclusionDelay: 1, Data: util.HydrateAttestationData(ð.AttestationData{})}))
|
||||
err = reportEpochMetrics(context.Background(), h, h)
|
||||
require.ErrorContains(t, "slot 0 out of bounds", err)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ func TestStore_OnAttestation_ErrorConditions_ProtoArray(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, blkWithValidStateRoot))
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
a *ethpb.Attestation
|
||||
@@ -78,17 +77,17 @@ func TestStore_OnAttestation_ErrorConditions_ProtoArray(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "attestation's data slot not aligned with target vote",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Root: make([]byte, 32)}}}),
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Root: make([]byte, 32)}}}),
|
||||
wantedErr: "slot 32 does not match target epoch 0",
|
||||
},
|
||||
{
|
||||
name: "no pre state for attestations's target block",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),
|
||||
wantedErr: "could not get pre state for epoch 0",
|
||||
},
|
||||
{
|
||||
name: "process attestation doesn't match current epoch",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 100 * params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Epoch: 100,
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 100 * params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Epoch: 100,
|
||||
Root: BlkWithStateBadAttRoot[:]}}}),
|
||||
wantedErr: "target epoch 100 does not match current epoch",
|
||||
},
|
||||
@@ -177,7 +176,6 @@ func TestStore_OnAttestation_ErrorConditions_DoublyLinkedTree(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, blkWithValidStateRoot))
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
a *ethpb.Attestation
|
||||
@@ -185,17 +183,17 @@ func TestStore_OnAttestation_ErrorConditions_DoublyLinkedTree(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "attestation's data slot not aligned with target vote",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Root: make([]byte, 32)}}}),
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Root: make([]byte, 32)}}}),
|
||||
wantedErr: "slot 32 does not match target epoch 0",
|
||||
},
|
||||
{
|
||||
name: "no pre state for attestations's target block",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),
|
||||
wantedErr: "could not get pre state for epoch 0",
|
||||
},
|
||||
{
|
||||
name: "process attestation doesn't match current epoch",
|
||||
a: au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 100 * params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Epoch: 100,
|
||||
a: util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 100 * params.BeaconConfig().SlotsPerEpoch, Target: ðpb.Checkpoint{Epoch: 100,
|
||||
Root: BlkWithStateBadAttRoot[:]}}}),
|
||||
wantedErr: "target epoch 100 does not match current epoch",
|
||||
},
|
||||
@@ -251,7 +249,7 @@ func TestStore_OnAttestation_Ok_ProtoArray(t *testing.T) {
|
||||
genesisState, pks := util.DeterministicGenesisState(t, 64)
|
||||
service.SetGenesisTime(time.Unix(time.Now().Unix()-int64(params.BeaconConfig().SecondsPerSlot), 0))
|
||||
require.NoError(t, service.saveGenesisData(ctx, genesisState))
|
||||
att, err := util.NewAttestationUtil().GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
att, err := util.GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
require.NoError(t, err)
|
||||
tRoot := bytesutil.ToBytes32(att[0].Data.Target.Root)
|
||||
copied := genesisState.Copy()
|
||||
@@ -281,7 +279,7 @@ func TestStore_OnAttestation_Ok_DoublyLinkedTree(t *testing.T) {
|
||||
genesisState, pks := util.DeterministicGenesisState(t, 64)
|
||||
service.SetGenesisTime(time.Unix(time.Now().Unix()-int64(params.BeaconConfig().SecondsPerSlot), 0))
|
||||
require.NoError(t, service.saveGenesisData(ctx, genesisState))
|
||||
att, err := util.NewAttestationUtil().GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
att, err := util.GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
require.NoError(t, err)
|
||||
tRoot := bytesutil.ToBytes32(att[0].Data.Target.Root)
|
||||
copied := genesisState.Copy()
|
||||
@@ -424,7 +422,8 @@ func TestVerifyBeaconBlock_NoBlock(t *testing.T) {
|
||||
opts := testServiceOptsWithDB(t)
|
||||
service, err := NewService(ctx, opts...)
|
||||
require.NoError(t, err)
|
||||
d := util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
d := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
require.Equal(t, errBlockNotFoundInCacheOrDB, service.verifyBeaconBlock(ctx, d))
|
||||
}
|
||||
|
||||
|
||||
@@ -1606,9 +1606,8 @@ func TestService_insertSlashingsToForkChoiceStore(t *testing.T) {
|
||||
service, err := NewService(ctx, opts...)
|
||||
require.NoError(t, err)
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
beaconState, privKeys := util.DeterministicGenesisState(t, 100)
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
@@ -1623,7 +1622,7 @@ func TestService_insertSlashingsToForkChoiceStore(t *testing.T) {
|
||||
aggregateSig := bls.AggregateSignatures([]bls.Signature{sig0, sig1})
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
})
|
||||
signingRoot, err = signing.ComputeSigningRoot(att2.Data, domain)
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestVerifyLMDFFGConsistent_NotOK(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
wanted := "FFG and LMD votes are not consistent"
|
||||
a := util.NewAttestationUtil().NewAttestation()
|
||||
a := util.NewAttestation()
|
||||
a.Data.Target.Epoch = 1
|
||||
a.Data.Target.Root = []byte{'a'}
|
||||
a.Data.BeaconBlockRoot = r33[:]
|
||||
@@ -85,7 +85,8 @@ func TestVerifyLMDFFGConsistent_OK(t *testing.T) {
|
||||
util.SaveBlock(t, ctx, service.cfg.BeaconDB, b33)
|
||||
r33, err := b33.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
a := util.NewAttestationUtil().NewAttestation()
|
||||
|
||||
a := util.NewAttestation()
|
||||
a.Data.Target.Epoch = 1
|
||||
a.Data.Target.Root = r32[:]
|
||||
a.Data.BeaconBlockRoot = r33[:]
|
||||
@@ -105,7 +106,7 @@ func TestProcessAttestations_Ok(t *testing.T) {
|
||||
genesisState, pks := util.DeterministicGenesisState(t, 64)
|
||||
require.NoError(t, genesisState.SetGenesisTime(uint64(prysmTime.Now().Unix())-params.BeaconConfig().SecondsPerSlot))
|
||||
require.NoError(t, service.saveGenesisData(ctx, genesisState))
|
||||
atts, err := util.NewAttestationUtil().GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
atts, err := util.GenerateAttestations(genesisState, pks, 1, 0, false)
|
||||
require.NoError(t, err)
|
||||
tRoot := bytesutil.ToBytes32(atts[0].Data.Target.Root)
|
||||
copied := genesisState.Copy()
|
||||
@@ -226,7 +227,7 @@ func TestService_ProcessAttestationsAndUpdateHead(t *testing.T) {
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wsb))
|
||||
|
||||
// Generate attestatios for this block in Slot 1
|
||||
atts, err := util.NewAttestationUtil().GenerateAttestations(copied, pks, 1, 1, false)
|
||||
atts, err := util.GenerateAttestations(copied, pks, 1, 1, false)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.AttPool.SaveForkchoiceAttestations(atts))
|
||||
// Verify the target is in forchoice
|
||||
|
||||
@@ -16,7 +16,6 @@ go_library(
|
||||
"//beacon-chain/db:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//network:go_default_library",
|
||||
"//network/authorization:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
|
||||
@@ -4,16 +4,16 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/api/client/builder"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/network"
|
||||
v1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
@@ -60,7 +60,7 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) {
|
||||
return nil, err
|
||||
}
|
||||
s.c = c
|
||||
log.WithField("endpoint", c.NodeURL()).Info("Builder has configured")
|
||||
log.Infof("Builder configured with end point: %s", s.cfg.builderEndpoint.Url)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
@@ -73,6 +73,11 @@ func (*Service) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Configured returns true if the user has input a builder URL.
|
||||
func (s *Service) Configured() bool {
|
||||
return s.cfg.builderEndpoint.Url != ""
|
||||
}
|
||||
|
||||
// SubmitBlindedBlock submits a blinded block to the builder relay network.
|
||||
func (s *Service) SubmitBlindedBlock(ctx context.Context, b *ethpb.SignedBlindedBeaconBlockBellatrix) (*v1.ExecutionPayload, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "builder.SubmitBlindedBlock")
|
||||
@@ -129,14 +134,14 @@ func (s *Service) RegisterValidator(ctx context.Context, reg []*ethpb.SignedVali
|
||||
valid := make([]*ethpb.SignedValidatorRegistrationV1, 0)
|
||||
for i := 0; i < len(reg); i++ {
|
||||
r := reg[i]
|
||||
nx, exists := s.cfg.headFetcher.HeadPublicKeyToValidatorIndex(bytesutil.ToBytes48(r.Message.Pubkey))
|
||||
if !exists {
|
||||
// we want to allow validators to set up keys that haven't been added to the beaconstate validator list yet,
|
||||
// so we should tolerate keys that do not seem to be valid by skipping past them.
|
||||
log.Warnf("Skipping validator registration for pubkey=%#x - not in current validator set.", r.Message.Pubkey)
|
||||
continue
|
||||
}
|
||||
idxs = append(idxs, nx)
|
||||
//nx, exists := s.cfg.headFetcher.HeadPublicKeyToValidatorIndex(bytesutil.ToBytes48(r.Message.Pubkey))
|
||||
//if !exists {
|
||||
// // we want to allow validators to set up keys that haven't been added to the beaconstate validator list yet,
|
||||
// // so we should tolerate keys that do not seem to be valid by skipping past them.
|
||||
// log.Warnf("Skipping validator registration for pubkey=%#x - not in current validator set.", r.Message.Pubkey)
|
||||
// continue
|
||||
//}
|
||||
idxs = append(idxs, 0)
|
||||
msgs = append(msgs, r.Message)
|
||||
valid = append(valid, r)
|
||||
}
|
||||
@@ -146,8 +151,3 @@ func (s *Service) RegisterValidator(ctx context.Context, reg []*ethpb.SignedVali
|
||||
|
||||
return s.cfg.beaconDB.SaveRegistrationsByValidatorIDs(ctx, idxs, msgs)
|
||||
}
|
||||
|
||||
// Configured returns true if the user has input a builder URL.
|
||||
func (s *Service) Configured() bool {
|
||||
return s.cfg.builderEndpoint.Url != ""
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func TestProcessAttestations_InclusionDelayFailure(t *testing.T) {
|
||||
attestations := []*ethpb.Attestation{
|
||||
util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Epoch: 0, Root: make([]byte, fieldparams.RootLength)},
|
||||
Slot: 5,
|
||||
@@ -55,7 +55,7 @@ func TestProcessAttestations_InclusionDelayFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) {
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
|
||||
Target: ðpb.Checkpoint{Epoch: 0}}})
|
||||
@@ -201,7 +201,7 @@ func TestProcessAttestations_OK(t *testing.T) {
|
||||
aggBits.SetBitAt(0, true)
|
||||
var mockRoot [32]byte
|
||||
copy(mockRoot[:], "hello-world")
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Root: mockRoot[:]},
|
||||
Target: ðpb.Checkpoint{Root: mockRoot[:]},
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) {
|
||||
beaconState, privKeys := util.DeterministicGenesisState(t, 100)
|
||||
data := util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{
|
||||
data := util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||
Target: ðpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||
})
|
||||
@@ -85,7 +85,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) {
|
||||
func TestVerifyAttestationNoVerifySignature_IncorrectSlotTargetEpoch(t *testing.T) {
|
||||
beaconState, _ := util.DeterministicGenesisState(t, 1)
|
||||
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch,
|
||||
Target: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
@@ -218,7 +218,7 @@ func TestConvertToIndexed_OK(t *testing.T) {
|
||||
|
||||
var sig [fieldparams.BLSSignatureLength]byte
|
||||
copy(sig[:], "signed")
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Signature: sig[:],
|
||||
})
|
||||
for _, tt := range tests {
|
||||
@@ -261,12 +261,11 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
attestation *ethpb.IndexedAttestation
|
||||
}{
|
||||
{attestation: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 2,
|
||||
},
|
||||
@@ -276,7 +275,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
Signature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}},
|
||||
{attestation: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 1,
|
||||
},
|
||||
@@ -285,7 +284,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
Signature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}},
|
||||
{attestation: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 4,
|
||||
},
|
||||
@@ -294,7 +293,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
Signature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}},
|
||||
{attestation: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Epoch: 7,
|
||||
},
|
||||
@@ -412,8 +411,7 @@ func TestVerifyAttestations_HandlesPlannedFork(t *testing.T) {
|
||||
|
||||
comm1, err := helpers.BeaconCommitteeFromState(context.Background(), st, 1 /*slot*/, 0 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm1))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
@@ -432,7 +430,7 @@ func TestVerifyAttestations_HandlesPlannedFork(t *testing.T) {
|
||||
|
||||
comm2, err := helpers.BeaconCommitteeFromState(context.Background(), st, 1*params.BeaconConfig().SlotsPerEpoch+1 /*slot*/, 1 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm2))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1*params.BeaconConfig().SlotsPerEpoch + 1,
|
||||
@@ -472,8 +470,7 @@ func TestRetrieveAttestationSignatureSet_VerifiesMultipleAttestations(t *testing
|
||||
|
||||
comm1, err := helpers.BeaconCommitteeFromState(context.Background(), st, 1 /*slot*/, 0 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm1))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
@@ -492,7 +489,7 @@ func TestRetrieveAttestationSignatureSet_VerifiesMultipleAttestations(t *testing
|
||||
|
||||
comm2, err := helpers.BeaconCommitteeFromState(context.Background(), st, 1 /*slot*/, 1 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm2))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
@@ -537,8 +534,7 @@ func TestRetrieveAttestationSignatureSet_AcrossFork(t *testing.T) {
|
||||
|
||||
comm1, err := helpers.BeaconCommitteeFromState(ctx, st, 1 /*slot*/, 0 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm1))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
@@ -557,7 +553,7 @@ func TestRetrieveAttestationSignatureSet_AcrossFork(t *testing.T) {
|
||||
|
||||
comm2, err := helpers.BeaconCommitteeFromState(ctx, st, 1 /*slot*/, 1 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(uint64(len(comm2))),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
|
||||
@@ -19,12 +19,11 @@ import (
|
||||
)
|
||||
|
||||
func TestSlashableAttestationData_CanSlash(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestationData(ðpb.AttestationData{
|
||||
att1 := util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Epoch: 1, Root: make([]byte, 32)},
|
||||
Source: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte{'A'}, 32)},
|
||||
})
|
||||
att2 := au.HydrateAttestationData(ðpb.AttestationData{
|
||||
att2 := util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Epoch: 1, Root: make([]byte, 32)},
|
||||
Source: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte{'B'}, 32)},
|
||||
})
|
||||
@@ -36,10 +35,9 @@ func TestSlashableAttestationData_CanSlash(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
slashings := []*ethpb.AttesterSlashing{{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{}),
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
Target: ðpb.Checkpoint{Epoch: 1}},
|
||||
@@ -73,16 +71,15 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
slashings := []*ethpb.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
AttestingIndices: make([]uint64, params.BeaconConfig().MaxValidatorsPerCommittee+1),
|
||||
}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: make([]uint64, params.BeaconConfig().MaxValidatorsPerCommittee+1),
|
||||
}),
|
||||
},
|
||||
@@ -105,8 +102,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) {
|
||||
vv.WithdrawableEpoch = types.Epoch(params.BeaconConfig().SlotsPerEpoch)
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
@@ -121,7 +117,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) {
|
||||
aggregateSig := bls.AggregateSignatures([]bls.Signature{sig0, sig1})
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
})
|
||||
signingRoot, err = signing.ComputeSigningRoot(att2.Data, domain)
|
||||
@@ -175,8 +171,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatusAltair(t *testing.T) {
|
||||
vv.WithdrawableEpoch = types.Epoch(params.BeaconConfig().SlotsPerEpoch)
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
@@ -191,7 +186,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatusAltair(t *testing.T) {
|
||||
aggregateSig := bls.AggregateSignatures([]bls.Signature{sig0, sig1})
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
})
|
||||
signingRoot, err = signing.ComputeSigningRoot(att2.Data, domain)
|
||||
@@ -245,8 +240,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatusBellatrix(t *testing.T) {
|
||||
vv.WithdrawableEpoch = types.Epoch(params.BeaconConfig().SlotsPerEpoch)
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
@@ -261,7 +255,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatusBellatrix(t *testing.T) {
|
||||
aggregateSig := bls.AggregateSignatures([]bls.Signature{sig0, sig1})
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
})
|
||||
signingRoot, err = signing.ComputeSigningRoot(att2.Data, domain)
|
||||
|
||||
@@ -39,9 +39,8 @@ func TestProcessAttesterSlashings_RegressionSlashableIndices(t *testing.T) {
|
||||
expectedSlashedVal := 2800
|
||||
|
||||
root1 := [32]byte{'d', 'o', 'u', 'b', 'l', 'e', '1'}
|
||||
au := util.AttestationUtil{}
|
||||
att1 := ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{Target: ðpb.Checkpoint{Epoch: 0, Root: root1[:]}}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{Target: ðpb.Checkpoint{Epoch: 0, Root: root1[:]}}),
|
||||
AttestingIndices: setA,
|
||||
Signature: make([]byte, 96),
|
||||
}
|
||||
@@ -59,7 +58,7 @@ func TestProcessAttesterSlashings_RegressionSlashableIndices(t *testing.T) {
|
||||
|
||||
root2 := [32]byte{'d', 'o', 'u', 'b', 'l', 'e', '2'}
|
||||
att2 := ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Root: root2[:]},
|
||||
}),
|
||||
AttestingIndices: setB,
|
||||
|
||||
@@ -133,16 +133,15 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
}
|
||||
au := util.AttestationUtil{}
|
||||
attesterSlashings := []*ethpb.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
Signature: make([]byte, 96),
|
||||
},
|
||||
Attestation_2: ðpb.IndexedAttestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
Signature: make([]byte, 96),
|
||||
},
|
||||
@@ -153,7 +152,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
|
||||
blockRoots = append(blockRoots, []byte{byte(i)})
|
||||
}
|
||||
require.NoError(t, beaconState.SetBlockRoots(blockRoots))
|
||||
blockAtt := au.HydrateAttestation(ðpb.Attestation{
|
||||
blockAtt := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||
},
|
||||
@@ -256,8 +255,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState,
|
||||
require.NoError(t, beaconState.SetValidators(validators))
|
||||
|
||||
mockRoot2 := [32]byte{'A'}
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 0, Root: mockRoot2[:]},
|
||||
},
|
||||
@@ -273,7 +271,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState,
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
mockRoot3 := [32]byte{'B'}
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 0, Root: mockRoot3[:]},
|
||||
Target: ðpb.Checkpoint{Epoch: 0, Root: make([]byte, fieldparams.RootLength)},
|
||||
@@ -303,7 +301,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState,
|
||||
|
||||
aggBits := bitfield.NewBitlist(1)
|
||||
aggBits.SetBitAt(0, true)
|
||||
blockAtt := au.HydrateAttestation(ðpb.Attestation{
|
||||
blockAtt := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: beaconState.Slot(),
|
||||
Target: ðpb.Checkpoint{Epoch: time.CurrentEpoch(beaconState)},
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessSlashings(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
block *ethpb.BeaconBlock
|
||||
@@ -78,13 +77,13 @@ func TestProcessSlashings(t *testing.T) {
|
||||
Body: ðpb.BeaconBlockBody{
|
||||
AttesterSlashings: []*ethpb.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
AttestingIndices: []uint64{1, 3, 4},
|
||||
}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{1, 5, 6},
|
||||
}),
|
||||
},
|
||||
@@ -100,13 +99,13 @@ func TestProcessSlashings(t *testing.T) {
|
||||
Body: ðpb.BeaconBlockBody{
|
||||
AttesterSlashings: []*ethpb.AttesterSlashing{
|
||||
{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
AttestingIndices: []uint64{1, 3, 4},
|
||||
}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{3, 5, 6},
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -23,15 +23,14 @@ func TestKV_Aggregated_AggregateUnaggregatedAttestations(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
sig1 := priv.Sign([]byte{'a'})
|
||||
sig2 := priv.Sign([]byte{'b'})
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig1.Marshal()})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1010}, Signature: sig1.Marshal()})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1100}, Signature: sig1.Marshal()})
|
||||
att4 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig2.Marshal()})
|
||||
att5 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig1.Marshal()})
|
||||
att6 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1010}, Signature: sig1.Marshal()})
|
||||
att7 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1100}, Signature: sig1.Marshal()})
|
||||
att8 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig2.Marshal()})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig1.Marshal()})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1010}, Signature: sig1.Marshal()})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1100}, Signature: sig1.Marshal()})
|
||||
att4 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig2.Marshal()})
|
||||
att5 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig1.Marshal()})
|
||||
att6 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1010}, Signature: sig1.Marshal()})
|
||||
att7 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1100}, Signature: sig1.Marshal()})
|
||||
att8 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1001}, Signature: sig2.Marshal()})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3, att4, att5, att6, att7, att8}
|
||||
require.NoError(t, cache.SaveUnaggregatedAttestations(atts))
|
||||
require.NoError(t, cache.AggregateUnaggregatedAttestations(context.Background()))
|
||||
@@ -43,7 +42,7 @@ func TestKV_Aggregated_AggregateUnaggregatedAttestations(t *testing.T) {
|
||||
func TestKV_Aggregated_AggregateUnaggregatedAttestationsBySlotIndex(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
genData := func(slot types.Slot, committeeIndex types.CommitteeIndex) *ethpb.AttestationData {
|
||||
return util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{
|
||||
return util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: slot,
|
||||
CommitteeIndex: committeeIndex,
|
||||
})
|
||||
@@ -96,7 +95,6 @@ func TestKV_Aggregated_AggregateUnaggregatedAttestationsBySlotIndex(t *testing.T
|
||||
}
|
||||
|
||||
func TestKV_Aggregated_SaveAggregatedAttestation(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
att *ethpb.Attestation
|
||||
@@ -115,23 +113,23 @@ func TestKV_Aggregated_SaveAggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "not aggregated",
|
||||
att: au.HydrateAttestation(ðpb.Attestation{
|
||||
att: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{}, AggregationBits: bitfield.Bitlist{0b10100}}),
|
||||
wantErrString: "attestation is not aggregated",
|
||||
},
|
||||
{
|
||||
name: "invalid hash",
|
||||
att: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
BeaconBlockRoot: []byte{0b0},
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b10111},
|
||||
},
|
||||
wantErrString: "could not tree hash attestation: --.BeaconBlockRoot (" + fssz.ErrBytesLength.Error() + ")",
|
||||
wantErrString: "could not tree hash attestation: " + fssz.ErrBytesLength.Error(),
|
||||
},
|
||||
{
|
||||
name: "already seen",
|
||||
att: au.HydrateAttestation(ðpb.Attestation{
|
||||
att: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 100,
|
||||
},
|
||||
@@ -141,7 +139,7 @@ func TestKV_Aggregated_SaveAggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "normal save",
|
||||
att: au.HydrateAttestation(ðpb.Attestation{
|
||||
att: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
},
|
||||
@@ -150,7 +148,7 @@ func TestKV_Aggregated_SaveAggregatedAttestation(t *testing.T) {
|
||||
count: 1,
|
||||
},
|
||||
}
|
||||
r, err := hashFn(au.HydrateAttestationData(ðpb.AttestationData{
|
||||
r, err := hashFn(util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 100,
|
||||
}))
|
||||
require.NoError(t, err)
|
||||
@@ -174,7 +172,6 @@ func TestKV_Aggregated_SaveAggregatedAttestation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Aggregated_SaveAggregatedAttestations(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
atts []*ethpb.Attestation
|
||||
@@ -184,9 +181,9 @@ func TestKV_Aggregated_SaveAggregatedAttestations(t *testing.T) {
|
||||
{
|
||||
name: "no duplicates",
|
||||
atts: []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
},
|
||||
count: 1,
|
||||
@@ -210,7 +207,6 @@ func TestKV_Aggregated_SaveAggregatedAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Aggregated_SaveAggregatedAttestations_SomeGoodSomeBad(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
atts []*ethpb.Attestation
|
||||
@@ -220,9 +216,9 @@ func TestKV_Aggregated_SaveAggregatedAttestations_SomeGoodSomeBad(t *testing.T)
|
||||
{
|
||||
name: "the first attestation is bad",
|
||||
atts: []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1},
|
||||
AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
},
|
||||
count: 1,
|
||||
@@ -247,11 +243,10 @@ func TestKV_Aggregated_SaveAggregatedAttestations_SomeGoodSomeBad(t *testing.T)
|
||||
|
||||
func TestKV_Aggregated_AggregatedAttestations(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
au := util.AttestationUtil{}
|
||||
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
@@ -266,17 +261,16 @@ func TestKV_Aggregated_AggregatedAttestations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Aggregated_DeleteAggregatedAttestation(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
t.Run("nil attestation", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
assert.ErrorContains(t, "attestation can't be nil", cache.DeleteAggregatedAttestation(nil))
|
||||
att := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10101}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
att := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10101}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
assert.NoError(t, cache.DeleteAggregatedAttestation(att))
|
||||
})
|
||||
|
||||
t.Run("non aggregated attestation", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
att := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1001}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
att := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1001}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
err := cache.DeleteAggregatedAttestation(att)
|
||||
assert.ErrorContains(t, "attestation is not aggregated", err)
|
||||
})
|
||||
@@ -292,22 +286,22 @@ func TestKV_Aggregated_DeleteAggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
err := cache.DeleteAggregatedAttestation(att)
|
||||
wantErr := "could not tree hash attestation data: --.BeaconBlockRoot (" + fssz.ErrBytesLength.Error() + ")"
|
||||
wantErr := "could not tree hash attestation data: " + fssz.ErrBytesLength.Error()
|
||||
assert.ErrorContains(t, wantErr, err)
|
||||
})
|
||||
|
||||
t.Run("nonexistent attestation", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
att := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1111}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
att := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1111}, Data: ðpb.AttestationData{Slot: 2}})
|
||||
assert.NoError(t, cache.DeleteAggregatedAttestation(att))
|
||||
})
|
||||
|
||||
t.Run("non-filtered deletion", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att4 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b10101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11010}})
|
||||
att4 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b10101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3, att4}
|
||||
require.NoError(t, cache.SaveAggregatedAttestations(atts))
|
||||
require.NoError(t, cache.DeleteAggregatedAttestation(att1))
|
||||
@@ -320,10 +314,10 @@ func TestKV_Aggregated_DeleteAggregatedAttestation(t *testing.T) {
|
||||
|
||||
t.Run("filtered deletion", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b110101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110111}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110100}})
|
||||
att4 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b110101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110111}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110100}})
|
||||
att4 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3, att4}
|
||||
require.NoError(t, cache.SaveAggregatedAttestations(atts))
|
||||
|
||||
@@ -340,7 +334,6 @@ func TestKV_Aggregated_DeleteAggregatedAttestation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
existing []*ethpb.Attestation
|
||||
@@ -364,7 +357,7 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "empty cache aggregated",
|
||||
input: au.HydrateAttestation(ðpb.Attestation{
|
||||
input: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
},
|
||||
@@ -373,7 +366,7 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "empty cache unaggregated",
|
||||
input: au.HydrateAttestation(ðpb.Attestation{
|
||||
input: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
},
|
||||
@@ -383,13 +376,13 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
{
|
||||
name: "single attestation in cache with exact match",
|
||||
existing: []*ethpb.Attestation{{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111}},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111}},
|
||||
@@ -398,13 +391,13 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
{
|
||||
name: "single attestation in cache with subset aggregation",
|
||||
existing: []*ethpb.Attestation{{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111}},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1110}},
|
||||
@@ -413,13 +406,13 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
{
|
||||
name: "single attestation in cache with superset aggregation",
|
||||
existing: []*ethpb.Attestation{{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1110}},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111}},
|
||||
@@ -429,20 +422,20 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
name: "multiple attestations with same data in cache with overlapping aggregation, input is subset",
|
||||
existing: []*ethpb.Attestation{
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111000},
|
||||
},
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1100111},
|
||||
},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1100000}},
|
||||
@@ -452,20 +445,20 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
name: "multiple attestations with same data in cache with overlapping aggregation and input is superset",
|
||||
existing: []*ethpb.Attestation{
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111000},
|
||||
},
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1100111},
|
||||
},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111111}},
|
||||
@@ -475,20 +468,20 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
name: "multiple attestations with different data in cache",
|
||||
existing: []*ethpb.Attestation{
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 2,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111000},
|
||||
},
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 3,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1100111},
|
||||
},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 1,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111111}},
|
||||
@@ -498,14 +491,14 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
name: "attestations with different bitlist lengths",
|
||||
existing: []*ethpb.Attestation{
|
||||
{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 2,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111000},
|
||||
},
|
||||
},
|
||||
input: ðpb.Attestation{
|
||||
Data: au.HydrateAttestationData(ðpb.AttestationData{
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 2,
|
||||
}),
|
||||
AggregationBits: bitfield.Bitlist{0b1111},
|
||||
@@ -547,9 +540,8 @@ func TestKV_Aggregated_HasAggregatedAttestation(t *testing.T) {
|
||||
func TestKV_Aggregated_DuplicateAggregatedAttestations(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1111}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1111}})
|
||||
atts := []*ethpb.Attestation{att1, att2}
|
||||
|
||||
for _, att := range atts {
|
||||
|
||||
@@ -14,17 +14,16 @@ import (
|
||||
func TestKV_BlockAttestation_CanSaveRetrieve(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
require.NoError(t, cache.SaveBlockAttestation(att))
|
||||
}
|
||||
// Diff bit length should not panic.
|
||||
att4 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11011}})
|
||||
att4 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11011}})
|
||||
if err := cache.SaveBlockAttestation(att4); err != bitfield.ErrBitlistDifferentLength {
|
||||
t.Errorf("Unexpected error: wanted %v, got %v", bitfield.ErrBitlistDifferentLength, err)
|
||||
}
|
||||
@@ -41,10 +40,9 @@ func TestKV_BlockAttestation_CanSaveRetrieve(t *testing.T) {
|
||||
func TestKV_BlockAttestation_CanDelete(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
|
||||
@@ -14,10 +14,9 @@ import (
|
||||
func TestKV_Forkchoice_CanSaveRetrieve(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
@@ -36,10 +35,9 @@ func TestKV_Forkchoice_CanSaveRetrieve(t *testing.T) {
|
||||
func TestKV_Forkchoice_CanDelete(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
@@ -57,10 +55,9 @@ func TestKV_Forkchoice_CanDelete(t *testing.T) {
|
||||
func TestKV_Forkchoice_CanCount(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
|
||||
@@ -12,21 +12,20 @@ import (
|
||||
func TestAttCaches_hasSeenBit(t *testing.T) {
|
||||
c := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
seenA1 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}})
|
||||
seenA2 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11100000}})
|
||||
seenA1 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}})
|
||||
seenA2 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11100000}})
|
||||
require.NoError(t, c.insertSeenBit(seenA1))
|
||||
require.NoError(t, c.insertSeenBit(seenA2))
|
||||
tests := []struct {
|
||||
att *ethpb.Attestation
|
||||
want bool
|
||||
}{
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000000}}), want: true},
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000001}}), want: true},
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11100000}}), want: true},
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}}), want: true},
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10001000}}), want: false},
|
||||
{att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11110111}}), want: false},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000000}}), want: true},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000001}}), want: true},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11100000}}), want: true},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}}), want: true},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10001000}}), want: false},
|
||||
{att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b11110111}}), want: false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got, err := c.hasSeenBit(tt.att)
|
||||
@@ -39,8 +38,7 @@ func TestAttCaches_hasSeenBit(t *testing.T) {
|
||||
|
||||
func TestAttCaches_insertSeenBitDuplicates(t *testing.T) {
|
||||
c := NewAttCaches()
|
||||
|
||||
att1 := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b10000011}})
|
||||
r, err := hashFn(att1.Data)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, c.insertSeenBit(att1))
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
)
|
||||
|
||||
func TestKV_Unaggregated_SaveUnaggregatedAttestation(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
att *ethpb.Attestation
|
||||
@@ -44,12 +43,12 @@ func TestKV_Unaggregated_SaveUnaggregatedAttestation(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "normal save",
|
||||
att: au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b0001}}),
|
||||
att: util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b0001}}),
|
||||
count: 1,
|
||||
},
|
||||
{
|
||||
name: "already seen",
|
||||
att: au.HydrateAttestation(ðpb.Attestation{
|
||||
att: util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 100,
|
||||
},
|
||||
@@ -58,7 +57,7 @@ func TestKV_Unaggregated_SaveUnaggregatedAttestation(t *testing.T) {
|
||||
count: 0,
|
||||
},
|
||||
}
|
||||
r, err := hashFn(au.HydrateAttestationData(ðpb.AttestationData{Slot: 100}))
|
||||
r, err := hashFn(util.HydrateAttestationData(ðpb.AttestationData{Slot: 100}))
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -84,7 +83,6 @@ func TestKV_Unaggregated_SaveUnaggregatedAttestation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Unaggregated_SaveUnaggregatedAttestations(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
atts []*ethpb.Attestation
|
||||
@@ -94,18 +92,18 @@ func TestKV_Unaggregated_SaveUnaggregatedAttestations(t *testing.T) {
|
||||
{
|
||||
name: "unaggregated only",
|
||||
atts: []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}}),
|
||||
},
|
||||
count: 3,
|
||||
},
|
||||
{
|
||||
name: "has aggregated",
|
||||
atts: []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}}),
|
||||
{AggregationBits: bitfield.Bitlist{0b1111}, Data: ðpb.AttestationData{Slot: 2}},
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}}),
|
||||
},
|
||||
wantErrString: "attestation is aggregated",
|
||||
count: 1,
|
||||
@@ -143,11 +141,10 @@ func TestKV_Unaggregated_DeleteUnaggregatedAttestation(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("successful deletion", func(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
cache := NewAttCaches()
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
require.NoError(t, cache.SaveUnaggregatedAttestations(atts))
|
||||
for _, att := range atts {
|
||||
@@ -160,8 +157,7 @@ func TestKV_Unaggregated_DeleteUnaggregatedAttestation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
d := au.HydrateAttestationData(ðpb.AttestationData{})
|
||||
d := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
t.Run("no attestations", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
@@ -173,9 +169,9 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
|
||||
t.Run("none seen", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
atts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
}
|
||||
require.NoError(t, cache.SaveUnaggregatedAttestations(atts))
|
||||
assert.Equal(t, 3, cache.UnaggregatedAttestationCount())
|
||||
@@ -190,9 +186,9 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
|
||||
t.Run("some seen", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
atts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
}
|
||||
require.NoError(t, cache.SaveUnaggregatedAttestations(atts))
|
||||
assert.Equal(t, 3, cache.UnaggregatedAttestationCount())
|
||||
@@ -215,9 +211,9 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
|
||||
t.Run("all seen", func(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
atts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1001}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1010}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: d, AggregationBits: bitfield.Bitlist{0b1100}}),
|
||||
}
|
||||
require.NoError(t, cache.SaveUnaggregatedAttestations(atts))
|
||||
assert.Equal(t, 3, cache.UnaggregatedAttestationCount())
|
||||
@@ -240,10 +236,9 @@ func TestKV_Unaggregated_DeleteSeenUnaggregatedAttestations(t *testing.T) {
|
||||
func TestKV_Unaggregated_UnaggregatedAttestationsBySlotIndex(t *testing.T) {
|
||||
cache := NewAttCaches()
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1, CommitteeIndex: 1}, AggregationBits: bitfield.Bitlist{0b101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1, CommitteeIndex: 2}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2, CommitteeIndex: 1}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1, CommitteeIndex: 1}, AggregationBits: bitfield.Bitlist{0b101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1, CommitteeIndex: 2}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2, CommitteeIndex: 1}, AggregationBits: bitfield.Bitlist{0b110}})
|
||||
atts := []*ethpb.Attestation{att1, att2, att3}
|
||||
|
||||
for _, att := range atts {
|
||||
|
||||
@@ -234,7 +234,7 @@ func TestSeenAttestations_PresentInCache(t *testing.T) {
|
||||
s, err := NewService(context.Background(), &Config{Pool: NewPool()})
|
||||
require.NoError(t, err)
|
||||
|
||||
ad1 := util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{})
|
||||
ad1 := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
att1 := ðpb.Attestation{Data: ad1, Signature: []byte{'A'}, AggregationBits: bitfield.Bitlist{0x13} /* 0b00010011 */}
|
||||
got, err := s.seen(att1)
|
||||
require.NoError(t, err)
|
||||
@@ -252,9 +252,9 @@ func TestSeenAttestations_PresentInCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestService_seen(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
ad1 := au.HydrateAttestationData(ðpb.AttestationData{Slot: 1})
|
||||
ad2 := au.HydrateAttestationData(ðpb.AttestationData{Slot: 2})
|
||||
ad1 := util.HydrateAttestationData(ðpb.AttestationData{Slot: 1})
|
||||
|
||||
ad2 := util.HydrateAttestationData(ðpb.AttestationData{Slot: 2})
|
||||
|
||||
// Attestation are checked in order of this list.
|
||||
tests := []struct {
|
||||
|
||||
@@ -26,9 +26,9 @@ func TestPruneExpired_Ticker(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
ad1 := au.HydrateAttestationData(ðpb.AttestationData{})
|
||||
ad2 := au.HydrateAttestationData(ðpb.AttestationData{Slot: 1})
|
||||
ad1 := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
ad2 := util.HydrateAttestationData(ðpb.AttestationData{Slot: 1})
|
||||
|
||||
atts := []*ethpb.Attestation{
|
||||
{Data: ad1, AggregationBits: bitfield.Bitlist{0b1000, 0b1}, Signature: make([]byte, fieldparams.BLSSignatureLength)},
|
||||
@@ -85,9 +85,9 @@ func TestPruneExpired_PruneExpiredAtts(t *testing.T) {
|
||||
s, err := NewService(context.Background(), &Config{Pool: NewPool()})
|
||||
require.NoError(t, err)
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
ad1 := au.HydrateAttestationData(ðpb.AttestationData{})
|
||||
ad2 := au.HydrateAttestationData(ðpb.AttestationData{})
|
||||
ad1 := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
ad2 := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
att1 := ðpb.Attestation{Data: ad1, AggregationBits: bitfield.Bitlist{0b1101}}
|
||||
att2 := ðpb.Attestation{Data: ad1, AggregationBits: bitfield.Bitlist{0b1111}}
|
||||
|
||||
@@ -162,7 +162,7 @@ func TestService_BroadcastAttestation(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
msg := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)})
|
||||
msg := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)})
|
||||
subnet := uint64(5)
|
||||
|
||||
topic := AttestationSubnetTopicFormat
|
||||
@@ -323,7 +323,7 @@ func TestService_BroadcastAttestationWithDiscoveryAttempts(t *testing.T) {
|
||||
go p.listenForNewNodes()
|
||||
go p2.listenForNewNodes()
|
||||
|
||||
msg := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)})
|
||||
msg := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.NewBitlist(7)})
|
||||
topic := AttestationSubnetTopicFormat
|
||||
GossipTypeMapping[reflect.TypeOf(msg)] = topic
|
||||
digest, err := p.currentForkDigest()
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/prysmaticlabs/prysm/network"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/engine/v1"
|
||||
"github.com/prysmaticlabs/prysm/time/slots"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -86,8 +85,7 @@ func (s *Service) checkTransitionConfiguration(
|
||||
ctx, cancel := context.WithDeadline(ctx, tm.Add(network.DefaultRPCHTTPTimeout))
|
||||
err = s.ExchangeTransitionConfiguration(ctx, cfg)
|
||||
s.handleExchangeConfigurationError(err)
|
||||
currentEpoch := slots.ToEpoch(slots.CurrentSlot(s.chainStartData.GetGenesisTime()))
|
||||
if currentEpoch >= params.BeaconConfig().BellatrixForkEpoch && !hasTtdReached {
|
||||
if !hasTtdReached {
|
||||
hasTtdReached, err = s.logTtdStatus(ctx, ttd)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not log ttd status")
|
||||
|
||||
@@ -41,11 +41,10 @@ func fillDBTestBlocks(ctx context.Context, t *testing.T, beaconDB db.Database) (
|
||||
b := util.NewBeaconBlock()
|
||||
b.Block.Slot = i
|
||||
b.Block.ParentRoot = bytesutil.PadTo([]byte{uint8(i)}, 32)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.NewAttestation()
|
||||
att1 := util.NewAttestation()
|
||||
att1.Data.Slot = i
|
||||
att1.Data.CommitteeIndex = types.CommitteeIndex(i)
|
||||
att2 := au.NewAttestation()
|
||||
att2 := util.NewAttestation()
|
||||
att2.Data.Slot = i
|
||||
att2.Data.CommitteeIndex = types.CommitteeIndex(i + 1)
|
||||
b.Block.Body.Attestations = []*ethpbalpha.Attestation{att1, att2}
|
||||
@@ -85,11 +84,10 @@ func fillDBTestBlocksAltair(ctx context.Context, t *testing.T, beaconDB db.Datab
|
||||
b := util.NewBeaconBlockAltair()
|
||||
b.Block.Slot = i
|
||||
b.Block.ParentRoot = bytesutil.PadTo([]byte{uint8(i)}, 32)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.NewAttestation()
|
||||
att1 := util.NewAttestation()
|
||||
att1.Data.Slot = i
|
||||
att1.Data.CommitteeIndex = types.CommitteeIndex(i)
|
||||
att2 := au.NewAttestation()
|
||||
att2 := util.NewAttestation()
|
||||
att2.Data.Slot = i
|
||||
att2.Data.CommitteeIndex = types.CommitteeIndex(i + 1)
|
||||
b.Block.Body.Attestations = []*ethpbalpha.Attestation{att1, att2}
|
||||
@@ -128,11 +126,10 @@ func fillDBTestBlocksBellatrix(ctx context.Context, t *testing.T, beaconDB db.Da
|
||||
b := util.NewBeaconBlockBellatrix()
|
||||
b.Block.Slot = i
|
||||
b.Block.ParentRoot = bytesutil.PadTo([]byte{uint8(i)}, 32)
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.NewAttestation()
|
||||
att1 := util.NewAttestation()
|
||||
att1.Data.Slot = i
|
||||
att1.Data.CommitteeIndex = types.CommitteeIndex(i)
|
||||
att2 := au.NewAttestation()
|
||||
att2 := util.NewAttestation()
|
||||
att2.Data.Slot = i
|
||||
att2.Data.CommitteeIndex = types.CommitteeIndex(i + 1)
|
||||
b.Block.Body.Attestations = []*ethpbalpha.Attestation{att1, att2}
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestStreamEvents_OperationsEvents(t *testing.T) {
|
||||
srv, ctrl, mockStream := setupServer(ctx, t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
wantedAttV1alpha1 := util.NewAttestationUtil().HydrateAttestation(ð.Attestation{
|
||||
wantedAttV1alpha1 := util.HydrateAttestation(ð.Attestation{
|
||||
Data: ð.AttestationData{
|
||||
Slot: 8,
|
||||
},
|
||||
@@ -127,7 +127,7 @@ func TestStreamEvents_OperationsEvents(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
wantedAttV1alpha1 := ð.AggregateAttestationAndProof{
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ð.Attestation{}),
|
||||
Aggregate: util.HydrateAttestation(ð.Attestation{}),
|
||||
}
|
||||
wantedAtt := migration.V1Alpha1AggregateAttAndProofToV1(wantedAttV1alpha1)
|
||||
genericResponse, err := anypb.New(wantedAtt)
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(0),
|
||||
Data: ðpb.AttestationData{
|
||||
Slot: 2,
|
||||
@@ -275,7 +275,7 @@ func TestServer_ListAttestations_Pagination_CustomPageParameters(t *testing.T) {
|
||||
blockExample := util.NewBeaconBlock()
|
||||
blockExample.Block.Slot = i
|
||||
blockExample.Block.Body.Attestations = []*ethpb.Attestation{
|
||||
util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
CommitteeIndex: s,
|
||||
Slot: i,
|
||||
@@ -754,7 +754,7 @@ func TestServer_AttestationPool_Pagination_DefaultPageSize(t *testing.T) {
|
||||
|
||||
atts := make([]*ethpb.Attestation, params.BeaconConfig().DefaultPageSize+1)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
att := util.NewAttestationUtil().NewAttestation()
|
||||
att := util.NewAttestation()
|
||||
att.Data.Slot = types.Slot(i)
|
||||
atts[i] = att
|
||||
}
|
||||
@@ -776,7 +776,7 @@ func TestServer_AttestationPool_Pagination_CustomPageSize(t *testing.T) {
|
||||
numAtts := 100
|
||||
atts := make([]*ethpb.Attestation, numAtts)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
att := util.NewAttestationUtil().NewAttestation()
|
||||
att := util.NewAttestation()
|
||||
att.Data.Slot = types.Slot(i)
|
||||
atts[i] = att
|
||||
}
|
||||
@@ -1031,11 +1031,10 @@ func TestServer_StreamAttestations_OnSlotTick(t *testing.T) {
|
||||
AttestationNotifier: chainService.OperationNotifier(),
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
atts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b1101}}),
|
||||
}
|
||||
|
||||
mockStream := mock.NewMockBeaconChain_StreamAttestationsServer(ctrl)
|
||||
|
||||
@@ -1525,7 +1525,7 @@ func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) {
|
||||
}
|
||||
|
||||
atts := []*ethpb.PendingAttestation{{
|
||||
Data: util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
InclusionDelay: 1,
|
||||
AggregationBits: bitfield.NewBitlist(validatorCount / uint64(params.BeaconConfig().SlotsPerEpoch)),
|
||||
}}
|
||||
@@ -1607,7 +1607,7 @@ func TestServer_GetValidatorParticipation_OrphanedUntilGenesis(t *testing.T) {
|
||||
}
|
||||
|
||||
atts := []*ethpb.PendingAttestation{{
|
||||
Data: util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
InclusionDelay: 1,
|
||||
AggregationBits: bitfield.NewBitlist(validatorCount / uint64(params.BeaconConfig().SlotsPerEpoch)),
|
||||
}}
|
||||
@@ -2292,10 +2292,9 @@ func TestServer_GetIndividualVotes_Working(t *testing.T) {
|
||||
require.NoError(t, beaconState.SetValidators(stateWithValidators.Validators()))
|
||||
|
||||
bf := bitfield.NewBitlist(validators / uint64(params.BeaconConfig().SlotsPerEpoch))
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.NewAttestation()
|
||||
att1 := util.NewAttestation()
|
||||
att1.AggregationBits = bf
|
||||
att2 := au.NewAttestation()
|
||||
att2 := util.NewAttestation()
|
||||
att2.AggregationBits = bf
|
||||
rt := [32]byte{'A'}
|
||||
att1.Data.Target.Root = rt[:]
|
||||
|
||||
@@ -118,7 +118,6 @@ go_test(
|
||||
deps = [
|
||||
"//async/event:go_default_library",
|
||||
"//beacon-chain/blockchain/testing:go_default_library",
|
||||
"//beacon-chain/builder/testing:go_default_library",
|
||||
"//beacon-chain/cache:go_default_library",
|
||||
"//beacon-chain/cache/depositcache:go_default_library",
|
||||
"//beacon-chain/core/altair:go_default_library",
|
||||
@@ -166,7 +165,6 @@ go_test(
|
||||
"@com_github_d4l3k_messagediff//:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
"@com_github_golang_mock//gomock:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
|
||||
@@ -217,7 +217,7 @@ func generateAtt(state state.ReadOnlyBeaconState, index uint64, privKeys []bls.S
|
||||
aggBits := bitfield.NewBitlist(4)
|
||||
aggBits.SetBitAt(index, true)
|
||||
aggBits.SetBitAt(index+1, true)
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{CommitteeIndex: 1},
|
||||
AggregationBits: aggBits,
|
||||
})
|
||||
@@ -254,7 +254,7 @@ func generateAtt(state state.ReadOnlyBeaconState, index uint64, privKeys []bls.S
|
||||
func generateUnaggregatedAtt(state state.ReadOnlyBeaconState, index uint64, privKeys []bls.SecretKey) (*ethpb.Attestation, error) {
|
||||
aggBits := bitfield.NewBitlist(4)
|
||||
aggBits.SetBitAt(index, true)
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
CommitteeIndex: 1,
|
||||
},
|
||||
|
||||
@@ -83,7 +83,7 @@ func TestProposeAttestation_IncorrectSignature(t *testing.T) {
|
||||
OperationNotifier: (&mock.ChainService{}).OperationNotifier(),
|
||||
}
|
||||
|
||||
req := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{})
|
||||
req := util.HydrateAttestation(ðpb.Attestation{})
|
||||
wanted := "Incorrect attestation signature"
|
||||
_, err := attesterServer.ProposeAttestation(context.Background(), req)
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
|
||||
@@ -62,7 +62,7 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (
|
||||
return nil, status.Errorf(codes.Internal, "Could not fetch Bellatrix beacon block: %v", err)
|
||||
}
|
||||
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Bellatrix{Bellatrix: blk}}, nil
|
||||
return blk, nil
|
||||
}
|
||||
|
||||
// GetBlock is called by a proposer during its assigned slot to request a block to sign
|
||||
@@ -141,6 +141,26 @@ func (vs *Server) proposeGenericBeaconBlock(ctx context.Context, blk interfaces.
|
||||
return nil, fmt.Errorf("could not tree hash block: %v", err)
|
||||
}
|
||||
|
||||
r, err := blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info("Block root with header", fmt.Sprintf("%#x", bytesutil.Trunc(r[:])))
|
||||
blk, err = vs.getBuilderBlock(ctx, blk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err = blk.Block().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info("block root with payload", fmt.Sprintf("%#x", bytesutil.Trunc(r[:])))
|
||||
payload, err := blk.Block().Body().ExecutionPayload()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info("Tx count: ", len(payload.Transactions))
|
||||
|
||||
// Do not block proposal critical path with debug logging or block feed updates.
|
||||
defer func() {
|
||||
log.WithField("blockRoot", fmt.Sprintf("%#x", bytesutil.Trunc(root[:]))).Debugf(
|
||||
@@ -198,6 +218,5 @@ func (vs *Server) SubmitValidatorRegistration(ctx context.Context, reg *ethpb.Si
|
||||
if err := vs.BlockBuilder.RegisterValidator(ctx, reg.Messages); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Could not register block builder: %v", err)
|
||||
}
|
||||
|
||||
return &emptypb.Empty{}, nil
|
||||
}
|
||||
|
||||
@@ -14,22 +14,21 @@ import (
|
||||
)
|
||||
|
||||
func TestProposer_ProposerAtts_sortByProfitability(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
atts := proposerAtts([]*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11110000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11110000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
})
|
||||
want := proposerAtts([]*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11110000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11110000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 4}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 3}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 2}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11100000}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11000000}}),
|
||||
})
|
||||
atts, err := atts.sortByProfitability()
|
||||
if err != nil {
|
||||
@@ -46,7 +45,7 @@ func TestProposer_ProposerAtts_sortByProfitabilityUsingMaxCover(t *testing.T) {
|
||||
getAtts := func(data []testData) proposerAtts {
|
||||
var atts proposerAtts
|
||||
for _, att := range data {
|
||||
atts = append(atts, util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
atts = append(atts, util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{Slot: att.slot}, AggregationBits: att.bits}))
|
||||
}
|
||||
return atts
|
||||
@@ -190,11 +189,10 @@ func TestProposer_ProposerAtts_sortByProfitabilityUsingMaxCover(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProposer_ProposerAtts_dedup(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
data1 := au.HydrateAttestationData(ðpb.AttestationData{
|
||||
data1 := util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 4,
|
||||
})
|
||||
data2 := au.HydrateAttestationData(ðpb.AttestationData{
|
||||
data2 := util.HydrateAttestationData(ðpb.AttestationData{
|
||||
Slot: 5,
|
||||
})
|
||||
tests := []struct {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/transition/interop"
|
||||
@@ -18,12 +19,33 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||
)
|
||||
|
||||
func (vs *Server) getBellatrixBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.BeaconBlockBellatrix, error) {
|
||||
func (vs *Server) getBellatrixBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
altairBlk, err := vs.buildAltairBeaconBlock(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Did the user specify block builder
|
||||
if vs.BlockBuilder != nil && vs.BlockBuilder.Configured() {
|
||||
// Does the protocol allow node to use block builder to construct payload header now
|
||||
ready, err := vs.readyForBuilder(ctx)
|
||||
if err == nil && ready {
|
||||
// Retrieve header from block builder and construct the head block if there's no error.
|
||||
h, err := vs.getPayloadHeader(ctx, req.Slot, altairBlk.ProposerIndex)
|
||||
if err == nil {
|
||||
return vs.buildHeaderBlock(ctx, altairBlk, h)
|
||||
}
|
||||
// If there's an error at retrieving header, default back to using local EE.
|
||||
log.WithError(err).Warning("Could not construct block using the header from builders, using local execution engine instead")
|
||||
}
|
||||
if err != nil {
|
||||
log.WithError(err).Warning("Could not decide builder is ready")
|
||||
}
|
||||
if !ready {
|
||||
log.Debug("Can't use builder yet. Using local execution engine to propose")
|
||||
}
|
||||
}
|
||||
|
||||
payload, err := vs.getExecutionPayload(ctx, req.Slot, altairBlk.ProposerIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -60,7 +82,24 @@ func (vs *Server) getBellatrixBeaconBlock(ctx context.Context, req *ethpb.BlockR
|
||||
return nil, fmt.Errorf("could not compute state root: %v", err)
|
||||
}
|
||||
blk.StateRoot = stateRoot
|
||||
return blk, nil
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Bellatrix{Bellatrix: blk}}, nil
|
||||
}
|
||||
|
||||
// readyForBuilder returns true if builder is allowed to be used. Builder is allowed to be use after the
|
||||
// first finalized checkpt has been execution-enabled.
|
||||
func (vs *Server) readyForBuilder(ctx context.Context) (bool, error) {
|
||||
cp := vs.FinalizationFetcher.FinalizedCheckpt()
|
||||
if bytesutil.ToBytes32(cp.Root) == params.BeaconConfig().ZeroHash {
|
||||
return false, nil
|
||||
}
|
||||
b, err := vs.BeaconDB.Block(ctx, bytesutil.ToBytes32(cp.Root))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if err := coreBlock.BeaconBlockIsNil(b); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return blocks.IsExecutionBlock(b.Block().Body())
|
||||
}
|
||||
|
||||
// This function retrieves the payload header given the slot number and the validator index.
|
||||
@@ -80,11 +119,15 @@ func (vs *Server) getPayloadHeader(ctx context.Context, slot types.Slot, idx typ
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pk, err := vs.HeadFetcher.HeadValidatorIndexToPublicKey(ctx, idx)
|
||||
//pk, err := vs.HeadFetcher.HeadValidatorIndexToPublicKey(ctx, idx)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
k, err := hexutil.Decode("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bid, err := vs.BlockBuilder.GetHeader(ctx, slot, bytesutil.ToBytes32(h.BlockHash), pk)
|
||||
bid, err := vs.BlockBuilder.GetHeader(ctx, slot, bytesutil.ToBytes32(h.BlockHash), bytesutil.ToBytes48(k))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
blockchainTest "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
||||
builderTest "github.com/prysmaticlabs/prysm/beacon-chain/builder/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/altair"
|
||||
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
@@ -65,6 +62,35 @@ func TestServer_buildHeaderBlock(t *testing.T) {
|
||||
got, err := vs.buildHeaderBlock(ctx, b1.Block, h)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, h, got.GetBlindedBellatrix().Body.ExecutionPayloadHeader)
|
||||
}
|
||||
|
||||
func TestServer_readyForBuilder(t *testing.T) {
|
||||
vs := &Server{BeaconDB: dbTest.SetupDB(t)}
|
||||
b := util.NewBeaconBlockBellatrix()
|
||||
wb, err := wrapper.WrappedSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
wbr, err := wb.Block().HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
b1 := util.NewBeaconBlockBellatrix()
|
||||
b1.Block.Body.ExecutionPayload.BlockNumber = 1
|
||||
wb1, err := wrapper.WrappedSignedBeaconBlock(b1)
|
||||
require.NoError(t, err)
|
||||
wbr1, err := wb1.Block().HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
require.NoError(t, vs.BeaconDB.SaveBlock(ctx, wb))
|
||||
require.NoError(t, vs.BeaconDB.SaveBlock(ctx, wb1))
|
||||
cs := &ct.ChainService{FinalizedCheckPoint: ðpb.Checkpoint{Root: wbr[:]}}
|
||||
vs.FinalizationFetcher = cs
|
||||
ready, err := vs.readyForBuilder(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ready)
|
||||
|
||||
cs = &ct.ChainService{FinalizedCheckPoint: ðpb.Checkpoint{Root: wbr1[:]}}
|
||||
vs.FinalizationFetcher = cs
|
||||
ready, err = vs.readyForBuilder(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, ready)
|
||||
|
||||
_, err = vs.buildHeaderBlock(ctx, nil, h)
|
||||
require.ErrorContains(t, "nil block", err)
|
||||
@@ -259,3 +285,105 @@ func TestServer_getBuilderBlock(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_GetBellatrixBeaconBlock_HappyCase(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
hook := logTest.NewGlobal()
|
||||
|
||||
terminalBlockHash := bytesutil.PadTo([]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 32)
|
||||
params.SetupTestConfigCleanup(t)
|
||||
cfg := params.MainnetConfig().Copy()
|
||||
cfg.BellatrixForkEpoch = 2
|
||||
cfg.AltairForkEpoch = 1
|
||||
cfg.TerminalBlockHash = common.BytesToHash(terminalBlockHash)
|
||||
cfg.TerminalBlockHashActivationEpoch = 2
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
|
||||
beaconState, privKeys := util.DeterministicGenesisState(t, 64)
|
||||
stateRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err, "Could not hash genesis state")
|
||||
|
||||
genesis := b.NewGenesisBlock(stateRoot[:])
|
||||
wsb, err := wrapper.WrappedSignedBeaconBlock(genesis)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, db.SaveBlock(ctx, wsb), "Could not save genesis block")
|
||||
|
||||
parentRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err, "Could not get signing root")
|
||||
require.NoError(t, db.SaveState(ctx, beaconState, parentRoot), "Could not save genesis state")
|
||||
require.NoError(t, db.SaveHeadBlockRoot(ctx, parentRoot), "Could not save genesis state")
|
||||
|
||||
bellatrixSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
|
||||
require.NoError(t, err)
|
||||
|
||||
emptyPayload := &v1.ExecutionPayload{
|
||||
ParentHash: make([]byte, fieldparams.RootLength),
|
||||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
|
||||
StateRoot: make([]byte, fieldparams.RootLength),
|
||||
ReceiptsRoot: make([]byte, fieldparams.RootLength),
|
||||
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
|
||||
PrevRandao: make([]byte, fieldparams.RootLength),
|
||||
BaseFeePerGas: make([]byte, fieldparams.RootLength),
|
||||
BlockHash: make([]byte, fieldparams.RootLength),
|
||||
}
|
||||
blk := ðpb.SignedBeaconBlockBellatrix{
|
||||
Block: ðpb.BeaconBlockBellatrix{
|
||||
Slot: bellatrixSlot + 1,
|
||||
ParentRoot: parentRoot[:],
|
||||
StateRoot: genesis.Block.StateRoot,
|
||||
Body: ðpb.BeaconBlockBodyBellatrix{
|
||||
RandaoReveal: genesis.Block.Body.RandaoReveal,
|
||||
Graffiti: genesis.Block.Body.Graffiti,
|
||||
Eth1Data: genesis.Block.Body.Eth1Data,
|
||||
SyncAggregate: ðpb.SyncAggregate{SyncCommitteeBits: bitfield.NewBitvector512(), SyncCommitteeSignature: make([]byte, 96)},
|
||||
ExecutionPayload: emptyPayload,
|
||||
},
|
||||
},
|
||||
Signature: genesis.Signature,
|
||||
}
|
||||
|
||||
blkRoot, err := blk.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err, "Could not get signing root")
|
||||
require.NoError(t, db.SaveState(ctx, beaconState, blkRoot), "Could not save genesis state")
|
||||
require.NoError(t, db.SaveHeadBlockRoot(ctx, blkRoot), "Could not save genesis state")
|
||||
|
||||
proposerServer := &Server{
|
||||
HeadFetcher: &ct.ChainService{State: beaconState, Root: parentRoot[:], Optimistic: false},
|
||||
TimeFetcher: &ct.ChainService{Genesis: time.Now()},
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
||||
BlockReceiver: &ct.ChainService{},
|
||||
HeadUpdater: &ct.ChainService{},
|
||||
ChainStartFetcher: &mockPOW.POWChain{},
|
||||
Eth1InfoFetcher: &mockPOW.POWChain{},
|
||||
MockEth1Votes: true,
|
||||
AttPool: attestations.NewPool(),
|
||||
SlashingsPool: slashings.NewPool(),
|
||||
ExitPool: voluntaryexits.NewPool(),
|
||||
StateGen: stategen.New(db),
|
||||
SyncCommitteePool: synccommittee.NewStore(),
|
||||
ExecutionEngineCaller: &mockPOW.EngineClient{
|
||||
PayloadIDBytes: &v1.PayloadIDBytes{1},
|
||||
ExecutionPayload: emptyPayload,
|
||||
},
|
||||
BeaconDB: db,
|
||||
ProposerSlotIndexCache: cache.NewProposerPayloadIDsCache(),
|
||||
BlockBuilder: &bt.MockBuilderService{},
|
||||
}
|
||||
proposerServer.ProposerSlotIndexCache.SetProposerAndPayloadIDs(65, 40, [8]byte{'a'})
|
||||
|
||||
randaoReveal, err := util.RandaoReveal(beaconState, 0, privKeys)
|
||||
require.NoError(t, err)
|
||||
|
||||
block, err := proposerServer.getBellatrixBeaconBlock(ctx, ðpb.BlockRequest{
|
||||
Slot: bellatrixSlot + 1,
|
||||
RandaoReveal: randaoReveal,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
bellatrixBlk, ok := block.GetBlock().(*ethpb.GenericBeaconBlock_Bellatrix)
|
||||
require.Equal(t, true, ok)
|
||||
require.LogsContain(t, hook, "Computed state root")
|
||||
require.DeepEqual(t, emptyPayload, bellatrixBlk.Bellatrix.Body.ExecutionPayload) // Payload should equal.
|
||||
}
|
||||
|
||||
@@ -148,9 +148,8 @@ func TestProposer_GetBlock_AddsUnaggregatedAtts(t *testing.T) {
|
||||
// Generate a bunch of random attestations at slot. These would be considered double votes, but
|
||||
// we don't care for the purpose of this test.
|
||||
var atts []*ethpb.Attestation
|
||||
au := util.AttestationUtil{}
|
||||
for i := uint64(0); len(atts) < int(params.BeaconConfig().MaxAttestations); i++ {
|
||||
a, err := au.GenerateAttestations(beaconState, privKeys, 4, 1, true)
|
||||
a, err := util.GenerateAttestations(beaconState, privKeys, 4, 1, true)
|
||||
require.NoError(t, err)
|
||||
atts = append(atts, a...)
|
||||
}
|
||||
@@ -161,7 +160,7 @@ func TestProposer_GetBlock_AddsUnaggregatedAtts(t *testing.T) {
|
||||
|
||||
// Generate some more random attestations with a larger spread so that we can capture at least
|
||||
// one unaggregated attestation.
|
||||
atts, err := au.GenerateAttestations(beaconState, privKeys, 300, 1, true)
|
||||
atts, err := util.GenerateAttestations(beaconState, privKeys, 300, 1, true)
|
||||
require.NoError(t, err)
|
||||
found := false
|
||||
for _, a := range atts {
|
||||
@@ -1816,7 +1815,6 @@ func TestProposer_FilterAttestation(t *testing.T) {
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
tests := []struct {
|
||||
name string
|
||||
wantedErr string
|
||||
@@ -1837,7 +1835,7 @@ func TestProposer_FilterAttestation(t *testing.T) {
|
||||
inputAtts: func() []*ethpb.Attestation {
|
||||
atts := make([]*ethpb.Attestation, 10)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = au.HydrateAttestation(ðpb.Attestation{
|
||||
atts[i] = util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
CommitteeIndex: types.CommitteeIndex(i),
|
||||
},
|
||||
@@ -1854,7 +1852,7 @@ func TestProposer_FilterAttestation(t *testing.T) {
|
||||
inputAtts: func() []*ethpb.Attestation {
|
||||
atts := make([]*ethpb.Attestation, 10)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = au.HydrateAttestation(ðpb.Attestation{
|
||||
atts[i] = util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
CommitteeIndex: types.CommitteeIndex(i),
|
||||
Source: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
||||
@@ -2013,13 +2011,12 @@ func TestProposer_DeleteAttsInPool_Aggregated(t *testing.T) {
|
||||
priv, err := bls.RandKey()
|
||||
require.NoError(t, err)
|
||||
sig := priv.Sign([]byte("foo")).Marshal()
|
||||
au := util.AttestationUtil{}
|
||||
aggregatedAtts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10101}, Signature: sig}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11010}, Signature: sig})}
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10101}, Signature: sig}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b11010}, Signature: sig})}
|
||||
unaggregatedAtts := []*ethpb.Attestation{
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10010}, Signature: sig}),
|
||||
au.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10100}, Signature: sig})}
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10010}, Signature: sig}),
|
||||
util.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: 1}, AggregationBits: bitfield.Bitlist{0b10100}, Signature: sig})}
|
||||
|
||||
require.NoError(t, s.AttPool.SaveAggregatedAttestations(aggregatedAtts))
|
||||
require.NoError(t, s.AttPool.SaveUnaggregatedAttestations(unaggregatedAtts))
|
||||
|
||||
@@ -186,7 +186,6 @@ func (s *Service) Start() {
|
||||
}
|
||||
withCache := stategen.WithCache(stateCache)
|
||||
ch := stategen.NewCanonicalHistory(s.cfg.BeaconDB, s.cfg.ChainInfoFetcher, s.cfg.ChainInfoFetcher, withCache)
|
||||
|
||||
validatorServer := &validatorv1alpha1.Server{
|
||||
Ctx: s.ctx,
|
||||
AttestationCache: cache.NewAttestationCache(),
|
||||
|
||||
@@ -50,11 +50,10 @@ func TestService_processAttesterSlashings(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
firstAtt := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
firstAtt := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0},
|
||||
})
|
||||
secondAtt := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
secondAtt := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0},
|
||||
})
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ func TestProcessPendingAtts_NoBroadcastWithBadSignature(t *testing.T) {
|
||||
Aggregate: ðpb.Attestation{
|
||||
Signature: priv.Sign([]byte("foo")).Marshal(),
|
||||
AggregationBits: bitfield.Bitlist{0x02},
|
||||
Data: util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{}),
|
||||
Data: util.HydrateAttestationData(ðpb.AttestationData{}),
|
||||
},
|
||||
SelectionProof: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestBeaconAggregateProofSubscriber_CanSaveAggregatedAttestation(t *testing.
|
||||
|
||||
a := ðpb.SignedAggregateAttestationAndProof{
|
||||
Message: ðpb.AggregateAttestationAndProof{
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
Aggregate: util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.Bitlist{0x07},
|
||||
}),
|
||||
AggregatorIndex: 100,
|
||||
@@ -48,7 +48,7 @@ func TestBeaconAggregateProofSubscriber_CanSaveUnaggregatedAttestation(t *testin
|
||||
|
||||
a := ðpb.SignedAggregateAttestationAndProof{
|
||||
Message: ðpb.AggregateAttestationAndProof{
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
Aggregate: util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.Bitlist{0x03},
|
||||
Signature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}),
|
||||
|
||||
@@ -25,11 +25,10 @@ func TestDeleteAttsInPool(t *testing.T) {
|
||||
cfg: &config{attPool: attestations.NewPool()},
|
||||
}
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1110}})
|
||||
att3 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1011}})
|
||||
att4 := au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1001}})
|
||||
att1 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1101}})
|
||||
att2 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1110}})
|
||||
att3 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1011}})
|
||||
att4 := util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b1001}})
|
||||
require.NoError(t, r.cfg.attPool.SaveAggregatedAttestation(att1))
|
||||
require.NoError(t, r.cfg.attPool.SaveAggregatedAttestation(att2))
|
||||
require.NoError(t, r.cfg.attPool.SaveAggregatedAttestation(att3))
|
||||
@@ -43,12 +42,11 @@ func TestDeleteAttsInPool(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestService_beaconBlockSubscriber(t *testing.T) {
|
||||
au := util.AttestationUtil{}
|
||||
pooledAttestations := []*ethpb.Attestation{
|
||||
// Aggregated.
|
||||
au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b00011111}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b00011111}}),
|
||||
// Unaggregated.
|
||||
au.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b00010001}}),
|
||||
util.HydrateAttestation(ðpb.Attestation{AggregationBits: bitfield.Bitlist{0b00010001}}),
|
||||
}
|
||||
|
||||
type args struct {
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestVerifySelection_NotAnAggregator(t *testing.T) {
|
||||
beaconState, privKeys := util.DeterministicGenesisState(t, validators)
|
||||
|
||||
sig := privKeys[0].Sign([]byte{'A'})
|
||||
data := util.NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{})
|
||||
data := util.HydrateAttestationData(ðpb.AttestationData{})
|
||||
|
||||
_, err := validateSelectionIndex(ctx, beaconState, data, 0, sig.Marshal())
|
||||
wanted := "validator is not an aggregator for slot"
|
||||
@@ -98,7 +98,7 @@ func TestValidateAggregateAndProof_NoBlock(t *testing.T) {
|
||||
db := dbtest.SetupDB(t)
|
||||
p := p2ptest.NewTestP2P(t)
|
||||
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
att := util.HydrateAttestation(ðpb.Attestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||
Target: ðpb.Checkpoint{Root: bytesutil.PadTo([]byte("hello-world"), 32)},
|
||||
|
||||
@@ -33,8 +33,7 @@ func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, state.Be
|
||||
}
|
||||
require.NoError(t, s.SetValidators(vals))
|
||||
|
||||
au := util.AttestationUtil{}
|
||||
att1 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att1 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Source: ðpb.Checkpoint{Epoch: 1},
|
||||
},
|
||||
@@ -49,7 +48,7 @@ func setupValidAttesterSlashing(t *testing.T) (*ethpb.AttesterSlashing, state.Be
|
||||
aggregateSig := bls.AggregateSignatures([]bls.Signature{sig0, sig1})
|
||||
att1.Signature = aggregateSig.Marshal()
|
||||
|
||||
att2 := au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
att2 := util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{0, 1},
|
||||
})
|
||||
hashTreeRoot, err = signing.ComputeSigningRoot(att2.Data, domain)
|
||||
@@ -133,13 +132,12 @@ func TestValidateAttesterSlashing_CanFilter(t *testing.T) {
|
||||
d, err := r.currentForkDigest()
|
||||
assert.NoError(t, err)
|
||||
topic = r.addDigestToTopic(topic, d)
|
||||
au := util.AttestationUtil{}
|
||||
buf := new(bytes.Buffer)
|
||||
_, err = p.Encoding().EncodeGossip(buf, ðpb.AttesterSlashing{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{3},
|
||||
}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{3},
|
||||
}),
|
||||
})
|
||||
@@ -157,10 +155,10 @@ func TestValidateAttesterSlashing_CanFilter(t *testing.T) {
|
||||
|
||||
buf = new(bytes.Buffer)
|
||||
_, err = p.Encoding().EncodeGossip(buf, ðpb.AttesterSlashing{
|
||||
Attestation_1: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_1: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{4, 3},
|
||||
}),
|
||||
Attestation_2: au.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
Attestation_2: util.HydrateIndexedAttestation(ðpb.IndexedAttestation{
|
||||
AttestingIndices: []uint64{3, 4},
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -68,9 +68,9 @@ func (r *configset) add(c *BeaconChainConfig) error {
|
||||
}
|
||||
c.InitializeForkSchedule()
|
||||
for v := range c.ForkVersionSchedule {
|
||||
if n, exists := r.versionToName[v]; exists {
|
||||
return errors.Wrapf(errCollisionFork, "config name=%s conflicts with existing config named=%s", name, n)
|
||||
}
|
||||
//if n, exists := r.versionToName[v]; exists {
|
||||
// return errors.Wrapf(errCollisionFork, "config name=%s conflicts with existing config named=%s", name, n)
|
||||
//}
|
||||
r.versionToName[v] = name
|
||||
}
|
||||
r.nameToConfig[name] = c
|
||||
|
||||
4
deps.bzl
4
deps.bzl
@@ -3193,8 +3193,8 @@ def prysm_deps():
|
||||
go_repository(
|
||||
name = "com_github_prysmaticlabs_fastssz",
|
||||
importpath = "github.com/prysmaticlabs/fastssz",
|
||||
sum = "h1:Y3PcvUrnneMWLuypZpwPz8P70/DQsz6KgV9JveKpyZs=",
|
||||
version = "v0.0.0-20220628121656-93dfe28febab",
|
||||
sum = "h1:fat9avCPKKYZKe9KJq/VlF43/Nrxmn+sg59Ibe/pGs8=",
|
||||
version = "v0.0.0-20220624091035-af5440c5d1dc",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
|
||||
2
go.mod
2
go.mod
@@ -61,7 +61,7 @@ require (
|
||||
github.com/prometheus/client_golang v1.12.1
|
||||
github.com/prometheus/client_model v0.2.0
|
||||
github.com/prometheus/prom2json v1.3.0
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220624091035-af5440c5d1dc
|
||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
|
||||
github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c
|
||||
github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20211014160335-757fae4f38c6
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1192,8 +1192,8 @@ github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic=
|
||||
github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4=
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab h1:Y3PcvUrnneMWLuypZpwPz8P70/DQsz6KgV9JveKpyZs=
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg=
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220624091035-af5440c5d1dc h1:fat9avCPKKYZKe9KJq/VlF43/Nrxmn+sg59Ibe/pGs8=
|
||||
github.com/prysmaticlabs/fastssz v0.0.0-20220624091035-af5440c5d1dc/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg=
|
||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210108222456-8e92c3709aa0/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s=
|
||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw=
|
||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4=
|
||||
|
||||
@@ -17,43 +17,43 @@ func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
offset := int(508)
|
||||
|
||||
// Field (0) 'ParentHash'
|
||||
if size := len(e.ParentHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32)
|
||||
if len(e.ParentHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ParentHash...)
|
||||
|
||||
// Field (1) 'FeeRecipient'
|
||||
if size := len(e.FeeRecipient); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20)
|
||||
if len(e.FeeRecipient) != 20 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.FeeRecipient...)
|
||||
|
||||
// Field (2) 'StateRoot'
|
||||
if size := len(e.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(e.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.StateRoot...)
|
||||
|
||||
// Field (3) 'ReceiptsRoot'
|
||||
if size := len(e.ReceiptsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32)
|
||||
if len(e.ReceiptsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ReceiptsRoot...)
|
||||
|
||||
// Field (4) 'LogsBloom'
|
||||
if size := len(e.LogsBloom); size != 256 {
|
||||
err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256)
|
||||
if len(e.LogsBloom) != 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.LogsBloom...)
|
||||
|
||||
// Field (5) 'PrevRandao'
|
||||
if size := len(e.PrevRandao); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32)
|
||||
if len(e.PrevRandao) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.PrevRandao...)
|
||||
@@ -75,15 +75,15 @@ func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
offset += len(e.ExtraData)
|
||||
|
||||
// Field (11) 'BaseFeePerGas'
|
||||
if size := len(e.BaseFeePerGas); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32)
|
||||
if len(e.BaseFeePerGas) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.BaseFeePerGas...)
|
||||
|
||||
// Field (12) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.BlockHash...)
|
||||
@@ -96,15 +96,15 @@ func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (10) 'ExtraData'
|
||||
if size := len(e.ExtraData); size > 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32)
|
||||
if len(e.ExtraData) > 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ExtraData...)
|
||||
|
||||
// Field (13) 'Transactions'
|
||||
if size := len(e.Transactions); size > 1048576 {
|
||||
err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576)
|
||||
if len(e.Transactions) > 1048576 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -115,8 +115,8 @@ func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
}
|
||||
for ii := 0; ii < len(e.Transactions); ii++ {
|
||||
if size := len(e.Transactions[ii]); size > 1073741824 {
|
||||
err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824)
|
||||
if len(e.Transactions[ii]) > 1073741824 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.Transactions[ii]...)
|
||||
@@ -273,43 +273,43 @@ func (e *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'ParentHash'
|
||||
if size := len(e.ParentHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32)
|
||||
if len(e.ParentHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.ParentHash)
|
||||
|
||||
// Field (1) 'FeeRecipient'
|
||||
if size := len(e.FeeRecipient); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20)
|
||||
if len(e.FeeRecipient) != 20 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.FeeRecipient)
|
||||
|
||||
// Field (2) 'StateRoot'
|
||||
if size := len(e.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(e.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.StateRoot)
|
||||
|
||||
// Field (3) 'ReceiptsRoot'
|
||||
if size := len(e.ReceiptsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32)
|
||||
if len(e.ReceiptsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.ReceiptsRoot)
|
||||
|
||||
// Field (4) 'LogsBloom'
|
||||
if size := len(e.LogsBloom); size != 256 {
|
||||
err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256)
|
||||
if len(e.LogsBloom) != 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.LogsBloom)
|
||||
|
||||
// Field (5) 'PrevRandao'
|
||||
if size := len(e.PrevRandao); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32)
|
||||
if len(e.PrevRandao) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.PrevRandao)
|
||||
@@ -343,15 +343,15 @@ func (e *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (11) 'BaseFeePerGas'
|
||||
if size := len(e.BaseFeePerGas); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32)
|
||||
if len(e.BaseFeePerGas) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.BaseFeePerGas)
|
||||
|
||||
// Field (12) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.BlockHash)
|
||||
@@ -406,43 +406,43 @@ func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error
|
||||
offset := int(536)
|
||||
|
||||
// Field (0) 'ParentHash'
|
||||
if size := len(e.ParentHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32)
|
||||
if len(e.ParentHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ParentHash...)
|
||||
|
||||
// Field (1) 'FeeRecipient'
|
||||
if size := len(e.FeeRecipient); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20)
|
||||
if len(e.FeeRecipient) != 20 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.FeeRecipient...)
|
||||
|
||||
// Field (2) 'StateRoot'
|
||||
if size := len(e.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(e.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.StateRoot...)
|
||||
|
||||
// Field (3) 'ReceiptsRoot'
|
||||
if size := len(e.ReceiptsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32)
|
||||
if len(e.ReceiptsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ReceiptsRoot...)
|
||||
|
||||
// Field (4) 'LogsBloom'
|
||||
if size := len(e.LogsBloom); size != 256 {
|
||||
err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256)
|
||||
if len(e.LogsBloom) != 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.LogsBloom...)
|
||||
|
||||
// Field (5) 'PrevRandao'
|
||||
if size := len(e.PrevRandao); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32)
|
||||
if len(e.PrevRandao) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.PrevRandao...)
|
||||
@@ -464,29 +464,29 @@ func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error
|
||||
offset += len(e.ExtraData)
|
||||
|
||||
// Field (11) 'BaseFeePerGas'
|
||||
if size := len(e.BaseFeePerGas); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32)
|
||||
if len(e.BaseFeePerGas) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.BaseFeePerGas...)
|
||||
|
||||
// Field (12) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.BlockHash...)
|
||||
|
||||
// Field (13) 'TransactionsRoot'
|
||||
if size := len(e.TransactionsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32)
|
||||
if len(e.TransactionsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.TransactionsRoot...)
|
||||
|
||||
// Field (10) 'ExtraData'
|
||||
if size := len(e.ExtraData); size > 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32)
|
||||
if len(e.ExtraData) > 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.ExtraData...)
|
||||
@@ -614,43 +614,43 @@ func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'ParentHash'
|
||||
if size := len(e.ParentHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32)
|
||||
if len(e.ParentHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.ParentHash)
|
||||
|
||||
// Field (1) 'FeeRecipient'
|
||||
if size := len(e.FeeRecipient); size != 20 {
|
||||
err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20)
|
||||
if len(e.FeeRecipient) != 20 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.FeeRecipient)
|
||||
|
||||
// Field (2) 'StateRoot'
|
||||
if size := len(e.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(e.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.StateRoot)
|
||||
|
||||
// Field (3) 'ReceiptsRoot'
|
||||
if size := len(e.ReceiptsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32)
|
||||
if len(e.ReceiptsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.ReceiptsRoot)
|
||||
|
||||
// Field (4) 'LogsBloom'
|
||||
if size := len(e.LogsBloom); size != 256 {
|
||||
err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256)
|
||||
if len(e.LogsBloom) != 256 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.LogsBloom)
|
||||
|
||||
// Field (5) 'PrevRandao'
|
||||
if size := len(e.PrevRandao); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32)
|
||||
if len(e.PrevRandao) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.PrevRandao)
|
||||
@@ -684,22 +684,22 @@ func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (11) 'BaseFeePerGas'
|
||||
if size := len(e.BaseFeePerGas); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32)
|
||||
if len(e.BaseFeePerGas) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.BaseFeePerGas)
|
||||
|
||||
// Field (12) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.BlockHash)
|
||||
|
||||
// Field (13) 'TransactionsRoot'
|
||||
if size := len(e.TransactionsRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32)
|
||||
if len(e.TransactionsRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.TransactionsRoot)
|
||||
|
||||
@@ -30,15 +30,15 @@ func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Signature'
|
||||
if size := len(a.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(a.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, a.Signature...)
|
||||
|
||||
// Field (0) 'AggregationBits'
|
||||
if size := len(a.AggregationBits); size > 2048 {
|
||||
err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048)
|
||||
if len(a.AggregationBits) > 2048 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, a.AggregationBits...)
|
||||
@@ -126,8 +126,8 @@ func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Signature'
|
||||
if size := len(a.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(a.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(a.Signature)
|
||||
@@ -161,8 +161,8 @@ func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err
|
||||
offset += a.Aggregate.SizeSSZ()
|
||||
|
||||
// Field (2) 'SelectionProof'
|
||||
if size := len(a.SelectionProof); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96)
|
||||
if len(a.SelectionProof) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, a.SelectionProof...)
|
||||
@@ -248,8 +248,8 @@ func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err err
|
||||
}
|
||||
|
||||
// Field (2) 'SelectionProof'
|
||||
if size := len(a.SelectionProof); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96)
|
||||
if len(a.SelectionProof) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(a.SelectionProof)
|
||||
@@ -280,8 +280,8 @@ func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byt
|
||||
offset += s.Message.SizeSSZ()
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -361,8 +361,8 @@ func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (e
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -391,8 +391,8 @@ func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, uint64(a.Index))
|
||||
|
||||
// Field (2) 'BeaconBlockRoot'
|
||||
if size := len(a.BeaconBlockRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32)
|
||||
if len(a.BeaconBlockRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, a.BeaconBlockRoot...)
|
||||
@@ -477,8 +477,8 @@ func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(a.Index))
|
||||
|
||||
// Field (2) 'BeaconBlockRoot'
|
||||
if size := len(a.BeaconBlockRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32)
|
||||
if len(a.BeaconBlockRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(a.BeaconBlockRoot)
|
||||
@@ -514,8 +514,8 @@ func (c *Checkpoint) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, uint64(c.Epoch))
|
||||
|
||||
// Field (1) 'Root'
|
||||
if size := len(c.Root); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Root", size, 32)
|
||||
if len(c.Root) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, c.Root...)
|
||||
@@ -562,8 +562,8 @@ func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(c.Epoch))
|
||||
|
||||
// Field (1) 'Root'
|
||||
if size := len(c.Root); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Root", size, 32)
|
||||
if len(c.Root) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(c.Root)
|
||||
@@ -593,15 +593,15 @@ func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.ParentRoot...)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.StateRoot...)
|
||||
@@ -701,15 +701,15 @@ func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.ParentRoot)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.StateRoot)
|
||||
@@ -745,8 +745,8 @@ func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
offset += s.Block.SizeSSZ()
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -826,8 +826,8 @@ func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -851,8 +851,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
offset := int(220)
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.RandaoReveal...)
|
||||
@@ -866,8 +866,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.Graffiti...)
|
||||
@@ -899,8 +899,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
offset += len(b.VoluntaryExits) * 112
|
||||
|
||||
// Field (3) 'ProposerSlashings'
|
||||
if size := len(b.ProposerSlashings); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16)
|
||||
if len(b.ProposerSlashings) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
||||
@@ -910,8 +910,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (4) 'AttesterSlashings'
|
||||
if size := len(b.AttesterSlashings); size > 2 {
|
||||
err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2)
|
||||
if len(b.AttesterSlashings) > 2 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -928,8 +928,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (5) 'Attestations'
|
||||
if size := len(b.Attestations); size > 128 {
|
||||
err = ssz.ErrListTooBigFn("--.Attestations", size, 128)
|
||||
if len(b.Attestations) > 128 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -946,8 +946,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (6) 'Deposits'
|
||||
if size := len(b.Deposits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.Deposits", size, 16)
|
||||
if len(b.Deposits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.Deposits); ii++ {
|
||||
@@ -957,8 +957,8 @@ func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (7) 'VoluntaryExits'
|
||||
if size := len(b.VoluntaryExits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16)
|
||||
if len(b.VoluntaryExits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
||||
@@ -1168,8 +1168,8 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.RandaoReveal)
|
||||
@@ -1180,8 +1180,8 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.Graffiti)
|
||||
@@ -1524,13 +1524,13 @@ func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'Proof'
|
||||
if size := len(d.Proof); size != 33 {
|
||||
err = ssz.ErrVectorLengthFn("--.Proof", size, 33)
|
||||
if len(d.Proof) != 33 {
|
||||
err = ssz.ErrVectorLength
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < 33; ii++ {
|
||||
if size := len(d.Proof[ii]); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Proof[ii]", size, 32)
|
||||
if len(d.Proof[ii]) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.Proof[ii]...)
|
||||
@@ -1592,8 +1592,8 @@ func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
|
||||
// Field (0) 'Proof'
|
||||
{
|
||||
if size := len(d.Proof); size != 33 {
|
||||
err = ssz.ErrVectorLengthFn("--.Proof", size, 33)
|
||||
if len(d.Proof) != 33 {
|
||||
err = ssz.ErrVectorLength
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
@@ -1707,8 +1707,8 @@ func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -1762,8 +1762,8 @@ func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -1786,8 +1786,8 @@ func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'DepositRoot'
|
||||
if size := len(e.DepositRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32)
|
||||
if len(e.DepositRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.DepositRoot...)
|
||||
@@ -1796,8 +1796,8 @@ func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, e.DepositCount)
|
||||
|
||||
// Field (2) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.BlockHash...)
|
||||
@@ -1847,8 +1847,8 @@ func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'DepositRoot'
|
||||
if size := len(e.DepositRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32)
|
||||
if len(e.DepositRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.DepositRoot)
|
||||
@@ -1857,8 +1857,8 @@ func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(e.DepositCount)
|
||||
|
||||
// Field (2) 'BlockHash'
|
||||
if size := len(e.BlockHash); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32)
|
||||
if len(e.BlockHash) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(e.BlockHash)
|
||||
@@ -1887,22 +1887,22 @@ func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.ParentRoot...)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.StateRoot...)
|
||||
|
||||
// Field (4) 'BodyRoot'
|
||||
if size := len(b.BodyRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32)
|
||||
if len(b.BodyRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.BodyRoot...)
|
||||
@@ -1967,22 +1967,22 @@ func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.ParentRoot)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.StateRoot)
|
||||
|
||||
// Field (4) 'BodyRoot'
|
||||
if size := len(b.BodyRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32)
|
||||
if len(b.BodyRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.BodyRoot)
|
||||
@@ -2013,8 +2013,8 @@ func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err erro
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -2068,8 +2068,8 @@ func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -2105,15 +2105,15 @@ func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Signature'
|
||||
if size := len(i.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(i.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, i.Signature...)
|
||||
|
||||
// Field (0) 'AttestingIndices'
|
||||
if size := len(i.AttestingIndices); size > 2048 {
|
||||
err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048)
|
||||
if len(i.AttestingIndices) > 2048 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(i.AttestingIndices); ii++ {
|
||||
@@ -2193,8 +2193,8 @@ func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
|
||||
// Field (0) 'AttestingIndices'
|
||||
{
|
||||
if size := len(i.AttestingIndices); size > 2048 {
|
||||
err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048)
|
||||
if len(i.AttestingIndices) > 2048 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
@@ -2217,8 +2217,8 @@ func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Signature'
|
||||
if size := len(i.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(i.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(i.Signature)
|
||||
@@ -2241,15 +2241,15 @@ func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'SyncCommitteeBits'
|
||||
if size := len(s.SyncCommitteeBits); size != 64 {
|
||||
err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64)
|
||||
if len(s.SyncCommitteeBits) != 64 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.SyncCommitteeBits...)
|
||||
|
||||
// Field (1) 'SyncCommitteeSignature'
|
||||
if size := len(s.SyncCommitteeSignature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96)
|
||||
if len(s.SyncCommitteeSignature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.SyncCommitteeSignature...)
|
||||
@@ -2296,15 +2296,15 @@ func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'SyncCommitteeBits'
|
||||
if size := len(s.SyncCommitteeBits); size != 64 {
|
||||
err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64)
|
||||
if len(s.SyncCommitteeBits) != 64 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.SyncCommitteeBits)
|
||||
|
||||
// Field (1) 'SyncCommitteeSignature'
|
||||
if size := len(s.SyncCommitteeSignature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96)
|
||||
if len(s.SyncCommitteeSignature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.SyncCommitteeSignature)
|
||||
@@ -2327,15 +2327,15 @@ func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if size := len(d.Pubkey); size != 48 {
|
||||
err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48)
|
||||
if len(d.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.Pubkey...)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if size := len(d.WithdrawalCredentials); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32)
|
||||
if len(d.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.WithdrawalCredentials...)
|
||||
@@ -2344,8 +2344,8 @@ func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, d.Amount)
|
||||
|
||||
// Field (3) 'Signature'
|
||||
if size := len(d.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(d.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.Signature...)
|
||||
@@ -2401,15 +2401,15 @@ func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if size := len(d.Pubkey); size != 48 {
|
||||
err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48)
|
||||
if len(d.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(d.Pubkey)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if size := len(d.WithdrawalCredentials); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32)
|
||||
if len(d.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(d.WithdrawalCredentials)
|
||||
@@ -2418,8 +2418,8 @@ func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(d.Amount)
|
||||
|
||||
// Field (3) 'Signature'
|
||||
if size := len(d.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(d.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(d.Signature)
|
||||
@@ -2442,15 +2442,15 @@ func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if size := len(v.Pubkey); size != 48 {
|
||||
err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48)
|
||||
if len(v.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, v.Pubkey...)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if size := len(v.WithdrawalCredentials); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32)
|
||||
if len(v.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, v.WithdrawalCredentials...)
|
||||
@@ -2533,15 +2533,15 @@ func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if size := len(v.Pubkey); size != 48 {
|
||||
err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48)
|
||||
if len(v.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(v.Pubkey)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if size := len(v.WithdrawalCredentials); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32)
|
||||
if len(v.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(v.WithdrawalCredentials)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 041d5d528e07bf99188c39100dc83a4e6ba1f1d4cd190c46fcf27af4ca367fda
|
||||
// Hash: 16637c49444f2c3a90bcc4587dfbc26b39f45c26129de7d43fea32a2bcf8441e
|
||||
package eth
|
||||
|
||||
import (
|
||||
@@ -27,8 +27,8 @@ func (s *SignedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err e
|
||||
offset += s.Message.SizeSSZ()
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -108,8 +108,8 @@ func (s *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -140,8 +140,8 @@ func (s *SignedBlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte
|
||||
offset += s.Message.SizeSSZ()
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -221,8 +221,8 @@ func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (er
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -253,8 +253,8 @@ func (s *SignedBeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err erro
|
||||
offset += s.Message.SizeSSZ()
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, s.Signature...)
|
||||
@@ -334,8 +334,8 @@ func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (1) 'Signature'
|
||||
if size := len(s.Signature); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
|
||||
if len(s.Signature) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(s.Signature)
|
||||
@@ -365,15 +365,15 @@ func (b *BeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.ParentRoot...)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.StateRoot...)
|
||||
@@ -473,15 +473,15 @@ func (b *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.ParentRoot)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.StateRoot)
|
||||
@@ -516,15 +516,15 @@ func (b *BlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.ParentRoot...)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.StateRoot...)
|
||||
@@ -624,15 +624,15 @@ func (b *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err erro
|
||||
hh.PutUint64(uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.ParentRoot)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.StateRoot)
|
||||
@@ -667,15 +667,15 @@ func (b *BeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.ParentRoot...)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.StateRoot...)
|
||||
@@ -775,15 +775,15 @@ func (b *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.PutUint64(uint64(b.ProposerIndex))
|
||||
|
||||
// Field (2) 'ParentRoot'
|
||||
if size := len(b.ParentRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32)
|
||||
if len(b.ParentRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.ParentRoot)
|
||||
|
||||
// Field (3) 'StateRoot'
|
||||
if size := len(b.StateRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32)
|
||||
if len(b.StateRoot) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.StateRoot)
|
||||
@@ -812,8 +812,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
offset := int(384)
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.RandaoReveal...)
|
||||
@@ -827,8 +827,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.Graffiti...)
|
||||
@@ -875,8 +875,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
offset += b.ExecutionPayload.SizeSSZ()
|
||||
|
||||
// Field (3) 'ProposerSlashings'
|
||||
if size := len(b.ProposerSlashings); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16)
|
||||
if len(b.ProposerSlashings) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
||||
@@ -886,8 +886,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
}
|
||||
|
||||
// Field (4) 'AttesterSlashings'
|
||||
if size := len(b.AttesterSlashings); size > 2 {
|
||||
err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2)
|
||||
if len(b.AttesterSlashings) > 2 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -904,8 +904,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
}
|
||||
|
||||
// Field (5) 'Attestations'
|
||||
if size := len(b.Attestations); size > 128 {
|
||||
err = ssz.ErrListTooBigFn("--.Attestations", size, 128)
|
||||
if len(b.Attestations) > 128 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -922,8 +922,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
}
|
||||
|
||||
// Field (6) 'Deposits'
|
||||
if size := len(b.Deposits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.Deposits", size, 16)
|
||||
if len(b.Deposits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.Deposits); ii++ {
|
||||
@@ -933,8 +933,8 @@ func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err err
|
||||
}
|
||||
|
||||
// Field (7) 'VoluntaryExits'
|
||||
if size := len(b.VoluntaryExits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16)
|
||||
if len(b.VoluntaryExits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
||||
@@ -1179,8 +1179,8 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.RandaoReveal)
|
||||
@@ -1191,8 +1191,8 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.Graffiti)
|
||||
@@ -1326,8 +1326,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
offset := int(384)
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.RandaoReveal...)
|
||||
@@ -1341,8 +1341,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.Graffiti...)
|
||||
@@ -1389,8 +1389,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
offset += b.ExecutionPayloadHeader.SizeSSZ()
|
||||
|
||||
// Field (3) 'ProposerSlashings'
|
||||
if size := len(b.ProposerSlashings); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16)
|
||||
if len(b.ProposerSlashings) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
||||
@@ -1400,8 +1400,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
}
|
||||
|
||||
// Field (4) 'AttesterSlashings'
|
||||
if size := len(b.AttesterSlashings); size > 2 {
|
||||
err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2)
|
||||
if len(b.AttesterSlashings) > 2 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -1418,8 +1418,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
}
|
||||
|
||||
// Field (5) 'Attestations'
|
||||
if size := len(b.Attestations); size > 128 {
|
||||
err = ssz.ErrListTooBigFn("--.Attestations", size, 128)
|
||||
if len(b.Attestations) > 128 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -1436,8 +1436,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
}
|
||||
|
||||
// Field (6) 'Deposits'
|
||||
if size := len(b.Deposits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.Deposits", size, 16)
|
||||
if len(b.Deposits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.Deposits); ii++ {
|
||||
@@ -1447,8 +1447,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte,
|
||||
}
|
||||
|
||||
// Field (7) 'VoluntaryExits'
|
||||
if size := len(b.VoluntaryExits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16)
|
||||
if len(b.VoluntaryExits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
||||
@@ -1693,8 +1693,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.RandaoReveal)
|
||||
@@ -1705,8 +1705,8 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.Graffiti)
|
||||
@@ -1840,8 +1840,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
offset := int(380)
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.RandaoReveal...)
|
||||
@@ -1855,8 +1855,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, b.Graffiti...)
|
||||
@@ -1896,8 +1896,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (3) 'ProposerSlashings'
|
||||
if size := len(b.ProposerSlashings); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16)
|
||||
if len(b.ProposerSlashings) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
||||
@@ -1907,8 +1907,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (4) 'AttesterSlashings'
|
||||
if size := len(b.AttesterSlashings); size > 2 {
|
||||
err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2)
|
||||
if len(b.AttesterSlashings) > 2 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -1925,8 +1925,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (5) 'Attestations'
|
||||
if size := len(b.Attestations); size > 128 {
|
||||
err = ssz.ErrListTooBigFn("--.Attestations", size, 128)
|
||||
if len(b.Attestations) > 128 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
{
|
||||
@@ -1943,8 +1943,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (6) 'Deposits'
|
||||
if size := len(b.Deposits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.Deposits", size, 16)
|
||||
if len(b.Deposits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.Deposits); ii++ {
|
||||
@@ -1954,8 +1954,8 @@ func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error)
|
||||
}
|
||||
|
||||
// Field (7) 'VoluntaryExits'
|
||||
if size := len(b.VoluntaryExits); size > 16 {
|
||||
err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16)
|
||||
if len(b.VoluntaryExits) > 16 {
|
||||
err = ssz.ErrListTooBig
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
||||
@@ -2173,8 +2173,8 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'RandaoReveal'
|
||||
if size := len(b.RandaoReveal); size != 96 {
|
||||
err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96)
|
||||
if len(b.RandaoReveal) != 96 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.RandaoReveal)
|
||||
@@ -2185,8 +2185,8 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
}
|
||||
|
||||
// Field (2) 'Graffiti'
|
||||
if size := len(b.Graffiti); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32)
|
||||
if len(b.Graffiti) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(b.Graffiti)
|
||||
|
||||
@@ -72,7 +72,7 @@ func Test_BlockIfaceToV1BlockHeader(t *testing.T) {
|
||||
|
||||
func Test_V1Alpha1AggregateAttAndProofToV1(t *testing.T) {
|
||||
proof := [32]byte{1}
|
||||
att := util.NewAttestationUtil().HydrateAttestation(ðpbalpha.Attestation{
|
||||
att := util.HydrateAttestation(ðpbalpha.Attestation{
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 5,
|
||||
},
|
||||
@@ -428,7 +428,7 @@ func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
|
||||
v1Att := ðpbv1.SignedAggregateAttestationAndProof{
|
||||
Message: ðpbv1.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 1,
|
||||
Aggregate: util.NewAttestationUtil().HydrateV1Attestation(ðpbv1.Attestation{}),
|
||||
Aggregate: util.HydrateV1Attestation(ðpbv1.Attestation{}),
|
||||
SelectionProof: selectionProof,
|
||||
},
|
||||
Signature: signature,
|
||||
@@ -443,7 +443,7 @@ func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_V1AttestationToV1Alpha1(t *testing.T) {
|
||||
v1Att := util.NewAttestationUtil().HydrateV1Attestation(ðpbv1.Attestation{})
|
||||
v1Att := util.HydrateV1Attestation(ðpbv1.Attestation{})
|
||||
v1Alpha1Att := V1AttToV1Alpha1(v1Att)
|
||||
|
||||
v1Root, err := v1Att.HashTreeRoot()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -352,7 +352,7 @@ func GenerateFullBlockAltair(
|
||||
numToGen = conf.NumAttestations
|
||||
var atts []*ethpb.Attestation
|
||||
if numToGen > 0 {
|
||||
atts, err = NewAttestationUtil().GenerateAttestations(bState, privs, numToGen, slot, false)
|
||||
atts, err = GenerateAttestations(bState, privs, numToGen, slot, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed generating %d attestations:", numToGen)
|
||||
}
|
||||
|
||||
@@ -25,16 +25,8 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// AttestationUtil is an empty struct used as the receiver for all attestation utility methods.
|
||||
type AttestationUtil struct{}
|
||||
|
||||
// NewAttestationUtil returns a set of attestation utilities.
|
||||
func NewAttestationUtil() *AttestationUtil {
|
||||
return &AttestationUtil{}
|
||||
}
|
||||
|
||||
// NewAttestation creates an attestation block with minimum marshalable fields.
|
||||
func (u *AttestationUtil) NewAttestation() *ethpb.Attestation {
|
||||
func NewAttestation() *ethpb.Attestation {
|
||||
return ðpb.Attestation{
|
||||
AggregationBits: bitfield.Bitlist{0b1101},
|
||||
Data: ðpb.AttestationData{
|
||||
@@ -57,7 +49,7 @@ func (u *AttestationUtil) NewAttestation() *ethpb.Attestation {
|
||||
// for the same data with their aggregation bits split uniformly.
|
||||
//
|
||||
// If you request 4 attestations, but there are 8 committees, you will get 4 fully aggregated attestations.
|
||||
func (u *AttestationUtil) GenerateAttestations(
|
||||
func GenerateAttestations(
|
||||
bState state.BeaconState, privs []bls.SecretKey, numToGen uint64, slot types.Slot, randomRoot bool,
|
||||
) ([]*ethpb.Attestation, error) {
|
||||
var attestations []*ethpb.Attestation
|
||||
@@ -213,7 +205,7 @@ func (u *AttestationUtil) GenerateAttestations(
|
||||
|
||||
// HydrateAttestation hydrates an attestation object with correct field length sizes
|
||||
// to comply with fssz marshalling and unmarshalling rules.
|
||||
func (u *AttestationUtil) HydrateAttestation(a *ethpb.Attestation) *ethpb.Attestation {
|
||||
func HydrateAttestation(a *ethpb.Attestation) *ethpb.Attestation {
|
||||
if a.Signature == nil {
|
||||
a.Signature = make([]byte, 96)
|
||||
}
|
||||
@@ -223,13 +215,13 @@ func (u *AttestationUtil) HydrateAttestation(a *ethpb.Attestation) *ethpb.Attest
|
||||
if a.Data == nil {
|
||||
a.Data = ðpb.AttestationData{}
|
||||
}
|
||||
a.Data = u.HydrateAttestationData(a.Data)
|
||||
a.Data = HydrateAttestationData(a.Data)
|
||||
return a
|
||||
}
|
||||
|
||||
// HydrateV1Attestation hydrates a v1 attestation object with correct field length sizes
|
||||
// to comply with fssz marshalling and unmarshalling rules.
|
||||
func (u *AttestationUtil) HydrateV1Attestation(a *attv1.Attestation) *attv1.Attestation {
|
||||
func HydrateV1Attestation(a *attv1.Attestation) *attv1.Attestation {
|
||||
if a.Signature == nil {
|
||||
a.Signature = make([]byte, 96)
|
||||
}
|
||||
@@ -239,13 +231,13 @@ func (u *AttestationUtil) HydrateV1Attestation(a *attv1.Attestation) *attv1.Atte
|
||||
if a.Data == nil {
|
||||
a.Data = &attv1.AttestationData{}
|
||||
}
|
||||
a.Data = u.HydrateV1AttestationData(a.Data)
|
||||
a.Data = HydrateV1AttestationData(a.Data)
|
||||
return a
|
||||
}
|
||||
|
||||
// HydrateAttestationData hydrates an attestation data object with correct field length sizes
|
||||
// to comply with fssz marshalling and unmarshalling rules.
|
||||
func (u *AttestationUtil) HydrateAttestationData(d *ethpb.AttestationData) *ethpb.AttestationData {
|
||||
func HydrateAttestationData(d *ethpb.AttestationData) *ethpb.AttestationData {
|
||||
if d.BeaconBlockRoot == nil {
|
||||
d.BeaconBlockRoot = make([]byte, fieldparams.RootLength)
|
||||
}
|
||||
@@ -266,7 +258,7 @@ func (u *AttestationUtil) HydrateAttestationData(d *ethpb.AttestationData) *ethp
|
||||
|
||||
// HydrateV1AttestationData hydrates a v1 attestation data object with correct field length sizes
|
||||
// to comply with fssz marshalling and unmarshalling rules.
|
||||
func (u *AttestationUtil) HydrateV1AttestationData(d *attv1.AttestationData) *attv1.AttestationData {
|
||||
func HydrateV1AttestationData(d *attv1.AttestationData) *attv1.AttestationData {
|
||||
if d.BeaconBlockRoot == nil {
|
||||
d.BeaconBlockRoot = make([]byte, fieldparams.RootLength)
|
||||
}
|
||||
@@ -287,13 +279,13 @@ func (u *AttestationUtil) HydrateV1AttestationData(d *attv1.AttestationData) *at
|
||||
|
||||
// HydrateIndexedAttestation hydrates an indexed attestation with correct field length sizes
|
||||
// to comply with fssz marshalling and unmarshalling rules.
|
||||
func (u *AttestationUtil) HydrateIndexedAttestation(a *ethpb.IndexedAttestation) *ethpb.IndexedAttestation {
|
||||
func HydrateIndexedAttestation(a *ethpb.IndexedAttestation) *ethpb.IndexedAttestation {
|
||||
if a.Signature == nil {
|
||||
a.Signature = make([]byte, 96)
|
||||
}
|
||||
if a.Data == nil {
|
||||
a.Data = ðpb.AttestationData{}
|
||||
}
|
||||
a.Data = u.HydrateAttestationData(a.Data)
|
||||
a.Data = HydrateAttestationData(a.Data)
|
||||
return a
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
)
|
||||
|
||||
func TestHydrateAttestation(t *testing.T) {
|
||||
a := NewAttestationUtil().HydrateAttestation(ðpb.Attestation{})
|
||||
a := HydrateAttestation(ðpb.Attestation{})
|
||||
_, err := a.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, a.Signature, make([]byte, fieldparams.BLSSignatureLength))
|
||||
}
|
||||
|
||||
func TestHydrateAttestationData(t *testing.T) {
|
||||
d := NewAttestationUtil().HydrateAttestationData(ðpb.AttestationData{})
|
||||
d := HydrateAttestationData(ðpb.AttestationData{})
|
||||
_, err := d.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, fieldparams.RootLength))
|
||||
@@ -27,14 +27,14 @@ func TestHydrateAttestationData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHydrateV1Attestation(t *testing.T) {
|
||||
a := NewAttestationUtil().HydrateV1Attestation(&v1.Attestation{})
|
||||
a := HydrateV1Attestation(&v1.Attestation{})
|
||||
_, err := a.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, a.Signature, make([]byte, fieldparams.BLSSignatureLength))
|
||||
}
|
||||
|
||||
func TestHydrateV1AttestationData(t *testing.T) {
|
||||
d := NewAttestationUtil().HydrateV1AttestationData(&v1.AttestationData{})
|
||||
d := HydrateV1AttestationData(&v1.AttestationData{})
|
||||
_, err := d.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, fieldparams.RootLength))
|
||||
@@ -44,7 +44,7 @@ func TestHydrateV1AttestationData(t *testing.T) {
|
||||
|
||||
func TestHydrateIndexedAttestation(t *testing.T) {
|
||||
a := ðpb.IndexedAttestation{}
|
||||
a = NewAttestationUtil().HydrateIndexedAttestation(a)
|
||||
a = HydrateIndexedAttestation(a)
|
||||
_, err := a.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
_, err = a.Data.HashTreeRoot()
|
||||
@@ -53,6 +53,6 @@ func TestHydrateIndexedAttestation(t *testing.T) {
|
||||
|
||||
func TestGenerateAttestations_EpochBoundary(t *testing.T) {
|
||||
gs, pk := DeterministicGenesisState(t, 32)
|
||||
_, err := NewAttestationUtil().GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false)
|
||||
_, err := GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func GenerateFullBlock(
|
||||
numToGen = conf.NumAttestations
|
||||
var atts []*ethpb.Attestation
|
||||
if numToGen > 0 {
|
||||
atts, err = NewAttestationUtil().GenerateAttestations(bState, privs, numToGen, slot, false)
|
||||
atts, err = GenerateAttestations(bState, privs, numToGen, slot, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed generating %d attestations:", numToGen)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
// > 50 Untestable code, very high risk
|
||||
//
|
||||
// This threshold should be lowered to 50 over time.
|
||||
const over = 100
|
||||
const over = 200
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspectResult, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
|
||||
@@ -122,7 +122,7 @@ func generateMarshalledFullStateAndBlock() error {
|
||||
|
||||
var atts []*ethpb.Attestation
|
||||
for i := slotOffset + 1; i < slotsPerEpoch+slotOffset; i++ {
|
||||
attsForSlot, err := util.NewAttestationUtil().GenerateAttestations(beaconState, privs, attConfig.NumAttestations, i, false)
|
||||
attsForSlot, err := util.GenerateAttestations(beaconState, privs, attConfig.NumAttestations, i, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestSubmitAggregateAndProof_SignFails(t *testing.T) {
|
||||
).Return(ðpb.AggregateSelectionResponse{
|
||||
AggregateAndProof: ðpb.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 0,
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
Aggregate: util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: make([]byte, 1),
|
||||
}),
|
||||
SelectionProof: make([]byte, 96),
|
||||
@@ -96,7 +96,7 @@ func TestSubmitAggregateAndProof_Ok(t *testing.T) {
|
||||
).Return(ðpb.AggregateSelectionResponse{
|
||||
AggregateAndProof: ðpb.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 0,
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
Aggregate: util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: make([]byte, 1),
|
||||
}),
|
||||
SelectionProof: make([]byte, 96),
|
||||
@@ -159,7 +159,7 @@ func TestAggregateAndProofSignature_CanSignValidSignature(t *testing.T) {
|
||||
|
||||
agg := ðpb.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 0,
|
||||
Aggregate: util.NewAttestationUtil().HydrateAttestation(ðpb.Attestation{
|
||||
Aggregate: util.HydrateAttestation(ðpb.Attestation{
|
||||
AggregationBits: bitfield.NewBitlist(1),
|
||||
}),
|
||||
SelectionProof: make([]byte, 96),
|
||||
|
||||
@@ -461,7 +461,7 @@ func TestSignAttestation(t *testing.T) {
|
||||
DomainData(gomock.Any(), gomock.Any()).
|
||||
Return(ðpb.DomainResponse{SignatureDomain: attesterDomain}, nil)
|
||||
ctx := context.Background()
|
||||
att := util.NewAttestationUtil().NewAttestation()
|
||||
att := util.NewAttestation()
|
||||
att.Data.Source.Epoch = 100
|
||||
att.Data.Target.Epoch = 200
|
||||
att.Data.Slot = 999
|
||||
|
||||
@@ -89,6 +89,18 @@ func run(ctx context.Context, v iface.Validator) {
|
||||
}
|
||||
}
|
||||
case slot := <-v.NextSlot():
|
||||
m, err := v.Keymanager()
|
||||
if err != nil {
|
||||
log.WithError(err)
|
||||
continue
|
||||
}
|
||||
pks, err := m.FetchValidatingPublicKeys(ctx)
|
||||
if err != nil {
|
||||
log.WithError(err)
|
||||
continue
|
||||
}
|
||||
v.ProposeBlock(ctx, slot, pks[0])
|
||||
|
||||
span.AddAttributes(trace.Int64Attribute("slot", int64(slot))) // lint:ignore uintcast -- This conversion is OK for tracing.
|
||||
reloadRemoteKeys(ctx, km)
|
||||
allExited, err := v.AllValidatorsAreExited(ctx)
|
||||
|
||||
@@ -386,7 +386,7 @@ func (v *validator) checkAndLogValidatorStatus(statuses []*validatorStatus) bool
|
||||
}
|
||||
switch status.status.Status {
|
||||
case ethpb.ValidatorStatus_UNKNOWN_STATUS:
|
||||
log.Info("Waiting for deposit to be observed by beacon node")
|
||||
validatorActivated = true
|
||||
case ethpb.ValidatorStatus_DEPOSITED:
|
||||
if status.status.PositionInActivationQueue != 0 {
|
||||
log.WithField(
|
||||
@@ -971,6 +971,7 @@ func (v *validator) PushProposerSettings(ctx context.Context, km keymanager.IKey
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(feeRecipients) == 0 {
|
||||
log.Warnf("no valid validator indices were found, prepare beacon proposer request fee recipients array is empty")
|
||||
return nil
|
||||
@@ -1031,14 +1032,15 @@ func (v *validator) buildProposerSettingsRequests(ctx context.Context, pubkeys [
|
||||
FeeRecipient: feeRecipient[:],
|
||||
})
|
||||
}
|
||||
|
||||
registerValidatorRequests = append(registerValidatorRequests, ðpb.ValidatorRegistrationV1{
|
||||
FeeRecipient: feeRecipient[:],
|
||||
FeeRecipient: bytesutil.SafeCopyBytes(feeRecipient[:]),
|
||||
GasLimit: gasLimit,
|
||||
Timestamp: uint64(time.Now().UTC().Unix()),
|
||||
Pubkey: pubkeys[i][:],
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return validatorToFeeRecipients, registerValidatorRequests, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user