Skip to content

Commit b7ea6a6

Browse files
authored
fix some deprecation warnings (#6702)
1 parent 544b07b commit b7ea6a6

File tree

8 files changed

+23
-25
lines changed

8 files changed

+23
-25
lines changed

beacon_chain/beacon_node.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type
7070
config*: BeaconNodeConf
7171
attachedValidators*: ref ValidatorPool
7272
optimisticProcessor*: OptimisticProcessor
73-
optimisticFcuFut*: Future[(PayloadExecutionStatus, Opt[BlockHash])]
73+
optimisticFcuFut*: Future[(PayloadExecutionStatus, Opt[Hash32])]
7474
.Raising([CancelledError])
7575
lightClient*: LightClient
7676
dag*: ChainDAGRef

beacon_chain/el/el_manager.nim

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ type
4545
SignatureBytes = DynamicBytes[96, 96]
4646
Int64LeBytes = DynamicBytes[8, 8]
4747
WithoutTimeout* = distinct int
48-
Address = web3.Address
4948

5049
DeadlineObject* = object
5150
# TODO (cheatfate): This object declaration could be removed when
@@ -130,7 +129,7 @@ type
130129

131130
depositContractAddress*: Eth1Address
132131
depositContractBlockNumber: uint64
133-
depositContractBlockHash: BlockHash
132+
depositContractBlockHash: Hash32
134133

135134
blocksPerLogsRequest: uint64
136135
## This value is used to dynamically adjust the number of
@@ -199,7 +198,7 @@ type
199198

200199
FullBlockId* = object
201200
number: Eth1BlockNumber
202-
hash: BlockHash
201+
hash: Hash32
203202

204203
DataProviderFailure* = object of CatchableError
205204
CorruptDataProvider* = object of DataProviderFailure
@@ -458,7 +457,7 @@ proc connectedRpcClient(connection: ELConnection): Future[RpcClient] {.
458457

459458
proc getBlockByHash(
460459
rpcClient: RpcClient,
461-
hash: BlockHash
460+
hash: Hash32
462461
): Future[BlockObject] {.async: (raises: [CatchableError]).} =
463462
await rpcClient.eth_getBlockByHash(hash, false)
464463

@@ -730,7 +729,7 @@ proc getPayload*(
730729

731730
proc waitELToSyncDeposits(
732731
connection: ELConnection,
733-
minimalRequiredBlock: BlockHash
732+
minimalRequiredBlock: Hash32
734733
) {.async: (raises: [CancelledError]).} =
735734
var rpcClient: RpcClient = nil
736735

@@ -776,7 +775,7 @@ proc waitELToSyncDeposits(
776775
func networkHasDepositContract(m: ELManager): bool =
777776
not m.cfg.DEPOSIT_CONTRACT_ADDRESS.isDefaultValue
778777

779-
func mostRecentKnownBlock(m: ELManager): BlockHash =
778+
func mostRecentKnownBlock(m: ELManager): Hash32 =
780779
if m.eth1Chain.finalizedDepositsMerkleizer.getChunkCount() > 0:
781780
m.eth1Chain.finalizedBlockHash.asBlockHash
782781
else:
@@ -1111,7 +1110,7 @@ proc forkchoiceUpdated*(
11111110
Opt[PayloadAttributesV3],
11121111
deadlineObj: DeadlineObject,
11131112
maxRetriesCount: int
1114-
): Future[(PayloadExecutionStatus, Opt[BlockHash])] {.
1113+
): Future[(PayloadExecutionStatus, Opt[Hash32])] {.
11151114
async: (raises: [CancelledError]).} =
11161115

11171116
doAssert not headBlockHash.isZero
@@ -1129,7 +1128,7 @@ proc forkchoiceUpdated*(
11291128
# payload (`Hash32()` if none yet finalized)"
11301129

11311130
if m.elConnections.len == 0:
1132-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1131+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
11331132

11341133
when payloadAttributes is Opt[PayloadAttributesV3]:
11351134
template payloadAttributesV3(): auto =
@@ -1238,7 +1237,7 @@ proc forkchoiceUpdated*(
12381237
pendingRequests.filterIt(not(it.finished())).
12391238
mapIt(it.cancelAndWait())
12401239
await noCancel allFutures(pending)
1241-
return (PayloadExecutionStatus.invalid, Opt.none BlockHash)
1240+
return (PayloadExecutionStatus.invalid, Opt.none Hash32)
12421241
elif responseProcessor.selectedResponse.isSome:
12431242
# We spawn task which will wait for all other responses which are
12441243
# still pending, after 30.seconds all pending requests will be
@@ -1253,14 +1252,14 @@ proc forkchoiceUpdated*(
12531252
pendingRequests.filterIt(not(it.finished())).
12541253
mapIt(it.cancelAndWait())
12551254
await noCancel allFutures(pending)
1256-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1255+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
12571256

12581257
if len(pendingRequests) == 0:
12591258
# All requests failed, we will continue our attempts until deadline
12601259
# is not finished.
12611260
inc(retriesCount)
12621261
if retriesCount == maxRetriesCount:
1263-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1262+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
12641263

12651264
# To avoid continous spam of requests when EL node is offline we
12661265
# going to sleep until next attempt.
@@ -1273,7 +1272,7 @@ proc forkchoiceUpdated*(
12731272
payloadAttributes: Opt[PayloadAttributesV1] |
12741273
Opt[PayloadAttributesV2] |
12751274
Opt[PayloadAttributesV3]
1276-
): Future[(PayloadExecutionStatus, Opt[BlockHash])] {.
1275+
): Future[(PayloadExecutionStatus, Opt[Hash32])] {.
12771276
async: (raises: [CancelledError], raw: true).} =
12781277
forkchoiceUpdated(
12791278
m, headBlockHash, safeBlockHash, finalizedBlockHash,
@@ -1389,7 +1388,7 @@ func depositEventsToBlocks(
13891388
let
13901389
logEvent = JrpcConv.decode(logEventData.string, LogObject)
13911390
blockNumber = Eth1BlockNumber readJsonField(logEvent, blockNumber, Quantity)
1392-
blockHash = readJsonField(logEvent, blockHash, BlockHash)
1391+
blockHash = readJsonField(logEvent, blockHash, Hash32)
13931392

13941393
if lastEth1Block == nil or lastEth1Block.number != blockNumber:
13951394
lastEth1Block = Eth1Block(

beacon_chain/el/engine_api_conversions.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ type
1919
executionPayload*: ExecutionPayloadV1
2020
blockValue*: UInt256
2121

22-
func asEth2Digest*(x: BlockHash|Bytes32): Eth2Digest =
22+
func asEth2Digest*(x: Hash32|Bytes32): Eth2Digest =
2323
Eth2Digest(data: array[32, byte](x))
2424

25-
template asBlockHash*(x: Eth2Digest): BlockHash =
26-
BlockHash(x.data)
25+
template asBlockHash*(x: Eth2Digest): Hash32 =
26+
Hash32(x.data)
2727

2828
func asConsensusWithdrawal*(w: WithdrawalV1): capella.Withdrawal =
2929
capella.Withdrawal(

beacon_chain/el/eth1_chain.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ declarePublicGauge eth1_finalized_deposits,
3232
declareGauge eth1_chain_len,
3333
"The length of the in-memory chain of Eth1 blocks"
3434

35-
template toGaugeValue*(x: Quantity | BlockNumber): int64 =
35+
template toGaugeValue*(x: Quantity): int64 =
3636
toGaugeValue(distinctBase x)
3737

3838
type
@@ -69,7 +69,7 @@ type
6969
## A non-forkable chain of blocks ending at the block with
7070
## ETH1_FOLLOW_DISTANCE offset from the head.
7171

72-
blocksByHash: Table[BlockHash, Eth1Block]
72+
blocksByHash: Table[Hash32, Eth1Block]
7373

7474
headMerkleizer: DepositsMerkleizer
7575
## Merkleizer state after applying all `blocks`

beacon_chain/networking/eth2_network.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import
2424
pubsub, gossipsub, rpc/message, rpc/messages, peertable, pubsubpeer],
2525
libp2p/stream/connection,
2626
libp2p/services/wildcardresolverservice,
27-
eth/[keys, async_utils],
27+
eth/[common/keys, async_utils],
2828
eth/net/nat, eth/p2p/discoveryv5/[enr, node, random2],
2929
".."/[version, conf, beacon_clock, conf_light_client],
3030
../spec/[eth2_ssz_serialization, network, helpers, forks],

beacon_chain/spec/presets.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ elif const_preset == "minimal":
457457
TERMINAL_TOTAL_DIFFICULTY:
458458
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
459459
# By default, don't use these params
460-
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
460+
TERMINAL_BLOCK_HASH: Hash32.fromHex(
461461
"0x0000000000000000000000000000000000000000000000000000000000000000"),
462462

463463

ncli/ncli_testnet.nim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import
1111
std/[json, options, times],
1212
chronos, bearssl/rand, chronicles, confutils, stint, json_serialization,
13-
web3, eth/keys, eth/p2p/discoveryv5/random2,
13+
web3, eth/common/keys, eth/p2p/discoveryv5/random2,
1414
stew/[io2, byteutils], json_rpc/jsonmarshal,
1515
../beacon_chain/conf,
1616
../beacon_chain/el/el_manager,
@@ -21,7 +21,6 @@ import
2121
../beacon_chain/validators/keystore_management
2222

2323
from std/os import changeFileExt, fileExists
24-
from std/times import toUnix
2524
from ../beacon_chain/el/engine_api_conversions import asEth2Digest
2625
from ../beacon_chain/spec/beaconstate import initialize_beacon_state_from_eth1
2726
from ../tests/mocking/mock_genesis import mockEth1BlockHash
@@ -239,7 +238,7 @@ contract(DepositContract):
239238
template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T =
240239
T(data: distinctBase(address))
241240

242-
template `as`(address: BlockHash, T: type Eth2Digest): T =
241+
template `as`(address: Hash32, T: type Eth2Digest): T =
243242
asEth2Digest(address)
244243

245244
func getOrDefault[T](x: Opt[T]): T =

tests/test_discovery.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import
1212
testutils/unittests,
13-
chronos, eth/keys, eth/p2p/discoveryv5/enr,
13+
chronos, eth/p2p/discoveryv5/enr,
1414
../beacon_chain/spec/[forks, network],
1515
../beacon_chain/networking/[eth2_network, eth2_discovery],
1616
./testutil

0 commit comments

Comments
 (0)