Skip to content

Commit 8be4f41

Browse files
committed
Wait for validator index to be included in finalized state
1 parent 8272e68 commit 8be4f41

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

rocketpool/node/stake-megapool-validator.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package node
22

33
import (
44
"math/big"
5+
"strconv"
56

67
"github.com/docker/docker/client"
78
"github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -202,6 +203,20 @@ func (t *stakeMegapoolValidator) stakeValidator(rp *rocketpool.RocketPool, beaco
202203
return err
203204
}
204205

206+
// Check if the validator is included in the finalized beacon state before attempting proof generation
207+
validatorIndexStr, err := t.bc.GetValidatorIndex(validatorPubkey)
208+
if err != nil {
209+
return err
210+
}
211+
validatorIndex, err := strconv.ParseUint(validatorIndexStr, 10, 64)
212+
if err != nil {
213+
return err
214+
}
215+
if validatorIndex >= uint64(len(beaconState.GetValidators())) {
216+
t.log.Printlnf("Validator id %d (beacon index %d) is not yet included in the finalized beacon state. Will retry on next cycle.", validatorId, validatorIndex)
217+
return nil
218+
}
219+
205220
t.log.Printlnf("Crafting a proof that the correct credentials were used on the first beacon chain deposit. This process can take several seconds and is CPU and memory intensive.")
206221

207222
validatorProof, slotTimestamp, slotProof, err := services.GetValidatorProof(t.c, 0, t.w, state.BeaconConfig, mp.GetAddress(), validatorPubkey, beaconState)

0 commit comments

Comments
 (0)