Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fastssz #6760

Merged
merged 80 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
16ceea5
Update fastssz
prestonvanloon Jul 29, 2020
9168900
Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
prestonvanloon Jul 29, 2020
c66eea8
fmt
prestonvanloon Jul 29, 2020
eb4603b
gaz
prestonvanloon Jul 29, 2020
64df3df
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
388650a
goimports
prestonvanloon Jul 29, 2020
6ffd821
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
f819926
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
aa6e365
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
3e37b5a
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
dfc58e5
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Jul 29, 2020
5ed1dfe
Fix
prestonvanloon Jul 29, 2020
e7bd70f
fix ethereumapis
prestonvanloon Jul 29, 2020
77a0f26
fix again
prestonvanloon Jul 29, 2020
6ce947f
kafka
prestonvanloon Jul 29, 2020
1f3872d
fix gen file
prestonvanloon Jul 29, 2020
42d8e38
fix compute signing root
prestonvanloon Jul 29, 2020
f1b857e
gofmt
prestonvanloon Jul 29, 2020
628d621
checkpoint progress
prestonvanloon Jul 29, 2020
f94bb7b
progress
prestonvanloon Jul 29, 2020
dc17b7a
checkpoint
prestonvanloon Jul 29, 2020
08115fc
progress
prestonvanloon Jul 29, 2020
f1a6f80
Fix build
prestonvanloon Jul 29, 2020
16ac9e3
checkpoint
prestonvanloon Jul 29, 2020
36c2e87
helpers
prestonvanloon Jul 30, 2020
686289a
Another test fixed
prestonvanloon Jul 30, 2020
255d577
gaz
prestonvanloon Jul 30, 2020
5fd324e
another test fix
prestonvanloon Jul 30, 2020
2f96680
gofmt
prestonvanloon Jul 30, 2020
edf9e80
some fixes
prestonvanloon Jul 30, 2020
ab9a266
Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
prestonvanloon Aug 6, 2020
d2ca974
fix one test
prestonvanloon Aug 6, 2020
3105607
Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
prestonvanloon Aug 8, 2020
3524f85
fill empty checkpoint roots
prestonvanloon Aug 8, 2020
c3b72d0
more padding
prestonvanloon Aug 8, 2020
ca23800
more padding
prestonvanloon Aug 8, 2020
641a1f8
Fix //beacon-chain/rpc/debug:go_default_test
prestonvanloon Aug 9, 2020
313dc58
fix //beacon-chain/core/state:go_default_test
prestonvanloon Aug 9, 2020
da45a60
fix //beacon-chain/core/state:go_default_test
prestonvanloon Aug 9, 2020
17282e3
fix some htr errors
prestonvanloon Aug 9, 2020
c06da27
fix //slasher/rpc:go_default_test
prestonvanloon Aug 9, 2020
c6938fc
Progress on //beacon-chain/core/blocks:go_default_test
prestonvanloon Aug 9, 2020
7476df7
Progress on //beacon-chain/core/blocks:go_default_test
prestonvanloon Aug 9, 2020
bfe08d2
Progress on //beacon-chain/core/blocks:go_default_test
prestonvanloon Aug 9, 2020
9eebd93
fix //slasher/db/kv:go_default_test
prestonvanloon Aug 9, 2020
ef36945
progress
prestonvanloon Aug 9, 2020
395f992
fix //beacon-chain/sync/initial-sync:go_raceon_test
prestonvanloon Aug 9, 2020
41c2bef
gofmt and gaz
prestonvanloon Aug 9, 2020
af65a9c
fix one more test, taking a break
prestonvanloon Aug 9, 2020
f353bc6
Fix //beacon-chain/core/blocks:go_default_test
prestonvanloon Aug 9, 2020
a6cfbe0
Complete beacon-chain/powchain
0xKiwi Aug 9, 2020
649b82e
Do most of beacon-chain/rpc/beacon/
0xKiwi Aug 9, 2020
b5c6eac
Do most of beacon-chain/blockchain
0xKiwi Aug 9, 2020
e19c2bd
fix //beacon-chain/operations/attestations/kv:go_default_test
prestonvanloon Aug 9, 2020
3c8a3fa
Fix //beacon-chain/cache/depositcache:go_default_test
prestonvanloon Aug 12, 2020
38b9c01
Fix //slasher/detection:go_default_test
prestonvanloon Aug 12, 2020
74b74ab
Progress
prestonvanloon Aug 13, 2020
81be244
fix //beacon-chain/rpc/validator:go_default_test
prestonvanloon Aug 20, 2020
5fff369
gofmt
prestonvanloon Aug 20, 2020
b4ba52e
fix //validator/client:go_default_test
prestonvanloon Aug 20, 2020
4373cc6
fix
prestonvanloon Aug 20, 2020
a39a6d5
fix //beacon-chain/blockchain:go_raceoff_test
prestonvanloon Aug 21, 2020
7c0166a
fix //beacon-chain/rpc/beacon:go_default_test
prestonvanloon Aug 21, 2020
e1ba705
fix 1 of 4 shards in //beacon-chain/sync:go_default_test
prestonvanloon Aug 21, 2020
b0b571a
Fix //beacon-chain/sync:go_default_test and gofmt
prestonvanloon Aug 21, 2020
82be060
prevent panic
prestonvanloon Aug 21, 2020
6e65890
fix //beacon-chain/state/stategen:go_default_test
prestonvanloon Aug 21, 2020
4f775b2
fix
prestonvanloon Aug 22, 2020
1ff3012
Merge branch 'master' of github.com:prysmaticlabs/prysm into update-fssz
prestonvanloon Aug 22, 2020
cb5a07c
fix most tests
prestonvanloon Aug 22, 2020
3e48b81
Self review, go mod tidy, run regen scripts
prestonvanloon Aug 22, 2020
0c289b6
fix slasher
prestonvanloon Aug 22, 2020
4dc884d
Update ethereumapis
prestonvanloon Aug 22, 2020
e880499
disable spawn strategy override
prestonvanloon Aug 22, 2020
91ef174
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Aug 22, 2020
a6e6c82
Merge refs/heads/master into update-fssz
prylabs-bulldozer[bot] Aug 22, 2020
f1558cd
Remove extra line in imports
0xKiwi Aug 23, 2020
b8b725f
Remove extra line in imports
0xKiwi Aug 23, 2020
b1927b0
Gofmt
0xKiwi Aug 24, 2020
4862181
PR feedback from @nisdas
prestonvanloon Aug 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .buildkite-bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#
# This config is loaded from https://github.com/bazelbuild/bazel-toolchains/blob/master/bazelrc/latest.bazelrc
build:remote-cache --remote_timeout=3600
build:remote-cache --spawn_strategy=standalone
build:remote-cache --strategy=Javac=standalone
build:remote-cache --strategy=Closure=standalone
build:remote-cache --strategy=Genrule=standalone
#build:remote-cache --spawn_strategy=standalone
#build:remote-cache --strategy=Javac=standalone
#build:remote-cache --strategy=Closure=standalone
#build:remote-cache --strategy=Genrule=standalone
Comment on lines +6 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these stay commented?

