From ba4d4c14db2d4d808fabb62142230237d30d6d07 Mon Sep 17 00:00:00 2001 From: tersec Date: Fri, 1 Jul 2022 21:52:23 +0000 Subject: [PATCH] fix Nim 1.6 deprecation and unused import warnings (#3834) --- AllTests-mainnet.md | 5 +++-- .../block_pools_types_light_client.nim | 2 -- beacon_chain/rpc/rest_key_management_api.nim | 14 +++++++------- beacon_chain/validators/validator_duties.nim | 16 ++++++++-------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index 373bcfc3c..daec79829 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -47,9 +47,10 @@ OK: 16/16 Fail: 0/16 Skip: 0/16 + dependent_root OK + get_beacon_proposer_index OK + latest_block_root OK ++ merklizer state roundtrip OK + process_slots OK ``` -OK: 5/5 Fail: 0/5 Skip: 0/5 +OK: 6/6 Fail: 0/6 Skip: 0/6 ## Beacon time ```diff + basics OK @@ -568,4 +569,4 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 313/318 Fail: 0/318 Skip: 5/318 +OK: 314/319 Fail: 0/319 Skip: 5/319 diff --git a/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim b/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim index 0c2d33fbd..3b21a5e15 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types_light_client.nim @@ -11,8 +11,6 @@ # protocol. See https://github.com/ethereum/consensus-specs/pull/2802 import - # Status libraries - stew/bitops2, # Beacon chain internals ../spec/datatypes/altair, ../light_client_data_db, diff --git a/beacon_chain/rpc/rest_key_management_api.nim b/beacon_chain/rpc/rest_key_management_api.nim index fe67cced5..3ab9c4fe7 100644 --- a/beacon_chain/rpc/rest_key_management_api.nim +++ b/beacon_chain/rpc/rest_key_management_api.nim @@ -198,18 +198,18 @@ proc installKeymanagerHandlers*(router: var RestRouter, node: BeaconNode) = if res.isOk: case res.value() of RemoveValidatorStatus.deleted: - keysAndDeleteStatus.add( - pubkey, RequestItemStatus(status: $KeystoreStatus.deleted)) + keysAndDeleteStatus[pubkey] = + RequestItemStatus(status: $KeystoreStatus.deleted) # At first all keys with status missing directory after removal receive # status 'not_found' of RemoveValidatorStatus.notFound: - keysAndDeleteStatus.add( - pubkey, RequestItemStatus(status: $KeystoreStatus.notFound)) + keysAndDeleteStatus[pubkey] = + RequestItemStatus(status: $KeystoreStatus.notFound) else: - keysAndDeleteStatus.add(pubkey, - RequestItemStatus(status: $KeystoreStatus.error, - message: $res.error())) + keysAndDeleteStatus[pubkey] = + RequestItemStatus(status: $KeystoreStatus.error, + message: $res.error()) # If we discover slashing protection data for a validator that was not # found, this means the validator was active in the past, so we must diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index 02f17407c..d2f88f02d 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -151,13 +151,13 @@ proc addValidators*(node: BeaconNode) = node.addLocalValidators(localValidators) node.addRemoteValidators(remoteValidators) -proc getAttachedValidator*(node: BeaconNode, - pubkey: ValidatorPubKey): AttachedValidator = +proc getAttachedValidator(node: BeaconNode, + pubkey: ValidatorPubKey): AttachedValidator = node.attachedValidators[].getValidator(pubkey) -proc getAttachedValidator*(node: BeaconNode, - state_validators: auto, - idx: ValidatorIndex): AttachedValidator = +proc getAttachedValidator(node: BeaconNode, + state_validators: auto, + idx: ValidatorIndex): AttachedValidator = if uint64(idx) < state_validators.lenu64: let validator = node.getAttachedValidator(state_validators[idx].pubkey) if validator != nil and validator.index != some(idx): @@ -170,9 +170,9 @@ proc getAttachedValidator*(node: BeaconNode, idx, validators = state_validators.len nil -proc getAttachedValidator*(node: BeaconNode, - epochRef: EpochRef, - idx: ValidatorIndex): AttachedValidator = +proc getAttachedValidator(node: BeaconNode, + epochRef: EpochRef, + idx: ValidatorIndex): AttachedValidator = let key = epochRef.validatorKey(idx) if key.isSome(): let validator = node.getAttachedValidator(key.get().toPubKey())