mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 13:58:09 -05:00
Compare commits
15 Commits
plus-one-b
...
simplify-v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
485f80fa24 | ||
|
|
5bcc397db2 | ||
|
|
abdfb49434 | ||
|
|
91a3c78ca2 | ||
|
|
8b261d294f | ||
|
|
fc58d7d0a3 | ||
|
|
8cfcb8c114 | ||
|
|
73e7a5043b | ||
|
|
a33ff24303 | ||
|
|
270d2029ff | ||
|
|
c565774ed9 | ||
|
|
daf8deedbf | ||
|
|
4417238ca1 | ||
|
|
8417ca2741 | ||
|
|
060b3d4379 |
@@ -163,13 +163,13 @@ func ProcessWithdrawals(st state.BeaconState, executionData interfaces.Execution
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not get withdrawals")
|
return nil, errors.Wrap(err, "could not get withdrawals")
|
||||||
}
|
}
|
||||||
wdRoot, err = ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), wds, fieldparams.MaxWithdrawalsPerPayload)
|
wdRoot, err = ssz.WithdrawalSliceRoot(wds, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not get withdrawals root")
|
return nil, errors.Wrap(err, "could not get withdrawals root")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), expectedWithdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
expectedRoot, err := ssz.WithdrawalSliceRoot(expectedWithdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not get expected withdrawals root")
|
return nil, errors.Wrap(err, "could not get expected withdrawals root")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ func TestProcessBlindWithdrawals(t *testing.T) {
|
|||||||
}
|
}
|
||||||
st, err := prepareValidators(spb, test.Args)
|
st, err := prepareValidators(spb, test.Args)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wdRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), test.Args.Withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
wdRoot, err := ssz.WithdrawalSliceRoot(test.Args.Withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
p, err := consensusblocks.WrappedExecutionPayloadHeaderCapella(&enginev1.ExecutionPayloadHeaderCapella{WithdrawalsRoot: wdRoot[:]}, big.NewInt(0))
|
p, err := consensusblocks.WrappedExecutionPayloadHeaderCapella(&enginev1.ExecutionPayloadHeaderCapella{WithdrawalsRoot: wdRoot[:]}, big.NewInt(0))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ go_library(
|
|||||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||||
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
fastssz "github.com/prysmaticlabs/fastssz"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/cmd"
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
|
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||||
tracing2 "github.com/prysmaticlabs/prysm/v3/monitoring/tracing"
|
tracing2 "github.com/prysmaticlabs/prysm/v3/monitoring/tracing"
|
||||||
@@ -192,9 +190,3 @@ func configureExecutionSetting(cliCtx *cli.Context) error {
|
|||||||
" Default fee recipient will be used as a fall back", checksumAddress.Hex())
|
" Default fee recipient will be used as a fall back", checksumAddress.Hex())
|
||||||
return params.SetActive(c)
|
return params.SetActive(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureFastSSZHashingAlgorithm() {
|
|
||||||
if features.Get().EnableVectorizedHTR {
|
|
||||||
fastssz.EnableVectorizedHTR = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ func New(cliCtx *cli.Context, opts ...Option) (*BeaconNode, error) {
|
|||||||
if err := configureExecutionSetting(cliCtx); err != nil {
|
if err := configureExecutionSetting(cliCtx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
configureFastSSZHashingAlgorithm()
|
|
||||||
|
|
||||||
// Initializes any forks here.
|
// Initializes any forks here.
|
||||||
params.BeaconConfig().InitializeForkSchedule()
|
params.BeaconConfig().InitializeForkSchedule()
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/rpc/prysm/v1alpha1/validator"
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/rpc/prysm/v1alpha1/validator"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -1141,7 +1140,7 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
|||||||
Amount: 2,
|
Amount: 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), withdrawals, 16)
|
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(withdrawals, 16)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
beaconDB := dbTest.SetupDB(t)
|
beaconDB := dbTest.SetupDB(t)
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ go_test(
|
|||||||
"//consensus-types/blocks:go_default_library",
|
"//consensus-types/blocks:go_default_library",
|
||||||
"//consensus-types/primitives:go_default_library",
|
"//consensus-types/primitives:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//encoding/ssz:go_default_library",
|
"//encoding/ssz:go_default_library",
|
||||||
"//proto/engine/v1:go_default_library",
|
"//proto/engine/v1:go_default_library",
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -1177,7 +1176,7 @@ func TestProduceBlockV2(t *testing.T) {
|
|||||||
Amount: 123,
|
Amount: 123,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), withdrawals, 2)
|
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(withdrawals, 2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
payloadHeader, err := blocks.WrappedExecutionPayloadHeaderCapella(&enginev1.ExecutionPayloadHeaderCapella{
|
payloadHeader, err := blocks.WrappedExecutionPayloadHeaderCapella(&enginev1.ExecutionPayloadHeaderCapella{
|
||||||
@@ -2696,7 +2695,7 @@ func TestProduceBlindedBlock(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wds, err := beaconState.ExpectedWithdrawals()
|
wds, err := beaconState.ExpectedWithdrawals()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wr, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), wds, fieldparams.MaxWithdrawalsPerPayload)
|
wr, err := ssz.WithdrawalSliceRoot(wds, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
bid := ðpbalpha.BuilderBidCapella{
|
bid := ðpbalpha.BuilderBidCapella{
|
||||||
Header: &enginev1.ExecutionPayloadHeaderCapella{
|
Header: &enginev1.ExecutionPayloadHeaderCapella{
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import (
|
|||||||
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -344,7 +343,7 @@ func matchingWithdrawalsRoot(local, builder interfaces.ExecutionData) (bool, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "could not get builder withdrawals root")
|
return false, errors.Wrap(err, "could not get builder withdrawals root")
|
||||||
}
|
}
|
||||||
wr, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), wds, fieldparams.MaxWithdrawalsPerPayload)
|
wr, err := ssz.WithdrawalSliceRoot(wds, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "could not compute local withdrawals root")
|
return false, errors.Wrap(err, "could not compute local withdrawals root")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
v1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
v1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -136,7 +135,7 @@ func TestServer_setExecutionData(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sk, err := bls.RandKey()
|
sk, err := bls.RandKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wr, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
wr, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
bid := ðpb.BuilderBidCapella{
|
bid := ðpb.BuilderBidCapella{
|
||||||
Header: &v1.ExecutionPayloadHeaderCapella{
|
Header: &v1.ExecutionPayloadHeaderCapella{
|
||||||
@@ -579,7 +578,7 @@ func Test_matchingWithdrawalsRoot(t *testing.T) {
|
|||||||
p, err := blocks.WrappedExecutionPayloadCapella(local, big.NewInt(0))
|
p, err := blocks.WrappedExecutionPayloadCapella(local, big.NewInt(0))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
header := &v1.ExecutionPayloadHeaderCapella{}
|
header := &v1.ExecutionPayloadHeaderCapella{}
|
||||||
wr, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), wds, fieldparams.MaxWithdrawalsPerPayload)
|
wr, err := ssz.WithdrawalSliceRoot(wds, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
header.WithdrawalsRoot = wr[:]
|
header.WithdrawalsRoot = wr[:]
|
||||||
h, err := blocks.WrappedExecutionPayloadHeaderCapella(header, big.NewInt(0))
|
h, err := blocks.WrappedExecutionPayloadHeaderCapella(header, big.NewInt(0))
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ go_library(
|
|||||||
"//beacon-chain/state/state-native/custom-types:go_default_library",
|
"//beacon-chain/state/state-native/custom-types:go_default_library",
|
||||||
"//beacon-chain/state/state-native/types:go_default_library",
|
"//beacon-chain/state/state-native/types:go_default_library",
|
||||||
"//beacon-chain/state/stateutil:go_default_library",
|
"//beacon-chain/state/stateutil:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//math:go_default_library",
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
customtypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/custom-types"
|
customtypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/custom-types"
|
||||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
pmath "github.com/prysmaticlabs/prysm/v3/math"
|
pmath "github.com/prysmaticlabs/prysm/v3/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -216,9 +215,8 @@ func handleValidatorSlice(val []*ethpb.Validator, indices []uint64, convertAll b
|
|||||||
length = len(val)
|
length = len(val)
|
||||||
}
|
}
|
||||||
roots := make([][32]byte, 0, length)
|
roots := make([][32]byte, 0, length)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
rootCreator := func(input *ethpb.Validator) error {
|
rootCreator := func(input *ethpb.Validator) error {
|
||||||
newRoot, err := stateutil.ValidatorRootWithHasher(hasher, input)
|
newRoot, err := stateutil.ValidatorRoot(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -255,9 +253,8 @@ func handleEth1DataSlice(val []*ethpb.Eth1Data, indices []uint64, convertAll boo
|
|||||||
length = len(val)
|
length = len(val)
|
||||||
}
|
}
|
||||||
roots := make([][32]byte, 0, length)
|
roots := make([][32]byte, 0, length)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
rootCreator := func(input *ethpb.Eth1Data) error {
|
rootCreator := func(input *ethpb.Eth1Data) error {
|
||||||
newRoot, err := stateutil.Eth1DataRootWithHasher(hasher, input)
|
newRoot, err := stateutil.Eth1DataRoot(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -294,9 +291,8 @@ func handlePendingAttestationSlice(val []*ethpb.PendingAttestation, indices []ui
|
|||||||
length = len(val)
|
length = len(val)
|
||||||
}
|
}
|
||||||
roots := make([][32]byte, 0, length)
|
roots := make([][32]byte, 0, length)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
rootCreator := func(input *ethpb.PendingAttestation) error {
|
rootCreator := func(input *ethpb.PendingAttestation) error {
|
||||||
newRoot, err := stateutil.PendingAttRootWithHasher(hasher, input)
|
newRoot, err := stateutil.PendingAttRootWithHasher(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||||
@@ -24,7 +23,6 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
|||||||
if state == nil {
|
if state == nil {
|
||||||
return nil, errors.New("nil state")
|
return nil, errors.New("nil state")
|
||||||
}
|
}
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
var fieldRoots [][]byte
|
var fieldRoots [][]byte
|
||||||
switch state.version {
|
switch state.version {
|
||||||
case version.Phase0:
|
case version.Phase0:
|
||||||
@@ -98,7 +96,7 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
|||||||
fieldRoots[types.HistoricalRoots.RealPosition()] = historicalRootsRt[:]
|
fieldRoots[types.HistoricalRoots.RealPosition()] = historicalRootsRt[:]
|
||||||
|
|
||||||
// Eth1Data data structure root.
|
// Eth1Data data structure root.
|
||||||
eth1HashTreeRoot, err := stateutil.Eth1Root(hasher, state.eth1Data)
|
eth1HashTreeRoot, err := stateutil.Eth1DataRoot(state.eth1Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not compute eth1data merkleization")
|
return nil, errors.Wrap(err, "could not compute eth1data merkleization")
|
||||||
}
|
}
|
||||||
@@ -186,21 +184,21 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
|||||||
fieldRoots[types.JustificationBits.RealPosition()] = justifiedBitsRoot[:]
|
fieldRoots[types.JustificationBits.RealPosition()] = justifiedBitsRoot[:]
|
||||||
|
|
||||||
// PreviousJustifiedCheckpoint data structure root.
|
// PreviousJustifiedCheckpoint data structure root.
|
||||||
prevCheckRoot, err := ssz.CheckpointRoot(hasher, state.previousJustifiedCheckpoint)
|
prevCheckRoot, err := ssz.CheckpointRoot(state.previousJustifiedCheckpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not compute previous justified checkpoint merkleization")
|
return nil, errors.Wrap(err, "could not compute previous justified checkpoint merkleization")
|
||||||
}
|
}
|
||||||
fieldRoots[types.PreviousJustifiedCheckpoint.RealPosition()] = prevCheckRoot[:]
|
fieldRoots[types.PreviousJustifiedCheckpoint.RealPosition()] = prevCheckRoot[:]
|
||||||
|
|
||||||
// CurrentJustifiedCheckpoint data structure root.
|
// CurrentJustifiedCheckpoint data structure root.
|
||||||
currJustRoot, err := ssz.CheckpointRoot(hasher, state.currentJustifiedCheckpoint)
|
currJustRoot, err := ssz.CheckpointRoot(state.currentJustifiedCheckpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not compute current justified checkpoint merkleization")
|
return nil, errors.Wrap(err, "could not compute current justified checkpoint merkleization")
|
||||||
}
|
}
|
||||||
fieldRoots[types.CurrentJustifiedCheckpoint.RealPosition()] = currJustRoot[:]
|
fieldRoots[types.CurrentJustifiedCheckpoint.RealPosition()] = currJustRoot[:]
|
||||||
|
|
||||||
// FinalizedCheckpoint data structure root.
|
// FinalizedCheckpoint data structure root.
|
||||||
finalRoot, err := ssz.CheckpointRoot(hasher, state.finalizedCheckpoint)
|
finalRoot, err := ssz.CheckpointRoot(state.finalizedCheckpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not compute finalized checkpoint merkleization")
|
return nil, errors.Wrap(err, "could not compute finalized checkpoint merkleization")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/container/slice"
|
"github.com/prysmaticlabs/prysm/v3/container/slice"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -694,7 +693,6 @@ func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex)
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
span.AddAttributes(trace.StringAttribute("field", field.String(b.version)))
|
span.AddAttributes(trace.StringAttribute("field", field.String(b.version)))
|
||||||
|
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
switch field {
|
switch field {
|
||||||
case types.GenesisTime:
|
case types.GenesisTime:
|
||||||
return ssz.Uint64Root(b.genesisTime), nil
|
return ssz.Uint64Root(b.genesisTime), nil
|
||||||
@@ -735,7 +733,7 @@ func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex)
|
|||||||
}
|
}
|
||||||
return ssz.ByteArrayRootWithLimit(hRoots, fieldparams.HistoricalRootsLength)
|
return ssz.ByteArrayRootWithLimit(hRoots, fieldparams.HistoricalRootsLength)
|
||||||
case types.Eth1Data:
|
case types.Eth1Data:
|
||||||
return stateutil.Eth1Root(hasher, b.eth1Data)
|
return stateutil.Eth1DataRoot(b.eth1Data)
|
||||||
case types.Eth1DataVotes:
|
case types.Eth1DataVotes:
|
||||||
if b.rebuildTrie[field] {
|
if b.rebuildTrie[field] {
|
||||||
err := b.resetFieldTrie(
|
err := b.resetFieldTrie(
|
||||||
@@ -817,11 +815,11 @@ func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex)
|
|||||||
case types.JustificationBits:
|
case types.JustificationBits:
|
||||||
return bytesutil.ToBytes32(b.justificationBits), nil
|
return bytesutil.ToBytes32(b.justificationBits), nil
|
||||||
case types.PreviousJustifiedCheckpoint:
|
case types.PreviousJustifiedCheckpoint:
|
||||||
return ssz.CheckpointRoot(hasher, b.previousJustifiedCheckpoint)
|
return ssz.CheckpointRoot(b.previousJustifiedCheckpoint)
|
||||||
case types.CurrentJustifiedCheckpoint:
|
case types.CurrentJustifiedCheckpoint:
|
||||||
return ssz.CheckpointRoot(hasher, b.currentJustifiedCheckpoint)
|
return ssz.CheckpointRoot(b.currentJustifiedCheckpoint)
|
||||||
case types.FinalizedCheckpoint:
|
case types.FinalizedCheckpoint:
|
||||||
return ssz.CheckpointRoot(hasher, b.finalizedCheckpoint)
|
return ssz.CheckpointRoot(b.finalizedCheckpoint)
|
||||||
case types.InactivityScores:
|
case types.InactivityScores:
|
||||||
return stateutil.Uint64ListRootWithRegistryLimit(b.inactivityScores)
|
return stateutil.Uint64ListRootWithRegistryLimit(b.inactivityScores)
|
||||||
case types.CurrentSyncCommittee:
|
case types.CurrentSyncCommittee:
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ go_library(
|
|||||||
"block_header_root.go",
|
"block_header_root.go",
|
||||||
"eth1_root.go",
|
"eth1_root.go",
|
||||||
"field_root_attestation.go",
|
"field_root_attestation.go",
|
||||||
"field_root_eth1.go",
|
|
||||||
"field_root_validator.go",
|
"field_root_validator.go",
|
||||||
"field_root_vector.go",
|
"field_root_vector.go",
|
||||||
"historical_summaries_root.go",
|
"historical_summaries_root.go",
|
||||||
@@ -33,7 +32,6 @@ go_library(
|
|||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//beacon-chain/core/transition/stateutils:go_default_library",
|
"//beacon-chain/core/transition/stateutils:go_default_library",
|
||||||
"//config/features:go_default_library",
|
|
||||||
"//config/fieldparams:go_default_library",
|
"//config/fieldparams:go_default_library",
|
||||||
"//config/params:go_default_library",
|
"//config/params:go_default_library",
|
||||||
"//consensus-types/primitives:go_default_library",
|
"//consensus-types/primitives:go_default_library",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package stateutil
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -30,5 +29,5 @@ func BlockHeaderRoot(header *ethpb.BeaconBlockHeader) ([32]byte, error) {
|
|||||||
bodyRoot := bytesutil.ToBytes32(header.BodyRoot)
|
bodyRoot := bytesutil.ToBytes32(header.BodyRoot)
|
||||||
fieldRoots[4] = bodyRoot
|
fieldRoots[4] = bodyRoot
|
||||||
}
|
}
|
||||||
return ssz.BitwiseMerkleize(hash.CustomSHA256Hasher(), fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
params "github.com/prysmaticlabs/prysm/v3/config/params"
|
params "github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Eth1DataRootWithHasher returns the hash tree root of input `eth1Data`.
|
// Eth1DataRoot returns the hash tree root of input `eth1Data`.
|
||||||
func Eth1DataRootWithHasher(hasher ssz.HashFn, eth1Data *ethpb.Eth1Data) ([32]byte, error) {
|
func Eth1DataRoot(eth1Data *ethpb.Eth1Data) ([32]byte, error) {
|
||||||
if eth1Data == nil {
|
if eth1Data == nil {
|
||||||
return [32]byte{}, errors.New("nil eth1 data")
|
return [32]byte{}, errors.New("nil eth1 data")
|
||||||
}
|
}
|
||||||
@@ -33,31 +32,26 @@ func Eth1DataRootWithHasher(hasher ssz.HashFn, eth1Data *ethpb.Eth1Data) ([32]by
|
|||||||
if len(eth1Data.BlockHash) > 0 {
|
if len(eth1Data.BlockHash) > 0 {
|
||||||
fieldRoots[2] = bytesutil.ToBytes32(eth1Data.BlockHash)
|
fieldRoots[2] = bytesutil.ToBytes32(eth1Data.BlockHash)
|
||||||
}
|
}
|
||||||
root, err := ssz.BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
root, err := ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
return root, nil
|
return root, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eth1DatasRoot returns the hash tree root of input `eth1Datas`.
|
// Eth1DataVotesRoot returns the hash tree root of input `eth1Datas`.
|
||||||
func Eth1DatasRoot(eth1Datas []*ethpb.Eth1Data) ([32]byte, error) {
|
func Eth1DataVotesRoot(eth1Datas []*ethpb.Eth1Data) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
eth1VotesRoots := make([][32]byte, 0, len(eth1Datas))
|
eth1VotesRoots := make([][32]byte, 0, len(eth1Datas))
|
||||||
for i := 0; i < len(eth1Datas); i++ {
|
for i := 0; i < len(eth1Datas); i++ {
|
||||||
eth1, err := Eth1DataRootWithHasher(hasher, eth1Datas[i])
|
eth1, err := Eth1DataRoot(eth1Datas[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute eth1data merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute eth1data merkleization")
|
||||||
}
|
}
|
||||||
eth1VotesRoots = append(eth1VotesRoots, eth1)
|
eth1VotesRoots = append(eth1VotesRoots, eth1)
|
||||||
}
|
}
|
||||||
|
|
||||||
eth1VotesRootsRoot, err := ssz.BitwiseMerkleize(
|
vl := params.BeaconConfig().Eth1DataVotesLength()
|
||||||
hasher,
|
eth1VotesRootsRoot, err := ssz.BitwiseMerkleize(eth1VotesRoots, uint64(len(eth1VotesRoots)), vl)
|
||||||
eth1VotesRoots,
|
|
||||||
uint64(len(eth1VotesRoots)),
|
|
||||||
params.BeaconConfig().Eth1DataVotesLength(),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute eth1data votes merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute eth1data votes merkleization")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
params "github.com/prysmaticlabs/prysm/v3/config/params"
|
params "github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -24,22 +23,17 @@ func EpochAttestationsRoot(atts []*ethpb.PendingAttestation) ([32]byte, error) {
|
|||||||
return [32]byte{}, fmt.Errorf("epoch attestation exceeds max length %d", max)
|
return [32]byte{}, fmt.Errorf("epoch attestation exceeds max length %d", max)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
roots := make([][32]byte, len(atts))
|
roots := make([][32]byte, len(atts))
|
||||||
for i := 0; i < len(atts); i++ {
|
for i := 0; i < len(atts); i++ {
|
||||||
pendingRoot, err := pendingAttestationRoot(hasher, atts[i])
|
pendingRoot, err := pendingAttestationRoot(atts[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not attestation merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not attestation merkleization")
|
||||||
}
|
}
|
||||||
roots[i] = pendingRoot
|
roots[i] = pendingRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
attsRootsRoot, err := ssz.BitwiseMerkleize(
|
atLen := params.BeaconConfig().CurrentEpochAttestationsLength()
|
||||||
hasher,
|
attsRootsRoot, err := ssz.BitwiseMerkleize(roots, uint64(len(roots)), atLen)
|
||||||
roots,
|
|
||||||
uint64(len(roots)),
|
|
||||||
params.BeaconConfig().CurrentEpochAttestationsLength(),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute epoch attestations merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute epoch attestations merkleization")
|
||||||
}
|
}
|
||||||
@@ -54,9 +48,9 @@ func EpochAttestationsRoot(atts []*ethpb.PendingAttestation) ([32]byte, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pendingAttestationRoot(hasher ssz.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) {
|
func pendingAttestationRoot(att *ethpb.PendingAttestation) ([32]byte, error) {
|
||||||
if att == nil {
|
if att == nil {
|
||||||
return [32]byte{}, errors.New("nil pending attestation")
|
return [32]byte{}, errors.New("nil pending attestation")
|
||||||
}
|
}
|
||||||
return PendingAttRootWithHasher(hasher, att)
|
return PendingAttRootWithHasher(att)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package stateutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Eth1Root computes the HashTreeRoot Merkleization of
|
|
||||||
// a BeaconBlockHeader struct according to the eth2
|
|
||||||
// Simple Serialize specification.
|
|
||||||
func Eth1Root(hasher ssz.HashFn, eth1Data *ethpb.Eth1Data) ([32]byte, error) {
|
|
||||||
if eth1Data == nil {
|
|
||||||
return [32]byte{}, errors.New("nil eth1 data")
|
|
||||||
}
|
|
||||||
return Eth1DataRootWithHasher(hasher, eth1Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Eth1DataVotesRoot computes the HashTreeRoot Merkleization of
|
|
||||||
// a list of Eth1Data structs according to the eth2
|
|
||||||
// Simple Serialize specification.
|
|
||||||
func Eth1DataVotesRoot(eth1DataVotes []*ethpb.Eth1Data) ([32]byte, error) {
|
|
||||||
return Eth1DatasRoot(eth1DataVotes)
|
|
||||||
}
|
|
||||||
@@ -5,9 +5,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -27,28 +25,13 @@ const (
|
|||||||
// ValidatorRegistryRoot computes the HashTreeRoot Merkleization of
|
// ValidatorRegistryRoot computes the HashTreeRoot Merkleization of
|
||||||
// a list of validator structs according to the Ethereum
|
// a list of validator structs according to the Ethereum
|
||||||
// Simple Serialize specification.
|
// Simple Serialize specification.
|
||||||
func ValidatorRegistryRoot(vals []*ethpb.Validator) ([32]byte, error) {
|
func ValidatorRegistryRoot(validators []*ethpb.Validator) ([32]byte, error) {
|
||||||
return validatorRegistryRoot(vals)
|
roots, err := optimizedValidatorRoots(validators)
|
||||||
}
|
if err != nil {
|
||||||
|
return [32]byte{}, err
|
||||||
func validatorRegistryRoot(validators []*ethpb.Validator) ([32]byte, error) {
|
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
|
|
||||||
var err error
|
|
||||||
var roots [][32]byte
|
|
||||||
if features.Get().EnableVectorizedHTR {
|
|
||||||
roots, err = optimizedValidatorRoots(validators)
|
|
||||||
if err != nil {
|
|
||||||
return [32]byte{}, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
roots, err = validatorRoots(hasher, validators)
|
|
||||||
if err != nil {
|
|
||||||
return [32]byte{}, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validatorsRootsRoot, err := ssz.BitwiseMerkleize(hasher, roots, uint64(len(roots)), fieldparams.ValidatorRegistryLimit)
|
validatorsRootsRoot, err := ssz.BitwiseMerkleize(roots, uint64(len(roots)), fieldparams.ValidatorRegistryLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute validator registry merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute validator registry merkleization")
|
||||||
}
|
}
|
||||||
@@ -64,27 +47,14 @@ func validatorRegistryRoot(validators []*ethpb.Validator) ([32]byte, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validatorRoots(hasher func([]byte) [32]byte, validators []*ethpb.Validator) ([][32]byte, error) {
|
|
||||||
roots := make([][32]byte, len(validators))
|
|
||||||
for i := 0; i < len(validators); i++ {
|
|
||||||
val, err := validatorRoot(hasher, validators[i])
|
|
||||||
if err != nil {
|
|
||||||
return [][32]byte{}, errors.Wrap(err, "could not compute validators merkleization")
|
|
||||||
}
|
|
||||||
roots[i] = val
|
|
||||||
}
|
|
||||||
return roots, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func optimizedValidatorRoots(validators []*ethpb.Validator) ([][32]byte, error) {
|
func optimizedValidatorRoots(validators []*ethpb.Validator) ([][32]byte, error) {
|
||||||
// Exit early if no validators are provided.
|
// Exit early if no validators are provided.
|
||||||
if len(validators) == 0 {
|
if len(validators) == 0 {
|
||||||
return [][32]byte{}, nil
|
return [][32]byte{}, nil
|
||||||
}
|
}
|
||||||
roots := make([][32]byte, 0, len(validators)*validatorFieldRoots)
|
roots := make([][32]byte, 0, len(validators)*validatorFieldRoots)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
for i := 0; i < len(validators); i++ {
|
for i := 0; i < len(validators); i++ {
|
||||||
fRoots, err := ValidatorFieldRoots(hasher, validators[i])
|
fRoots, err := ValidatorFieldRoots(validators[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [][32]byte{}, errors.Wrap(err, "could not compute validators merkleization")
|
return [][32]byte{}, errors.Wrap(err, "could not compute validators merkleization")
|
||||||
}
|
}
|
||||||
@@ -103,10 +73,3 @@ func optimizedValidatorRoots(validators []*ethpb.Validator) ([][32]byte, error)
|
|||||||
}
|
}
|
||||||
return roots, nil
|
return roots, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validatorRoot(hasher ssz.HashFn, validator *ethpb.Validator) ([32]byte, error) {
|
|
||||||
if validator == nil {
|
|
||||||
return [32]byte{}, errors.New("nil validator")
|
|
||||||
}
|
|
||||||
return ValidatorRootWithHasher(hasher, validator)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,18 +2,15 @@ package stateutil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ArraysRoot(input [][]byte, length uint64) ([32]byte, error) {
|
func ArraysRoot(input [][]byte, length uint64) ([32]byte, error) {
|
||||||
hashFunc := hash.CustomSHA256Hasher()
|
|
||||||
|
|
||||||
leaves := make([][32]byte, length)
|
leaves := make([][32]byte, length)
|
||||||
for i, chunk := range input {
|
for i, chunk := range input {
|
||||||
copy(leaves[i][:], chunk)
|
copy(leaves[i][:], chunk)
|
||||||
}
|
}
|
||||||
res, err := merkleize(leaves, length, hashFunc)
|
res, err := merkleize(leaves, length)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
@@ -21,8 +18,7 @@ func ArraysRoot(input [][]byte, length uint64) ([32]byte, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func merkleize(leaves [][32]byte, length uint64,
|
func merkleize(leaves [][32]byte, length uint64) ([32]byte, error) {
|
||||||
hasher func([]byte) [32]byte) ([32]byte, error) {
|
|
||||||
if len(leaves) == 0 {
|
if len(leaves) == 0 {
|
||||||
return [32]byte{}, errors.New("zero leaves provided")
|
return [32]byte{}, errors.New("zero leaves provided")
|
||||||
}
|
}
|
||||||
@@ -33,7 +29,7 @@ func merkleize(leaves [][32]byte, length uint64,
|
|||||||
layers := make([][][32]byte, ssz.Depth(length)+1)
|
layers := make([][][32]byte, ssz.Depth(length)+1)
|
||||||
layers[0] = hashLayer
|
layers[0] = hashLayer
|
||||||
var err error
|
var err error
|
||||||
_, hashLayer, err = MerkleizeTrieLeaves(layers, hashLayer, hasher)
|
_, hashLayer, err = MerkleizeTrieLeaves(layers, hashLayer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -18,7 +17,6 @@ func HistoricalSummariesRoot(summaries []*ethpb.HistoricalSummary) ([32]byte, er
|
|||||||
return [32]byte{}, fmt.Errorf("historical summary exceeds max length %d", max)
|
return [32]byte{}, fmt.Errorf("historical summary exceeds max length %d", max)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
roots := make([][32]byte, len(summaries))
|
roots := make([][32]byte, len(summaries))
|
||||||
for i := 0; i < len(summaries); i++ {
|
for i := 0; i < len(summaries); i++ {
|
||||||
r, err := summaries[i].HashTreeRoot()
|
r, err := summaries[i].HashTreeRoot()
|
||||||
@@ -28,12 +26,7 @@ func HistoricalSummariesRoot(summaries []*ethpb.HistoricalSummary) ([32]byte, er
|
|||||||
roots[i] = r
|
roots[i] = r
|
||||||
}
|
}
|
||||||
|
|
||||||
summariesRoot, err := ssz.BitwiseMerkleize(
|
summariesRoot, err := ssz.BitwiseMerkleize(roots, uint64(len(roots)), fieldparams.HistoricalRootsLength)
|
||||||
hasher,
|
|
||||||
roots,
|
|
||||||
uint64(len(roots)),
|
|
||||||
fieldparams.HistoricalRootsLength,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute historical summaries merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute historical summaries merkleization")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParticipationBitsRoot computes the HashTreeRoot merkleization of
|
// ParticipationBitsRoot computes the HashTreeRoot merkleization of
|
||||||
// participation roots.
|
// participation roots.
|
||||||
func ParticipationBitsRoot(bits []byte) ([32]byte, error) {
|
func ParticipationBitsRoot(bits []byte) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
chunkedRoots, err := packParticipationBits(bits)
|
chunkedRoots, err := packParticipationBits(bits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
@@ -20,7 +18,7 @@ func ParticipationBitsRoot(bits []byte) ([32]byte, error) {
|
|||||||
|
|
||||||
limit := (uint64(fieldparams.ValidatorRegistryLimit + 31)) / 32
|
limit := (uint64(fieldparams.ValidatorRegistryLimit + 31)) / 32
|
||||||
|
|
||||||
bytesRoot, err := ssz.BitwiseMerkleize(hasher, chunkedRoots, uint64(len(chunkedRoots)), limit)
|
bytesRoot, err := ssz.BitwiseMerkleize(chunkedRoots, uint64(len(chunkedRoots)), limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ import (
|
|||||||
|
|
||||||
// PendingAttRootWithHasher describes a method from which the hash tree root
|
// PendingAttRootWithHasher describes a method from which the hash tree root
|
||||||
// of a pending attestation is returned.
|
// of a pending attestation is returned.
|
||||||
func PendingAttRootWithHasher(hasher ssz.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) {
|
func PendingAttRootWithHasher(att *ethpb.PendingAttestation) ([32]byte, error) {
|
||||||
var fieldRoots [][32]byte
|
var fieldRoots [][32]byte
|
||||||
|
|
||||||
// Bitfield.
|
// Bitfield.
|
||||||
aggregationRoot, err := ssz.BitlistRoot(hasher, att.AggregationBits, params.BeaconConfig().MaxValidatorsPerCommittee)
|
aggregationRoot, err := ssz.BitlistRoot(att.AggregationBits, params.BeaconConfig().MaxValidatorsPerCommittee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
// Attestation data.
|
// Attestation data.
|
||||||
attDataRoot, err := attDataRootWithHasher(hasher, att.Data)
|
attDataRoot, err := attDataRootWithHasher(att.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
@@ -37,10 +37,10 @@ func PendingAttRootWithHasher(hasher ssz.HashFn, att *ethpb.PendingAttestation)
|
|||||||
|
|
||||||
fieldRoots = [][32]byte{aggregationRoot, attDataRoot, inclusionRoot, proposerRoot}
|
fieldRoots = [][32]byte{aggregationRoot, attDataRoot, inclusionRoot, proposerRoot}
|
||||||
|
|
||||||
return ssz.BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func attDataRootWithHasher(hasher ssz.HashFn, data *ethpb.AttestationData) ([32]byte, error) {
|
func attDataRootWithHasher(data *ethpb.AttestationData) ([32]byte, error) {
|
||||||
fieldRoots := make([][32]byte, 5)
|
fieldRoots := make([][32]byte, 5)
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
@@ -58,18 +58,18 @@ func attDataRootWithHasher(hasher ssz.HashFn, data *ethpb.AttestationData) ([32]
|
|||||||
fieldRoots[2] = bytesutil.ToBytes32(data.BeaconBlockRoot)
|
fieldRoots[2] = bytesutil.ToBytes32(data.BeaconBlockRoot)
|
||||||
|
|
||||||
// Source
|
// Source
|
||||||
sourceRoot, err := ssz.CheckpointRoot(hasher, data.Source)
|
sourceRoot, err := ssz.CheckpointRoot(data.Source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute source checkpoint merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute source checkpoint merkleization")
|
||||||
}
|
}
|
||||||
fieldRoots[3] = sourceRoot
|
fieldRoots[3] = sourceRoot
|
||||||
|
|
||||||
// Target
|
// Target
|
||||||
fieldRoots[4], err = ssz.CheckpointRoot(hasher, data.Target)
|
fieldRoots[4], err = ssz.CheckpointRoot(data.Target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute target checkpoint merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute target checkpoint merkleization")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ssz.BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package stateutil
|
package stateutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -12,7 +10,6 @@ import (
|
|||||||
// a SyncCommitteeRoot struct according to the eth2
|
// a SyncCommitteeRoot struct according to the eth2
|
||||||
// Simple Serialize specification.
|
// Simple Serialize specification.
|
||||||
func SyncCommitteeRoot(committee *ethpb.SyncCommittee) ([32]byte, error) {
|
func SyncCommitteeRoot(committee *ethpb.SyncCommittee) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
var fieldRoots [][32]byte
|
var fieldRoots [][32]byte
|
||||||
if committee == nil {
|
if committee == nil {
|
||||||
return [32]byte{}, nil
|
return [32]byte{}, nil
|
||||||
@@ -21,42 +18,35 @@ func SyncCommitteeRoot(committee *ethpb.SyncCommittee) ([32]byte, error) {
|
|||||||
// Field 1: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE]
|
// Field 1: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE]
|
||||||
pubKeyRoots := make([][32]byte, 0)
|
pubKeyRoots := make([][32]byte, 0)
|
||||||
for _, pubkey := range committee.Pubkeys {
|
for _, pubkey := range committee.Pubkeys {
|
||||||
r, err := merkleizePubkey(hasher, pubkey)
|
r, err := merkleizePubkey(pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
pubKeyRoots = append(pubKeyRoots, r)
|
pubKeyRoots = append(pubKeyRoots, r)
|
||||||
}
|
}
|
||||||
pubkeyRoot, err := ssz.BitwiseMerkleize(hasher, pubKeyRoots, uint64(len(pubKeyRoots)), uint64(len(pubKeyRoots)))
|
pubkeyRoot, err := ssz.BitwiseMerkleize(pubKeyRoots, uint64(len(pubKeyRoots)), uint64(len(pubKeyRoots)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field 2: BLSPubkey
|
// Field 2: BLSPubkey
|
||||||
aggregateKeyRoot, err := merkleizePubkey(hasher, committee.AggregatePubkey)
|
aggregateKeyRoot, err := merkleizePubkey(committee.AggregatePubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
fieldRoots = [][32]byte{pubkeyRoot, aggregateKeyRoot}
|
fieldRoots = [][32]byte{pubkeyRoot, aggregateKeyRoot}
|
||||||
|
|
||||||
return ssz.BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func merkleizePubkey(hasher ssz.HashFn, pubkey []byte) ([32]byte, error) {
|
func merkleizePubkey(pubkey []byte) ([32]byte, error) {
|
||||||
chunks, err := ssz.PackByChunk([][]byte{pubkey})
|
chunks, err := ssz.PackByChunk([][]byte{pubkey})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
var pubKeyRoot [32]byte
|
var pubKeyRoot [32]byte
|
||||||
if features.Get().EnableVectorizedHTR {
|
outputChunk := make([][32]byte, 1)
|
||||||
outputChunk := make([][32]byte, 1)
|
htr.VectorizedSha256(chunks, outputChunk)
|
||||||
htr.VectorizedSha256(chunks, outputChunk)
|
pubKeyRoot = outputChunk[0]
|
||||||
pubKeyRoot = outputChunk[0]
|
|
||||||
} else {
|
|
||||||
pubKeyRoot, err = ssz.BitwiseMerkleize(hasher, chunks, uint64(len(chunks)), uint64(len(chunks)))
|
|
||||||
if err != nil {
|
|
||||||
return [32]byte{}, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pubKeyRoot, nil
|
return pubKeyRoot, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/container/trie"
|
"github.com/prysmaticlabs/prysm/v3/container/trie"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
||||||
@@ -17,7 +16,6 @@ import (
|
|||||||
// provided with the elements of a fixed sized trie and the corresponding depth of
|
// provided with the elements of a fixed sized trie and the corresponding depth of
|
||||||
// it.
|
// it.
|
||||||
func ReturnTrieLayer(elements [][32]byte, length uint64) ([][]*[32]byte, error) {
|
func ReturnTrieLayer(elements [][32]byte, length uint64) ([][]*[32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
leaves := elements
|
leaves := elements
|
||||||
|
|
||||||
if len(leaves) == 1 {
|
if len(leaves) == 1 {
|
||||||
@@ -27,7 +25,7 @@ func ReturnTrieLayer(elements [][32]byte, length uint64) ([][]*[32]byte, error)
|
|||||||
layers := make([][][32]byte, ssz.Depth(length)+1)
|
layers := make([][][32]byte, ssz.Depth(length)+1)
|
||||||
layers[0] = hashLayer
|
layers[0] = hashLayer
|
||||||
var err error
|
var err error
|
||||||
layers, _, err = MerkleizeTrieLeaves(layers, hashLayer, hasher)
|
layers, _, err = MerkleizeTrieLeaves(layers, hashLayer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -46,7 +44,6 @@ func ReturnTrieLayer(elements [][32]byte, length uint64) ([][]*[32]byte, error)
|
|||||||
// provided with the elements of a variable sized trie and the corresponding depth of
|
// provided with the elements of a variable sized trie and the corresponding depth of
|
||||||
// it.
|
// it.
|
||||||
func ReturnTrieLayerVariable(elements [][32]byte, length uint64) [][]*[32]byte {
|
func ReturnTrieLayerVariable(elements [][32]byte, length uint64) [][]*[32]byte {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
depth := ssz.Depth(length)
|
depth := ssz.Depth(length)
|
||||||
layers := make([][]*[32]byte, depth+1)
|
layers := make([][]*[32]byte, depth+1)
|
||||||
// Return zerohash at depth
|
// Return zerohash at depth
|
||||||
@@ -67,38 +64,18 @@ func ReturnTrieLayerVariable(elements [][32]byte, length uint64) [][]*[32]byte {
|
|||||||
for i := uint8(0); i < depth; i++ {
|
for i := uint8(0); i < depth; i++ {
|
||||||
layerLen := len(layers[i])
|
layerLen := len(layers[i])
|
||||||
oddNodeLength := layerLen%2 == 1
|
oddNodeLength := layerLen%2 == 1
|
||||||
if features.Get().EnableVectorizedHTR {
|
if oddNodeLength {
|
||||||
if oddNodeLength {
|
zerohash := trie.ZeroHashes[i]
|
||||||
zerohash := trie.ZeroHashes[i]
|
elements = append(elements, zerohash)
|
||||||
elements = append(elements, zerohash)
|
layerLen++
|
||||||
layerLen++
|
}
|
||||||
}
|
|
||||||
|
|
||||||
layers[i+1] = make([]*[32]byte, layerLen/2)
|
layers[i+1] = make([]*[32]byte, layerLen/2)
|
||||||
newElems := make([][32]byte, layerLen/2)
|
newElems := make([][32]byte, layerLen/2)
|
||||||
htr.VectorizedSha256(elements, newElems)
|
htr.VectorizedSha256(elements, newElems)
|
||||||
elements = newElems
|
elements = newElems
|
||||||
for j := range elements {
|
for j := range elements {
|
||||||
layers[i+1][j] = &elements[j]
|
layers[i+1][j] = &elements[j]
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if oddNodeLength {
|
|
||||||
zerohash := trie.ZeroHashes[i]
|
|
||||||
layers[i] = append(layers[i], &zerohash)
|
|
||||||
}
|
|
||||||
updatedValues := make([]*[32]byte, 0, len(layers[i])/2)
|
|
||||||
for j := 0; j < len(layers[i]); j += 2 {
|
|
||||||
buffer.Write(layers[i][j][:])
|
|
||||||
buffer.Write(layers[i][j+1][:])
|
|
||||||
concat := hasher(buffer.Bytes())
|
|
||||||
updatedValues = append(updatedValues, &concat)
|
|
||||||
buffer.Reset()
|
|
||||||
}
|
|
||||||
// remove zerohash node from tree
|
|
||||||
if oddNodeLength {
|
|
||||||
layers[i] = layers[i][:len(layers[i])-1]
|
|
||||||
}
|
|
||||||
layers[i+1] = updatedValues
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return layers
|
return layers
|
||||||
@@ -305,8 +282,7 @@ func Merkleize(leaves [][]byte) [][][]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MerkleizeTrieLeaves merkleize the trie leaves.
|
// MerkleizeTrieLeaves merkleize the trie leaves.
|
||||||
func MerkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte,
|
func MerkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte) ([][][32]byte, [][32]byte, error) {
|
||||||
hasher func([]byte) [32]byte) ([][][32]byte, [][32]byte, error) {
|
|
||||||
// We keep track of the hash layers of a Merkle trie until we reach
|
// We keep track of the hash layers of a Merkle trie until we reach
|
||||||
// the top layer of length 1, which contains the single root element.
|
// the top layer of length 1, which contains the single root element.
|
||||||
// [Root] -> Top layer has length 1.
|
// [Root] -> Top layer has length 1.
|
||||||
@@ -319,21 +295,9 @@ func MerkleizeTrieLeaves(layers [][][32]byte, hashLayer [][32]byte,
|
|||||||
if !math.IsPowerOf2(uint64(len(hashLayer))) {
|
if !math.IsPowerOf2(uint64(len(hashLayer))) {
|
||||||
return nil, nil, errors.Errorf("hash layer is a non power of 2: %d", len(hashLayer))
|
return nil, nil, errors.Errorf("hash layer is a non power of 2: %d", len(hashLayer))
|
||||||
}
|
}
|
||||||
if features.Get().EnableVectorizedHTR {
|
newLayer := make([][32]byte, len(hashLayer)/2)
|
||||||
newLayer := make([][32]byte, len(hashLayer)/2)
|
htr.VectorizedSha256(hashLayer, newLayer)
|
||||||
htr.VectorizedSha256(hashLayer, newLayer)
|
hashLayer = newLayer
|
||||||
hashLayer = newLayer
|
|
||||||
} else {
|
|
||||||
layer := make([][32]byte, len(hashLayer)/2)
|
|
||||||
for j := 0; j < len(hashLayer); j += 2 {
|
|
||||||
chunkBuffer.Write(hashLayer[j][:])
|
|
||||||
chunkBuffer.Write(hashLayer[j+1][:])
|
|
||||||
hashedChunk := hasher(chunkBuffer.Bytes())
|
|
||||||
layer[j/2] = hashedChunk
|
|
||||||
chunkBuffer.Reset()
|
|
||||||
}
|
|
||||||
hashLayer = layer
|
|
||||||
}
|
|
||||||
layers[i] = hashLayer
|
layers[i] = hashLayer
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
"github.com/prysmaticlabs/prysm/v3/config/features"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||||
@@ -27,7 +26,6 @@ func TestReturnTrieLayer_OK(t *testing.T) {
|
|||||||
assert.Equal(t, root, newRoot)
|
assert.Equal(t, root, newRoot)
|
||||||
|
|
||||||
flags := &features.Flags{}
|
flags := &features.Flags{}
|
||||||
flags.EnableVectorizedHTR = true
|
|
||||||
reset := features.InitWithReset(flags)
|
reset := features.InitWithReset(flags)
|
||||||
defer reset()
|
defer reset()
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ func BenchmarkReturnTrieLayer_NormalAlgorithm(b *testing.B) {
|
|||||||
|
|
||||||
func BenchmarkReturnTrieLayer_VectorizedAlgorithm(b *testing.B) {
|
func BenchmarkReturnTrieLayer_VectorizedAlgorithm(b *testing.B) {
|
||||||
flags := &features.Flags{}
|
flags := &features.Flags{}
|
||||||
flags.EnableVectorizedHTR = true
|
|
||||||
reset := features.InitWithReset(flags)
|
reset := features.InitWithReset(flags)
|
||||||
defer reset()
|
defer reset()
|
||||||
|
|
||||||
@@ -76,11 +73,10 @@ func TestReturnTrieLayerVariable_OK(t *testing.T) {
|
|||||||
newState, _ := util.DeterministicGenesisState(t, 32)
|
newState, _ := util.DeterministicGenesisState(t, 32)
|
||||||
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
validators := newState.Validators()
|
validators := newState.Validators()
|
||||||
roots := make([][32]byte, 0, len(validators))
|
roots := make([][32]byte, 0, len(validators))
|
||||||
for _, val := range validators {
|
for _, val := range validators {
|
||||||
rt, err := stateutil.ValidatorRootWithHasher(hasher, val)
|
rt, err := stateutil.ValidatorRoot(val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
roots = append(roots, rt)
|
roots = append(roots, rt)
|
||||||
}
|
}
|
||||||
@@ -91,7 +87,6 @@ func TestReturnTrieLayerVariable_OK(t *testing.T) {
|
|||||||
assert.Equal(t, root, newRoot)
|
assert.Equal(t, root, newRoot)
|
||||||
|
|
||||||
flags := &features.Flags{}
|
flags := &features.Flags{}
|
||||||
flags.EnableVectorizedHTR = true
|
|
||||||
reset := features.InitWithReset(flags)
|
reset := features.InitWithReset(flags)
|
||||||
defer reset()
|
defer reset()
|
||||||
|
|
||||||
@@ -107,11 +102,10 @@ func BenchmarkReturnTrieLayerVariable_NormalAlgorithm(b *testing.B) {
|
|||||||
newState, _ := util.DeterministicGenesisState(b, 16000)
|
newState, _ := util.DeterministicGenesisState(b, 16000)
|
||||||
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
validators := newState.Validators()
|
validators := newState.Validators()
|
||||||
roots := make([][32]byte, 0, len(validators))
|
roots := make([][32]byte, 0, len(validators))
|
||||||
for _, val := range validators {
|
for _, val := range validators {
|
||||||
rt, err := stateutil.ValidatorRootWithHasher(hasher, val)
|
rt, err := stateutil.ValidatorRoot(val)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
roots = append(roots, rt)
|
roots = append(roots, rt)
|
||||||
}
|
}
|
||||||
@@ -127,18 +121,16 @@ func BenchmarkReturnTrieLayerVariable_NormalAlgorithm(b *testing.B) {
|
|||||||
|
|
||||||
func BenchmarkReturnTrieLayerVariable_VectorizedAlgorithm(b *testing.B) {
|
func BenchmarkReturnTrieLayerVariable_VectorizedAlgorithm(b *testing.B) {
|
||||||
flags := &features.Flags{}
|
flags := &features.Flags{}
|
||||||
flags.EnableVectorizedHTR = true
|
|
||||||
reset := features.InitWithReset(flags)
|
reset := features.InitWithReset(flags)
|
||||||
defer reset()
|
defer reset()
|
||||||
|
|
||||||
newState, _ := util.DeterministicGenesisState(b, 16000)
|
newState, _ := util.DeterministicGenesisState(b, 16000)
|
||||||
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
root, err := stateutil.ValidatorRegistryRoot(newState.Validators())
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
validators := newState.Validators()
|
validators := newState.Validators()
|
||||||
roots := make([][32]byte, 0, len(validators))
|
roots := make([][32]byte, 0, len(validators))
|
||||||
for _, val := range validators {
|
for _, val := range validators {
|
||||||
rt, err := stateutil.ValidatorRootWithHasher(hasher, val)
|
rt, err := stateutil.ValidatorRoot(val)
|
||||||
require.NoError(b, err)
|
require.NoError(b, err)
|
||||||
roots = append(roots, rt)
|
roots = append(roots, rt)
|
||||||
}
|
}
|
||||||
@@ -174,10 +166,9 @@ func TestRecomputeFromLayer_FixedSizedArray(t *testing.T) {
|
|||||||
func TestRecomputeFromLayer_VariableSizedArray(t *testing.T) {
|
func TestRecomputeFromLayer_VariableSizedArray(t *testing.T) {
|
||||||
newState, _ := util.DeterministicGenesisState(t, 32)
|
newState, _ := util.DeterministicGenesisState(t, 32)
|
||||||
validators := newState.Validators()
|
validators := newState.Validators()
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
roots := make([][32]byte, 0, len(validators))
|
roots := make([][32]byte, 0, len(validators))
|
||||||
for _, val := range validators {
|
for _, val := range validators {
|
||||||
rt, err := stateutil.ValidatorRootWithHasher(hasher, val)
|
rt, err := stateutil.ValidatorRoot(val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
roots = append(roots, rt)
|
roots = append(roots, rt)
|
||||||
}
|
}
|
||||||
@@ -202,7 +193,7 @@ func TestRecomputeFromLayer_VariableSizedArray(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
roots = make([][32]byte, 0, len(changedVals))
|
roots = make([][32]byte, 0, len(changedVals))
|
||||||
for _, val := range changedVals {
|
for _, val := range changedVals {
|
||||||
rt, err := stateutil.ValidatorRootWithHasher(hasher, val)
|
rt, err := stateutil.ValidatorRoot(val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
roots = append(roots, rt)
|
roots = append(roots, rt)
|
||||||
}
|
}
|
||||||
@@ -216,9 +207,7 @@ func TestRecomputeFromLayer_VariableSizedArray(t *testing.T) {
|
|||||||
func TestMerkleizeTrieLeaves_BadHashLayer(t *testing.T) {
|
func TestMerkleizeTrieLeaves_BadHashLayer(t *testing.T) {
|
||||||
hashLayer := make([][32]byte, 12)
|
hashLayer := make([][32]byte, 12)
|
||||||
layers := make([][][32]byte, 20)
|
layers := make([][][32]byte, 20)
|
||||||
_, _, err := stateutil.MerkleizeTrieLeaves(layers, hashLayer, func(bytes []byte) [32]byte {
|
_, _, err := stateutil.MerkleizeTrieLeaves(layers, hashLayer)
|
||||||
return [32]byte{}
|
|
||||||
})
|
|
||||||
assert.ErrorContains(t, "hash layer is a non power of 2", err)
|
assert.ErrorContains(t, "hash layer is a non power of 2", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,25 +5,24 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidatorRootWithHasher describes a method from which the hash tree root
|
// ValidatorRoot describes a method from which the hash tree root
|
||||||
// of a validator is returned.
|
// of a validator is returned.
|
||||||
func ValidatorRootWithHasher(hasher ssz.HashFn, validator *ethpb.Validator) ([32]byte, error) {
|
func ValidatorRoot(validator *ethpb.Validator) ([32]byte, error) {
|
||||||
fieldRoots, err := ValidatorFieldRoots(hasher, validator)
|
fieldRoots, err := ValidatorFieldRoots(validator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
return ssz.BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return ssz.BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidatorFieldRoots describes a method from which the hash tree root
|
// ValidatorFieldRoots describes a method from which the hash tree root
|
||||||
// of a validator is returned.
|
// of a validator is returned.
|
||||||
func ValidatorFieldRoots(hasher ssz.HashFn, validator *ethpb.Validator) ([][32]byte, error) {
|
func ValidatorFieldRoots(validator *ethpb.Validator) ([][32]byte, error) {
|
||||||
var fieldRoots [][32]byte
|
var fieldRoots [][32]byte
|
||||||
if validator != nil {
|
if validator != nil {
|
||||||
pubkey := bytesutil.ToBytes48(validator.PublicKey)
|
pubkey := bytesutil.ToBytes48(validator.PublicKey)
|
||||||
@@ -50,7 +49,7 @@ func ValidatorFieldRoots(hasher ssz.HashFn, validator *ethpb.Validator) ([][32]b
|
|||||||
binary.LittleEndian.PutUint64(withdrawalBuf[:8], uint64(validator.WithdrawableEpoch))
|
binary.LittleEndian.PutUint64(withdrawalBuf[:8], uint64(validator.WithdrawableEpoch))
|
||||||
|
|
||||||
// Public key.
|
// Public key.
|
||||||
pubKeyRoot, err := merkleizePubkey(hasher, pubkey[:])
|
pubKeyRoot, err := merkleizePubkey(pubkey[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [][32]byte{}, err
|
return [][32]byte{}, err
|
||||||
}
|
}
|
||||||
@@ -63,12 +62,11 @@ func ValidatorFieldRoots(hasher ssz.HashFn, validator *ethpb.Validator) ([][32]b
|
|||||||
// Uint64ListRootWithRegistryLimit computes the HashTreeRoot Merkleization of
|
// Uint64ListRootWithRegistryLimit computes the HashTreeRoot Merkleization of
|
||||||
// a list of uint64 and mixed with registry limit.
|
// a list of uint64 and mixed with registry limit.
|
||||||
func Uint64ListRootWithRegistryLimit(balances []uint64) ([32]byte, error) {
|
func Uint64ListRootWithRegistryLimit(balances []uint64) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
balancesChunks, err := PackUint64IntoChunks(balances)
|
balancesChunks, err := PackUint64IntoChunks(balances)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not pack balances into chunks")
|
return [32]byte{}, errors.Wrap(err, "could not pack balances into chunks")
|
||||||
}
|
}
|
||||||
balancesRootsRoot, err := ssz.BitwiseMerkleize(hasher, balancesChunks, uint64(len(balancesChunks)), ValidatorLimitForBalancesChunks())
|
balancesRootsRoot, err := ssz.BitwiseMerkleize(balancesChunks, uint64(len(balancesChunks)), ValidatorLimitForBalancesChunks())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute balances merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute balances merkleization")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//cmd:go_default_library",
|
"//cmd:go_default_library",
|
||||||
"//config/params:go_default_library",
|
"//config/params:go_default_library",
|
||||||
"@com_github_prysmaticlabs_gohashtree//:go_default_library",
|
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ The process for implementing new features using this package is as follows:
|
|||||||
package features
|
package features
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/gohashtree"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/cmd"
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -64,7 +60,6 @@ type Flags struct {
|
|||||||
|
|
||||||
DisablePullTips bool // DisablePullTips disables experimental disabling of boundary checks.
|
DisablePullTips bool // DisablePullTips disables experimental disabling of boundary checks.
|
||||||
EnableDefensivePull bool // EnableDefensivePull enables exerimental back boundary checks.
|
EnableDefensivePull bool // EnableDefensivePull enables exerimental back boundary checks.
|
||||||
EnableVectorizedHTR bool // EnableVectorizedHTR specifies whether the beacon state will use the optimized sha256 routines.
|
|
||||||
DisableForkchoiceDoublyLinkedTree bool // DisableForkChoiceDoublyLinkedTree specifies whether fork choice store will use a doubly linked tree.
|
DisableForkchoiceDoublyLinkedTree bool // DisableForkChoiceDoublyLinkedTree specifies whether fork choice store will use a doubly linked tree.
|
||||||
EnableBatchGossipAggregation bool // EnableBatchGossipAggregation specifies whether to further aggregate our gossip batches before verifying them.
|
EnableBatchGossipAggregation bool // EnableBatchGossipAggregation specifies whether to further aggregate our gossip batches before verifying them.
|
||||||
EnableOnlyBlindedBeaconBlocks bool // EnableOnlyBlindedBeaconBlocks enables only storing blinded beacon blocks in the DB post-Bellatrix fork.
|
EnableOnlyBlindedBeaconBlocks bool // EnableOnlyBlindedBeaconBlocks enables only storing blinded beacon blocks in the DB post-Bellatrix fork.
|
||||||
@@ -218,26 +213,6 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
|
|||||||
logEnabled(disableStakinContractCheck)
|
logEnabled(disableStakinContractCheck)
|
||||||
cfg.DisableStakinContractCheck = true
|
cfg.DisableStakinContractCheck = true
|
||||||
}
|
}
|
||||||
if ctx.Bool(disableVecHTR.Name) {
|
|
||||||
logEnabled(disableVecHTR)
|
|
||||||
} else {
|
|
||||||
sigc := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(sigc, syscall.SIGILL)
|
|
||||||
defer signal.Stop(sigc)
|
|
||||||
buffer := make([][32]byte, 2)
|
|
||||||
err := gohashtree.Hash(buffer, buffer)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("could not test if gohashtree is supported")
|
|
||||||
} else {
|
|
||||||
t := time.NewTimer(time.Millisecond * 100)
|
|
||||||
select {
|
|
||||||
case <-sigc:
|
|
||||||
log.Error("gohashtree is not supported in this CPU")
|
|
||||||
case <-t.C:
|
|
||||||
cfg.EnableVectorizedHTR = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ctx.Bool(disableForkChoiceDoublyLinkedTree.Name) {
|
if ctx.Bool(disableForkChoiceDoublyLinkedTree.Name) {
|
||||||
logEnabled(disableForkChoiceDoublyLinkedTree)
|
logEnabled(disableForkChoiceDoublyLinkedTree)
|
||||||
cfg.DisableForkchoiceDoublyLinkedTree = true
|
cfg.DisableForkchoiceDoublyLinkedTree = true
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ go_library(
|
|||||||
"//config/fieldparams:go_default_library",
|
"//config/fieldparams:go_default_library",
|
||||||
"//consensus-types/interfaces:go_default_library",
|
"//consensus-types/interfaces:go_default_library",
|
||||||
"//consensus-types/primitives:go_default_library",
|
"//consensus-types/primitives:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//encoding/ssz:go_default_library",
|
"//encoding/ssz:go_default_library",
|
||||||
"//proto/engine/v1:go_default_library",
|
"//proto/engine/v1:go_default_library",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
fastssz "github.com/prysmaticlabs/fastssz"
|
fastssz "github.com/prysmaticlabs/fastssz"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -703,7 +702,7 @@ func PayloadToHeaderCapella(payload interfaces.ExecutionData) (*enginev1.Executi
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
4
deps.bzl
4
deps.bzl
@@ -2953,8 +2953,8 @@ def prysm_deps():
|
|||||||
go_repository(
|
go_repository(
|
||||||
name = "com_github_prysmaticlabs_fastssz",
|
name = "com_github_prysmaticlabs_fastssz",
|
||||||
importpath = "github.com/prysmaticlabs/fastssz",
|
importpath = "github.com/prysmaticlabs/fastssz",
|
||||||
sum = "h1:Y3PcvUrnneMWLuypZpwPz8P70/DQsz6KgV9JveKpyZs=",
|
sum = "h1:ygSxa+M1uZZ01Rd+AjHFQmjeuoohcfgmy5mVOxmpBJ0=",
|
||||||
version = "v0.0.0-20220628121656-93dfe28febab",
|
version = "v0.0.0-20230216165902-cac1483628fe",
|
||||||
)
|
)
|
||||||
|
|
||||||
go_repository(
|
go_repository(
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/v3/encoding/ssz",
|
importpath = "github.com/prysmaticlabs/prysm/v3/encoding/ssz",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//config/features:go_default_library",
|
|
||||||
"//config/fieldparams:go_default_library",
|
"//config/fieldparams:go_default_library",
|
||||||
"//container/trie:go_default_library",
|
"//container/trie:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
|
||||||
"//crypto/hash/htr:go_default_library",
|
"//crypto/hash/htr:go_default_library",
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//proto/engine/v1:go_default_library",
|
"//proto/engine/v1:go_default_library",
|
||||||
|
|||||||
@@ -8,18 +8,17 @@ import (
|
|||||||
"github.com/minio/sha256-simd"
|
"github.com/minio/sha256-simd"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
"github.com/prysmaticlabs/prysm/v3/config/features"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bytesPerChunk = 32
|
const bytesPerChunk = 32
|
||||||
|
|
||||||
// BitlistRoot returns the mix in length of a bitwise Merkleized bitfield.
|
// BitlistRoot returns the mix in length of a bitwise Merkleized bitfield.
|
||||||
func BitlistRoot(hasher HashFn, bfield bitfield.Bitfield, maxCapacity uint64) ([32]byte, error) {
|
func BitlistRoot(bfield bitfield.Bitfield, maxCapacity uint64) ([32]byte, error) {
|
||||||
limit := (maxCapacity + 255) / 256
|
limit := (maxCapacity + 255) / 256
|
||||||
if bfield == nil || bfield.Len() == 0 {
|
if bfield == nil || bfield.Len() == 0 {
|
||||||
length := make([]byte, 32)
|
length := make([]byte, 32)
|
||||||
root, err := BitwiseMerkleize(hasher, [][32]byte{}, 0, limit)
|
root, err := BitwiseMerkleize([][32]byte{}, 0, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
@@ -35,7 +34,7 @@ func BitlistRoot(hasher HashFn, bfield bitfield.Bitfield, maxCapacity uint64) ([
|
|||||||
}
|
}
|
||||||
output := make([]byte, 32)
|
output := make([]byte, 32)
|
||||||
copy(output, buf.Bytes())
|
copy(output, buf.Bytes())
|
||||||
root, err := BitwiseMerkleize(hasher, chunks, uint64(len(chunks)), limit)
|
root, err := BitwiseMerkleize(chunks, uint64(len(chunks)), limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
@@ -47,18 +46,11 @@ func BitlistRoot(hasher HashFn, bfield bitfield.Bitfield, maxCapacity uint64) ([
|
|||||||
// and return the root.
|
// and return the root.
|
||||||
// Note that merkleize on a single chunk is simply that chunk, i.e. the identity
|
// Note that merkleize on a single chunk is simply that chunk, i.e. the identity
|
||||||
// when the number of chunks is one.
|
// when the number of chunks is one.
|
||||||
func BitwiseMerkleize(hasher HashFn, chunks [][32]byte, count, limit uint64) ([32]byte, error) {
|
func BitwiseMerkleize(chunks [][32]byte, count, limit uint64) ([32]byte, error) {
|
||||||
if count > limit {
|
if count > limit {
|
||||||
return [32]byte{}, errors.New("merkleizing list that is too large, over limit")
|
return [32]byte{}, errors.New("merkleizing list that is too large, over limit")
|
||||||
}
|
}
|
||||||
if features.Get().EnableVectorizedHTR {
|
return MerkleizeVector(chunks, limit), nil
|
||||||
return MerkleizeVector(chunks, limit), nil
|
|
||||||
}
|
|
||||||
hashFn := NewHasherFunc(hasher)
|
|
||||||
leafIndexer := func(i uint64) []byte {
|
|
||||||
return chunks[i][:]
|
|
||||||
}
|
|
||||||
return Merkleize(hashFn, count, limit, leafIndexer), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackByChunk a given byte array's final chunk with zeroes if needed.
|
// PackByChunk a given byte array's final chunk with zeroes if needed.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||||
@@ -13,18 +12,16 @@ import (
|
|||||||
const merkleizingListLimitError = "merkleizing list that is too large, over limit"
|
const merkleizingListLimitError = "merkleizing list that is too large, over limit"
|
||||||
|
|
||||||
func TestBitlistRoot(t *testing.T) {
|
func TestBitlistRoot(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
capacity := uint64(10)
|
capacity := uint64(10)
|
||||||
bfield := bitfield.NewBitlist(capacity)
|
bfield := bitfield.NewBitlist(capacity)
|
||||||
expected := [32]byte{176, 76, 194, 203, 142, 166, 117, 79, 148, 194, 231, 64, 60, 245, 142, 32, 201, 2, 58, 152, 53, 12, 132, 40, 41, 102, 224, 189, 103, 41, 211, 202}
|
expected := [32]byte{176, 76, 194, 203, 142, 166, 117, 79, 148, 194, 231, 64, 60, 245, 142, 32, 201, 2, 58, 152, 53, 12, 132, 40, 41, 102, 224, 189, 103, 41, 211, 202}
|
||||||
|
|
||||||
result, err := ssz.BitlistRoot(hasher, bfield, capacity)
|
result, err := ssz.BitlistRoot(bfield, capacity)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, result)
|
assert.Equal(t, expected, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBitwiseMerkleizeOverLimit(t *testing.T) {
|
func TestBitwiseMerkleizeOverLimit(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
chunks := [][32]byte{
|
chunks := [][32]byte{
|
||||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||||
{11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
|
{11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
|
||||||
@@ -32,12 +29,11 @@ func TestBitwiseMerkleizeOverLimit(t *testing.T) {
|
|||||||
count := uint64(2)
|
count := uint64(2)
|
||||||
limit := uint64(1)
|
limit := uint64(1)
|
||||||
|
|
||||||
_, err := ssz.BitwiseMerkleize(hasher, chunks, count, limit)
|
_, err := ssz.BitwiseMerkleize(chunks, count, limit)
|
||||||
assert.ErrorContains(t, merkleizingListLimitError, err)
|
assert.ErrorContains(t, merkleizingListLimitError, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBitwiseMerkleizeArrays(t *testing.T) {
|
func TestBitwiseMerkleizeArrays(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
chunks := [][32]byte{
|
chunks := [][32]byte{
|
||||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||||
{33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 62, 63, 64},
|
{33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 62, 63, 64},
|
||||||
@@ -46,7 +42,7 @@ func TestBitwiseMerkleizeArrays(t *testing.T) {
|
|||||||
limit := uint64(2)
|
limit := uint64(2)
|
||||||
expected := [32]byte{138, 81, 210, 194, 151, 231, 249, 241, 64, 118, 209, 58, 145, 109, 225, 89, 118, 110, 159, 220, 193, 183, 203, 124, 166, 24, 65, 26, 160, 215, 233, 219}
|
expected := [32]byte{138, 81, 210, 194, 151, 231, 249, 241, 64, 118, 209, 58, 145, 109, 225, 89, 118, 110, 159, 220, 193, 183, 203, 124, 166, 24, 65, 26, 160, 215, 233, 219}
|
||||||
|
|
||||||
result, err := ssz.BitwiseMerkleize(hasher, chunks, count, limit)
|
result, err := ssz.BitwiseMerkleize(chunks, count, limit)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, result)
|
assert.Equal(t, expected, result)
|
||||||
|
|
||||||
@@ -58,13 +54,12 @@ func TestBitwiseMerkleizeArrays(t *testing.T) {
|
|||||||
limit = uint64(2)
|
limit = uint64(2)
|
||||||
expected = [32]byte{194, 32, 213, 52, 220, 127, 18, 240, 43, 151, 19, 79, 188, 175, 142, 177, 208, 46, 96, 20, 18, 231, 208, 29, 120, 102, 122, 17, 46, 31, 155, 30}
|
expected = [32]byte{194, 32, 213, 52, 220, 127, 18, 240, 43, 151, 19, 79, 188, 175, 142, 177, 208, 46, 96, 20, 18, 231, 208, 29, 120, 102, 122, 17, 46, 31, 155, 30}
|
||||||
|
|
||||||
result, err = ssz.BitwiseMerkleize(hasher, chunks, count, limit)
|
result, err = ssz.BitwiseMerkleize(chunks, count, limit)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, result)
|
assert.Equal(t, expected, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBitwiseMerkleizeArraysOverLimit(t *testing.T) {
|
func TestBitwiseMerkleizeArraysOverLimit(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
chunks := [][32]byte{
|
chunks := [][32]byte{
|
||||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||||
{33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 62, 63, 64},
|
{33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 62, 63, 64},
|
||||||
@@ -72,7 +67,7 @@ func TestBitwiseMerkleizeArraysOverLimit(t *testing.T) {
|
|||||||
count := uint64(2)
|
count := uint64(2)
|
||||||
limit := uint64(1)
|
limit := uint64(1)
|
||||||
|
|
||||||
_, err := ssz.BitwiseMerkleize(hasher, chunks, count, limit)
|
_, err := ssz.BitwiseMerkleize(chunks, count, limit)
|
||||||
assert.ErrorContains(t, merkleizingListLimitError, err)
|
assert.ErrorContains(t, merkleizingListLimitError, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -34,13 +33,13 @@ func ForkRoot(fork *ethpb.Fork) ([32]byte, error) {
|
|||||||
binary.LittleEndian.PutUint64(forkEpochBuf, uint64(fork.Epoch))
|
binary.LittleEndian.PutUint64(forkEpochBuf, uint64(fork.Epoch))
|
||||||
fieldRoots[2] = bytesutil.ToBytes32(forkEpochBuf)
|
fieldRoots[2] = bytesutil.ToBytes32(forkEpochBuf)
|
||||||
}
|
}
|
||||||
return BitwiseMerkleize(hash.CustomSHA256Hasher(), fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckpointRoot computes the HashTreeRoot Merkleization of
|
// CheckpointRoot computes the HashTreeRoot Merkleization of
|
||||||
// a InitWithReset struct value according to the Ethereum
|
// a InitWithReset struct value according to the Ethereum
|
||||||
// Simple Serialize specification.
|
// Simple Serialize specification.
|
||||||
func CheckpointRoot(hasher HashFn, checkpoint *ethpb.Checkpoint) ([32]byte, error) {
|
func CheckpointRoot(checkpoint *ethpb.Checkpoint) ([32]byte, error) {
|
||||||
fieldRoots := make([][32]byte, 2)
|
fieldRoots := make([][32]byte, 2)
|
||||||
if checkpoint != nil {
|
if checkpoint != nil {
|
||||||
epochBuf := make([]byte, 8)
|
epochBuf := make([]byte, 8)
|
||||||
@@ -48,7 +47,7 @@ func CheckpointRoot(hasher HashFn, checkpoint *ethpb.Checkpoint) ([32]byte, erro
|
|||||||
fieldRoots[0] = bytesutil.ToBytes32(epochBuf)
|
fieldRoots[0] = bytesutil.ToBytes32(epochBuf)
|
||||||
fieldRoots[1] = bytesutil.ToBytes32(checkpoint.Root)
|
fieldRoots[1] = bytesutil.ToBytes32(checkpoint.Root)
|
||||||
}
|
}
|
||||||
return BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByteArrayRootWithLimit computes the HashTreeRoot Merkleization of
|
// ByteArrayRootWithLimit computes the HashTreeRoot Merkleization of
|
||||||
@@ -59,7 +58,7 @@ func ByteArrayRootWithLimit(roots [][]byte, limit uint64) ([32]byte, error) {
|
|||||||
for i, r := range roots {
|
for i, r := range roots {
|
||||||
copy(newRoots[i][:], r)
|
copy(newRoots[i][:], r)
|
||||||
}
|
}
|
||||||
result, err := BitwiseMerkleize(hash.CustomSHA256Hasher(), newRoots, uint64(len(newRoots)), limit)
|
result, err := BitwiseMerkleize(newRoots, uint64(len(newRoots)), limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute byte array merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute byte array merkleization")
|
||||||
}
|
}
|
||||||
@@ -88,14 +87,13 @@ func SlashingsRoot(slashings []uint64) ([32]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not pack slashings into chunks")
|
return [32]byte{}, errors.Wrap(err, "could not pack slashings into chunks")
|
||||||
}
|
}
|
||||||
return BitwiseMerkleize(hash.CustomSHA256Hasher(), slashingChunks, uint64(len(slashingChunks)), uint64(len(slashingChunks)))
|
return BitwiseMerkleize(slashingChunks, uint64(len(slashingChunks)), uint64(len(slashingChunks)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionsRoot computes the HTR for the Transactions' property of the ExecutionPayload
|
// TransactionsRoot computes the HTR for the Transactions' property of the ExecutionPayload
|
||||||
// The code was largely copy/pasted from the code generated to compute the HTR of the entire
|
// The code was largely copy/pasted from the code generated to compute the HTR of the entire
|
||||||
// ExecutionPayload.
|
// ExecutionPayload.
|
||||||
func TransactionsRoot(txs [][]byte) ([32]byte, error) {
|
func TransactionsRoot(txs [][]byte) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
txRoots := make([][32]byte, 0)
|
txRoots := make([][32]byte, 0)
|
||||||
for i := 0; i < len(txs); i++ {
|
for i := 0; i < len(txs); i++ {
|
||||||
rt, err := transactionRoot(txs[i])
|
rt, err := transactionRoot(txs[i])
|
||||||
@@ -105,7 +103,7 @@ func TransactionsRoot(txs [][]byte) ([32]byte, error) {
|
|||||||
txRoots = append(txRoots, rt)
|
txRoots = append(txRoots, rt)
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesRoot, err := BitwiseMerkleize(hasher, txRoots, uint64(len(txRoots)), fieldparams.MaxTxsPerPayloadLength)
|
bytesRoot, err := BitwiseMerkleize(txRoots, uint64(len(txRoots)), fieldparams.MaxTxsPerPayloadLength)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
||||||
}
|
}
|
||||||
@@ -120,17 +118,17 @@ func TransactionsRoot(txs [][]byte) ([32]byte, error) {
|
|||||||
|
|
||||||
// WithdrawalSliceRoot computes the HTR of a slice of withdrawals.
|
// WithdrawalSliceRoot computes the HTR of a slice of withdrawals.
|
||||||
// The limit parameter is used as input to the bitwise merkleization algorithm.
|
// The limit parameter is used as input to the bitwise merkleization algorithm.
|
||||||
func WithdrawalSliceRoot(hasher HashFn, withdrawals []*enginev1.Withdrawal, limit uint64) ([32]byte, error) {
|
func WithdrawalSliceRoot(withdrawals []*enginev1.Withdrawal, limit uint64) ([32]byte, error) {
|
||||||
roots := make([][32]byte, len(withdrawals))
|
roots := make([][32]byte, len(withdrawals))
|
||||||
for i := 0; i < len(withdrawals); i++ {
|
for i := 0; i < len(withdrawals); i++ {
|
||||||
r, err := withdrawalRoot(hasher, withdrawals[i])
|
r, err := withdrawalRoot(withdrawals[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
roots[i] = r
|
roots[i] = r
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesRoot, err := BitwiseMerkleize(hasher, roots, uint64(len(roots)), limit)
|
bytesRoot, err := BitwiseMerkleize(roots, uint64(len(roots)), limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
||||||
}
|
}
|
||||||
@@ -144,14 +142,13 @@ func WithdrawalSliceRoot(hasher HashFn, withdrawals []*enginev1.Withdrawal, limi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func transactionRoot(tx []byte) ([32]byte, error) {
|
func transactionRoot(tx []byte) ([32]byte, error) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
|
||||||
chunkedRoots, err := PackByChunk([][]byte{tx})
|
chunkedRoots, err := PackByChunk([][]byte{tx})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, err
|
return [32]byte{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
maxLength := (fieldparams.MaxBytesPerTxLength + 31) / 32
|
maxLength := (fieldparams.MaxBytesPerTxLength + 31) / 32
|
||||||
bytesRoot, err := BitwiseMerkleize(hasher, chunkedRoots, uint64(len(chunkedRoots)), uint64(maxLength))
|
bytesRoot, err := BitwiseMerkleize(chunkedRoots, uint64(len(chunkedRoots)), uint64(maxLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
return [32]byte{}, errors.Wrap(err, "could not compute merkleization")
|
||||||
}
|
}
|
||||||
@@ -164,7 +161,7 @@ func transactionRoot(tx []byte) ([32]byte, error) {
|
|||||||
return MixInLength(bytesRoot, bytesRootBufRoot), nil
|
return MixInLength(bytesRoot, bytesRootBufRoot), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func withdrawalRoot(hasher HashFn, w *enginev1.Withdrawal) ([32]byte, error) {
|
func withdrawalRoot(w *enginev1.Withdrawal) ([32]byte, error) {
|
||||||
fieldRoots := make([][32]byte, 4)
|
fieldRoots := make([][32]byte, 4)
|
||||||
if w != nil {
|
if w != nil {
|
||||||
binary.LittleEndian.PutUint64(fieldRoots[0][:], w.Index)
|
binary.LittleEndian.PutUint64(fieldRoots[0][:], w.Index)
|
||||||
@@ -174,5 +171,5 @@ func withdrawalRoot(hasher HashFn, w *enginev1.Withdrawal) ([32]byte, error) {
|
|||||||
fieldRoots[2] = bytesutil.ToBytes32(w.Address)
|
fieldRoots[2] = bytesutil.ToBytes32(w.Address)
|
||||||
binary.LittleEndian.PutUint64(fieldRoots[3][:], w.Amount)
|
binary.LittleEndian.PutUint64(fieldRoots[3][:], w.Amount)
|
||||||
}
|
}
|
||||||
return BitwiseMerkleize(hasher, fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
return BitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||||
@@ -35,14 +34,13 @@ func TestForkRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckPointRoot(t *testing.T) {
|
func TestCheckPointRoot(t *testing.T) {
|
||||||
testHasher := hash.CustomSHA256Hasher()
|
|
||||||
testCheckpoint := ethpb.Checkpoint{
|
testCheckpoint := ethpb.Checkpoint{
|
||||||
Epoch: 1234567890,
|
Epoch: 1234567890,
|
||||||
Root: []byte{222},
|
Root: []byte{222},
|
||||||
}
|
}
|
||||||
expected := [32]byte{228, 65, 39, 109, 183, 249, 167, 232, 125, 239, 25, 155, 207, 4, 84, 174, 176, 229, 175, 224, 62, 33, 215, 254, 170, 220, 132, 65, 246, 128, 68, 194}
|
expected := [32]byte{228, 65, 39, 109, 183, 249, 167, 232, 125, 239, 25, 155, 207, 4, 84, 174, 176, 229, 175, 224, 62, 33, 215, 254, 170, 220, 132, 65, 246, 128, 68, 194}
|
||||||
|
|
||||||
result, err := ssz.CheckpointRoot(testHasher, &testCheckpoint)
|
result, err := ssz.CheckpointRoot(&testCheckpoint)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, result)
|
assert.Equal(t, expected, result)
|
||||||
}
|
}
|
||||||
@@ -191,8 +189,7 @@ func TestWithdrawalRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
got, err := ssz.WithdrawalRoot(tt.input)
|
||||||
got, err := ssz.WithdrawalRoot(hasher, tt.input)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.DeepSSZEqual(t, tt.want, got)
|
require.DeepSSZEqual(t, tt.want, got)
|
||||||
})
|
})
|
||||||
@@ -224,8 +221,7 @@ func TestWithrawalSliceRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
hasher := hash.CustomSHA256Hasher()
|
got, err := ssz.WithdrawalSliceRoot(tt.input, 16)
|
||||||
got, err := ssz.WithdrawalSliceRoot(hasher, tt.input, 16)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.DeepSSZEqual(t, tt.want, got)
|
require.DeepSSZEqual(t, tt.want, got)
|
||||||
})
|
})
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -58,7 +58,7 @@ require (
|
|||||||
github.com/prometheus/client_golang v1.14.0
|
github.com/prometheus/client_golang v1.14.0
|
||||||
github.com/prometheus/client_model v0.3.0
|
github.com/prometheus/client_model v0.3.0
|
||||||
github.com/prometheus/prom2json v1.3.0
|
github.com/prometheus/prom2json v1.3.0
|
||||||
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab
|
github.com/prysmaticlabs/fastssz v0.0.0-20230216165902-cac1483628fe
|
||||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
|
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
|
||||||
github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c
|
github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c
|
||||||
github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20211014160335-757fae4f38c6
|
github.com/prysmaticlabs/protoc-gen-go-cast v0.0.0-20211014160335-757fae4f38c6
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -989,8 +989,8 @@ github.com/prometheus/prom2json v1.3.0/go.mod h1:rMN7m0ApCowcoDlypBHlkNbp5eJQf/+
|
|||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
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 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic=
|
||||||
github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4=
|
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-20230216165902-cac1483628fe h1:ygSxa+M1uZZ01Rd+AjHFQmjeuoohcfgmy5mVOxmpBJ0=
|
||||||
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab/go.mod h1:MA5zShstUwCQaE9faGHgCGvEWUbG87p4SAXINhmCkvg=
|
github.com/prysmaticlabs/fastssz v0.0.0-20230216165902-cac1483628fe/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-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 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw=
|
||||||
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4=
|
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4=
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by fastssz. DO NOT EDIT.
|
// Code generated by fastssz. DO NOT EDIT.
|
||||||
// Hash: edbc5aa03156793a03df9d7bed8634b21e5f8b384316f8925d25a5d693045bf8
|
// Hash: be89d82f1c95830b54bed191097f10ab24b28445bc12a16529695c77978f46b0
|
||||||
package enginev1
|
package enginev1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -336,11 +336,7 @@ func (e *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.PutBytes(e.ExtraData)
|
hh.PutBytes(e.ExtraData)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (32+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (11) 'BaseFeePerGas'
|
// Field (11) 'BaseFeePerGas'
|
||||||
@@ -374,25 +370,13 @@ func (e *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.AppendBytes32(elem)
|
hh.AppendBytes32(elem)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (1073741824+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 1048576)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 1048576)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 1048576)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,11 +750,7 @@ func (e *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.PutBytes(e.ExtraData)
|
hh.PutBytes(e.ExtraData)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (32+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (11) 'BaseFeePerGas'
|
// Field (11) 'BaseFeePerGas'
|
||||||
@@ -804,18 +784,10 @@ func (e *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.AppendBytes32(elem)
|
hh.AppendBytes32(elem)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (1073741824+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 1048576)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 1048576)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 1048576)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (14) 'Withdrawals'
|
// Field (14) 'Withdrawals'
|
||||||
@@ -831,18 +803,10 @@ func (e *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1127,11 +1091,7 @@ func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.PutBytes(e.ExtraData)
|
hh.PutBytes(e.ExtraData)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (32+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (11) 'BaseFeePerGas'
|
// Field (11) 'BaseFeePerGas'
|
||||||
@@ -1155,11 +1115,7 @@ func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(e.TransactionsRoot)
|
hh.PutBytes(e.TransactionsRoot)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1457,11 +1413,7 @@ func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hh.PutBytes(e.ExtraData)
|
hh.PutBytes(e.ExtraData)
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (32+31)/32)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (11) 'BaseFeePerGas'
|
// Field (11) 'BaseFeePerGas'
|
||||||
@@ -1492,11 +1444,7 @@ func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
}
|
}
|
||||||
hh.PutBytes(e.WithdrawalsRoot)
|
hh.PutBytes(e.WithdrawalsRoot)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1585,10 +1533,6 @@ func (w *Withdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
// Field (3) 'Amount'
|
// Field (3) 'Amount'
|
||||||
hh.PutUint64(w.Amount)
|
hh.PutUint64(w.Amount)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by fastssz. DO NOT EDIT.
|
// Code generated by fastssz. DO NOT EDIT.
|
||||||
// Hash: fb4dd6cca9018196eaa56d51f14f2e924edf2ea0e1e19e262b24651d34d0fbfd
|
// Hash: 1fc0701eb982d4705c6a41c7814704034a36ec718a48ed4395135b8480ee6535
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -132,11 +132,7 @@ func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(a.Signature)
|
hh.PutBytes(a.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,11 +250,7 @@ func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err err
|
|||||||
}
|
}
|
||||||
hh.PutBytes(a.SelectionProof)
|
hh.PutBytes(a.SelectionProof)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,11 +359,7 @@ func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (e
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,11 +481,7 @@ func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,11 +552,7 @@ func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(c.Root)
|
hh.PutBytes(c.Root)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,11 +699,7 @@ func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,11 +808,7 @@ func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1199,11 +1171,7 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -1219,11 +1187,7 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -1239,11 +1203,7 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -1259,11 +1219,7 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -1279,18 +1235,10 @@ func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,11 +1322,7 @@ func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1506,11 +1450,7 @@ func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1604,12 +1544,7 @@ func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.Append(i)
|
hh.Append(i)
|
||||||
}
|
}
|
||||||
|
hh.Merkleize(subIndx)
|
||||||
if ssz.EnableVectorizedHTR {
|
|
||||||
hh.MerkleizeVectorizedHTR(subIndx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(subIndx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (1) 'Data'
|
// Field (1) 'Data'
|
||||||
@@ -1617,11 +1552,7 @@ func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1681,11 +1612,7 @@ func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
// Field (1) 'ValidatorIndex'
|
// Field (1) 'ValidatorIndex'
|
||||||
hh.PutUint64(uint64(v.ValidatorIndex))
|
hh.PutUint64(uint64(v.ValidatorIndex))
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1768,11 +1695,7 @@ func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1863,11 +1786,7 @@ func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(e.BlockHash)
|
hh.PutBytes(e.BlockHash)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1987,11 +1906,7 @@ func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(b.BodyRoot)
|
hh.PutBytes(b.BodyRoot)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2074,11 +1989,7 @@ func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2204,11 +2115,7 @@ func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
hh.FillUpTo32()
|
hh.FillUpTo32()
|
||||||
|
|
||||||
numItems := uint64(len(i.AttestingIndices))
|
numItems := uint64(len(i.AttestingIndices))
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8))
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8))
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (1) 'Data'
|
// Field (1) 'Data'
|
||||||
@@ -2223,11 +2130,7 @@ func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(i.Signature)
|
hh.PutBytes(i.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2309,11 +2212,7 @@ func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.SyncCommitteeSignature)
|
hh.PutBytes(s.SyncCommitteeSignature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2424,11 +2323,7 @@ func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(d.Signature)
|
hh.PutBytes(d.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2564,10 +2459,6 @@ func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
// Field (7) 'WithdrawableEpoch'
|
// Field (7) 'WithdrawableEpoch'
|
||||||
hh.PutUint64(uint64(v.WithdrawableEpoch))
|
hh.PutUint64(uint64(v.WithdrawableEpoch))
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by fastssz. DO NOT EDIT.
|
// Code generated by fastssz. DO NOT EDIT.
|
||||||
// Hash: aee43aed536b874e25f44d6a1c015d4064b7928ff1dd3bd0634687c4082215ef
|
// Hash: 48878097ddad0db20c93baba93629f6a82f26e4fecfcf4a80d96b4a6fcf1c32f
|
||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -114,11 +114,7 @@ func (s *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,11 +223,7 @@ func (s *SignedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,11 +332,7 @@ func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (er
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,11 +441,7 @@ func (s *SignedBlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,11 +550,7 @@ func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,11 +697,7 @@ func (b *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,11 +844,7 @@ func (b *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err erro
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,11 +991,7 @@ func (b *BeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1170,11 +1138,7 @@ func (b *BlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1321,11 +1285,7 @@ func (b *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1738,11 +1698,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -1758,11 +1714,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -1778,11 +1730,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -1798,11 +1746,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -1818,11 +1762,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (8) 'SyncAggregate'
|
// Field (8) 'SyncAggregate'
|
||||||
@@ -1835,11 +1775,7 @@ func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2252,11 +2188,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -2272,11 +2204,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -2292,11 +2220,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -2312,11 +2236,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -2332,11 +2252,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (8) 'SyncAggregate'
|
// Field (8) 'SyncAggregate'
|
||||||
@@ -2349,11 +2265,7 @@ func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2807,11 +2719,7 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -2827,11 +2735,7 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -2847,11 +2751,7 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -2867,11 +2767,7 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -2887,11 +2783,7 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (8) 'SyncAggregate'
|
// Field (8) 'SyncAggregate'
|
||||||
@@ -2917,18 +2809,10 @@ func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3382,11 +3266,7 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -3402,11 +3282,7 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -3422,11 +3298,7 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -3442,11 +3314,7 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -3462,11 +3330,7 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (8) 'SyncAggregate'
|
// Field (8) 'SyncAggregate'
|
||||||
@@ -3492,18 +3356,10 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3882,11 +3738,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (4) 'AttesterSlashings'
|
// Field (4) 'AttesterSlashings'
|
||||||
@@ -3902,11 +3754,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 2)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (5) 'Attestations'
|
// Field (5) 'Attestations'
|
||||||
@@ -3922,11 +3770,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 128)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (6) 'Deposits'
|
// Field (6) 'Deposits'
|
||||||
@@ -3942,11 +3786,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (7) 'VoluntaryExits'
|
// Field (7) 'VoluntaryExits'
|
||||||
@@ -3962,11 +3802,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
||||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16)
|
|
||||||
} else {
|
|
||||||
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field (8) 'SyncAggregate'
|
// Field (8) 'SyncAggregate'
|
||||||
@@ -3974,11 +3810,7 @@ func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4069,11 +3901,7 @@ func (b *BLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|||||||
}
|
}
|
||||||
hh.PutBytes(b.ToExecutionAddress)
|
hh.PutBytes(b.ToExecutionAddress)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4156,10 +3984,6 @@ func (s *SignedBLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error
|
|||||||
}
|
}
|
||||||
hh.PutBytes(s.Signature)
|
hh.PutBytes(s.Signature)
|
||||||
|
|
||||||
if ssz.EnableVectorizedHTR {
|
hh.Merkleize(indx)
|
||||||
hh.MerkleizeVectorizedHTR(indx)
|
|
||||||
} else {
|
|
||||||
hh.Merkleize(indx)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ go_library(
|
|||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//config/fieldparams:go_default_library",
|
"//config/fieldparams:go_default_library",
|
||||||
"//consensus-types/interfaces:go_default_library",
|
"//consensus-types/interfaces:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
|
||||||
"//encoding/bytesutil:go_default_library",
|
"//encoding/bytesutil:go_default_library",
|
||||||
"//encoding/ssz:go_default_library",
|
"//encoding/ssz:go_default_library",
|
||||||
"//proto/engine/v1:go_default_library",
|
"//proto/engine/v1:go_default_library",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||||
@@ -447,7 +446,6 @@ func V1Alpha1BeaconBlockCapellaToV2Blinded(v1alpha1Block *ethpbalpha.BeaconBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(
|
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(
|
||||||
hash.CustomSHA256Hasher(),
|
|
||||||
v1alpha1Block.Body.ExecutionPayload.Withdrawals,
|
v1alpha1Block.Body.ExecutionPayload.Withdrawals,
|
||||||
fieldparams.MaxWithdrawalsPerPayload,
|
fieldparams.MaxWithdrawalsPerPayload,
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -71,7 +71,6 @@ go_library(
|
|||||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||||
"@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library",
|
"@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_fastssz//:go_default_library",
|
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
"@in_gopkg_yaml_v2//:go_default_library",
|
"@in_gopkg_yaml_v2//:go_default_library",
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
fastssz "github.com/prysmaticlabs/fastssz"
|
|
||||||
"github.com/prysmaticlabs/prysm/v3/api/gateway"
|
"github.com/prysmaticlabs/prysm/v3/api/gateway"
|
||||||
"github.com/prysmaticlabs/prysm/v3/api/gateway/apimiddleware"
|
"github.com/prysmaticlabs/prysm/v3/api/gateway/apimiddleware"
|
||||||
"github.com/prysmaticlabs/prysm/v3/async/event"
|
"github.com/prysmaticlabs/prysm/v3/async/event"
|
||||||
@@ -124,8 +123,6 @@ func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFastSSZHashingAlgorithm()
|
|
||||||
|
|
||||||
// If the --web flag is enabled to administer the validator
|
// If the --web flag is enabled to administer the validator
|
||||||
// client via a web portal, we start the validator client in a different way.
|
// client via a web portal, we start the validator client in a different way.
|
||||||
if cliCtx.IsSet(flags.EnableWebFlag.Name) {
|
if cliCtx.IsSet(flags.EnableWebFlag.Name) {
|
||||||
@@ -881,9 +878,3 @@ func unmarshalFromFile(ctx context.Context, from string, to interface{}) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureFastSSZHashingAlgorithm() {
|
|
||||||
if features.Get().EnableVectorizedHTR {
|
|
||||||
fastssz.EnableVectorizedHTR = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user