mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 14:26:26 +00:00
align MockPrivKeys
with EF keys (#4866)
Back then, Milagro interop used offset 1000 for mock BLS keys. Meanwhile, interop code was removed and multi client testnets are there. EF tests use an offset of 1 for mock BLS keys. This patch aligns our implementation to also use offset of 1, potentially making debugging of state differences a bit easier (but, ultimately, low impact). Furthermore, simulation files are now emitted into a subdirectory to have less chunk in the repo root directory, and to avoid conflicts where a cached file with offset 1000 runs against tests expecting 1. See https://github.com/status-im/nimbus-eth2/pull/2928/files#r719266863
This commit is contained in:
parent
dd1ffa5ded
commit
445ece1157
1
.gitignore
vendored
1
.gitignore
vendored
@ -49,6 +49,7 @@ build/
|
||||
/local_testnet*_data*/
|
||||
|
||||
test_keymanager_api
|
||||
test_sim
|
||||
|
||||
/libnfuzz_linkerArgs.txt
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2020-2022 Status Research & Development GmbH
|
||||
# Copyright (c) 2020-2023 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
@ -8,7 +8,7 @@
|
||||
import
|
||||
stats, strformat, times,
|
||||
../tests/testblockutil, ../tests/consensus_spec/os_ops,
|
||||
../beacon_chain/beacon_chain_db,
|
||||
../beacon_chain/[beacon_chain_db, filepath],
|
||||
../beacon_chain/spec/datatypes/[phase0, altair],
|
||||
../beacon_chain/spec/[beaconstate, deposit_snapshots, forks, helpers],
|
||||
../beacon_chain/consensus_object_pools/[blockchain_dag, block_pools_types]
|
||||
@ -68,10 +68,16 @@ func verifyConsensus*(state: ForkedHashedBeaconState, attesterRatio: auto) =
|
||||
|
||||
proc loadGenesis*(validators: Natural, validate: bool):
|
||||
(ref ForkedHashedBeaconState, DepositTreeSnapshot) =
|
||||
const genesisDir = "test_sim"
|
||||
if (let res = secureCreatePath(genesisDir); res.isErr):
|
||||
fatal "Could not create directory",
|
||||
path = genesisDir, err = ioErrorMsg(res.error)
|
||||
quit 1
|
||||
|
||||
let
|
||||
genesisFn =
|
||||
genesisFn = genesisDir /
|
||||
&"genesis_{const_preset}_{validators}_{SPEC_VERSION}.ssz"
|
||||
contractSnapshotFn =
|
||||
contractSnapshotFn = genesisDir /
|
||||
&"deposit_contract_snapshot_{const_preset}_{validators}_{SPEC_VERSION}.ssz"
|
||||
cfg = defaultRuntimeConfig
|
||||
|
||||
@ -89,7 +95,7 @@ proc loadGenesis*(validators: Natural, validate: bool):
|
||||
|
||||
echo &"Loaded {genesisFn}..."
|
||||
|
||||
# TODO check that the private keys are interop keys
|
||||
# TODO check that the private keys are EF test keys
|
||||
|
||||
let contractSnapshot = SSZ.loadFile(contractSnapshotFn,
|
||||
DepositTreeSnapshot)
|
||||
|
@ -30,9 +30,7 @@ const
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/helpers/keys.py
|
||||
func `[]`*(_: MockPrivKeysT, index: ValidatorIndex|uint64): ValidatorPrivKey =
|
||||
# 0 is not a valid BLS private key - 1000 helps interop with rust BLS library,
|
||||
# lighthouse. EF tests use 1 instead of 1000.
|
||||
var bytes = (index.uint64 + 1000'u64).toBytesLE()
|
||||
var bytes = (index.uint64 + 1'u64).toBytesLE() # Consistent with EF tests
|
||||
static: doAssert sizeof(bytes) <= sizeof(result)
|
||||
copyMem(addr result, addr bytes, sizeof(bytes))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user