mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 14:26:26 +00:00
remove skipMerkleValidation and skipBlockParentRootValidation (#1197)
This commit is contained in:
parent
a9c7e19450
commit
ee9f4a2e3f
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
# Standard library
|
# Standard library
|
||||||
os, tables, random, strutils, times, math,
|
algorithm, os, tables, random, strutils, times, math,
|
||||||
|
|
||||||
# Nimble packages
|
# Nimble packages
|
||||||
stew/[objects, byteutils], stew/shims/macros,
|
stew/[objects, byteutils], stew/shims/macros,
|
||||||
@ -1005,8 +1005,10 @@ programMain:
|
|||||||
|
|
||||||
case config.cmd
|
case config.cmd
|
||||||
of createTestnet:
|
of createTestnet:
|
||||||
var deposits: seq[Deposit]
|
var
|
||||||
var i = -1
|
depositDirs: seq[string]
|
||||||
|
deposits: seq[Deposit]
|
||||||
|
i = -1
|
||||||
for kind, dir in walkDir(config.testnetDepositsDir.string):
|
for kind, dir in walkDir(config.testnetDepositsDir.string):
|
||||||
if kind != pcDir:
|
if kind != pcDir:
|
||||||
continue
|
continue
|
||||||
@ -1015,6 +1017,12 @@ programMain:
|
|||||||
if i < config.firstValidator.int:
|
if i < config.firstValidator.int:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
depositDirs.add dir
|
||||||
|
|
||||||
|
# Add deposits, in order, to pass Merkle validation
|
||||||
|
sort(depositDirs, system.cmp)
|
||||||
|
|
||||||
|
for dir in depositDirs:
|
||||||
let depositFile = dir / "deposit.json"
|
let depositFile = dir / "deposit.json"
|
||||||
try:
|
try:
|
||||||
deposits.add Json.loadFile(depositFile, Deposit)
|
deposits.add Json.loadFile(depositFile, Deposit)
|
||||||
@ -1031,7 +1039,7 @@ programMain:
|
|||||||
else: waitFor getLatestEth1BlockHash(config.web3Url)
|
else: waitFor getLatestEth1BlockHash(config.web3Url)
|
||||||
var
|
var
|
||||||
initialState = initialize_beacon_state_from_eth1(
|
initialState = initialize_beacon_state_from_eth1(
|
||||||
eth1Hash, startTime, deposits, {skipBlsValidation, skipMerkleValidation})
|
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
|
||||||
initialState.genesis_time = startTime
|
initialState.genesis_time = startTime
|
||||||
|
@ -20,17 +20,12 @@
|
|||||||
|
|
||||||
type
|
type
|
||||||
UpdateFlag* = enum
|
UpdateFlag* = enum
|
||||||
skipMerkleValidation ##\
|
|
||||||
## When processing deposits, skip verifying the Merkle proof trees of each
|
|
||||||
## deposit.
|
|
||||||
skipBlsValidation ##\
|
skipBlsValidation ##\
|
||||||
## Skip verification of BLS signatures in block processing.
|
## Skip verification of BLS signatures in block processing.
|
||||||
## Predominantly intended for use in testing, e.g. to allow extra coverage.
|
## Predominantly intended for use in testing, e.g. to allow extra coverage.
|
||||||
## Also useful to avoid unnecessary work when replaying known, good blocks.
|
## Also useful to avoid unnecessary work when replaying known, good blocks.
|
||||||
skipStateRootValidation ##\
|
skipStateRootValidation ##\
|
||||||
## Skip verification of block state root.
|
## Skip verification of block state root.
|
||||||
skipBlockParentRootValidation ##\
|
|
||||||
## Skip verification that the block's parent root matches the previous block header.
|
|
||||||
verifyFinalization
|
verifyFinalization
|
||||||
|
|
||||||
UpdateFlags* = set[UpdateFlag]
|
UpdateFlags* = set[UpdateFlag]
|
||||||
|
@ -109,7 +109,7 @@ proc generateDeposits*(totalValidators: int,
|
|||||||
let credentials = generateCredentials(password = password)
|
let credentials = generateCredentials(password = password)
|
||||||
|
|
||||||
let
|
let
|
||||||
keyName = $(credentials.signingKey.toPubKey)
|
keyName = intToStr(i, 6) & "_" & $(credentials.signingKey.toPubKey)
|
||||||
validatorDir = validatorsDir / keyName
|
validatorDir = validatorsDir / keyName
|
||||||
passphraseFile = secretsDir / keyName
|
passphraseFile = secretsDir / keyName
|
||||||
depositFile = validatorDir / depositFileName
|
depositFile = validatorDir / depositFileName
|
||||||
|
@ -55,14 +55,14 @@ proc process_deposit*(
|
|||||||
# Process an Eth1 deposit, registering a validator or increasing its balance.
|
# Process an Eth1 deposit, registering a validator or increasing its balance.
|
||||||
|
|
||||||
# Verify the Merkle branch
|
# Verify the Merkle branch
|
||||||
if skipMerkleValidation notin flags and not is_valid_merkle_branch(
|
if not is_valid_merkle_branch(
|
||||||
hash_tree_root(deposit.data),
|
hash_tree_root(deposit.data),
|
||||||
deposit.proof,
|
deposit.proof,
|
||||||
DEPOSIT_CONTRACT_TREE_DEPTH + 1, # Add 1 for the `List` length mix-in
|
DEPOSIT_CONTRACT_TREE_DEPTH + 1, # Add 1 for the `List` length mix-in
|
||||||
state.eth1_deposit_index,
|
state.eth1_deposit_index,
|
||||||
state.eth1_data.deposit_root,
|
state.eth1_data.deposit_root,
|
||||||
):
|
):
|
||||||
notice "Deposit merkle validation failed",
|
notice "Deposit Merkle validation failed",
|
||||||
proof = deposit.proof, deposit_root = state.eth1_data.deposit_root,
|
proof = deposit.proof, deposit_root = state.eth1_data.deposit_root,
|
||||||
deposit_index = state.eth1_deposit_index
|
deposit_index = state.eth1_deposit_index
|
||||||
return false
|
return false
|
||||||
|
@ -71,8 +71,7 @@ proc process_block_header*(
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
# Verify that the parent matches
|
# Verify that the parent matches
|
||||||
if skipBlockParentRootValidation notin flags and not (blck.parent_root ==
|
if not (blck.parent_root == hash_tree_root(state.latest_block_header)):
|
||||||
hash_tree_root(state.latest_block_header)):
|
|
||||||
notice "Block header: previous block root mismatch",
|
notice "Block header: previous block root mismatch",
|
||||||
latest_block_header = state.latest_block_header,
|
latest_block_header = state.latest_block_header,
|
||||||
blck = shortLog(blck),
|
blck = shortLog(blck),
|
||||||
|
@ -19,7 +19,7 @@ cd - &>/dev/null
|
|||||||
|
|
||||||
# When changing these, also update the readme section on running simulation
|
# When changing these, also update the readme section on running simulation
|
||||||
# so that the run_node example is correct!
|
# so that the run_node example is correct!
|
||||||
NUM_VALIDATORS=${VALIDATORS:-192}
|
NUM_VALIDATORS=${VALIDATORS:-128}
|
||||||
TOTAL_NODES=${NODES:-4}
|
TOTAL_NODES=${NODES:-4}
|
||||||
TOTAL_USER_NODES=${USER_NODES:-0}
|
TOTAL_USER_NODES=${USER_NODES:-0}
|
||||||
TOTAL_SYSTEM_NODES=$(( TOTAL_NODES - TOTAL_USER_NODES ))
|
TOTAL_SYSTEM_NODES=$(( TOTAL_NODES - TOTAL_USER_NODES ))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user