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