Removed some simple go-ssz usage (#8250)

Co-authored-by: terence tsao <terence@prysmaticlabs.com>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
pinglamb
2021-01-13 03:31:34 +08:00
committed by GitHub
parent 9f423617cb
commit 1a9207ba46
4 changed files with 10 additions and 14 deletions

View File

@@ -7,7 +7,6 @@ import (
"testing"
"github.com/ghodss/yaml"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
@@ -44,7 +43,7 @@ func runPrecomputeRewardsAndPenaltiesTest(t *testing.T, testFolderPath string) {
preBeaconStateFile, err := testutil.BazelFileBytes(path.Join(testFolderPath, "pre.ssz"))
require.NoError(t, err)
preBeaconStateBase := &pb.BeaconState{}
require.NoError(t, ssz.Unmarshal(preBeaconStateFile, preBeaconStateBase), "Failed to unmarshal")
require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateFile), "Failed to unmarshal")
preBeaconState, err := beaconstate.InitializeFromProto(preBeaconStateBase)
require.NoError(t, err)

View File

@@ -65,7 +65,6 @@ go_test(
"//shared/testutil/require:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
],
)

View File

@@ -5,7 +5,6 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
@@ -372,22 +371,22 @@ func TestLastAncestorState_CanGetUsingDB(t *testing.T) {
b0 := testutil.NewBeaconBlock()
b0.Block.ParentRoot = bytesutil.PadTo([]byte{'a'}, 32)
r0, err := ssz.HashTreeRoot(b0.Block)
r0, err := b0.Block.HashTreeRoot()
require.NoError(t, err)
b1 := testutil.NewBeaconBlock()
b1.Block.Slot = 1
b1.Block.ParentRoot = bytesutil.PadTo(r0[:], 32)
r1, err := ssz.HashTreeRoot(b1.Block)
r1, err := b1.Block.HashTreeRoot()
require.NoError(t, err)
b2 := testutil.NewBeaconBlock()
b2.Block.Slot = 2
b2.Block.ParentRoot = bytesutil.PadTo(r1[:], 32)
r2, err := ssz.HashTreeRoot(b2.Block)
r2, err := b2.Block.HashTreeRoot()
require.NoError(t, err)
b3 := testutil.NewBeaconBlock()
b3.Block.Slot = 3
b3.Block.ParentRoot = bytesutil.PadTo(r2[:], 32)
r3, err := ssz.HashTreeRoot(b3.Block)
r3, err := b3.Block.HashTreeRoot()
require.NoError(t, err)
b1State := testutil.NewBeaconState()
@@ -411,22 +410,22 @@ func TestLastAncestorState_CanGetUsingCache(t *testing.T) {
b0 := testutil.NewBeaconBlock()
b0.Block.ParentRoot = bytesutil.PadTo([]byte{'a'}, 32)
r0, err := ssz.HashTreeRoot(b0.Block)
r0, err := b0.Block.HashTreeRoot()
require.NoError(t, err)
b1 := testutil.NewBeaconBlock()
b1.Block.Slot = 1
b1.Block.ParentRoot = bytesutil.PadTo(r0[:], 32)
r1, err := ssz.HashTreeRoot(b1.Block)
r1, err := b1.Block.HashTreeRoot()
require.NoError(t, err)
b2 := testutil.NewBeaconBlock()
b2.Block.Slot = 2
b2.Block.ParentRoot = bytesutil.PadTo(r1[:], 32)
r2, err := ssz.HashTreeRoot(b2.Block)
r2, err := b2.Block.HashTreeRoot()
require.NoError(t, err)
b3 := testutil.NewBeaconBlock()
b3.Block.Slot = 3
b3.Block.ParentRoot = bytesutil.PadTo(r2[:], 32)
r3, err := ssz.HashTreeRoot(b3.Block)
r3, err := b3.Block.HashTreeRoot()
require.NoError(t, err)
b1State := testutil.NewBeaconState()

View File

@@ -13,7 +13,6 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
@@ -69,7 +68,7 @@ func setupDB() {
if err := db1.SaveBlock(ctx, b); err != nil {
panic(err)
}
br, err := ssz.HashTreeRoot(b)
br, err := b.HashTreeRoot()
if err != nil {
panic(err)
}