From efb0e04ecc4c4c3bcb838794a2b493ea2d1fb326 Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 14:57:31 +0200 Subject: [PATCH 01/11] save --- cl/phase1/forkchoice/on_attestation.go | 69 +++++++++++++++++++++----- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/cl/phase1/forkchoice/on_attestation.go b/cl/phase1/forkchoice/on_attestation.go index ea51aeb70fc..e40e796acdf 100644 --- a/cl/phase1/forkchoice/on_attestation.go +++ b/cl/phase1/forkchoice/on_attestation.go @@ -42,42 +42,85 @@ func (f *ForkChoiceStore) OnAttestation(attestation *solid.Attestation, fromBloc return err } } + headState := f.syncedDataManager.HeadState() + var attestationIndicies []uint64 + var err error target := data.Target() + if headState == nil { + attestationIndicies, err = f.verifyAttestationWithCheckpointState(target, attestation, fromBlock) + } else { + attestationIndicies, err = f.verifyAttestationWithState(headState, attestation, fromBlock) + } + if err != nil { + return err + } + + // Lastly update latest messages. + f.processAttestingIndicies(attestation, attestationIndicies) + if !fromBlock && insert { + // Add to the pool when verified. + f.operationsPool.AttestationsPool.Insert(attestation.Signature(), attestation) + } + return nil +} + +func (f *ForkChoiceStore) verifyAttestationWithCheckpointState(target solid.Checkpoint, attestation *solid.Attestation, fromBlock bool) (attestationIndicies []uint64, err error) { + data := attestation.AttestantionData() targetState, err := f.getCheckpointState(target) if err != nil { - return nil + return nil, err } // Verify attestation signature. if targetState == nil { - return fmt.Errorf("target state does not exist") + return nil, fmt.Errorf("target state does not exist") } // Now we need to find the attesting indicies. - attestationIndicies, err := targetState.getAttestingIndicies(&data, attestation.AggregationBits()) + attestationIndicies, err = targetState.getAttestingIndicies(&data, attestation.AggregationBits()) if err != nil { - return err + return nil, err } if !fromBlock { indexedAttestation := state.GetIndexedAttestation(attestation, attestationIndicies) if err != nil { - return err + return nil, err } valid, err := targetState.isValidIndexedAttestation(indexedAttestation) if err != nil { - return err + return nil, err } if !valid { - return fmt.Errorf("invalid attestation") + return nil, fmt.Errorf("invalid attestation") } } - // Lastly update latest messages. - f.processAttestingIndicies(attestation, attestationIndicies) - if !fromBlock && insert { - // Add to the pool when verified. - f.operationsPool.AttestationsPool.Insert(attestation.Signature(), attestation) + return attestationIndicies, nil +} + +func (f *ForkChoiceStore) verifyAttestationWithState(s *state.CachingBeaconState, attestation *solid.Attestation, fromBlock bool) (attestationIndicies []uint64, err error) { + data := attestation.AttestantionData() + if err != nil { + return nil, err } - return nil + + attestationIndicies, err = s.GetAttestingIndicies(data, attestation.AggregationBits(), true) + if err != nil { + return nil, err + } + if !fromBlock { + indexedAttestation := state.GetIndexedAttestation(attestation, attestationIndicies) + if err != nil { + return nil, err + } + valid, err := state.IsValidIndexedAttestation(s, indexedAttestation) + if err != nil { + return nil, err + } + if !valid { + return nil, fmt.Errorf("invalid attestation") + } + } + return attestationIndicies, nil } func (f *ForkChoiceStore) setLatestMessage(index uint64, message LatestMessage) { From 5509dad0af0e017374f0d402f08da997322031ae Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 15:02:26 +0200 Subject: [PATCH 02/11] save --- cl/phase1/forkchoice/on_attestation.go | 12 ++---------- cl/phase1/network/services/block_service.go | 2 ++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cl/phase1/forkchoice/on_attestation.go b/cl/phase1/forkchoice/on_attestation.go index e40e796acdf..4a09fc98e82 100644 --- a/cl/phase1/forkchoice/on_attestation.go +++ b/cl/phase1/forkchoice/on_attestation.go @@ -2,7 +2,6 @@ package forkchoice import ( "fmt" - "time" "github.com/ledgerwatch/erigon/cl/cltypes/solid" "github.com/ledgerwatch/erigon/cl/phase1/core/state" @@ -10,11 +9,6 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" ) -const ( - maxAttestationJobLifetime = 30 * time.Minute - maxBlockJobLifetime = 36 * time.Second // 3 mainnet slots -) - var ( ErrIgnore = fmt.Errorf("ignore") ) @@ -50,6 +44,7 @@ func (f *ForkChoiceStore) OnAttestation(attestation *solid.Attestation, fromBloc if headState == nil { attestationIndicies, err = f.verifyAttestationWithCheckpointState(target, attestation, fromBlock) } else { + fmt.Println("A") attestationIndicies, err = f.verifyAttestationWithState(headState, attestation, fromBlock) } if err != nil { @@ -58,10 +53,7 @@ func (f *ForkChoiceStore) OnAttestation(attestation *solid.Attestation, fromBloc // Lastly update latest messages. f.processAttestingIndicies(attestation, attestationIndicies) - if !fromBlock && insert { - // Add to the pool when verified. - f.operationsPool.AttestationsPool.Insert(attestation.Signature(), attestation) - } + return nil } diff --git a/cl/phase1/network/services/block_service.go b/cl/phase1/network/services/block_service.go index a00fe075082..75ffe8ed703 100644 --- a/cl/phase1/network/services/block_service.go +++ b/cl/phase1/network/services/block_service.go @@ -191,6 +191,7 @@ func (b *blockService) importBlockAttestations(block *cltypes.SignedBeaconBlock) log.Warn("recovered from panic", "err", r) } }() + start := time.Now() block.Block.Body.Attestations.Range(func(idx int, a *solid.Attestation, total int) bool { if err := b.forkchoiceStore.OnAttestation(a, true, false); err != nil { log.Debug("bad attestation received", "err", err) @@ -198,6 +199,7 @@ func (b *blockService) importBlockAttestations(block *cltypes.SignedBeaconBlock) return true }) + log.Debug("import attestation", "time", time.Since(start)) } // loop is the main loop of the block service From f04db0fbf1cfb41a1bb6aff3fe2dd2f7753c7686 Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 15:05:40 +0200 Subject: [PATCH 03/11] save --- cl/phase1/forkchoice/on_attestation.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cl/phase1/forkchoice/on_attestation.go b/cl/phase1/forkchoice/on_attestation.go index 4a09fc98e82..55ecfe5381f 100644 --- a/cl/phase1/forkchoice/on_attestation.go +++ b/cl/phase1/forkchoice/on_attestation.go @@ -44,7 +44,6 @@ func (f *ForkChoiceStore) OnAttestation(attestation *solid.Attestation, fromBloc if headState == nil { attestationIndicies, err = f.verifyAttestationWithCheckpointState(target, attestation, fromBlock) } else { - fmt.Println("A") attestationIndicies, err = f.verifyAttestationWithState(headState, attestation, fromBlock) } if err != nil { From 19b8794c38bf192a3a278c53af024bf1fbebc954 Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 15:49:50 +0200 Subject: [PATCH 04/11] save --- cl/spectest/Makefile | 2 +- cl/spectest/consensus_tests/fork_choice.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cl/spectest/Makefile b/cl/spectest/Makefile index 7f34a91d8b4..68959bfba32 100644 --- a/cl/spectest/Makefile +++ b/cl/spectest/Makefile @@ -13,4 +13,4 @@ clean: rm -rf tests mainnet: - CGO_CFLAGS=-D__BLST_PORTABLE__ go test -tags=spectest -run=/mainnet/deneb -failfast -v --timeout 30m + CGO_CFLAGS=-D__BLST_PORTABLE__ go test -tags=spectest -run=/mainnet -failfast -v --timeout 30m diff --git a/cl/spectest/consensus_tests/fork_choice.go b/cl/spectest/consensus_tests/fork_choice.go index 67d005a7240..96644a01ed1 100644 --- a/cl/spectest/consensus_tests/fork_choice.go +++ b/cl/spectest/consensus_tests/fork_choice.go @@ -14,6 +14,7 @@ import ( "github.com/ledgerwatch/erigon/cl/abstract" "github.com/ledgerwatch/erigon/cl/beacon/beacon_router_configuration" "github.com/ledgerwatch/erigon/cl/beacon/beaconevents" + "github.com/ledgerwatch/erigon/cl/beacon/synced_data" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/clparams/initial_state" "github.com/ledgerwatch/erigon/cl/cltypes/solid" @@ -187,7 +188,7 @@ func (b *ForkChoice) Run(t *testing.T, root fs.FS, c spectest.TestCase) (err err ethClock := eth_clock.NewEthereumClock(genesisState.GenesisTime(), genesisState.GenesisValidatorsRoot(), beaconConfig) blobStorage := blob_storage.NewBlobStore(memdb.New("/tmp"), afero.NewMemMapFs(), math.MaxUint64, &clparams.MainnetBeaconConfig, ethClock) - forkStore, err := forkchoice.NewForkChoiceStore(ethClock, anchorState, nil, pool.NewOperationsPool(&clparams.MainnetBeaconConfig), fork_graph.NewForkGraphDisk(anchorState, afero.NewMemMapFs(), beacon_router_configuration.RouterConfiguration{}), emitters, nil, blobStorage) + forkStore, err := forkchoice.NewForkChoiceStore(ethClock, anchorState, nil, pool.NewOperationsPool(&clparams.MainnetBeaconConfig), fork_graph.NewForkGraphDisk(anchorState, afero.NewMemMapFs(), beacon_router_configuration.RouterConfiguration{}), emitters, synced_data.NewSyncedDataManager(true, &clparams.MainnetBeaconConfig), blobStorage) require.NoError(t, err) forkStore.SetSynced(true) From 6113ca3ebc36b6692c26d88d60b684c000e247dc Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 19:19:08 +0200 Subject: [PATCH 05/11] save --- cl/phase1/network/services/block_service.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cl/phase1/network/services/block_service.go b/cl/phase1/network/services/block_service.go index 75ffe8ed703..554c5c5f5be 100644 --- a/cl/phase1/network/services/block_service.go +++ b/cl/phase1/network/services/block_service.go @@ -176,15 +176,15 @@ func (b *blockService) processAndStoreBlock(ctx context.Context, block *cltypes. if err := b.forkchoiceStore.OnBlock(ctx, block, true, true, true); err != nil { return err } - go b.importBlockAttestations(block) + go b.importBlockOperations(block) return b.db.Update(ctx, func(tx kv.RwTx) error { return beacon_indicies.WriteHighestFinalized(tx, b.forkchoiceStore.FinalizedSlot()) }) } -// importBlockAttestationsInParallel imports block attestations in parallel -func (b *blockService) importBlockAttestations(block *cltypes.SignedBeaconBlock) { +// importBlockOperations imports block operations in parallel +func (b *blockService) importBlockOperations(block *cltypes.SignedBeaconBlock) { defer func() { // Would prefer this not to crash but rather log the error r := recover() if r != nil { @@ -199,7 +199,13 @@ func (b *blockService) importBlockAttestations(block *cltypes.SignedBeaconBlock) return true }) - log.Debug("import attestation", "time", time.Since(start)) + block.Block.Body.AttesterSlashings.Range(func(idx int, a *cltypes.AttesterSlashing, total int) bool { + if err := b.forkchoiceStore.OnAttesterSlashing(a, false); err != nil { + log.Debug("bad attester slashing received", "err", err) + } + return true + }) + log.Debug("import operations", "time", time.Since(start)) } // loop is the main loop of the block service From dc7d261c7c2570607daa324289e141d2599fd66c Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 19:22:30 +0200 Subject: [PATCH 06/11] save --- cl/phase1/forkchoice/on_attester_slashing.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cl/phase1/forkchoice/on_attester_slashing.go b/cl/phase1/forkchoice/on_attester_slashing.go index 1c7eeda0722..af701d7f918 100644 --- a/cl/phase1/forkchoice/on_attester_slashing.go +++ b/cl/phase1/forkchoice/on_attester_slashing.go @@ -24,13 +24,17 @@ func (f *ForkChoiceStore) OnAttesterSlashing(attesterSlashing *cltypes.AttesterS if !cltypes.IsSlashableAttestationData(attestation1.Data, attestation2.Data) { return fmt.Errorf("attestation data is not slashable") } - // Retrieve justified state - s, err := f.forkGraph.GetState(f.justifiedCheckpoint.Load().(solid.Checkpoint).BlockRoot(), false) - if err != nil { - return err + var err error + s := f.syncedDataManager.HeadState() + if s == nil { + // Retrieve justified state + s, err = f.forkGraph.GetState(f.justifiedCheckpoint.Load().(solid.Checkpoint).BlockRoot(), false) + if err != nil { + return err + } } if s == nil { - return fmt.Errorf("justified checkpoint state not accessible") + return fmt.Errorf("no state accessible") } attestation1PublicKeys, err := getIndexedAttestationPublicKeys(s, attestation1) if err != nil { From e5ad942bb66e8bc3edb4b37b3d743822ca4b5a1f Mon Sep 17 00:00:00 2001 From: Giulio Date: Mon, 22 Apr 2024 21:32:15 +0200 Subject: [PATCH 07/11] save --- cl/pool/operations_pool.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/cl/pool/operations_pool.go b/cl/pool/operations_pool.go index 92613eb2f1c..dde5db71cba 100644 --- a/cl/pool/operations_pool.go +++ b/cl/pool/operations_pool.go @@ -8,6 +8,8 @@ import ( "github.com/ledgerwatch/erigon/cl/cltypes/solid" ) +const operationsPerPool = 512 + // DoubleSignatureKey uses blake2b algorithm to merge two signatures together. blake2 is faster than sha3. func doubleSignatureKey(one, two libcommon.Bytes96) (out libcommon.Bytes96) { res := blake2b.Sum256(append(one[:], two[:]...)) @@ -25,24 +27,20 @@ func ComputeKeyForAttesterSlashing(slashing *cltypes.AttesterSlashing) libcommon // OperationsPool is the collection of all gossip-collectable operations. type OperationsPool struct { - AttestationsPool *OperationPool[libcommon.Bytes96, *solid.Attestation] - AttesterSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing] - ProposerSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing] - BLSToExecutionChangesPool *OperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange] - SignedContributionAndProofPool *OperationPool[libcommon.Bytes96, *cltypes.SignedContributionAndProof] - VoluntaryExistsPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit] - ContributionCache *OperationPool[cltypes.ContributionKey, [][]byte] + AttestationsPool *OperationPool[libcommon.Bytes96, *solid.Attestation] + AttesterSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing] + ProposerSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing] + BLSToExecutionChangesPool *OperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange] + VoluntaryExistsPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit] } func NewOperationsPool(beaconCfg *clparams.BeaconChainConfig) OperationsPool { return OperationsPool{ - AttestationsPool: NewOperationPool[libcommon.Bytes96, *solid.Attestation](int(beaconCfg.MaxAttestations), "attestationsPool"), - AttesterSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing](int(beaconCfg.MaxAttestations), "attesterSlashingsPool"), - ProposerSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing](int(beaconCfg.MaxAttestations), "proposerSlashingsPool"), - BLSToExecutionChangesPool: NewOperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange](int(beaconCfg.MaxBlsToExecutionChanges), "blsExecutionChangesPool"), - SignedContributionAndProofPool: NewOperationPool[libcommon.Bytes96, *cltypes.SignedContributionAndProof](int(beaconCfg.MaxAttestations), "signedContributionAndProof"), - VoluntaryExistsPool: NewOperationPool[uint64, *cltypes.SignedVoluntaryExit](int(beaconCfg.MaxBlsToExecutionChanges), "voluntaryExitsPool"), - ContributionCache: NewOperationPool[cltypes.ContributionKey, [][]byte](int(beaconCfg.MaxAttestations), "contributionCache"), + AttestationsPool: NewOperationPool[libcommon.Bytes96, *solid.Attestation](operationsPerPool, "attestationsPool"), + AttesterSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing](operationsPerPool, "attesterSlashingsPool"), + ProposerSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing](operationsPerPool, "proposerSlashingsPool"), + BLSToExecutionChangesPool: NewOperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange](operationsPerPool, "blsExecutionChangesPool"), + VoluntaryExistsPool: NewOperationPool[uint64, *cltypes.SignedVoluntaryExit](operationsPerPool, "voluntaryExitsPool"), } } From 686d48a5712624187b53eeb6f43ef1c60d0d0d70 Mon Sep 17 00:00:00 2001 From: Giulio Date: Wed, 24 Apr 2024 10:21:50 +0200 Subject: [PATCH 08/11] save --- cl/pool/operations_pool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl/pool/operations_pool.go b/cl/pool/operations_pool.go index 9f3afe06cf7..dde5db71cba 100644 --- a/cl/pool/operations_pool.go +++ b/cl/pool/operations_pool.go @@ -46,7 +46,7 @@ func NewOperationsPool(beaconCfg *clparams.BeaconChainConfig) OperationsPool { func (o *OperationsPool) NotifyBlock(blk *cltypes.BeaconBlock) { blk.Body.VoluntaryExits.Range(func(_ int, exit *cltypes.SignedVoluntaryExit, _ int) bool { - o.VoluntaryExitPool.DeleteIfExist(exit.VoluntaryExit.ValidatorIndex) + o.VoluntaryExistsPool.DeleteIfExist(exit.VoluntaryExit.ValidatorIndex) return true }) blk.Body.AttesterSlashings.Range(func(_ int, att *cltypes.AttesterSlashing, _ int) bool { From bd4167fe630f2a01f9ceb58e45ef4269e0946a6b Mon Sep 17 00:00:00 2001 From: Giulio Date: Wed, 24 Apr 2024 10:38:33 +0200 Subject: [PATCH 09/11] save --- cl/phase1/network/services/voluntary_exit_service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl/phase1/network/services/voluntary_exit_service.go b/cl/phase1/network/services/voluntary_exit_service.go index 7dae5b9224c..95d40340d39 100644 --- a/cl/phase1/network/services/voluntary_exit_service.go +++ b/cl/phase1/network/services/voluntary_exit_service.go @@ -46,7 +46,7 @@ func (s *voluntaryExitService) ProcessMessage(ctx context.Context, subnet *uint6 defer s.emitters.Publish("voluntary_exit", voluntaryExit) // [IGNORE] The voluntary exit is the first valid voluntary exit received for the validator with index signed_voluntary_exit.message.validator_index. - if s.operationsPool.VoluntaryExitPool.Has(voluntaryExit.ValidatorIndex) { + if s.operationsPool.VoluntaryExistsPool.Has(voluntaryExit.ValidatorIndex) { return ErrIgnore } @@ -111,7 +111,7 @@ func (s *voluntaryExitService) ProcessMessage(ctx context.Context, subnet *uint6 return errors.New("ProcessVoluntaryExit: BLS verification failed") } - s.operationsPool.VoluntaryExitPool.Insert(voluntaryExit.ValidatorIndex, msg) + s.operationsPool.VoluntaryExistsPool.Insert(voluntaryExit.ValidatorIndex, msg) return nil } From 84ce8c514f38dbe3c4028a1ab61d0782a6d8d27c Mon Sep 17 00:00:00 2001 From: Giulio Date: Wed, 24 Apr 2024 13:37:32 +0200 Subject: [PATCH 10/11] save --- cl/beacon/handler/pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl/beacon/handler/pool.go b/cl/beacon/handler/pool.go index 05386e8828a..046319478e0 100644 --- a/cl/beacon/handler/pool.go +++ b/cl/beacon/handler/pool.go @@ -17,7 +17,7 @@ import ( ) func (a *ApiHandler) GetEthV1BeaconPoolVoluntaryExits(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) { - return newBeaconResponse(a.operationsPool.VoluntaryExitPool.Raw()), nil + return newBeaconResponse(a.operationsPool.VoluntaryExistsPool.Raw()), nil } func (a *ApiHandler) GetEthV1BeaconPoolAttesterSlashings(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) { @@ -144,7 +144,7 @@ func (a *ApiHandler) PostEthV1BeaconPoolVoluntaryExits(w http.ResponseWriter, r http.Error(w, err.Error(), http.StatusInternalServerError) return } - a.operationsPool.VoluntaryExitPool.Insert(req.VoluntaryExit.ValidatorIndex, &req) + a.operationsPool.VoluntaryExistsPool.Insert(req.VoluntaryExit.ValidatorIndex, &req) } // Only write 200 w.WriteHeader(http.StatusOK) From b00ea8439cbde45eb053a5e7c4cb105b68b7bde0 Mon Sep 17 00:00:00 2001 From: Giulio Date: Wed, 24 Apr 2024 19:46:18 +0200 Subject: [PATCH 11/11] save --- cl/beacon/handler/pool.go | 4 ++-- cl/beacon/handler/utils_test.go | 2 +- cl/phase1/network/services/voluntary_exit_service.go | 4 ++-- cl/pool/operations_pool.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cl/beacon/handler/pool.go b/cl/beacon/handler/pool.go index 046319478e0..f6f246669c2 100644 --- a/cl/beacon/handler/pool.go +++ b/cl/beacon/handler/pool.go @@ -17,7 +17,7 @@ import ( ) func (a *ApiHandler) GetEthV1BeaconPoolVoluntaryExits(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) { - return newBeaconResponse(a.operationsPool.VoluntaryExistsPool.Raw()), nil + return newBeaconResponse(a.operationsPool.VoluntaryExitsPool.Raw()), nil } func (a *ApiHandler) GetEthV1BeaconPoolAttesterSlashings(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) { @@ -144,7 +144,7 @@ func (a *ApiHandler) PostEthV1BeaconPoolVoluntaryExits(w http.ResponseWriter, r http.Error(w, err.Error(), http.StatusInternalServerError) return } - a.operationsPool.VoluntaryExistsPool.Insert(req.VoluntaryExit.ValidatorIndex, &req) + a.operationsPool.VoluntaryExitsPool.Insert(req.VoluntaryExit.ValidatorIndex, &req) } // Only write 200 w.WriteHeader(http.StatusOK) diff --git a/cl/beacon/handler/utils_test.go b/cl/beacon/handler/utils_test.go index 4af1a581739..03ac9e58eb2 100644 --- a/cl/beacon/handler/utils_test.go +++ b/cl/beacon/handler/utils_test.go @@ -105,7 +105,7 @@ func setupTestingHandler(t *testing.T, v clparams.StateVersion, logger log.Logge return nil }).AnyTimes() voluntaryExitService.EXPECT().ProcessMessage(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, subnetID *uint64, msg *cltypes.SignedVoluntaryExit) error { - opPool.VoluntaryExitPool.Insert(msg.VoluntaryExit.ValidatorIndex, msg) + opPool.VoluntaryExitsPool.Insert(msg.VoluntaryExit.ValidatorIndex, msg) return nil }).AnyTimes() blsToExecutionChangeService.EXPECT().ProcessMessage(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, subnetID *uint64, msg *cltypes.SignedBLSToExecutionChange) error { diff --git a/cl/phase1/network/services/voluntary_exit_service.go b/cl/phase1/network/services/voluntary_exit_service.go index 95d40340d39..925ed88e447 100644 --- a/cl/phase1/network/services/voluntary_exit_service.go +++ b/cl/phase1/network/services/voluntary_exit_service.go @@ -46,7 +46,7 @@ func (s *voluntaryExitService) ProcessMessage(ctx context.Context, subnet *uint6 defer s.emitters.Publish("voluntary_exit", voluntaryExit) // [IGNORE] The voluntary exit is the first valid voluntary exit received for the validator with index signed_voluntary_exit.message.validator_index. - if s.operationsPool.VoluntaryExistsPool.Has(voluntaryExit.ValidatorIndex) { + if s.operationsPool.VoluntaryExitsPool.Has(voluntaryExit.ValidatorIndex) { return ErrIgnore } @@ -111,7 +111,7 @@ func (s *voluntaryExitService) ProcessMessage(ctx context.Context, subnet *uint6 return errors.New("ProcessVoluntaryExit: BLS verification failed") } - s.operationsPool.VoluntaryExistsPool.Insert(voluntaryExit.ValidatorIndex, msg) + s.operationsPool.VoluntaryExitsPool.Insert(voluntaryExit.ValidatorIndex, msg) return nil } diff --git a/cl/pool/operations_pool.go b/cl/pool/operations_pool.go index dde5db71cba..0cb4da68a0f 100644 --- a/cl/pool/operations_pool.go +++ b/cl/pool/operations_pool.go @@ -31,7 +31,7 @@ type OperationsPool struct { AttesterSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing] ProposerSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing] BLSToExecutionChangesPool *OperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange] - VoluntaryExistsPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit] + VoluntaryExitsPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit] } func NewOperationsPool(beaconCfg *clparams.BeaconChainConfig) OperationsPool { @@ -40,13 +40,13 @@ func NewOperationsPool(beaconCfg *clparams.BeaconChainConfig) OperationsPool { AttesterSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.AttesterSlashing](operationsPerPool, "attesterSlashingsPool"), ProposerSlashingsPool: NewOperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing](operationsPerPool, "proposerSlashingsPool"), BLSToExecutionChangesPool: NewOperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange](operationsPerPool, "blsExecutionChangesPool"), - VoluntaryExistsPool: NewOperationPool[uint64, *cltypes.SignedVoluntaryExit](operationsPerPool, "voluntaryExitsPool"), + VoluntaryExitsPool: NewOperationPool[uint64, *cltypes.SignedVoluntaryExit](operationsPerPool, "voluntaryExitsPool"), } } func (o *OperationsPool) NotifyBlock(blk *cltypes.BeaconBlock) { blk.Body.VoluntaryExits.Range(func(_ int, exit *cltypes.SignedVoluntaryExit, _ int) bool { - o.VoluntaryExistsPool.DeleteIfExist(exit.VoluntaryExit.ValidatorIndex) + o.VoluntaryExitsPool.DeleteIfExist(exit.VoluntaryExit.ValidatorIndex) return true }) blk.Body.AttesterSlashings.Range(func(_ int, att *cltypes.AttesterSlashing, _ int) bool {