From f46590f5e3c976e5d685439285d03ed8f81d3911 Mon Sep 17 00:00:00 2001 From: kewei Date: Fri, 29 Nov 2024 00:41:32 +0800 Subject: [PATCH] update --- cl/cltypes/beacon_block.go | 2 +- cl/cltypes/solid/validator_set.go | 18 +----------------- cl/phase1/core/state/upgrade.go | 2 +- cl/spectest/Makefile | 4 ++-- cl/transition/impl/eth2/operations.go | 2 ++ 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cl/cltypes/beacon_block.go b/cl/cltypes/beacon_block.go index 76e098383fc..e9b2bb22c1c 100644 --- a/cl/cltypes/beacon_block.go +++ b/cl/cltypes/beacon_block.go @@ -63,8 +63,8 @@ var ( // Definition of SignedBeaconBlock type SignedBeaconBlock struct { - Signature libcommon.Bytes96 `json:"signature"` Block *BeaconBlock `json:"message"` + Signature libcommon.Bytes96 `json:"signature"` } func NewSignedBeaconBlock(beaconCfg *clparams.BeaconChainConfig, version clparams.StateVersion) *SignedBeaconBlock { diff --git a/cl/cltypes/solid/validator_set.go b/cl/cltypes/solid/validator_set.go index 1af61dfd9cc..6c439c5d53c 100644 --- a/cl/cltypes/solid/validator_set.go +++ b/cl/cltypes/solid/validator_set.go @@ -21,7 +21,6 @@ import ( "io" libcommon "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/common/length" "github.com/erigontech/erigon-lib/types/clonable" "github.com/erigontech/erigon-lib/types/ssz" "github.com/erigontech/erigon/cl/merkle_tree" @@ -208,27 +207,12 @@ func (v *ValidatorSet) HashSSZ() ([32]byte, error) { return utils.Sha256(coreRoot[:], lengthRoot[:]), nil } -func computeFlatRootsToBuffer(depth uint8, layerBuffer, output []byte) error { - for i := uint8(0); i < depth; i++ { - // Sequential - if len(layerBuffer)%64 != 0 { - layerBuffer = append(layerBuffer, merkle_tree.ZeroHashes[i][:]...) - } - if err := merkle_tree.HashByteSlice(layerBuffer, layerBuffer); err != nil { - return err - } - layerBuffer = layerBuffer[:len(layerBuffer)/2] - } - - copy(output, layerBuffer[:length.Hash]) - return nil -} - func (v *ValidatorSet) Set(idx int, val Validator) { if idx >= v.l { panic("ValidatorSet -- Set: out of bounds") } copy(v.buffer[idx*validatorSize:(idx*validatorSize)+validatorSize], val) + v.zeroTreeHash(idx) } func (v *ValidatorSet) getPhase0(idx int) *Phase0Data { diff --git a/cl/phase1/core/state/upgrade.go b/cl/phase1/core/state/upgrade.go index 39d4b57259d..cf47b18e207 100644 --- a/cl/phase1/core/state/upgrade.go +++ b/cl/phase1/core/state/upgrade.go @@ -155,7 +155,7 @@ func (b *CachingBeaconState) UpgradeToElectra() error { // Update the state root cache b.SetVersion(clparams.ElectraVersion) - earliestExitEpoch := epoch + earliestExitEpoch := ComputeActivationExitEpoch(b.BeaconConfig(), epoch) b.ValidatorSet().Range(func(i int, v solid.Validator, _ int) bool { if v.ExitEpoch() != b.BeaconConfig().FarFutureEpoch { if v.ExitEpoch() > earliestExitEpoch { diff --git a/cl/spectest/Makefile b/cl/spectest/Makefile index 7a2f249fb94..4a15ce9e1cd 100644 --- a/cl/spectest/Makefile +++ b/cl/spectest/Makefile @@ -2,7 +2,7 @@ tests: - wget https://github.com/ethereum/consensus-spec-tests/releases/download/v1.5.0-alpha.8/mainnet.tar.gz + wget https://github.com/ethereum/consensus-spec-tests/releases/download/v1.5.0-alpha.9/mainnet.tar.gz tar xf mainnet.tar.gz rm mainnet.tar.gz # not needed for now @@ -24,4 +24,4 @@ eip7594: CGO_CFLAGS=-D__BLST_PORTABLE__ go test -tags=spectest -run=/mainnet/eip7594/ -v --timeout 30m deneb: - CGO_CFLAGS=-D__BLST_PORTABLE__ go test -tags=spectest -run=/mainnet/deneb/ -v --timeout 30m \ No newline at end of file + CGO_CFLAGS=-D__BLST_PORTABLE__ go test -tags=spectest -run=/mainnet/deneb/ -v --timeout 30m diff --git a/cl/transition/impl/eth2/operations.go b/cl/transition/impl/eth2/operations.go index 13f015f8120..e686c815355 100644 --- a/cl/transition/impl/eth2/operations.go +++ b/cl/transition/impl/eth2/operations.go @@ -1211,6 +1211,7 @@ func (I *impl) ProcessConsolidationRequest(s abstract.BeaconState, consolidation // Initiate source validator exit and append pending consolidation sourceValidator.SetExitEpoch(computeConsolidationEpochAndUpdateChurn(s, sourceValidator.EffectiveBalance())) sourceValidator.SetWithdrawableEpoch(sourceValidator.ExitEpoch() + s.BeaconConfig().MinValidatorWithdrawabilityDelay) + s.SetValidatorAtIndex(int(sourceIndex), sourceValidator) // update the state and underlying validator set. Mark the merkle tree dirty. s.AppendPendingConsolidation(&solid.PendingConsolidation{ SourceIndex: sourceIndex, TargetIndex: targetIndex, @@ -1268,6 +1269,7 @@ func switchToCompoundingValidator(s abstract.BeaconState, vindex uint64) error { copy(newWc[:], wc[:]) newWc[0] = s.BeaconConfig().CompoundingWithdrawalPrefix validator.SetWithdrawalCredentials(newWc) + s.SetValidatorAtIndex(int(vindex), validator) // update the state return state.QueueExcessActiveBalance(s, vindex, &validator) }