Skip to content

Commit

Permalink
VoluntaryExitPool
Browse files Browse the repository at this point in the history
  • Loading branch information
domiwei committed Apr 18, 2024
1 parent 83857d7 commit 95172a1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cl/beacon/handler/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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.VoluntaryExitPool.Raw()), nil
}

func (a *ApiHandler) GetEthV1BeaconPoolAttesterSlashings(w http.ResponseWriter, r *http.Request) (*beaconhttp.BeaconResponse, error) {
Expand Down Expand Up @@ -143,7 +143,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.VoluntaryExitPool.Insert(req.VoluntaryExit.ValidatorIndex, &req)
}
// Only write 200
w.WriteHeader(http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/handler/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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.VoluntaryExistsPool.Insert(msg.VoluntaryExit.ValidatorIndex, msg)
opPool.VoluntaryExitPool.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 {
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/forkchoice/fork_choice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestForkChoiceBasic(t *testing.T) {
time.Sleep(time.Millisecond)
}
require.NoError(t, err)
require.Equal(t, len(pool.VoluntaryExistsPool.Raw()), 1)
require.Equal(t, len(pool.VoluntaryExitPool.Raw()), 1)
}

func TestForkChoiceChainBellatrix(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/forkchoice/forkchoice_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (f *ForkChoiceStorageMock) Partecipation(epoch uint64) (*solid.BitList, boo
}

func (f *ForkChoiceStorageMock) OnVoluntaryExit(signedVoluntaryExit *cltypes.SignedVoluntaryExit, test bool) error {
f.Pool.VoluntaryExistsPool.Insert(signedVoluntaryExit.VoluntaryExit.ValidatorIndex, signedVoluntaryExit)
f.Pool.VoluntaryExitPool.Insert(signedVoluntaryExit.VoluntaryExit.ValidatorIndex, signedVoluntaryExit)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions cl/phase1/network/services/voluntary_exit_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *voluntaryExitService) ProcessMessage(ctx context.Context, subnet *uint6
// ref: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#voluntary_exit
voluntaryExit := msg.VoluntaryExit
defer s.emitters.Publish("voluntary_exit", voluntaryExit)
if s.operationsPool.VoluntaryExistsPool.Has(voluntaryExit.ValidatorIndex) {
if s.operationsPool.VoluntaryExitPool.Has(voluntaryExit.ValidatorIndex) {
return ErrIgnore
}

Expand Down Expand Up @@ -117,7 +117,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.VoluntaryExitPool.Insert(voluntaryExit.ValidatorIndex, msg)

// Initiate exit
// initiate_validator_exit(state, voluntary_exit.validator_index)
Expand Down
6 changes: 3 additions & 3 deletions cl/pool/operations_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type OperationsPool struct {
ProposerSlashingsPool *OperationPool[libcommon.Bytes96, *cltypes.ProposerSlashing]
BLSToExecutionChangesPool *OperationPool[libcommon.Bytes96, *cltypes.SignedBLSToExecutionChange]
SignedContributionAndProofPool *OperationPool[libcommon.Bytes96, *cltypes.SignedContributionAndProof]
VoluntaryExistsPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit]
VoluntaryExitPool *OperationPool[uint64, *cltypes.SignedVoluntaryExit]
ContributionCache *OperationPool[cltypes.ContributionKey, [][]byte]
}

Expand All @@ -41,14 +41,14 @@ func NewOperationsPool(beaconCfg *clparams.BeaconChainConfig) OperationsPool {
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"),
VoluntaryExitPool: NewOperationPool[uint64, *cltypes.SignedVoluntaryExit](int(beaconCfg.MaxBlsToExecutionChanges), "voluntaryExitsPool"),
ContributionCache: NewOperationPool[cltypes.ContributionKey, [][]byte](int(beaconCfg.MaxAttestations), "contributionCache"),
}
}

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.VoluntaryExitPool.DeleteIfExist(exit.VoluntaryExit.ValidatorIndex)
return true
})
blk.Body.AttesterSlashings.Range(func(_ int, att *cltypes.AttesterSlashing, _ int) bool {
Expand Down

0 comments on commit 95172a1

Please sign in to comment.