Skip to content

Commit

Permalink
refactor engine API conversions out of EL manager
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec committed Aug 22, 2024
1 parent 77c36b3 commit c783dbc
Show file tree
Hide file tree
Showing 10 changed files with 3,165 additions and 3,123 deletions.
12 changes: 8 additions & 4 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,20 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
+ URL parsing OK
```
OK: 5/5 Fail: 0/5 Skip: 0/5
## Eth1 monitor
## Engine API conversions
```diff
+ Deposits chain OK
+ Rewrite URLs OK
+ Roundtrip engine RPC V1 and bellatrix ExecutionPayload representations OK
+ Roundtrip engine RPC V2 and capella ExecutionPayload representations OK
+ Roundtrip engine RPC V3 and deneb ExecutionPayload representations OK
+ Roundtrip engine RPC V4 and electra ExecutionPayload representations OK
```
OK: 6/6 Fail: 0/6 Skip: 0/6
OK: 4/4 Fail: 0/4 Skip: 0/4
## Eth1 monitor
```diff
+ Deposits chain OK
+ Rewrite URLs OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
## Eth2 specific discovery tests
```diff
+ Invalid attnets field OK
Expand Down
1 change: 1 addition & 0 deletions beacon_chain/consensus_object_pools/consensus_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import
../beacon_clock,
./common_tools

from ../el/engine_api_conversions import asBlockHash
from ../spec/beaconstate import
get_expected_withdrawals, has_eth1_withdrawal_credential
from ../spec/datatypes/capella import Withdrawal
Expand Down
352 changes: 7 additions & 345 deletions beacon_chain/el/el_manager.nim

Large diffs are not rendered by default.

359 changes: 359 additions & 0 deletions beacon_chain/el/engine_api_conversions.nim

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions beacon_chain/el/eth1_chain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import
web3/[conversions, eth_api_types],
./merkle_minimal

from ./engine_api_conversions import asBlockHash, asEth2Digest

export beacon_chain_db, deques, digest, base, forks

logScope:
Expand Down Expand Up @@ -80,12 +82,6 @@ type
deposits*: seq[Deposit]
hasMissingDeposits*: bool

func asEth2Digest*(x: BlockHash): Eth2Digest =
Eth2Digest(data: array[32, byte](x))

template asBlockHash*(x: Eth2Digest): BlockHash =
BlockHash(x.data)

# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
genesis_time + slot * SECONDS_PER_SLOT
Expand Down Expand Up @@ -115,7 +111,7 @@ template findBlock(chain: Eth1Chain, eth1Data: Eth1Data): Eth1Block =

func makeSuccessorWithoutDeposits*(existingBlock: Eth1Block,
successor: BlockObject): Eth1Block =
result = Eth1Block(
Eth1Block(
hash: successor.hash.asEth2Digest,
number: Eth1BlockNumber successor.number,
timestamp: Eth1BlockTimestamp successor.timestamp)
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/libnimbus_lc/libnimbus_lc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import
json_rpc/jsonmarshal,
secp256k1,
web3/[engine_api_types, eth_api_types, conversions],
../el/eth1_chain,
../el/[engine_api_conversions, eth1_chain],
../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls],
../spec/[helpers, light_client_sync],
../sync/light_client_sync_helpers,
Expand Down
3 changes: 2 additions & 1 deletion ncli/ncli_testnet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import
from std/os import changeFileExt, fileExists
from std/sequtils import mapIt, toSeq
from std/times import toUnix
from ../beacon_chain/el/engine_api_conversions import asEth2Digest
from ../beacon_chain/spec/beaconstate import initialize_beacon_state_from_eth1
from ../tests/mocking/mock_genesis import mockEth1BlockHash

Expand Down Expand Up @@ -721,4 +722,4 @@ when isMainModule:
# This is handled above before the case statement
discard

waitFor main()
waitFor main()
1 change: 1 addition & 0 deletions tests/all_tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import # Unit test
./test_datatypes,
./test_deposit_snapshots,
./test_discovery,
./test_engine_api_conversions,
./test_engine_authentication,
./test_el_manager,
./test_el_conf,
Expand Down
2,766 changes: 1 addition & 2,765 deletions tests/test_el_manager.nim

Large diffs are not rendered by default.

2,782 changes: 2,782 additions & 0 deletions tests/test_engine_api_conversions.nim

Large diffs are not rendered by default.

0 comments on commit c783dbc

Please sign in to comment.