diff --git a/cmd/validator/credentials/set/process.go b/cmd/validator/credentials/set/process.go index 5a63060..fb38d5b 100644 --- a/cmd/validator/credentials/set/process.go +++ b/cmd/validator/credentials/set/process.go @@ -196,12 +196,16 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context) } // Scan the keys from the seed to find the path. + maxDistance := 1024 + if c.maxDistance > 0 { + maxDistance = int(c.maxDistance) + } // Start scanning the validator keys. var withdrawalAccount e2wtypes.Account for i := 0; ; i++ { - if uint64(i) == c.maxDistance { + if i == maxDistance { if c.debug { - fmt.Fprintf(os.Stderr, "Gone %d indices without finding the validator, not scanning any further\n", c.maxDistance) + fmt.Fprintf(os.Stderr, "Gone %d indices without finding the validator, not scanning any further\n", maxDistance) } return fmt.Errorf("failed to find validator using the provided mnemonic, validator=%s, pubkey=%#x", c.validator, validatorInfo.Pubkey) } @@ -249,12 +253,16 @@ func (c *command) generateOperationsFromMnemonic(ctx context.Context) error { // Start scanning the validator keys. lastFoundIndex := 0 foundValidatorCount := 0 + maxDistance := 1024 + if c.maxDistance > 0 { + maxDistance = int(c.maxDistance) + } for i := 0; ; i++ { // If no validators have been found in the last maxDistance indices, stop scanning. - if uint64(i-lastFoundIndex) > c.maxDistance { + if i-lastFoundIndex > maxDistance { // If no validators were found at all, return an error. if foundValidatorCount == 0 { - return fmt.Errorf("failed to find validators using the provided mnemonic: searched %d indices without finding a validator", c.maxDistance) + return fmt.Errorf("failed to find validators using the provided mnemonic: searched %d indices without finding a validator", maxDistance) } break } diff --git a/cmd/validator/exit/process.go b/cmd/validator/exit/process.go index 2a00026..c9bbc16 100644 --- a/cmd/validator/exit/process.go +++ b/cmd/validator/exit/process.go @@ -176,11 +176,15 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context) } // Scan the keys from the seed to find the path. + maxDistance := 1024 + if c.maxDistance > 0 { + maxDistance = int(c.maxDistance) + } // Start scanning the validator keys. for i := 0; ; i++ { - if uint64(i) == c.maxDistance { + if i == maxDistance { if c.debug { - fmt.Fprintf(os.Stderr, "Gone %d indices without finding the validator, not scanning any further\n", c.maxDistance) + fmt.Fprintf(os.Stderr, "Gone %d indices without finding the validator, not scanning any further\n", maxDistance) } break } @@ -218,15 +222,20 @@ func (c *command) generateOperationsFromMnemonic(ctx context.Context) error { validators[fmt.Sprintf("%#x", validator.Pubkey)] = validator } + // Scan the keys from the seed to find the path. + maxDistance := 1024 + if c.maxDistance > 0 { + maxDistance = int(c.maxDistance) + } // Start scanning the validator keys. lastFoundIndex := 0 foundValidatorCount := 0 for i := 0; ; i++ { // If no validators have been found in the last maxDistance indices, stop scanning. - if uint64(i-lastFoundIndex) > c.maxDistance { + if i-lastFoundIndex > maxDistance { // If no validators were found at all, return an error. if foundValidatorCount == 0 { - return fmt.Errorf("failed to find validators using the provided mnemonic: searched %d indices without finding a validator", c.maxDistance) + return fmt.Errorf("failed to find validators using the provided mnemonic: searched %d indices without finding a validator", maxDistance) } break }