Native Blocks Ep. 2 - Switch usages to new package (#10885)

* panic in SizeSSZ

* moving slowly

* adapt old code to new interfaces

* return interfaces from factory functions

* replace the rest of WrappedSignedBeaconBlock

* WrappedBeaconBlock

* WrappedBeaconBlockBody

* miscellaneous

* Test_BeaconBlockIsNil

* replace usages of BeaconBlockIsNil

* replace usages of mutator

* fix all build errors

* fix some more issues

* mutator changes

* relax assertions when initializing

* revert changes in object_mapping.go

* allow calling Proto on nil

* Revert "allow calling Proto on nil"

This reverts commit ecc84e4553.

* modify Copy and Proto methods

* remove unused var

* fix block batch tests

* correct BUILD file

* Error when initializing nil objects

* one more error fix

* add missing comma

* rename alias to blocktest

* add logging

* error when SignedBeaconBlock is nil

* fix last test

* import fix

* broken

* working

* test fixes

* reduce complexity of processPendingBlocks

* simplified
This commit is contained in:
Radosław Kapka
2022-08-02 17:30:46 +02:00
committed by GitHub
parent 4b46dead2f
commit 879e310332
217 changed files with 2282 additions and 1176 deletions

View File

@@ -15,9 +15,9 @@ go_library(
"//beacon-chain/state/v3:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/wrapper:go_default_library",
"//encoding/bytesutil:go_default_library",
"//network/forks:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
@@ -38,9 +38,9 @@ go_test(
deps = [
"//beacon-chain/state:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/wrapper:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//runtime/version:go_default_library",

View File

@@ -3,6 +3,7 @@ package detect
import (
"fmt"
"github.com/prysmaticlabs/prysm/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/network/forks"
@@ -16,7 +17,6 @@ import (
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
"github.com/prysmaticlabs/prysm/config/params"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/consensus-types/wrapper"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/time/slots"
@@ -165,7 +165,7 @@ func (cf *VersionedUnmarshaler) UnmarshalBeaconBlock(marshaled []byte) (interfac
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal SignedBeaconBlock in UnmarshalSSZ")
}
return wrapper.WrappedSignedBeaconBlock(blk)
return blocks.NewSignedBeaconBlock(blk)
}
// UnmarshalBlindedBeaconBlock uses internal knowledge in the VersionedUnmarshaler to pick the right concrete blinded SignedBeaconBlock type,
@@ -196,7 +196,7 @@ func (cf *VersionedUnmarshaler) UnmarshalBlindedBeaconBlock(marshaled []byte) (i
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal SignedBeaconBlock in UnmarshalSSZ")
}
return wrapper.WrappedSignedBeaconBlock(blk)
return blocks.NewSignedBeaconBlock(blk)
}
// Heuristic to make sure block is from the same version as the VersionedUnmarshaler.

View File

@@ -8,8 +8,8 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/config/params"
"github.com/prysmaticlabs/prysm/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/consensus-types/wrapper"
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/testing/util"
@@ -371,7 +371,7 @@ func TestUnmarshalBlindedBlock(t *testing.T) {
func signedTestBlockGenesis(t *testing.T, slot types.Slot) interfaces.SignedBeaconBlock {
b := util.NewBeaconBlock()
b.Block.Slot = slot
s, err := wrapper.WrappedSignedBeaconBlock(b)
s, err := blocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
return s
}
@@ -379,7 +379,7 @@ func signedTestBlockGenesis(t *testing.T, slot types.Slot) interfaces.SignedBeac
func signedTestBlockAltair(t *testing.T, slot types.Slot) interfaces.SignedBeaconBlock {
b := util.NewBeaconBlockAltair()
b.Block.Slot = slot
s, err := wrapper.WrappedSignedBeaconBlock(b)
s, err := blocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
return s
}
@@ -387,7 +387,7 @@ func signedTestBlockAltair(t *testing.T, slot types.Slot) interfaces.SignedBeaco
func signedTestBlockBellatrix(t *testing.T, slot types.Slot) interfaces.SignedBeaconBlock {
b := util.NewBeaconBlockBellatrix()
b.Block.Slot = slot
s, err := wrapper.WrappedSignedBeaconBlock(b)
s, err := blocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
return s
}
@@ -395,7 +395,7 @@ func signedTestBlockBellatrix(t *testing.T, slot types.Slot) interfaces.SignedBe
func signedTestBlindedBlockBellatrix(t *testing.T, slot types.Slot) interfaces.SignedBeaconBlock {
b := util.NewBlindedBeaconBlockBellatrix()
b.Block.Slot = slot
s, err := wrapper.WrappedSignedBeaconBlock(b)
s, err := blocks.NewSignedBeaconBlock(b)
require.NoError(t, err)
return s
}