mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-26 13:15:16 +00:00
rename initialize_beacon_state to initialize_beacon_state_from_eth1 (#2536)
This commit is contained in:
parent
51fde853d5
commit
e0f4d28116
@ -94,7 +94,7 @@ OK: 11/11 Fail: 0/11 Skip: 0/11
|
|||||||
OK: 9/9 Fail: 0/9 Skip: 0/9
|
OK: 9/9 Fail: 0/9 Skip: 0/9
|
||||||
## Beacon state [Preset: mainnet]
|
## Beacon state [Preset: mainnet]
|
||||||
```diff
|
```diff
|
||||||
+ Smoke test initialize_beacon_state [Preset: mainnet] OK
|
+ Smoke test initialize_beacon_state_from_eth1 [Preset: mainnet] OK
|
||||||
```
|
```
|
||||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||||
## Bit fields
|
## Bit fields
|
||||||
|
@ -195,7 +195,7 @@ when hasGenesisDetection:
|
|||||||
|
|
||||||
var deposits = m.allGenesisDepositsUpTo(eth1Block.voteData.deposit_count)
|
var deposits = m.allGenesisDepositsUpTo(eth1Block.voteData.deposit_count)
|
||||||
|
|
||||||
result = initialize_beacon_state(
|
result = initialize_beacon_state_from_eth1(
|
||||||
m.preset,
|
m.preset,
|
||||||
eth1Block.voteData.block_hash,
|
eth1Block.voteData.block_hash,
|
||||||
eth1Block.timestamp.uint64,
|
eth1Block.timestamp.uint64,
|
||||||
|
@ -1748,7 +1748,7 @@ proc doCreateTestnet(config: BeaconNodeConf, rng: var BrHmacDrbgContext) {.raise
|
|||||||
else: (waitFor getEth1BlockHash(config.web3Urls[0], blockId("latest"))).asEth2Digest
|
else: (waitFor getEth1BlockHash(config.web3Urls[0], blockId("latest"))).asEth2Digest
|
||||||
runtimePreset = getRuntimePresetForNetwork(config.eth2Network)
|
runtimePreset = getRuntimePresetForNetwork(config.eth2Network)
|
||||||
var
|
var
|
||||||
initialState = initialize_beacon_state(
|
initialState = initialize_beacon_state_from_eth1(
|
||||||
runtimePreset, eth1Hash, startTime, deposits, {skipBlsValidation})
|
runtimePreset, eth1Hash, startTime, deposits, {skipBlsValidation})
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state
|
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state
|
||||||
|
@ -240,7 +240,7 @@ func genesis_time_from_eth1_timestamp*(preset: RuntimePreset, eth1_timestamp: ui
|
|||||||
eth1_timestamp + preset.GENESIS_DELAY
|
eth1_timestamp + preset.GENESIS_DELAY
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#genesis
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#genesis
|
||||||
proc initialize_beacon_state*(
|
proc initialize_beacon_state_from_eth1*(
|
||||||
preset: RuntimePreset,
|
preset: RuntimePreset,
|
||||||
eth1_block_hash: Eth2Digest,
|
eth1_block_hash: Eth2Digest,
|
||||||
eth1_timestamp: uint64,
|
eth1_timestamp: uint64,
|
||||||
@ -335,7 +335,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
|
|||||||
eth1_timestamp: uint64,
|
eth1_timestamp: uint64,
|
||||||
deposits: openArray[DepositData],
|
deposits: openArray[DepositData],
|
||||||
flags: UpdateFlags = {}): HashedBeaconState =
|
flags: UpdateFlags = {}): HashedBeaconState =
|
||||||
let genesisState = initialize_beacon_state(
|
let genesisState = initialize_beacon_state_from_eth1(
|
||||||
preset, eth1_block_hash, eth1_timestamp, deposits, flags)
|
preset, eth1_block_hash, eth1_timestamp, deposits, flags)
|
||||||
HashedBeaconState(data: genesisState[], root: hash_tree_root(genesisState[]))
|
HashedBeaconState(data: genesisState[], root: hash_tree_root(genesisState[]))
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ proc loadGenesis*(validators: Natural, validate: bool):
|
|||||||
let contractSnapshot = DepositContractSnapshot(
|
let contractSnapshot = DepositContractSnapshot(
|
||||||
depositContractState: merkleizer.toDepositContractState)
|
depositContractState: merkleizer.toDepositContractState)
|
||||||
|
|
||||||
res.data = initialize_beacon_state(
|
res.data = initialize_beacon_state_from_eth1(
|
||||||
defaultRuntimePreset,
|
defaultRuntimePreset,
|
||||||
Eth2Digest(),
|
Eth2Digest(),
|
||||||
0,
|
0,
|
||||||
|
@ -215,7 +215,7 @@ suite "Beacon chain DB" & preset():
|
|||||||
db = BeaconChainDB.new(defaultRuntimePreset, "", inMemory = true)
|
db = BeaconChainDB.new(defaultRuntimePreset, "", inMemory = true)
|
||||||
|
|
||||||
let
|
let
|
||||||
state = initialize_beacon_state(
|
state = initialize_beacon_state_from_eth1(
|
||||||
defaultRuntimePreset, eth1BlockHash, 0,
|
defaultRuntimePreset, eth1BlockHash, 0,
|
||||||
makeInitialDeposits(SLOTS_PER_EPOCH), {skipBlsValidation})
|
makeInitialDeposits(SLOTS_PER_EPOCH), {skipBlsValidation})
|
||||||
root = hash_tree_root(state[])
|
root = hash_tree_root(state[])
|
||||||
|
@ -13,7 +13,7 @@ import
|
|||||||
./testutil, ./testblockutil
|
./testutil, ./testblockutil
|
||||||
|
|
||||||
suite "Beacon state" & preset():
|
suite "Beacon state" & preset():
|
||||||
test "Smoke test initialize_beacon_state" & preset():
|
test "Smoke test initialize_beacon_state_from_eth1" & preset():
|
||||||
let state = initialize_beacon_state(
|
let state = initialize_beacon_state_from_eth1(
|
||||||
defaultRuntimePreset, Eth2Digest(), 0, makeInitialDeposits(SLOTS_PER_EPOCH, {}), {})
|
defaultRuntimePreset, Eth2Digest(), 0, makeInitialDeposits(SLOTS_PER_EPOCH, {}), {})
|
||||||
check: state.validators.lenu64 == SLOTS_PER_EPOCH
|
check: state.validators.lenu64 == SLOTS_PER_EPOCH
|
||||||
|
@ -150,7 +150,7 @@ suite "Interop":
|
|||||||
|
|
||||||
const genesis_time = 1570500000
|
const genesis_time = 1570500000
|
||||||
var
|
var
|
||||||
initialState = initialize_beacon_state(
|
initialState = initialize_beacon_state_from_eth1(
|
||||||
defaultRuntimePreset, eth1BlockHash, genesis_time, deposits, {})
|
defaultRuntimePreset, eth1BlockHash, genesis_time, deposits, {})
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state
|
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# beacon_chain
|
# beacon_chain
|
||||||
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * 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).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
@ -21,7 +21,7 @@ proc makeTestDB*(tailState: var BeaconState, tailBlock: SignedBeaconBlock): Beac
|
|||||||
|
|
||||||
proc makeTestDB*(validators: Natural): BeaconChainDB =
|
proc makeTestDB*(validators: Natural): BeaconChainDB =
|
||||||
let
|
let
|
||||||
genState = initialize_beacon_state(
|
genState = initialize_beacon_state_from_eth1(
|
||||||
defaultRuntimePreset,
|
defaultRuntimePreset,
|
||||||
Eth2Digest(),
|
Eth2Digest(),
|
||||||
0,
|
0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user