Skip to content

Keymanager FR and GL fixes #6916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
+ parent sanity OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
## Combined scenarios [Beacon Node] [Preset: mainnet]
```diff
+ ImportKeystores should not be blocked by fee recipient setting [Beacon Node] [Preset: main OK
+ ImportKeystores should not be blocked by gas limit setting [Beacon Node] [Preset: mainnet] OK
+ ImportRemoteKeys should not be blocked by fee recipient setting [Beacon Node] [Preset: mai OK
+ ImportRemoteKeys should not be blocked by gas limit setting [Beacon Node] [Preset: mainnet OK
```
OK: 4/4 Fail: 0/4 Skip: 0/4
## DeleteKeys requests [Beacon Node] [Preset: mainnet]
```diff
+ Deleting not existing key [Beacon Node] [Preset: mainnet] OK
Expand Down Expand Up @@ -593,14 +601,16 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
## Fee recipient management [Beacon Node] [Preset: mainnet]
```diff
+ Configuring the fee recipient [Beacon Node] [Preset: mainnet] OK
+ Configuring the fee recipient for dynamic validator [Beacon Node] [Preset: mainnet] OK
+ Invalid Authorization Header [Beacon Node] [Preset: mainnet] OK
+ Invalid Authorization Token [Beacon Node] [Preset: mainnet] OK
+ Missing Authorization header [Beacon Node] [Preset: mainnet] OK
+ Obtaining the fee recipient for dynamic validator returns suggested default [Beacon Node] OK
+ Obtaining the fee recipient of a missing validator returns 404 [Beacon Node] [Preset: main OK
+ Obtaining the fee recipient of an unconfigured validator returns the suggested default [Be OK
+ Setting the fee recipient on a missing validator creates a record for it [Beacon Node] [Pr OK
```
OK: 7/7 Fail: 0/7 Skip: 0/7
OK: 9/9 Fail: 0/9 Skip: 0/9
## FinalizedBlocks [Preset: mainnet]
```diff
+ Basic ops [Preset: mainnet] OK
Expand Down Expand Up @@ -631,14 +641,16 @@ OK: 11/11 Fail: 0/11 Skip: 0/11
## Gas limit management [Beacon Node] [Preset: mainnet]
```diff
+ Configuring the gas limit [Beacon Node] [Preset: mainnet] OK
+ Configuring the gas limit for dynamic validator [Beacon Node] [Preset: mainnet] OK
+ Invalid Authorization Header [Beacon Node] [Preset: mainnet] OK
+ Invalid Authorization Token [Beacon Node] [Preset: mainnet] OK
+ Missing Authorization header [Beacon Node] [Preset: mainnet] OK
+ Obtaining the gas limit for dynamic validator returns suggested default [Beacon Node] [Pre OK
+ Obtaining the gas limit of a missing validator returns 404 [Beacon Node] [Preset: mainnet] OK
+ Obtaining the gas limit of an unconfigured validator returns the suggested default [Beacon OK
+ Setting the gas limit on a missing validator creates a record for it [Beacon Node] [Preset OK
```
OK: 7/7 Fail: 0/7 Skip: 0/7
OK: 9/9 Fail: 0/9 Skip: 0/9
## Gossip fork transition
```diff
+ Gossip fork transition OK
Expand Down Expand Up @@ -1150,4 +1162,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 779/784 Fail: 0/784 Skip: 5/784
OK: 787/792 Fail: 0/792 Skip: 5/792
34 changes: 22 additions & 12 deletions beacon_chain/validators/keystore_management.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,6 @@ proc saveLockedKeystore(
keystoreDir = validatorsDir / keyName
keystoreFile = keystoreDir / KeystoreFileName

if dirExists(keystoreDir):
return err(KeystoreGenerationError(kind: DuplicateKeystoreDir,
error: "Keystore directory already exists"))
if fileExists(keystoreFile):
return err(KeystoreGenerationError(kind: DuplicateKeystoreFile,
error: "Keystore file already exists"))
Expand Down Expand Up @@ -1335,9 +1332,6 @@ proc saveLockedKeystore(
remotes: urls,
flags: flags)

if dirExists(keystoreDir):
return err(KeystoreGenerationError(kind: DuplicateKeystoreDir,
error: "Keystore directory already exists"))
if fileExists(keystoreFile):
return err(KeystoreGenerationError(kind: DuplicateKeystoreFile,
error: "Keystore file already exists"))
Expand Down Expand Up @@ -1579,10 +1573,18 @@ func getPerValidatorDefaultFeeRecipient*(
(static(default(Eth1Address)))

proc getSuggestedFeeRecipient*(
host: KeymanagerHost, pubkey: ValidatorPubKey,
defaultFeeRecipient: Eth1Address):
Result[Eth1Address, ValidatorConfigFileStatus] =
host.validatorsDir.getSuggestedFeeRecipient(pubkey, defaultFeeRecipient)
host: KeymanagerHost,
pubkey: ValidatorPubKey,
defaultFeeRecipient: Eth1Address
): Result[Eth1Address, ValidatorConfigFileStatus] =
let res = getSuggestedFeeRecipient(
host.validatorsDir, pubkey, defaultFeeRecipient).valueOr:
if error == ValidatorConfigFileStatus.noSuchValidator:
# Dynamic validators do not have directories.
if host.validatorPool[].isDynamic(pubkey):
return ok(defaultFeeRecipient)
return err(error)
ok(res)

proc getSuggestedFeeRecipient(
host: KeymanagerHost, pubkey: ValidatorPubKey,
Expand All @@ -1596,8 +1598,16 @@ proc getSuggestedFeeRecipient(

proc getSuggestedGasLimit*(
host: KeymanagerHost,
pubkey: ValidatorPubKey): Result[uint64, ValidatorConfigFileStatus] =
host.validatorsDir.getSuggestedGasLimit(pubkey, host.defaultGasLimit)
pubkey: ValidatorPubKey
): Result[uint64, ValidatorConfigFileStatus] =
let res = getSuggestedGasLimit(
host.validatorsDir, pubkey, host.defaultGasLimit).valueOr:
if error == ValidatorConfigFileStatus.noSuchValidator:
# Dynamic validators do not have directories.
if host.validatorPool[].isDynamic(pubkey):
return ok(host.defaultGasLimit)
return err(error)
ok(res)

proc getSuggestedGraffiti*(
host: KeymanagerHost,
Expand Down
9 changes: 9 additions & 0 deletions beacon_chain/validators/validator_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ proc removeValidator*(pool: var ValidatorPool, pubkey: ValidatorPubKey) =
validator = shortLog(validator)
validators.set(pool.count().int64)

proc isDynamic*(pool: var ValidatorPool, pubkey: ValidatorPubKey): bool =
## Returns ``true`` if attached validator exists it is dynamic.
let validator = pool.validators.getOrDefault(pubkey)
if not(isNil(validator)):
if (validator.kind == ValidatorKind.Remote) and
(RemoteKeystoreFlag.DynamicKeystore in validator.data.flags):
return true
false

func needsUpdate*(validator: AttachedValidator): bool =
validator.index.isNone() or validator.activationEpoch == FAR_FUTURE_EPOCH

Expand Down
Loading
Loading