Skip to content

Commit 317b604

Browse files
authored
Merge branch 'unstable' into fulu
2 parents 6bf7fec + a89ee31 commit 317b604

File tree

10 files changed

+25
-27
lines changed

10 files changed

+25
-27
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

@@ -737,7 +736,7 @@ proc getPayload*(
737736

738737
proc waitELToSyncDeposits(
739738
connection: ELConnection,
740-
minimalRequiredBlock: BlockHash
739+
minimalRequiredBlock: Hash32
741740
) {.async: (raises: [CancelledError]).} =
742741
var rpcClient: RpcClient = nil
743742

@@ -783,7 +782,7 @@ proc waitELToSyncDeposits(
783782
func networkHasDepositContract(m: ELManager): bool =
784783
not m.cfg.DEPOSIT_CONTRACT_ADDRESS.isDefaultValue
785784

786-
func mostRecentKnownBlock(m: ELManager): BlockHash =
785+
func mostRecentKnownBlock(m: ELManager): Hash32 =
787786
if m.eth1Chain.finalizedDepositsMerkleizer.getChunkCount() > 0:
788787
m.eth1Chain.finalizedBlockHash.asBlockHash
789788
else:
@@ -1118,7 +1117,7 @@ proc forkchoiceUpdated*(
11181117
Opt[PayloadAttributesV3],
11191118
deadlineObj: DeadlineObject,
11201119
maxRetriesCount: int
1121-
): Future[(PayloadExecutionStatus, Opt[BlockHash])] {.
1120+
): Future[(PayloadExecutionStatus, Opt[Hash32])] {.
11221121
async: (raises: [CancelledError]).} =
11231122

11241123
doAssert not headBlockHash.isZero
@@ -1136,7 +1135,7 @@ proc forkchoiceUpdated*(
11361135
# payload (`Hash32()` if none yet finalized)"
11371136

11381137
if m.elConnections.len == 0:
1139-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1138+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
11401139

11411140
when payloadAttributes is Opt[PayloadAttributesV3]:
11421141
template payloadAttributesV3(): auto =
@@ -1245,7 +1244,7 @@ proc forkchoiceUpdated*(
12451244
pendingRequests.filterIt(not(it.finished())).
12461245
mapIt(it.cancelAndWait())
12471246
await noCancel allFutures(pending)
1248-
return (PayloadExecutionStatus.invalid, Opt.none BlockHash)
1247+
return (PayloadExecutionStatus.invalid, Opt.none Hash32)
12491248
elif responseProcessor.selectedResponse.isSome:
12501249
# We spawn task which will wait for all other responses which are
12511250
# still pending, after 30.seconds all pending requests will be
@@ -1260,14 +1259,14 @@ proc forkchoiceUpdated*(
12601259
pendingRequests.filterIt(not(it.finished())).
12611260
mapIt(it.cancelAndWait())
12621261
await noCancel allFutures(pending)
1263-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1262+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
12641263

12651264
if len(pendingRequests) == 0:
12661265
# All requests failed, we will continue our attempts until deadline
12671266
# is not finished.
12681267
inc(retriesCount)
12691268
if retriesCount == maxRetriesCount:
1270-
return (PayloadExecutionStatus.syncing, Opt.none BlockHash)
1269+
return (PayloadExecutionStatus.syncing, Opt.none Hash32)
12711270

12721271
# To avoid continous spam of requests when EL node is offline we
12731272
# going to sleep until next attempt.
@@ -1280,7 +1279,7 @@ proc forkchoiceUpdated*(
12801279
payloadAttributes: Opt[PayloadAttributesV1] |
12811280
Opt[PayloadAttributesV2] |
12821281
Opt[PayloadAttributesV3]
1283-
): Future[(PayloadExecutionStatus, Opt[BlockHash])] {.
1282+
): Future[(PayloadExecutionStatus, Opt[Hash32])] {.
12841283
async: (raises: [CancelledError], raw: true).} =
12851284
forkchoiceUpdated(
12861285
m, headBlockHash, safeBlockHash, finalizedBlockHash,
@@ -1396,7 +1395,7 @@ func depositEventsToBlocks(
13961395
let
13971396
logEvent = JrpcConv.decode(logEventData.string, LogObject)
13981397
blockNumber = Eth1BlockNumber readJsonField(logEvent, blockNumber, Quantity)
1399-
blockHash = readJsonField(logEvent, blockHash, BlockHash)
1398+
blockHash = readJsonField(logEvent, blockHash, Hash32)
14001399

14011400
if lastEth1Block == nil or lastEth1Block.number != blockNumber:
14021401
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
@@ -464,7 +464,7 @@ elif const_preset == "minimal":
464464
TERMINAL_TOTAL_DIFFICULTY:
465465
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
466466
# By default, don't use these params
467-
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
467+
TERMINAL_BLOCK_HASH: Hash32.fromHex(
468468
"0x0000000000000000000000000000000000000000000000000000000000000000"),
469469

470470

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
@@ -244,7 +243,7 @@ contract(DepositContract):
244243
template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T =
245244
T(data: distinctBase(address))
246245

247-
template `as`(address: BlockHash, T: type Eth2Digest): T =
246+
template `as`(address: Hash32, T: type Eth2Digest): T =
248247
asEth2Digest(address)
249248

250249
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

vendor/nim-libbacktrace

0 commit comments

Comments
 (0)