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: Attempt 2 #7115

Merged
merged 21 commits into from
Aug 27, 2020
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
265b05a
Revert "Revert "Update fastssz" (#7100)"
terencechain Aug 25, 2020
0109747
Preston's patch
terencechain Aug 25, 2020
d139830
Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7…
prestonvanloon Aug 26, 2020
20f7aff
Update fssz, add regression test case
prestonvanloon Aug 26, 2020
e4d3918
more HTR with fssz
prestonvanloon Aug 26, 2020
ac94304
fix some tests
prestonvanloon Aug 26, 2020
b728a68
only one test left
prestonvanloon Aug 26, 2020
927aecc
Make it so that HTR will work
prestonvanloon Aug 26, 2020
0cb37d1
gofmt, imports
prestonvanloon Aug 26, 2020
a949973
gofmt, imports
prestonvanloon Aug 26, 2020
025cc21
fix
prestonvanloon Aug 27, 2020
4632df4
Merge branch 'master' of github.com:prysmaticlabs/prysm into revert-7…
prestonvanloon Aug 27, 2020
4a3ca21
fix
prestonvanloon Aug 27, 2020
522c3c5
Merge branch 'master' into revert-7100-revert-6760-update-fssz
prestonvanloon Aug 27, 2020
d62a7a0
Merge refs/heads/master into revert-7100-revert-6760-update-fssz
prylabs-bulldozer[bot] Aug 27, 2020
ae6cdd3
gaz
prestonvanloon Aug 27, 2020
50019ca
Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prys…
prestonvanloon Aug 27, 2020
ad18dca
Merge refs/heads/master into revert-7100-revert-6760-update-fssz
prylabs-bulldozer[bot] Aug 27, 2020
6925750
fix test
prestonvanloon Aug 27, 2020
5c1304d
Merge branch 'revert-7100-revert-6760-update-fssz' of github.com:prys…
prestonvanloon Aug 27, 2020
e190ea5
Merge refs/heads/master into revert-7100-revert-6760-update-fssz
prylabs-bulldozer[bot] Aug 27, 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
Prev Previous commit
Next Next commit
only one test left
prestonvanloon committed Aug 26, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b728a685e5c43b51fde8a5705b2711d719bee35d
6 changes: 2 additions & 4 deletions beacon-chain/blockchain/service_test.go
Original file line number Diff line number Diff line change
@@ -290,12 +290,10 @@ func TestHasBlock_ForkChoiceAndDB(t *testing.T) {
finalizedCheckpt: &ethpb.Checkpoint{Root: make([]byte, 32)},
beaconDB: db,
}
block := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Body: &ethpb.BeaconBlockBody{}}}
block := testutil.NewBeaconBlock()
r, err := block.Block.HashTreeRoot()
require.NoError(t, err)
bs := &pb.BeaconState{FinalizedCheckpoint: &ethpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: &ethpb.Checkpoint{Root: make([]byte, 32)}}
state, err := beaconstate.InitializeFromProto(bs)
require.NoError(t, err)
state := testutil.NewBeaconState()
require.NoError(t, s.insertBlockAndAttestationsToForkChoiceStore(ctx, block.Block, r, state))

assert.Equal(t, false, s.hasBlock(ctx, [32]byte{}), "Should not have block")
3 changes: 2 additions & 1 deletion beacon-chain/core/blocks/genesis.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ package blocks

import (
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
)

