diff --git a/Makefile b/Makefile index 8d46dd4a1..4c0d55722 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ TOOLS := \ TOOLS_DIRS := \ beacon_chain \ + beacon_chain/eth1 \ benchmarks \ ncli \ nbench \ diff --git a/beacon_chain/beacon_chain_db.nim b/beacon_chain/beacon_chain_db.nim index a7aa79aae..b80d1a2c1 100644 --- a/beacon_chain/beacon_chain_db.nim +++ b/beacon_chain/beacon_chain_db.nim @@ -8,7 +8,8 @@ import ./network_metadata, ./spec/[crypto, datatypes, digest, state_transition], ./ssz/[ssz_serialization, merkleization], - merkle_minimal, filepath + ./eth1/merkle_minimal, + filepath type DbSeq*[T] = object diff --git a/beacon_chain/beacon_node_common.nim b/beacon_chain/beacon_node_common.nim index 58b086cc6..3ad5d4443 100644 --- a/beacon_chain/beacon_node_common.nim +++ b/beacon_chain/beacon_node_common.nim @@ -15,8 +15,9 @@ import # Local modules ./conf, ./time, ./beacon_chain_db, ./attestation_pool, ./eth2_network, - ./beacon_node_types, ./eth1_monitor, + ./beacon_node_types, ./eth2_processor, + ./eth1/eth1_monitor, ./block_pools/[chain_dag, quarantine], ./spec/datatypes, ./sync/[sync_manager, request_manager] diff --git a/beacon_chain/deposit_contract.nim b/beacon_chain/eth1/deposit_contract.nim similarity index 97% rename from beacon_chain/deposit_contract.nim rename to beacon_chain/eth1/deposit_contract.nim index 5aad8d638..abdfb6148 100644 --- a/beacon_chain/deposit_contract.nim +++ b/beacon_chain/eth1/deposit_contract.nim @@ -1,10 +1,10 @@ import os, sequtils, strutils, options, json, terminal, random, chronos, chronicles, confutils, stint, json_serialization, - ../beacon_chain/network_metadata, - web3, web3/confutils_defs, eth/keys, stew/io2, filepath, - spec/[datatypes, crypto, presets], ssz/merkleization, - ./validators/keystore_management + ".."/[network_metadata, filepath], + web3, web3/confutils_defs, eth/keys, stew/io2, + ../spec/[datatypes, crypto, presets], ../ssz/merkleization, + ../validators/keystore_management # Compiled version of /scripts/depositContract.v.py in this repo # The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler. diff --git a/beacon_chain/deposit_contract_code.txt b/beacon_chain/eth1/deposit_contract_code.txt similarity index 100% rename from beacon_chain/deposit_contract_code.txt rename to beacon_chain/eth1/deposit_contract_code.txt diff --git a/beacon_chain/eth1_monitor.nim b/beacon_chain/eth1/eth1_monitor.nim similarity index 99% rename from beacon_chain/eth1_monitor.nim rename to beacon_chain/eth1/eth1_monitor.nim index f2a4e2b9b..3ba4b9962 100644 --- a/beacon_chain/eth1_monitor.nim +++ b/beacon_chain/eth1/eth1_monitor.nim @@ -5,8 +5,10 @@ import chronos, json, metrics, chronicles/timings, web3, web3/ethtypes as web3Types, eth/common/eth_types, eth/async_utils, # Local modules: - spec/[datatypes, digest, crypto, helpers], - ssz, beacon_chain_db, network_metadata, merkle_minimal, beacon_node_status + ../spec/[datatypes, digest, crypto, helpers], + ../ssz, + ".."/[beacon_chain_db, network_metadata, beacon_node_status], + ./merkle_minimal export web3Types diff --git a/beacon_chain/merkle_minimal.nim b/beacon_chain/eth1/merkle_minimal.nim similarity index 100% rename from beacon_chain/merkle_minimal.nim rename to beacon_chain/eth1/merkle_minimal.nim diff --git a/beacon_chain/eth2_processor.nim b/beacon_chain/eth2_processor.nim index 7f1442a7e..f3578ad1b 100644 --- a/beacon_chain/eth2_processor.nim +++ b/beacon_chain/eth2_processor.nim @@ -16,7 +16,7 @@ import ./attestation_aggregation, ./exit_pool, ./validators/validator_pool, ./beacon_node_types, ./attestation_pool, - ./time, ./conf, ./sszdump + ./time, ./conf, ./ssz/sszdump # Metrics for tracking attestation and beacon block loss declareCounter beacon_attestations_received, diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index a8169db83..7adf36223 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -25,7 +25,7 @@ import "."/[ attestation_aggregation, attestation_pool, beacon_chain_db, beacon_node_common, beacon_node_status, beacon_node_types, conf, - eth1_monitor, eth2_discovery, eth2_network, eth2_processor, exit_pool, + eth2_discovery, eth2_network, eth2_processor, exit_pool, extras, filepath, interop, network_metadata, nimbus_binary_common, ssz/merkleization, statusbar, time, version], @@ -36,7 +36,8 @@ import ./spec/[ datatypes, digest, crypto, beaconstate, eth2_apis/beacon_rpc_client, helpers, network, presets, validator, weak_subjectivity, signatures], - ./block_pools/[chain_dag, quarantine, clearance, block_pools_types] + ./block_pools/[chain_dag, quarantine, clearance, block_pools_types], + ./eth1/eth1_monitor from eth/common/eth_types import BlockHashOrNumber diff --git a/beacon_chain/rpc/config_api.nim b/beacon_chain/rpc/config_api.nim index f2fbbe016..b9411c16b 100644 --- a/beacon_chain/rpc/config_api.nim +++ b/beacon_chain/rpc/config_api.nim @@ -9,7 +9,8 @@ import json_rpc/[rpcserver, jsonmarshal], chronicles, nimcrypto/utils as ncrutils, - ../beacon_node_common, ../eth1_monitor, + ../beacon_node_common, + ../eth1/eth1_monitor, ../spec/[datatypes, digest, presets] logScope: topics = "configapi" diff --git a/beacon_chain/rpc/nimbus_api.nim b/beacon_chain/rpc/nimbus_api.nim index 3a5afa67d..4cac508e0 100644 --- a/beacon_chain/rpc/nimbus_api.nim +++ b/beacon_chain/rpc/nimbus_api.nim @@ -13,7 +13,8 @@ import rpc_utils, ../beacon_node_common, ../nimbus_binary_common, ../eth2_network, - ../eth1_monitor, ../validators/validator_duties, + ../eth1/eth1_monitor, + ../validators/validator_duties, ../spec/[digest, datatypes, presets], libp2p/protocols/pubsub/pubsubpeer diff --git a/beacon_chain/ssz.nim b/beacon_chain/ssz.nim index d3311421d..3b0be2919 100644 --- a/beacon_chain/ssz.nim +++ b/beacon_chain/ssz.nim @@ -15,8 +15,7 @@ # https://github.com/nim-lang/Nim/issues/14126 import - ./ssz/[merkleization, ssz_serialization, types] + ssz/[merkleization, ssz_serialization, types] export merkleization, ssz_serialization, types - diff --git a/beacon_chain/sszdump.nim b/beacon_chain/ssz/sszdump.nim similarity index 93% rename from beacon_chain/sszdump.nim rename to beacon_chain/ssz/sszdump.nim index b418d8dc3..b18390aaa 100644 --- a/beacon_chain/sszdump.nim +++ b/beacon_chain/ssz/sszdump.nim @@ -2,9 +2,9 @@ import os, strformat, chronicles, - ssz/ssz_serialization, - beacon_node_types, - ./spec/[crypto, datatypes, digest] + ./ssz_serialization, + ../beacon_node_types, + ../spec/[crypto, datatypes, digest] # Dump errors are generally not fatal where used currently - the code calling # these functions, like most code, is not exception safe diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index 6816bee40..6fa0fa46f 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -24,9 +24,10 @@ import ../conf, ../time, ../attestation_pool, ../exit_pool, ../block_pools/[spec_cache, chain_dag, clearance], + ../eth1/eth1_monitor, ../eth2_network, ../beacon_node_common, - ../beacon_node_types, ../nimbus_binary_common, ../eth1_monitor, ../version, - ../ssz/merkleization, ../attestation_aggregation, ../sync/sync_manager, ../sszdump, + ../beacon_node_types, ../nimbus_binary_common, ../version, + ../ssz, ../ssz/sszdump, ../attestation_aggregation, ../sync/sync_manager, ./slashing_protection, ./validator_pool, ./keystore_management diff --git a/ncli/ncli_db.nim b/ncli/ncli_db.nim index c488b5b00..201b6c1a0 100644 --- a/ncli/ncli_db.nim +++ b/ncli/ncli_db.nim @@ -6,7 +6,7 @@ import ../beacon_chain/block_pools/chain_dag, ../beacon_chain/spec/[crypto, datatypes, digest, helpers, state_transition, presets], - ../beacon_chain/[ssz, sszdump], + ../beacon_chain/ssz, ../beacon_chain/ssz/sszdump, ../research/simutils type Timers = enum diff --git a/research/block_sim.nim b/research/block_sim.nim index 529963a0e..d99678311 100644 --- a/research/block_sim.nim +++ b/research/block_sim.nim @@ -23,8 +23,8 @@ import ../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, presets, helpers, validator, signatures, state_transition], ../beacon_chain/[ - attestation_pool, beacon_node_types, beacon_chain_db, - eth1_monitor, extras], + attestation_pool, beacon_node_types, beacon_chain_db, extras], + ../beacon_chain/eth1/eth1_monitor, ../beacon_chain/validators/validator_pool, ../beacon_chain/block_pools/[chain_dag, quarantine, clearance], ../beacon_chain/ssz/[merkleization, ssz_serialization], diff --git a/research/simutils.nim b/research/simutils.nim index 50fb26d78..8de5f3050 100644 --- a/research/simutils.nim +++ b/research/simutils.nim @@ -1,9 +1,10 @@ import stats, os, strformat, times, ../tests/[testblockutil], - ../beacon_chain/[extras, eth1_monitor, beacon_chain_db], + ../beacon_chain/[extras, beacon_chain_db], ../beacon_chain/ssz/[merkleization, ssz_serialization], - ../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, presets] + ../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, helpers, presets], + ../beacon_chain/eth1/eth1_monitor template withTimer*(stats: var RunningStat, body: untyped) = # TODO unify timing somehow diff --git a/tests/fuzzing/ssz_fuzzing.nim b/tests/fuzzing/ssz_fuzzing.nim index 80b49ab7d..b076becbf 100644 --- a/tests/fuzzing/ssz_fuzzing.nim +++ b/tests/fuzzing/ssz_fuzzing.nim @@ -39,4 +39,3 @@ template sszFuzzingTest*(T: type) = echo repr(decoded) doAssert false - diff --git a/tests/mocking/mock_deposits.nim b/tests/mocking/mock_deposits.nim index ec26532ec..6c02fd6cf 100644 --- a/tests/mocking/mock_deposits.nim +++ b/tests/mocking/mock_deposits.nim @@ -17,7 +17,9 @@ import keystore, signatures, presets], # Internals - ../../beacon_chain/[ssz, extras, merkle_minimal], + ../../beacon_chain/extras, + ../../beacon_chain/ssz, + ../../beacon_chain/eth1/merkle_minimal, # Mocking procs ./mock_validator_keys diff --git a/tests/spec_block_processing/test_process_deposits.nim b/tests/spec_block_processing/test_process_deposits.nim index 02c0d90c5..b511d026e 100644 --- a/tests/spec_block_processing/test_process_deposits.nim +++ b/tests/spec_block_processing/test_process_deposits.nim @@ -18,7 +18,8 @@ import # Specs ../../beacon_chain/spec/[beaconstate, datatypes, crypto, presets], # Internals - ../../beacon_chain/[ssz, extras], + ../../beacon_chain/ssz, + ../../beacon_chain/extras, # Mock helpers ../mocking/[mock_deposits, mock_genesis], ../testutil, ../helpers/math_helpers diff --git a/tests/test_beacon_chain_db.nim b/tests/test_beacon_chain_db.nim index 13788e433..b8dba782b 100644 --- a/tests/test_beacon_chain_db.nim +++ b/tests/test_beacon_chain_db.nim @@ -8,7 +8,8 @@ {.used.} import options, unittest, sequtils, - ../beacon_chain/[beacon_chain_db, extras, interop, ssz], + ../beacon_chain/[beacon_chain_db, extras, interop], + ../beacon_chain/ssz, ../beacon_chain/spec/[ beaconstate, datatypes, digest, crypto, state_transition, presets], eth/db/kvstore, diff --git a/tests/test_block_pool.nim b/tests/test_block_pool.nim index af5667953..ae93dc4c9 100644 --- a/tests/test_block_pool.nim +++ b/tests/test_block_pool.nim @@ -13,7 +13,8 @@ import eth/keys, ./testutil, ./testblockutil, ../beacon_chain/spec/[datatypes, digest, helpers, state_transition, presets], - ../beacon_chain/[beacon_node_types, ssz], + ../beacon_chain/beacon_node_types, + ../beacon_chain/ssz, ../beacon_chain/block_pools/[chain_dag, quarantine, clearance] when isMainModule: diff --git a/tests/test_eth1_monitor.nim b/tests/test_eth1_monitor.nim index 428cc86dd..931356d38 100644 --- a/tests/test_eth1_monitor.nim +++ b/tests/test_eth1_monitor.nim @@ -3,7 +3,7 @@ import unittest, chronos, web3/ethtypes, - ../beacon_chain/eth1_monitor + ../beacon_chain/eth1/eth1_monitor suite "Eth1 Chain": discard @@ -47,4 +47,3 @@ suite "Eth1 monitor": unspecifiedProtocolUrl == gethWsUrl gethWsUrl == "ws://localhost:8545" - diff --git a/tests/test_interop.nim b/tests/test_interop.nim index ef545c6ba..1dfcc78c9 100644 --- a/tests/test_interop.nim +++ b/tests/test_interop.nim @@ -2,7 +2,8 @@ import unittest, stint, ./testutil, stew/byteutils, - ../beacon_chain/[interop, ssz], + ../beacon_chain/interop, + ../beacon_chain/ssz, ../beacon_chain/spec/[beaconstate, crypto, datatypes, presets] # Interop test yaml, found here: diff --git a/tests/test_ssz_merkleization.nim b/tests/test_ssz_merkleization.nim index 8dcb5e904..6fdd2ffa1 100644 --- a/tests/test_ssz_merkleization.nim +++ b/tests/test_ssz_merkleization.nim @@ -2,7 +2,8 @@ import std/[strutils, sequtils, macros, bitops], stew/[bitops2, endians2], ../beacon_chain/spec/[beaconstate, datatypes, digest, helpers], - ../beacon_chain/[ssz, merkle_minimal], + ../beacon_chain/eth1/merkle_minimal, + ../beacon_chain/ssz, mocking/mock_deposits func round_step_down(x: Natural, step: static Natural): int = @@ -265,4 +266,3 @@ proc testMerkleizer = doAssert deposits[i].proof == depositsCopy[i].proof testMerkleizer() - diff --git a/tests/test_statediff.nim b/tests/test_statediff.nim index a972807eb..7e208aeae 100644 --- a/tests/test_statediff.nim +++ b/tests/test_statediff.nim @@ -14,7 +14,8 @@ import ./mocking/mock_deposits, ../beacon_chain/spec/[beaconstate, datatypes, digest, helpers, state_transition, presets], - ../beacon_chain/[beacon_node_types, ssz, statediff], + ../beacon_chain/[beacon_node_types, statediff], + ../beacon_chain/ssz, ../beacon_chain/block_pools/[chain_dag, quarantine, clearance] when isMainModule: diff --git a/tests/testutil.nim b/tests/testutil.nim index f4ce36ce8..cf4b4101f 100644 --- a/tests/testutil.nim +++ b/tests/testutil.nim @@ -8,7 +8,8 @@ import os, algorithm, strformat, stats, times, tables, std/monotimes, stew/endians2, testutils/markdown_reports, chronicles, - ../beacon_chain/[beacon_chain_db, extras, ssz], + ../beacon_chain/[beacon_chain_db, extras], + ../beacon_chain/ssz, ../beacon_chain/spec/[digest, beaconstate, datatypes, presets], ../beacon_chain/block_pools/chain_dag, eth/db/[kvstore, kvstore_sqlite3],