From 74c993d61644f2e24ec231ed46e1ee0abdbcbef1 Mon Sep 17 00:00:00 2001 From: Philippe Schommers Date: Wed, 26 Jul 2023 14:54:16 +0200 Subject: [PATCH] feat: add support for Chiado (#5208) --- beacon_chain/networking/network_metadata.nim | 18 ++++++++++++++++-- .../networking/network_metadata_gnosis.S | 12 ++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 19875b12c..6f9b243d1 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -221,6 +221,9 @@ when const_preset == "gnosis": gnosisGenesis {.importc: "gnosis_mainnet_genesis".}: ptr UncheckedArray[byte] gnosisGenesisSize {.importc: "gnosis_mainnet_genesis_size".}: int + chiadoGenesis {.importc: "gnosis_chiado_genesis".}: ptr UncheckedArray[byte] + chiadoGenesisSize {.importc: "gnosis_chiado_genesis_size".}: int + # let `.incbin` in assembly file find the binary file through search path {.passc: "-I" & vendorDir.} {.compile: "network_metadata_gnosis.S".} @@ -229,10 +232,19 @@ when const_preset == "gnosis": gnosisMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/gnosis-chain-configs/mainnet", none(Eth1Network), not incbinEnabled) + chiadoMetadata = loadCompileTimeNetworkMetadata( + vendorDir & "/gnosis-chain-configs/chiado", + none(Eth1Network), not incbinEnabled) static: - checkForkConsistency(gnosisMetadata.cfg) - doAssert gnosisMetadata.cfg.DENEB_FORK_EPOCH == FAR_FUTURE_EPOCH + for network in [gnosisMetadata, chiadoMetadata]: + checkForkConsistency(network.cfg) + + for network in [gnosisMetadata, chiadoMetadata]: + doAssert network.cfg.ALTAIR_FORK_EPOCH < FAR_FUTURE_EPOCH + doAssert network.cfg.BELLATRIX_FORK_EPOCH < FAR_FUTURE_EPOCH + doAssert network.cfg.CAPELLA_FORK_EPOCH < FAR_FUTURE_EPOCH + doAssert network.cfg.DENEB_FORK_EPOCH == FAR_FUTURE_EPOCH elif const_preset == "mainnet": import stew/assign2 @@ -309,6 +321,8 @@ proc getMetadataForNetwork*( warn "`--network:gnosis-chain` is deprecated, " & "use `--network:gnosis` instead" withGenesis(gnosisMetadata, gnosisGenesis) + of "chiado": + withGenesis(chiadoMetadata, chiadoGenesis) else: loadRuntimeMetadata() diff --git a/beacon_chain/networking/network_metadata_gnosis.S b/beacon_chain/networking/network_metadata_gnosis.S index 8e97f754d..2894de7a4 100644 --- a/beacon_chain/networking/network_metadata_gnosis.S +++ b/beacon_chain/networking/network_metadata_gnosis.S @@ -34,6 +34,13 @@ gnosis_mainnet_genesis_end: cdecl(gnosis_mainnet_genesis_size): .quad gnosis_mainnet_genesis_end - gnosis_mainnet_genesis_data +gnosis_chiado_genesis_data: + .incbin "gnosis-chain-configs/chiado/genesis.ssz" +gnosis_chiado_genesis_end: + .global cdecl(gnosis_chiado_genesis_size) +cdecl(gnosis_chiado_genesis_size): + .quad gnosis_chiado_genesis_end - gnosis_chiado_genesis_data + #if defined(__linux__) && defined(__pie__) .section .data.rel.ro,"aw",@progbits #elif defined(__APPLE__) @@ -44,3 +51,8 @@ cdecl(gnosis_mainnet_genesis_size): .p2align 3 cdecl(gnosis_mainnet_genesis): .quad gnosis_mainnet_genesis_data + + .global cdecl(gnosis_chiado_genesis) + .p2align 3 +cdecl(gnosis_chiado_genesis): + .quad gnosis_chiado_genesis_data