@@ -13,7 +14,7 @@ func NewGenesisBlock(stateRoot []byte) *ethpb.SignedBeaconBlock {
block := &ethpb.SignedBeaconBlock{
Block: &ethpb.BeaconBlock{
ParentRoot: zeroHash,
StateRoot: stateRoot,
StateRoot: bytesutil.PadTo(stateRoot, 32),
Body: &ethpb.BeaconBlockBody{
RandaoReveal: make([]byte, 96),
Eth1Data: &ethpb.Eth1Data{
3 changes: 2 additions & 1 deletion beacon-chain/core/blocks/genesis_test.go
Original file line number Diff line number Diff line change
@@ -4,11 +4,12 @@ import (
"testing"

"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)

func TestGenesisBlock_InitializedCorrectly(t *testing.T) {
stateHash := []byte{0}
stateHash := bytesutil.PadTo([]byte{0}, 32)
b1 := blocks.NewGenesisBlock(stateHash)

assert.NotNil(t, b1.Block.ParentRoot, "Genesis block missing ParentHash field")
34 changes: 15 additions & 19 deletions beacon-chain/core/state/transition_test.go
Original file line number Diff line number Diff line change
@@ -116,7 +116,9 @@ func TestExecuteStateTransitionNoVerify_FullProcess(t *testing.T) {
e := beaconState.Eth1Data()
e.DepositCount = 100
require.NoError(t, beaconState.SetEth1Data(e))
require.NoError(t, beaconState.SetLatestBlockHeader(&ethpb.BeaconBlockHeader{Slot: beaconState.Slot()}))
bh := beaconState.LatestBlockHeader()
bh.Slot = beaconState.Slot()
require.NoError(t, beaconState.SetLatestBlockHeader(bh))
require.NoError(t, beaconState.SetEth1DataVotes([]*ethpb.Eth1Data{eth1Data}))
parentRoot, err := beaconState.LatestBlockHeader().HashTreeRoot()
require.NoError(t, err)
@@ -281,9 +283,11 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
blockAtt := &ethpb.Attestation{
Data: &ethpb.AttestationData{
Source: &ethpb.Checkpoint{Epoch: 0, Root: make([]byte, 32)},
Target: &ethpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
Target: &ethpb.Checkpoint{Epoch: 0, Root: bytesutil.PadTo([]byte("hello-world"), 32)},
BeaconBlockRoot: make([]byte, 32),
},
AggregationBits: bitfield.Bitlist{0xC0, 0xC0, 0xC0, 0xC0, 0x01},
Signature: make([]byte, 96),
}
attestations := []*ethpb.Attestation{blockAtt}
var exits []*ethpb.SignedVoluntaryExit
@@ -302,23 +306,15 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
require.NoError(t, err)
parentRoot, err := beaconState.LatestBlockHeader().HashTreeRoot()
require.NoError(t, err)
block := &ethpb.SignedBeaconBlock{
Block: &ethpb.BeaconBlock{
ParentRoot: parentRoot[:],
Slot: 1,
Body: &ethpb.BeaconBlockBody{
RandaoReveal: make([]byte, 96),
ProposerSlashings: proposerSlashings,
AttesterSlashings: attesterSlashings,
Attestations: attestations,
VoluntaryExits: exits,
Eth1Data: &ethpb.Eth1Data{
DepositRoot: bytesutil.PadTo([]byte{2}, 32),
BlockHash: bytesutil.PadTo([]byte{3}, 32),
},
},
},
}
block := testutil.NewBeaconBlock()
block.Block.Slot = 1
block.Block.ParentRoot = parentRoot[:]
block.Block.Body.ProposerSlashings = proposerSlashings
block.Block.Body.Attestations = attestations
block.Block.Body.AttesterSlashings = attesterSlashings
block.Block.Body.VoluntaryExits = exits
block.Block.Body.Eth1Data.DepositRoot = bytesutil.PadTo([]byte{2}, 32)
block.Block.Body.Eth1Data.BlockHash = bytesutil.PadTo([]byte{3}, 32)
err = beaconState.SetSlot(beaconState.Slot() + params.BeaconConfig().MinAttestationInclusionDelay)
require.NoError(t, err)
cp := beaconState.CurrentJustifiedCheckpoint()
12 changes: 5 additions & 7 deletions beacon-chain/sync/initial-sync/initial_sync_test.go
Original file line number Diff line number Diff line change
@@ -128,18 +128,16 @@ func (c *testCache) initializeRootCache(reqSlots []uint64, t *testing.T) {
c.rootCache = make(map[uint64][32]byte)
c.parentSlotCache = make(map[uint64]uint64)
parentSlot := uint64(0)
genesisBlock := &eth.BeaconBlock{
Slot: 0,
}

genesisBlock := testutil.NewBeaconBlock().Block
genesisRoot, err := genesisBlock.HashTreeRoot()
require.NoError(t, err)
c.rootCache[0] = genesisRoot
parentRoot := genesisRoot
for _, slot := range reqSlots {
currentBlock := &eth.BeaconBlock{
Slot: slot,
ParentRoot: parentRoot[:],
}
currentBlock := testutil.NewBeaconBlock().Block
currentBlock.Slot = slot
currentBlock.ParentRoot = parentRoot[:]
parentRoot, err = currentBlock.HashTreeRoot()
require.NoError(t, err)
c.rootCache[slot] = parentRoot
2 changes: 1 addition & 1 deletion beacon-chain/sync/pending_blocks_queue_test.go
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ func TestRegularSyncBeaconBlockSubscriber_ProcessPendingBlocks1(t *testing.T) {
require.NoError(t, r.db.SaveBlock(context.Background(), b1))

// Insert bad b1 in the cache to verify the good one doesn't get replaced.
r.insertBlockToPendingQueue(b1.Block.Slot, &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{}}, [32]byte{})
r.insertBlockToPendingQueue(b1.Block.Slot, testutil.NewBeaconBlock(), [32]byte{})

require.NoError(t, r.processPendingBlocks(context.Background()))
assert.Equal(t, 1, len(r.slotToPendingBlocks), "Incorrect size for slot to pending blocks cache")
13 changes: 7 additions & 6 deletions beacon-chain/sync/subscriber_beacon_blocks_test.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
dbtest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
@@ -76,12 +77,11 @@ func TestService_beaconBlockSubscriber(t *testing.T) {
{
name: "invalid block does not remove attestations",
args: args{
msg: &ethpb.SignedBeaconBlock{
Block: &ethpb.BeaconBlock{
// An empty block will return an err in mocked chainService.ReceiveBlock.
Body: &ethpb.BeaconBlockBody{Attestations: pooledAttestations},
},
},
msg: func() *ethpb.SignedBeaconBlock{
b := testutil.NewBeaconBlock()
b.Block.Body.Attestations = pooledAttestations
return b
}(),
},
wantedErr: "nil inner state",
check: func(t *testing.T, s *Service) {
@@ -100,6 +100,7 @@ func TestService_beaconBlockSubscriber(t *testing.T) {
s := &Service{
chain: &chainMock.ChainService{
DB: db,
Root: make([]byte, 32),
},
attPool: attestations.NewPool(),
}