mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 14:26:26 +00:00
Disable the use of incbin as it breaks the retail build on Linux/ARM
This commit is contained in:
parent
a36cacda44
commit
4c3850f7df
@ -31,6 +31,13 @@ import
|
||||
export
|
||||
ethtypes, conversions, RuntimeConfig
|
||||
|
||||
const
|
||||
vendorDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor"
|
||||
|
||||
# TODO: Currently, this breaks the Linux/ARM packaging due
|
||||
# to a toolchain incompatibility problem
|
||||
incbinEnabled* = false
|
||||
|
||||
type
|
||||
Eth1BlockHash* = ethtypes.BlockHash
|
||||
|
||||
@ -64,11 +71,21 @@ type
|
||||
|
||||
# `genesisData` will have `len == 0` for networks with a still
|
||||
# unknown genesis state.
|
||||
genesisData*: seq[byte]
|
||||
genesisDepositsSnapshot*: seq[byte]
|
||||
when incbinEnabled:
|
||||
genesisData*: seq[byte]
|
||||
else:
|
||||
genesisData*: string
|
||||
|
||||
genesisDepositsSnapshot*: string
|
||||
else:
|
||||
incompatibilityDesc*: string
|
||||
|
||||
template genesisBytes*(metadata: Eth2NetworkMetadata): auto =
|
||||
when incbinEnabled:
|
||||
metadata.genesisData
|
||||
else:
|
||||
metadata.genesisData.toOpenArrayByte(0, metadata.genesisData.high)
|
||||
|
||||
proc readBootstrapNodes*(path: string): seq[string] {.raises: [IOError].} =
|
||||
# Read a list of ENR values from a YAML file containing a flat list of entries
|
||||
if fileExists(path):
|
||||
@ -157,14 +174,17 @@ proc loadEth2NetworkMetadata*(
|
||||
readBootEnr(bootEnrPath))
|
||||
|
||||
genesisData = if loadGenesis and fileExists(genesisPath):
|
||||
toBytes(readFile(genesisPath))
|
||||
when incbinEnabled:
|
||||
toBytes readFile(genesisPath)
|
||||
else:
|
||||
readFile(genesisPath)
|
||||
else:
|
||||
@[]
|
||||
""
|
||||
|
||||
genesisDepositsSnapshot = if fileExists(genesisDepositsSnapshotPath):
|
||||
toBytes(readFile(genesisDepositsSnapshotPath))
|
||||
readFile(genesisDepositsSnapshotPath)
|
||||
else:
|
||||
@[]
|
||||
""
|
||||
|
||||
Eth2NetworkMetadata(
|
||||
incompatible: false,
|
||||
@ -196,21 +216,19 @@ proc loadCompileTimeNetworkMetadata(
|
||||
else:
|
||||
macros.error "config.yaml not found for network '" & path
|
||||
|
||||
const vendorDir =
|
||||
currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor"
|
||||
|
||||
when const_preset == "gnosis":
|
||||
import stew/assign2
|
||||
|
||||
let
|
||||
gnosisGenesis {.importc: "gnosis_mainnet_genesis".}: ptr UncheckedArray[byte]
|
||||
gnosisGenesisSize {.importc: "gnosis_mainnet_genesis_size".}: int
|
||||
|
||||
{.compile: "network_metadata_gnosis.S".}
|
||||
when incbinEnabled:
|
||||
let
|
||||
gnosisGenesis {.importc: "gnosis_mainnet_genesis".}: ptr UncheckedArray[byte]
|
||||
gnosisGenesisSize {.importc: "gnosis_mainnet_genesis_size".}: int
|
||||
{.compile: "network_metadata_gnosis.S".}
|
||||
|
||||
const
|
||||
gnosisMetadata = loadCompileTimeNetworkMetadata(
|
||||
vendorDir & "/gnosis-chain-configs/mainnet")
|
||||
vendorDir & "/gnosis-chain-configs/mainnet",
|
||||
none(Eth1Network), not incbinEnabled)
|
||||
|
||||
static:
|
||||
checkForkConsistency(gnosisMetadata.cfg)
|
||||
@ -220,30 +238,31 @@ when const_preset == "gnosis":
|
||||
elif const_preset == "mainnet":
|
||||
import stew/assign2
|
||||
|
||||
# Nim is very inefficent at loading large constants from binary files so we
|
||||
# use this trick instead which saves significant amounts of compile time
|
||||
let
|
||||
mainnetGenesis {.importc: "eth2_mainnet_genesis".}: ptr UncheckedArray[byte]
|
||||
mainnetGenesisSize {.importc: "eth2_mainnet_genesis_size".}: int
|
||||
when incbinEnabled:
|
||||
# Nim is very inefficent at loading large constants from binary files so we
|
||||
# use this trick instead which saves significant amounts of compile time
|
||||
let
|
||||
mainnetGenesis {.importc: "eth2_mainnet_genesis".}: ptr UncheckedArray[byte]
|
||||
mainnetGenesisSize {.importc: "eth2_mainnet_genesis_size".}: int
|
||||
|
||||
praterGenesis {.importc: "eth2_goerli_genesis".}: ptr UncheckedArray[byte]
|
||||
praterGenesisSize {.importc: "eth2_goerli_genesis_size".}: int
|
||||
praterGenesis {.importc: "eth2_goerli_genesis".}: ptr UncheckedArray[byte]
|
||||
praterGenesisSize {.importc: "eth2_goerli_genesis_size".}: int
|
||||
|
||||
sepoliaGenesis {.importc: "eth2_sepolia_genesis".}: ptr UncheckedArray[byte]
|
||||
sepoliaGenesisSize {.importc: "eth2_sepolia_genesis_size".}: int
|
||||
sepoliaGenesis {.importc: "eth2_sepolia_genesis".}: ptr UncheckedArray[byte]
|
||||
sepoliaGenesisSize {.importc: "eth2_sepolia_genesis_size".}: int
|
||||
|
||||
{.compile: "network_metadata_mainnet.S".}
|
||||
{.compile: "network_metadata_mainnet.S".}
|
||||
|
||||
const
|
||||
eth2NetworksDir = vendorDir & "/eth2-networks"
|
||||
sepoliaDir = vendorDir & "/sepolia"
|
||||
|
||||
mainnetMetadata = loadCompileTimeNetworkMetadata(
|
||||
vendorDir & "/eth2-networks/shared/mainnet", some mainnet, false)
|
||||
vendorDir & "/eth2-networks/shared/mainnet", some mainnet, not incbinEnabled)
|
||||
praterMetadata = loadCompileTimeNetworkMetadata(
|
||||
vendorDir & "/eth2-networks/shared/prater", some goerli, false)
|
||||
vendorDir & "/eth2-networks/shared/prater", some goerli, not incbinEnabled)
|
||||
sepoliaMetadata = loadCompileTimeNetworkMetadata(
|
||||
vendorDir & "/sepolia/bepolia", some sepolia, false)
|
||||
vendorDir & "/sepolia/bepolia", some sepolia, not incbinEnabled)
|
||||
|
||||
static:
|
||||
for network in [mainnetMetadata, praterMetadata, sepoliaMetadata]:
|
||||
@ -272,9 +291,12 @@ proc getMetadataForNetwork*(
|
||||
warn "Ropsten is unsupported; https://blog.ethereum.org/2022/11/30/ropsten-shutdown-announcement suggests migrating to Goerli or Sepolia"
|
||||
|
||||
template withGenesis(metadata, genesis: untyped): untyped =
|
||||
var tmp = metadata
|
||||
assign(tmp.genesisData, genesis.toOpenArray(0, `genesis Size` - 1))
|
||||
tmp
|
||||
when incbinEnabled:
|
||||
var tmp = metadata
|
||||
assign(tmp.genesisData, genesis.toOpenArray(0, `genesis Size` - 1))
|
||||
tmp
|
||||
else:
|
||||
metadata
|
||||
|
||||
let metadata =
|
||||
when const_preset == "gnosis":
|
||||
|
@ -542,7 +542,7 @@ proc init*(T: type BeaconNode,
|
||||
var genesisState =
|
||||
if metadata.genesisData.len > 0:
|
||||
try:
|
||||
newClone readSszForkedHashedBeaconState(cfg, metadata.genesisData)
|
||||
newClone readSszForkedHashedBeaconState(cfg, metadata.genesisBytes)
|
||||
except CatchableError as err:
|
||||
raiseAssert "Invalid baked-in state: " & err.msg
|
||||
else:
|
||||
@ -2028,7 +2028,7 @@ proc handleStartUpCmd(config: var BeaconNodeConf) {.raises: [Defect, CatchableEr
|
||||
stateId: "finalized")
|
||||
genesis =
|
||||
if network.genesisData.len > 0:
|
||||
newClone(readSszForkedHashedBeaconState(cfg, network.genesisData))
|
||||
newClone(readSszForkedHashedBeaconState(cfg, network.genesisBytes))
|
||||
else: nil
|
||||
|
||||
if config.blockId.isSome():
|
||||
|
@ -11,7 +11,7 @@ import
|
||||
eth/db/kvstore_sqlite3, eth/keys,
|
||||
./el/el_manager,
|
||||
./gossip_processing/optimistic_processor,
|
||||
./networking/topic_params,
|
||||
./networking/[topic_params, network_metadata],
|
||||
./spec/beaconstate,
|
||||
./spec/datatypes/[phase0, altair, bellatrix, capella, deneb],
|
||||
"."/[filepath, light_client, light_client_db, nimbus_binary_common, version]
|
||||
@ -65,7 +65,7 @@ programMain:
|
||||
let
|
||||
genesisState =
|
||||
try:
|
||||
newClone(readSszForkedHashedBeaconState(cfg, metadata.genesisData))
|
||||
newClone(readSszForkedHashedBeaconState(cfg, metadata.genesisBytes))
|
||||
except CatchableError as err:
|
||||
raiseAssert "Invalid baked-in state: " & err.msg
|
||||
|
||||
|
@ -17,7 +17,7 @@ template checkRoot(name, root) =
|
||||
metadata = getMetadataForNetwork(name)
|
||||
cfg = metadata.cfg
|
||||
state = newClone(readSszForkedHashedBeaconState(
|
||||
metadata.cfg, metadata.genesisData))
|
||||
metadata.cfg, metadata.genesisBytes))
|
||||
|
||||
check:
|
||||
$getStateRoot(state[]) == root
|
||||
|
Loading…
x
Reference in New Issue
Block a user