Copy link
Member Author

@prestonvanloon prestonvanloon Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! Otherwise fssz generation fails for some reason...


# Prysm specific remote-cache properties.
#build:remote-cache --disk_cache=
Expand Down
11 changes: 7 additions & 4 deletions beacon-chain/blockchain/chain_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
Expand Down Expand Up @@ -42,7 +44,7 @@ func TestHeadRoot_Nil(t *testing.T) {
func TestFinalizedCheckpt_CanRetrieve(t *testing.T) {
db, sc := testDB.SetupDB(t)

cp := &ethpb.Checkpoint{Epoch: 5, Root: []byte("foo")}
cp := &ethpb.Checkpoint{Epoch: 5, Root: bytesutil.PadTo([]byte("foo"), 32)}
c := setupBeaconChain(t, db, sc)
c.finalizedCheckpt = cp

Expand All @@ -66,7 +68,7 @@ func TestFinalizedCheckpt_GenesisRootOk(t *testing.T) {
func TestCurrentJustifiedCheckpt_CanRetrieve(t *testing.T) {
db, sc := testDB.SetupDB(t)

cp := &ethpb.Checkpoint{Epoch: 6, Root: []byte("foo")}
cp := &ethpb.Checkpoint{Epoch: 6, Root: bytesutil.PadTo([]byte("foo"), 32)}
c := setupBeaconChain(t, db, sc)
c.justifiedCheckpt = cp

Expand All @@ -90,7 +92,7 @@ func TestJustifiedCheckpt_GenesisRootOk(t *testing.T) {
func TestPreviousJustifiedCheckpt_CanRetrieve(t *testing.T) {
db, sc := testDB.SetupDB(t)

cp := &ethpb.Checkpoint{Epoch: 7, Root: []byte("foo")}
cp := &ethpb.Checkpoint{Epoch: 7, Root: bytesutil.PadTo([]byte("foo"), 32)}
c := setupBeaconChain(t, db, sc)
c.prevJustifiedCheckpt = cp

Expand Down Expand Up @@ -128,7 +130,8 @@ func TestHeadRoot_CanRetrieve(t *testing.T) {
}

func TestHeadBlock_CanRetrieve(t *testing.T) {
b := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 1}}
b := testutil.NewBeaconBlock()
b.Block.Slot = 1
s, err := state.InitializeFromProto(&pb.BeaconState{})
require.NoError(t, err)
c := &Service{}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/checkpoint_info_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestHotStateCache_RoundTrip(t *testing.T) {
func TestHotStateCache_CanPrune(t *testing.T) {
c := newCheckPointInfoCache()
for i := 0; i < maxInfoSize+1; i++ {
cp := &ethpb.Checkpoint{Epoch: uint64(i)}
cp := &ethpb.Checkpoint{Epoch: uint64(i), Root: make([]byte, 32)}
require.NoError(t, c.put(cp, &pb.CheckPtInfo{}))
}
require.Equal(t, len(c.cache.Keys()), maxInfoSize)
Expand Down
15 changes: 7 additions & 8 deletions beacon-chain/blockchain/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"testing"

ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
Expand Down Expand Up @@ -35,8 +34,9 @@ func TestSaveHead_Different(t *testing.T) {
oldRoot := [32]byte{'A'}
service.head = &head{slot: 0, root: oldRoot}

newHeadBlock := &ethpb.BeaconBlock{Slot: 1}
newHeadSignedBlock := &ethpb.SignedBeaconBlock{Block: newHeadBlock}
newHeadSignedBlock := testutil.NewBeaconBlock()
newHeadSignedBlock.Block.Slot = 1
newHeadBlock := newHeadSignedBlock.Block

require.NoError(t, service.beaconDB.SaveBlock(context.Background(), newHeadSignedBlock))
newRoot, err := stateutil.BlockRoot(newHeadBlock)
Expand Down Expand Up @@ -68,11 +68,10 @@ func TestSaveHead_Different_Reorg(t *testing.T) {
service.head = &head{slot: 0, root: oldRoot}

reorgChainParent := [32]byte{'B'}
newHeadBlock := &ethpb.BeaconBlock{
Slot: 1,
ParentRoot: reorgChainParent[:],
}
newHeadSignedBlock := &ethpb.SignedBeaconBlock{Block: newHeadBlock}
newHeadSignedBlock := testutil.NewBeaconBlock()
newHeadSignedBlock.Block.Slot = 1
newHeadSignedBlock.Block.ParentRoot = reorgChainParent[:]
newHeadBlock := newHeadSignedBlock.Block

require.NoError(t, service.beaconDB.SaveBlock(context.Background(), newHeadSignedBlock))
newRoot, err := stateutil.BlockRoot(newHeadBlock)
Expand Down
98 changes: 53 additions & 45 deletions beacon-chain/blockchain/process_attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
Expand All @@ -37,12 +36,14 @@ func TestStore_OnAttestation(t *testing.T) {
_, err = blockTree1(db, []byte{'g'})
require.NoError(t, err)

BlkWithOutState := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 0}}
BlkWithOutState := testutil.NewBeaconBlock()
BlkWithOutState.Block.Slot = 0
require.NoError(t, db.SaveBlock(ctx, BlkWithOutState))
BlkWithOutStateRoot, err := stateutil.BlockRoot(BlkWithOutState.Block)
require.NoError(t, err)

BlkWithStateBadAtt := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 1}}
BlkWithStateBadAtt := testutil.NewBeaconBlock()
BlkWithStateBadAtt.Block.Slot = 1
require.NoError(t, db.SaveBlock(ctx, BlkWithStateBadAtt))
BlkWithStateBadAttRoot, err := stateutil.BlockRoot(BlkWithStateBadAtt.Block)
require.NoError(t, err)
Expand All @@ -51,7 +52,8 @@ func TestStore_OnAttestation(t *testing.T) {
require.NoError(t, s.SetSlot(100*params.BeaconConfig().SlotsPerEpoch))
require.NoError(t, service.beaconDB.SaveState(ctx, s, BlkWithStateBadAttRoot))

BlkWithValidState := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 2}}
BlkWithValidState := testutil.NewBeaconBlock()
BlkWithValidState.Block.Slot = 2
require.NoError(t, db.SaveBlock(ctx, BlkWithValidState))

BlkWithValidStateRoot, err := stateutil.BlockRoot(BlkWithValidState.Block)
Expand All @@ -69,57 +71,57 @@ func TestStore_OnAttestation(t *testing.T) {
tests := []struct {
name string
a *ethpb.Attestation
s *pb.BeaconState
wantErr bool
wantErrString string
}{
{
name: "attestation's data slot not aligned with target vote",
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: &ethpb.Checkpoint{}}},
s: &pb.BeaconState{},
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: &ethpb.Checkpoint{Root: make([]byte, 32)}}},
wantErr: true,
wantErrString: "data slot is not in the same epoch as target 1 != 0",
},
{
name: "attestation's target root not in db",
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: []byte{'A'}}}},
s: &pb.BeaconState{},
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: bytesutil.PadTo([]byte{'A'}, 32)}}},
wantErr: true,
wantErrString: "target root does not exist in db",
},
{
name: "no pre state for attestations's target block",
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}},
s: &pb.BeaconState{},
wantErr: true,
wantErrString: "could not get pre state for slot 0",
},
{
name: "process attestation doesn't match current epoch",
a: &ethpb.Attestation{Data: &ethpb.AttestationData{Slot: 100 * params.BeaconConfig().SlotsPerEpoch, Target: &ethpb.Checkpoint{Epoch: 100,
Root: BlkWithStateBadAttRoot[:]}}},
s: &pb.BeaconState{Slot: 100 * params.BeaconConfig().SlotsPerEpoch},
wantErr: true,
wantErrString: "target epoch 100 does not match current epoch",
},
{
name: "process nil field (a.Target) in attestation",
name: "process nil attestation",
a: nil,
s: &pb.BeaconState{},
wantErr: true,
wantErrString: "nil attestation",
},
{
name: "process nil field (a.Data) in attestation",
a: &ethpb.Attestation{},
s: &pb.BeaconState{},
wantErr: true,
wantErrString: "nil attestation.Data field",
},
{
name: "process nil field (a.Target) in attestation",
a: &ethpb.Attestation{Data: &ethpb.AttestationData{}},
s: &pb.BeaconState{},
name: "process nil field (a.Target) in attestation",
a: &ethpb.Attestation{
Data: &ethpb.AttestationData{
BeaconBlockRoot: make([]byte, 32),
Target: nil,
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
},
AggregationBits: make([]byte, 1),
Signature: make([]byte, 96),
},
wantErr: true,
wantErrString: "nil attestation.Data.Target field",
},
Expand Down Expand Up @@ -150,22 +152,16 @@ func TestStore_SaveCheckpointState(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

s, err := stateTrie.InitializeFromProto(&pb.BeaconState{
Fork: &pb.Fork{
Epoch: 0,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
LatestBlockHeader: &ethpb.BeaconBlockHeader{},
JustificationBits: []byte{0},
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
FinalizedCheckpoint: &ethpb.Checkpoint{Root: bytesutil.PadTo([]byte{'A'}, 32)},
Validators: []*ethpb.Validator{{PublicKey: bytesutil.PadTo([]byte("foo"), 48)}},
Balances: []uint64{0},
})
s := testutil.NewBeaconState()
err = s.SetFinalizedCheckpoint(&ethpb.Checkpoint{Root: bytesutil.PadTo([]byte{'A'}, 32)})
require.NoError(t, err)
val := &ethpb.Validator{
PublicKey: bytesutil.PadTo([]byte("foo"), 48),
WithdrawalCredentials: bytesutil.PadTo([]byte("bar"), 32),
}
err = s.SetValidators([]*ethpb.Validator{val})
require.NoError(t, err)
err = s.SetBalances([]uint64{0})
require.NoError(t, err)
r := [32]byte{'g'}
require.NoError(t, service.beaconDB.SaveState(ctx, s, r))
Expand Down Expand Up @@ -230,7 +226,7 @@ func TestStore_UpdateCheckpointState(t *testing.T) {
epoch := uint64(1)
baseState, _ := testutil.DeterministicGenesisState(t, 1)
require.NoError(t, baseState.SetSlot(epoch*params.BeaconConfig().SlotsPerEpoch))
checkpoint := &ethpb.Checkpoint{Epoch: epoch}
checkpoint := &ethpb.Checkpoint{Epoch: epoch, Root: bytesutil.PadTo([]byte("hi"), 32)}
require.NoError(t, service.beaconDB.SaveState(ctx, baseState, bytesutil.ToBytes32(checkpoint.Root)))
returned, err := service.getAttPreState(ctx, checkpoint)
require.NoError(t, err)
Expand All @@ -241,7 +237,7 @@ func TestStore_UpdateCheckpointState(t *testing.T) {
assert.NotNil(t, cached, "State should have been cached")

epoch = uint64(2)
newCheckpoint := &ethpb.Checkpoint{Epoch: epoch}
newCheckpoint := &ethpb.Checkpoint{Epoch: epoch, Root: bytesutil.PadTo([]byte("bye"), 32)}
require.NoError(t, service.beaconDB.SaveState(ctx, baseState, bytesutil.ToBytes32(newCheckpoint.Root)))
returned, err = service.getAttPreState(ctx, newCheckpoint)
require.NoError(t, err)
Expand All @@ -268,7 +264,7 @@ func TestAttEpoch_MatchPrevEpoch(t *testing.T) {
ctx,
0,
params.BeaconConfig().SlotsPerEpoch*params.BeaconConfig().SecondsPerSlot,
&ethpb.Checkpoint{}); err != nil {
&ethpb.Checkpoint{Root: make([]byte, 32)}); err != nil {
t.Error(err)
}
}
Expand Down Expand Up @@ -302,7 +298,7 @@ func TestAttEpoch_NotMatch(t *testing.T) {
ctx,
0,
2*params.BeaconConfig().SlotsPerEpoch*params.BeaconConfig().SecondsPerSlot,
&ethpb.Checkpoint{}); !strings.Contains(err.Error(),
&ethpb.Checkpoint{Root: make([]byte, 32)}); !strings.Contains(err.Error(),
"target epoch 0 does not match current epoch 2 or prev epoch 1") {
t.Error("Did not receive wanted error")
}
Expand All @@ -316,8 +312,12 @@ func TestVerifyBeaconBlock_NoBlock(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

d := &ethpb.AttestationData{}
assert.ErrorContains(t, "beacon block does not exist", service.verifyBeaconBlock(ctx, d))
d := &ethpb.AttestationData{
BeaconBlockRoot: make([]byte, 32),
Target: &ethpb.Checkpoint{Root: make([]byte, 32)},
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
}
assert.ErrorContains(t, "beacon block 0x000000000000 does not exist", service.verifyBeaconBlock(ctx, d))
}

func TestVerifyBeaconBlock_futureBlock(t *testing.T) {
Expand All @@ -328,7 +328,8 @@ func TestVerifyBeaconBlock_futureBlock(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

b := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 2}}
b := testutil.NewBeaconBlock()
b.Block.Slot = 2
require.NoError(t, service.beaconDB.SaveBlock(ctx, b))
r, err := stateutil.BlockRoot(b.Block)
require.NoError(t, err)
Expand All @@ -345,7 +346,8 @@ func TestVerifyBeaconBlock_OK(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

b := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 2}}
b := testutil.NewBeaconBlock()
b.Block.Slot = 2
require.NoError(t, service.beaconDB.SaveBlock(ctx, b))
r, err := stateutil.BlockRoot(b.Block)
require.NoError(t, err)
Expand All @@ -362,11 +364,14 @@ func TestVerifyLMDFFGConsistent_NotOK(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

b32 := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 32}}
b32 := testutil.NewBeaconBlock()
b32.Block.Slot = 32
require.NoError(t, service.beaconDB.SaveBlock(ctx, b32))
r32, err := stateutil.BlockRoot(b32.Block)
require.NoError(t, err)
b33 := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 33, ParentRoot: r32[:]}}
b33 := testutil.NewBeaconBlock()
b33.Block.Slot = 33
b33.Block.ParentRoot = r32[:]
require.NoError(t, service.beaconDB.SaveBlock(ctx, b33))
r33, err := stateutil.BlockRoot(b33.Block)
require.NoError(t, err)
Expand All @@ -383,11 +388,14 @@ func TestVerifyLMDFFGConsistent_OK(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)

b32 := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 32}}
b32 := testutil.NewBeaconBlock()
b32.Block.Slot = 32
require.NoError(t, service.beaconDB.SaveBlock(ctx, b32))
r32, err := stateutil.BlockRoot(b32.Block)
require.NoError(t, err)
b33 := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Slot: 33, ParentRoot: r32[:]}}
b33 := testutil.NewBeaconBlock()
b33.Block.Slot = 33
b33.Block.ParentRoot = r32[:]
require.NoError(t, service.beaconDB.SaveBlock(ctx, b33))
r33, err := stateutil.BlockRoot(b33.Block)
require.NoError(t, err)
Expand Down
Loading