Skip to content

Commit 44cc72c

Browse files
authored
refactor engine API conversions out of EL manager (#6507)
1 parent 77c36b3 commit 44cc72c

10 files changed

+3165
-3123
lines changed

AllTests-mainnet.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -464,16 +464,20 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
464464
+ URL parsing OK
465465
```
466466
OK: 5/5 Fail: 0/5 Skip: 0/5
467-
## Eth1 monitor
467+
## Engine API conversions
468468
```diff
469-
+ Deposits chain OK
470-
+ Rewrite URLs OK
471469
+ Roundtrip engine RPC V1 and bellatrix ExecutionPayload representations OK
472470
+ Roundtrip engine RPC V2 and capella ExecutionPayload representations OK
473471
+ Roundtrip engine RPC V3 and deneb ExecutionPayload representations OK
474472
+ Roundtrip engine RPC V4 and electra ExecutionPayload representations OK
475473
```
476-
OK: 6/6 Fail: 0/6 Skip: 0/6
474+
OK: 4/4 Fail: 0/4 Skip: 0/4
475+
## Eth1 monitor
476+
```diff
477+
+ Deposits chain OK
478+
+ Rewrite URLs OK
479+
```
480+
OK: 2/2 Fail: 0/2 Skip: 0/2
477481
## Eth2 specific discovery tests
478482
```diff
479483
+ Invalid attnets field OK

beacon_chain/consensus_object_pools/consensus_manager.nim

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import
1515
../beacon_clock,
1616
./common_tools
1717

18+
from ../el/engine_api_conversions import asBlockHash
1819
from ../spec/beaconstate import
1920
get_expected_withdrawals, has_eth1_withdrawal_credential
2021
from ../spec/datatypes/capella import Withdrawal

beacon_chain/el/el_manager.nim

+7-345
Large diffs are not rendered by default.

beacon_chain/el/engine_api_conversions.nim

+359
Large diffs are not rendered by default.

beacon_chain/el/eth1_chain.nim

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import
1616
web3/[conversions, eth_api_types],
1717
./merkle_minimal
1818

19+
from ./engine_api_conversions import asBlockHash, asEth2Digest
20+
1921
export beacon_chain_db, deques, digest, base, forks
2022

2123
logScope:
@@ -80,12 +82,6 @@ type
8082
deposits*: seq[Deposit]
8183
hasMissingDeposits*: bool
8284

83-
func asEth2Digest*(x: BlockHash): Eth2Digest =
84-
Eth2Digest(data: array[32, byte](x))
85-
86-
template asBlockHash*(x: Eth2Digest): BlockHash =
87-
BlockHash(x.data)
88-
8985
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
9086
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
9187
genesis_time + slot * SECONDS_PER_SLOT
@@ -115,7 +111,7 @@ template findBlock(chain: Eth1Chain, eth1Data: Eth1Data): Eth1Block =
115111

116112
func makeSuccessorWithoutDeposits*(existingBlock: Eth1Block,
117113
successor: BlockObject): Eth1Block =
118-
result = Eth1Block(
114+
Eth1Block(
119115
hash: successor.hash.asEth2Digest,
120116
number: Eth1BlockNumber successor.number,
121117
timestamp: Eth1BlockTimestamp successor.timestamp)

beacon_chain/libnimbus_lc/libnimbus_lc.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import
1717
json_rpc/jsonmarshal,
1818
secp256k1,
1919
web3/[engine_api_types, eth_api_types, conversions],
20-
../el/eth1_chain,
20+
../el/[engine_api_conversions, eth1_chain],
2121
../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls],
2222
../spec/[helpers, light_client_sync],
2323
../sync/light_client_sync_helpers,

ncli/ncli_testnet.nim

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import
2424
from std/os import changeFileExt, fileExists
2525
from std/sequtils import mapIt, toSeq
2626
from std/times import toUnix
27+
from ../beacon_chain/el/engine_api_conversions import asEth2Digest
2728
from ../beacon_chain/spec/beaconstate import initialize_beacon_state_from_eth1
2829
from ../tests/mocking/mock_genesis import mockEth1BlockHash
2930

@@ -721,4 +722,4 @@ when isMainModule:
721722
# This is handled above before the case statement
722723
discard
723724

724-
waitFor main()
725+
waitFor main()

tests/all_tests.nim

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import # Unit test
2525
./test_datatypes,
2626
./test_deposit_snapshots,
2727
./test_discovery,
28+
./test_engine_api_conversions,
2829
./test_engine_authentication,
2930
./test_el_manager,
3031
./test_el_conf,

tests/test_el_manager.nim

+1-2,765
Large diffs are not rendered by default.

tests/test_engine_api_conversions.nim

+2,782
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)