Refactor and apply renaming to post merge block proofs (#2648)
This commit is contained in:
parent
35d4529ef2
commit
0fb9581b96
|
@ -7,7 +7,12 @@
|
|||
|
||||
{.push raises: [].}
|
||||
|
||||
import std/os, stew/io2, results, ../network/history/accumulator, ../eth_data/era1
|
||||
import
|
||||
std/os,
|
||||
stew/io2,
|
||||
results,
|
||||
../network/history/validation/historical_hashes_accumulator,
|
||||
../eth_data/era1
|
||||
|
||||
type Era1DB* = ref object
|
||||
## The Era1 database manages a collection of era files that together make up
|
||||
|
|
|
@ -17,7 +17,7 @@ import
|
|||
beacon_chain/spec/beacon_time,
|
||||
ssz_serialization,
|
||||
ncli/e2store,
|
||||
../network/history/accumulator
|
||||
../network/history/validation/historical_hashes_accumulator
|
||||
|
||||
from nimcrypto/hash import fromHex
|
||||
from ../../nimbus/utils/utils import calcTxRoot, calcReceiptsRoot
|
||||
|
|
|
@ -15,7 +15,7 @@ import
|
|||
chronicles,
|
||||
eth/[rlp, common/eth_types],
|
||||
../../nimbus/common/[chain_config, genesis],
|
||||
../network/history/[history_content, accumulator]
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator]
|
||||
|
||||
export results, tables
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ import
|
|||
eth/common/eth_types,
|
||||
eth/rlp,
|
||||
../network/wire/portal_protocol,
|
||||
../network/history/[history_content, history_network, accumulator],
|
||||
../network/history/
|
||||
[history_content, history_network, validation/historical_hashes_accumulator],
|
||||
"."/[era1, history_data_json_store, history_data_ssz_e2s]
|
||||
|
||||
export results
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
results,
|
||||
eth/[rlp, common/eth_types],
|
||||
ncli/e2store,
|
||||
../network/history/[history_content, accumulator]
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator]
|
||||
|
||||
export results
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import
|
|||
ssz_serialization,
|
||||
../../../common/common_types,
|
||||
../../../database/content_db,
|
||||
../accumulator
|
||||
../validation/historical_hashes_accumulator
|
||||
|
||||
type
|
||||
ContentType = enum
|
||||
|
|
|
@ -17,13 +17,17 @@ import
|
|||
../../database/content_db,
|
||||
../../network_metadata,
|
||||
../wire/[portal_protocol, portal_stream, portal_protocol_config],
|
||||
"."/[history_content, accumulator, beacon_chain_historical_roots],
|
||||
"."/[
|
||||
history_content,
|
||||
beacon_chain_historical_roots,
|
||||
validation/historical_hashes_accumulator,
|
||||
],
|
||||
./content/content_deprecated
|
||||
|
||||
logScope:
|
||||
topics = "portal_hist"
|
||||
|
||||
export accumulator
|
||||
export historical_hashes_accumulator
|
||||
|
||||
type
|
||||
HistoryNetwork* = ref object
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import results, beacon_chain/spec/presets, beacon_chain/spec/forks
|
||||
|
||||
type BeaconBlockProof* = array[11, Digest]
|
||||
type ExecutionBlockProof* = array[11, Digest]
|
||||
|
||||
func getBlockRootsIndex*(slot: Slot): uint64 =
|
||||
slot mod SLOTS_PER_HISTORICAL_ROOT
|
||||
|
@ -19,7 +19,9 @@ func getBlockRootsIndex*(beaconBlock: SomeForkyBeaconBlock): uint64 =
|
|||
|
||||
# Builds proof to be able to verify that the EL block hash is part of the
|
||||
# CL BeaconBlock for given root.
|
||||
func buildProof*(blockBody: SomeForkyBeaconBlock): Result[BeaconBlockProof, string] =
|
||||
func buildProof*(
|
||||
beaconBlock: SomeForkyBeaconBlock
|
||||
): Result[ExecutionBlockProof, string] =
|
||||
let
|
||||
# BeaconBlock level:
|
||||
# - 8 as there are 5 fields
|
||||
|
@ -34,12 +36,14 @@ func buildProof*(blockBody: SomeForkyBeaconBlock): Result[BeaconBlockProof, stri
|
|||
# - 12 as pos of field is 12
|
||||
gIndex = GeneralizedIndex(gIndexMidLevel * 1 * 16 + 12)
|
||||
|
||||
var proof: BeaconBlockProof
|
||||
?blockBody.build_proof(gIndex, proof)
|
||||
var proof: ExecutionBlockProof
|
||||
?beaconBlock.build_proof(gIndex, proof)
|
||||
|
||||
ok(proof)
|
||||
|
||||
func verifyProof*(blockHash: Digest, proof: BeaconBlockProof, blockRoot: Digest): bool =
|
||||
func verifyProof*(
|
||||
blockHash: Digest, proof: ExecutionBlockProof, blockRoot: Digest
|
||||
): bool =
|
||||
let
|
||||
gIndexTopLevel = (1 * 1 * 8 + 4)
|
||||
gIndexMidLevel = (gIndexTopLevel * 1 * 16 + 9)
|
|
@ -79,18 +79,18 @@ import
|
|||
ssz_serialization/[proofs, merkleization],
|
||||
beacon_chain/spec/eth2_ssz_serialization,
|
||||
beacon_chain/spec/datatypes/bellatrix,
|
||||
./beacon_chain_block_proof_common
|
||||
./block_proof_common
|
||||
|
||||
export beacon_chain_block_proof_common
|
||||
export block_proof_common
|
||||
|
||||
type
|
||||
HistoricalRootsProof* = array[14, Digest]
|
||||
BeaconBlockProofHistoricalRoots* = array[14, Digest]
|
||||
|
||||
BeaconChainBlockProof* = object
|
||||
BlockProofHistoricalRoots* = object
|
||||
# Total size (11 + 1 + 14) * 32 bytes + 4 bytes = 836 bytes
|
||||
beaconBlockProof*: BeaconBlockProof
|
||||
beaconBlockProof*: BeaconBlockProofHistoricalRoots
|
||||
beaconBlockRoot*: Digest
|
||||
historicalRootsProof*: HistoricalRootsProof
|
||||
executionBlockProof*: ExecutionBlockProof
|
||||
slot*: Slot
|
||||
|
||||
func getHistoricalRootsIndex*(slot: Slot): uint64 =
|
||||
|
@ -111,11 +111,11 @@ template `[]`(x: openArray[Eth2Digest], chunk: Limit): Eth2Digest =
|
|||
# HistoricalBatch for given root.
|
||||
func buildProof*(
|
||||
batch: HistoricalBatch, blockRootIndex: uint64
|
||||
): Result[HistoricalRootsProof, string] =
|
||||
): Result[BeaconBlockProofHistoricalRoots, string] =
|
||||
# max list size * 2 is start point of leaves
|
||||
let gIndex = GeneralizedIndex(2 * SLOTS_PER_HISTORICAL_ROOT + blockRootIndex)
|
||||
|
||||
var proof: HistoricalRootsProof
|
||||
var proof: BeaconBlockProofHistoricalRoots
|
||||
?batch.build_proof(gIndex, proof)
|
||||
|
||||
ok(proof)
|
||||
|
@ -123,24 +123,24 @@ func buildProof*(
|
|||
func buildProof*(
|
||||
batch: HistoricalBatch,
|
||||
beaconBlock: bellatrix.TrustedBeaconBlock | bellatrix.BeaconBlock,
|
||||
): Result[BeaconChainBlockProof, string] =
|
||||
): Result[BlockProofHistoricalRoots, string] =
|
||||
let
|
||||
blockRootIndex = getBlockRootsIndex(beaconBlock)
|
||||
beaconBlockProof = ?beaconBlock.buildProof()
|
||||
historicalRootsProof = ?batch.buildProof(blockRootIndex)
|
||||
executionBlockProof = ?beaconBlock.buildProof()
|
||||
beaconBlockProof = ?batch.buildProof(blockRootIndex)
|
||||
|
||||
ok(
|
||||
BeaconChainBlockProof(
|
||||
BlockProofHistoricalRoots(
|
||||
beaconBlockProof: beaconBlockProof,
|
||||
beaconBlockRoot: hash_tree_root(beaconBlock),
|
||||
historicalRootsProof: historicalRootsProof,
|
||||
executionBlockProof: executionBlockProof,
|
||||
slot: beaconBlock.slot,
|
||||
)
|
||||
)
|
||||
|
||||
func verifyProof*(
|
||||
blockHeaderRoot: Digest,
|
||||
proof: HistoricalRootsProof,
|
||||
proof: BeaconBlockProofHistoricalRoots,
|
||||
historicalRoot: Digest,
|
||||
blockRootIndex: uint64,
|
||||
): bool =
|
||||
|
@ -150,14 +150,14 @@ func verifyProof*(
|
|||
|
||||
func verifyProof*(
|
||||
historical_roots: HashList[Eth2Digest, Limit HISTORICAL_ROOTS_LIMIT],
|
||||
proof: BeaconChainBlockProof,
|
||||
proof: BlockProofHistoricalRoots,
|
||||
blockHash: Digest,
|
||||
): bool =
|
||||
let
|
||||
historicalRootsIndex = getHistoricalRootsIndex(proof.slot)
|
||||
blockRootIndex = getBlockRootsIndex(proof.slot)
|
||||
|
||||
blockHash.verifyProof(proof.beaconBlockProof, proof.beaconBlockRoot) and
|
||||
blockHash.verifyProof(proof.executionBlockProof, proof.beaconBlockRoot) and
|
||||
proof.beaconBlockRoot.verifyProof(
|
||||
proof.historicalRootsProof, historical_roots[historicalRootsIndex], blockRootIndex
|
||||
proof.beaconBlockProof, historical_roots[historicalRootsIndex], blockRootIndex
|
||||
)
|
|
@ -30,18 +30,18 @@ import
|
|||
beacon_chain/spec/eth2_ssz_serialization,
|
||||
beacon_chain/spec/presets,
|
||||
beacon_chain/spec/datatypes/capella,
|
||||
../beacon_chain_block_proof_common
|
||||
./block_proof_common
|
||||
|
||||
export beacon_chain_block_proof_common
|
||||
export block_proof_common
|
||||
|
||||
type
|
||||
HistoricalSummariesProof* = array[13, Digest]
|
||||
BeaconBlockProofHistoricalRoots* = array[13, Digest]
|
||||
|
||||
BeaconChainBlockProof* = object
|
||||
BlockProofHistoricalSummaries* = object
|
||||
# Total size (11 + 1 + 13) * 32 bytes + 4 bytes = 804 bytes
|
||||
beaconBlockProof*: BeaconBlockProof
|
||||
beaconBlockProof*: BeaconBlockProofHistoricalRoots
|
||||
beaconBlockRoot*: Digest
|
||||
historicalSummariesProof*: HistoricalSummariesProof
|
||||
executionBlockProof*: ExecutionBlockProof
|
||||
slot*: Slot
|
||||
|
||||
template `[]`(x: openArray[Eth2Digest], chunk: Limit): Eth2Digest =
|
||||
|
@ -64,11 +64,11 @@ func getHistoricalSummariesIndex*(
|
|||
# block_roots for given root.
|
||||
func buildProof*(
|
||||
blockRoots: array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest], blockRootIndex: uint64
|
||||
): Result[HistoricalSummariesProof, string] =
|
||||
): Result[BeaconBlockProofHistoricalRoots, string] =
|
||||
# max list size * 1 is start point of leaves
|
||||
let gIndex = GeneralizedIndex(SLOTS_PER_HISTORICAL_ROOT + blockRootIndex)
|
||||
|
||||
var proof: HistoricalSummariesProof
|
||||
var proof: BeaconBlockProofHistoricalRoots
|
||||
?blockRoots.build_proof(gIndex, proof)
|
||||
|
||||
ok(proof)
|
||||
|
@ -78,24 +78,24 @@ func buildProof*(
|
|||
func buildProof*(
|
||||
blockRoots: array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest],
|
||||
beaconBlock: capella.TrustedBeaconBlock | capella.BeaconBlock,
|
||||
): Result[BeaconChainBlockProof, string] =
|
||||
): Result[BlockProofHistoricalSummaries, string] =
|
||||
let
|
||||
blockRootIndex = getBlockRootsIndex(beaconBlock)
|
||||
beaconBlockProof = ?beaconBlock.buildProof()
|
||||
historicalSummariesProof = ?blockRoots.buildProof(blockRootIndex)
|
||||
executionBlockProof = ?beaconBlock.buildProof()
|
||||
beaconBlockProof = ?blockRoots.buildProof(blockRootIndex)
|
||||
|
||||
ok(
|
||||
BeaconChainBlockProof(
|
||||
beaconBlockProof: beaconBlockProof,
|
||||
BlockProofHistoricalSummaries(
|
||||
beaconBlockRoot: hash_tree_root(beaconBlock),
|
||||
historicalSummariesProof: historicalSummariesProof,
|
||||
beaconBlockProof: beaconBlockProof,
|
||||
executionBlockProof: executionBlockProof,
|
||||
slot: beaconBlock.slot,
|
||||
)
|
||||
)
|
||||
|
||||
func verifyProof*(
|
||||
blockHeaderRoot: Digest,
|
||||
proof: HistoricalSummariesProof,
|
||||
proof: BeaconBlockProofHistoricalRoots,
|
||||
historicalRoot: Digest,
|
||||
blockRootIndex: uint64,
|
||||
): bool =
|
||||
|
@ -105,7 +105,7 @@ func verifyProof*(
|
|||
|
||||
func verifyProof*(
|
||||
historical_summaries: HashList[HistoricalSummary, Limit HISTORICAL_ROOTS_LIMIT],
|
||||
proof: BeaconChainBlockProof,
|
||||
proof: BlockProofHistoricalSummaries,
|
||||
blockHash: Digest,
|
||||
cfg: RuntimeConfig,
|
||||
): bool =
|
||||
|
@ -113,9 +113,9 @@ func verifyProof*(
|
|||
historicalRootsIndex = getHistoricalSummariesIndex(proof.slot, cfg)
|
||||
blockRootIndex = getBlockRootsIndex(proof.slot)
|
||||
|
||||
blockHash.verifyProof(proof.beaconBlockProof, proof.beaconBlockRoot) and
|
||||
blockHash.verifyProof(proof.executionBlockProof, proof.beaconBlockRoot) and
|
||||
proof.beaconBlockRoot.verifyProof(
|
||||
proof.historicalSummariesProof,
|
||||
proof.beaconBlockProof,
|
||||
historical_summaries[historicalRootsIndex].block_summary_root,
|
||||
blockRootIndex,
|
||||
)
|
|
@ -12,8 +12,8 @@ import
|
|||
eth/common/eth_types_rlp,
|
||||
ssz_serialization,
|
||||
ssz_serialization/[proofs, merkleization],
|
||||
../../common/common_types,
|
||||
./history_content
|
||||
../../../common/common_types,
|
||||
../history_content
|
||||
|
||||
export ssz_serialization, merkleization, proofs, eth_types_rlp
|
||||
|
|
@ -13,7 +13,7 @@ import
|
|||
stew/io2,
|
||||
chronos/timer,
|
||||
beacon_chain/spec/forks,
|
||||
./network/history/accumulator
|
||||
./network/history/validation/historical_hashes_accumulator
|
||||
|
||||
proc loadBootstrapNodes(path: string): seq[string] {.raises: [IOError].} =
|
||||
# Read a list of ENR URIs from a file containing a flat list of entries.
|
||||
|
|
|
@ -19,7 +19,7 @@ import
|
|||
../rpc/portal_rpc_client,
|
||||
../rpc/eth_rpc_client,
|
||||
../eth_data/[history_data_seeding, history_data_json_store, history_data_ssz_e2s],
|
||||
../network/history/[history_content, accumulator],
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator],
|
||||
../tests/test_history_util
|
||||
|
||||
type
|
||||
|
|
|
@ -13,9 +13,8 @@ import
|
|||
./test_history_network,
|
||||
./test_content_db,
|
||||
./test_discovery_rpc,
|
||||
./test_beacon_chain_block_proof_bellatrix,
|
||||
./test_beacon_chain_block_proof_capella,
|
||||
./test_beacon_chain_historical_roots,
|
||||
./test_beacon_chain_historical_summaries,
|
||||
./history_network_tests/all_history_network_tests,
|
||||
./beacon_network_tests/all_beacon_network_tests,
|
||||
./state_network_tests/all_state_network_tests
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2024 Status Research & Development GmbH
|
||||
# Licensed under either of
|
||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.warning[UnusedImport]: off.}
|
||||
|
||||
import
|
||||
./test_block_proof_historical_roots,
|
||||
./test_block_proof_historical_roots_vectors,
|
||||
./test_block_proof_historical_summaries,
|
||||
./test_block_proof_historical_summaries_vectors
|
|
@ -16,7 +16,7 @@ import
|
|||
beacon_chain /../ tests/testblockutil,
|
||||
# Mock helpers
|
||||
beacon_chain /../ tests/mocking/mock_genesis,
|
||||
../network/history/beacon_chain_block_proof_bellatrix
|
||||
../../network/history/validation/block_proof_historical_roots
|
||||
|
||||
# Test suite for the proofs:
|
||||
# - HistoricalRootsProof
|
||||
|
@ -67,7 +67,7 @@ suite "Beacon Chain Block Proofs - Bellatrix":
|
|||
SLOTS_PER_HISTORICAL_ROOT - 2,
|
||||
]
|
||||
|
||||
test "HistoricalRootsProof for BeaconBlock":
|
||||
test "BeaconBlockProofHistoricalRoots for BeaconBlock":
|
||||
let
|
||||
# Historical batch of first historical root
|
||||
batch = HistoricalBatch(
|
||||
|
@ -91,7 +91,7 @@ suite "Beacon Chain Block Proofs - Bellatrix":
|
|||
blocks[i].root, proof, historical_roots[historicalRootsIndex], blockRootIndex
|
||||
)
|
||||
|
||||
test "BeaconBlockProof for BeaconBlock":
|
||||
test "ExecutionBlockProof for Execution BlockHeader":
|
||||
# for i in 0..<(SLOTS_PER_HISTORICAL_ROOT - 1): # Test all blocks
|
||||
for i in blocksToTest:
|
||||
let beaconBlock = blocks[i].message
|
||||
|
@ -103,7 +103,7 @@ suite "Beacon Chain Block Proofs - Bellatrix":
|
|||
let leave = beaconBlock.body.execution_payload.block_hash
|
||||
check verifyProof(leave, proof, blocks[i].root)
|
||||
|
||||
test "BeaconChainBlockProof for Execution BlockHeader":
|
||||
test "BlockProofHistoricalRoots for Execution BlockHeader":
|
||||
let
|
||||
# Historical batch of first historical root
|
||||
batch = HistoricalBatch(
|
|
@ -14,13 +14,13 @@ import
|
|||
unittest2,
|
||||
yaml,
|
||||
beacon_chain/spec/datatypes/bellatrix,
|
||||
../../../common/common_types,
|
||||
../../../network_metadata,
|
||||
../../../network/history/beacon_chain_block_proof_bellatrix,
|
||||
../../../eth_data/[yaml_utils, yaml_eth_types]
|
||||
../../common/common_types,
|
||||
../../network_metadata,
|
||||
../../network/history/validation/block_proof_historical_roots,
|
||||
../../eth_data/[yaml_utils, yaml_eth_types]
|
||||
|
||||
suite "History Block Proofs - Bellatrix":
|
||||
test "BeaconChainBlockProof for Execution BlockHeader":
|
||||
suite "History Block Proofs - Historical Roots":
|
||||
test "BlockProofHistoricalRoots for Execution BlockHeader":
|
||||
let
|
||||
testsPath =
|
||||
"./vendor/portal-spec-tests/tests/mainnet/history/headers_with_proof/block_proofs_bellatrix/"
|
||||
|
@ -33,11 +33,11 @@ suite "History Block Proofs - Bellatrix":
|
|||
raiseAssert "Cannot read test vector: " & error
|
||||
|
||||
blockHash = BlockHash.fromHex(testProof.execution_block_header)
|
||||
blockProof = BeaconChainBlockProof(
|
||||
beaconBlockProof: array[11, Digest].fromHex(testProof.beacon_block_proof),
|
||||
beaconBlockRoot: Digest.fromHex(testProof.beacon_block_root),
|
||||
historicalRootsProof:
|
||||
blockProof = BlockProofHistoricalRoots(
|
||||
beaconBlockProof:
|
||||
array[14, Digest].fromHex(testProof.historical_roots_proof),
|
||||
beaconBlockRoot: Digest.fromHex(testProof.beacon_block_root),
|
||||
executionBlockProof: array[11, Digest].fromHex(testProof.beacon_block_proof),
|
||||
slot: Slot(testProof.slot),
|
||||
)
|
||||
|
|
@ -16,7 +16,7 @@ import
|
|||
beacon_chain /../ tests/testblockutil,
|
||||
# Mock helpers
|
||||
beacon_chain /../ tests/mocking/mock_genesis,
|
||||
../network/history/experimental/beacon_chain_block_proof_capella
|
||||
../../network/history/validation/block_proof_historical_summaries
|
||||
|
||||
# Test suite for the proofs:
|
||||
# - historicalSummariesProof
|
||||
|
@ -82,7 +82,7 @@ suite "Beacon Chain Block Proofs - Capella":
|
|||
SLOTS_PER_HISTORICAL_ROOT - 2,
|
||||
]
|
||||
|
||||
test "HistoricalRootsProof for BeaconBlockHeader":
|
||||
test "BeaconBlockProofHistoricalSummaries for BeaconBlock":
|
||||
let blockRoots = getStateField(state[], block_roots).data
|
||||
|
||||
withState(state[]):
|
||||
|
@ -107,7 +107,7 @@ suite "Beacon Chain Block Proofs - Capella":
|
|||
blockRootIndex,
|
||||
)
|
||||
|
||||
test "BeaconBlockProof for BeaconBlock":
|
||||
test "ExecutionBlockProof for Execution BlockHeader":
|
||||
# for i in 0..<(SLOTS_PER_HISTORICAL_ROOT - 1): # Test all blocks
|
||||
for i in blocksToTest:
|
||||
let beaconBlock = blocks[i].message
|
||||
|
@ -119,7 +119,7 @@ suite "Beacon Chain Block Proofs - Capella":
|
|||
let leave = beaconBlock.body.execution_payload.block_hash
|
||||
check verifyProof(leave, proof, blocks[i].root)
|
||||
|
||||
test "BeaconChainBlockProof for Execution BlockHeader":
|
||||
test "BlockProofHistoricalSummaries for Execution BlockHeader":
|
||||
let blockRoots = getStateField(state[], block_roots).data
|
||||
|
||||
withState(state[]):
|
|
@ -16,10 +16,10 @@ import
|
|||
yaml,
|
||||
ssz_serialization,
|
||||
beacon_chain/spec/datatypes/capella,
|
||||
../../../common/common_types,
|
||||
../../../network/history/experimental/beacon_chain_block_proof_capella,
|
||||
../../../network/beacon/beacon_init_loader,
|
||||
../../../eth_data/[yaml_utils, yaml_eth_types]
|
||||
../../common/common_types,
|
||||
../../network/history/validation/block_proof_historical_summaries,
|
||||
../../network/beacon/beacon_init_loader,
|
||||
../../eth_data/[yaml_utils, yaml_eth_types]
|
||||
|
||||
proc toString(v: IoErrorCode): string =
|
||||
try:
|
||||
|
@ -44,8 +44,8 @@ proc readHistoricalSummaries(
|
|||
except SerializationError as err:
|
||||
err("Failed decoding historical_summaries: " & err.msg)
|
||||
|
||||
suite "History Block Proofs - Capella":
|
||||
test "BeaconChainBlockProof for Execution BlockHeader":
|
||||
suite "History Block Proofs - Historical Summaries":
|
||||
test "BlockProofHistoricalSummaries for Execution BlockHeader":
|
||||
let
|
||||
testsPath =
|
||||
"./vendor/portal-spec-tests/tests/mainnet/history/headers_with_proof/block_proofs_capella/"
|
||||
|
@ -62,11 +62,11 @@ suite "History Block Proofs - Capella":
|
|||
raiseAssert "Cannot read test vector: " & error
|
||||
|
||||
blockHash = BlockHash.fromHex(testProof.execution_block_header)
|
||||
blockProof = BeaconChainBlockProof(
|
||||
beaconBlockProof: array[11, Digest].fromHex(testProof.beacon_block_proof),
|
||||
beaconBlockRoot: Digest.fromHex(testProof.beacon_block_root),
|
||||
historicalSummariesProof:
|
||||
blockProof = BlockProofHistoricalSummaries(
|
||||
beaconBlockProof:
|
||||
array[13, Digest].fromHex(testProof.historical_summaries_proof),
|
||||
beaconBlockRoot: Digest.fromHex(testProof.beacon_block_root),
|
||||
executionBlockProof: array[11, Digest].fromHex(testProof.beacon_block_proof),
|
||||
slot: Slot(testProof.slot),
|
||||
)
|
||||
|
|
@ -12,6 +12,4 @@ import
|
|||
./test_history_content_keys,
|
||||
./test_history_content,
|
||||
./test_history_content_validation,
|
||||
./test_history_block_proof_bellatrix,
|
||||
./test_history_block_proof_capella,
|
||||
./test_accumulator_root
|
||||
|
|
|
@ -15,7 +15,7 @@ import
|
|||
stew/byteutils,
|
||||
eth/common/eth_types_rlp,
|
||||
../../../eth_data/history_data_json_store,
|
||||
../../../network/history/[history_content, accumulator]
|
||||
../../../network/history/[history_content, validation/historical_hashes_accumulator]
|
||||
|
||||
suite "Header Accumulator Root":
|
||||
test "Header Accumulator Update":
|
||||
|
|
|
@ -15,7 +15,8 @@ import
|
|||
eth/common/eth_types_rlp,
|
||||
../../../network_metadata,
|
||||
../../../eth_data/[history_data_json_store, history_data_ssz_e2s],
|
||||
../../../network/history/[history_content, history_network, accumulator],
|
||||
../../../network/history/
|
||||
[history_content, history_network, validation/historical_hashes_accumulator],
|
||||
../../test_history_util,
|
||||
../../../eth_data/yaml_utils
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
stint,
|
||||
ssz_serialization,
|
||||
ssz_serialization/[proofs, merkleization],
|
||||
../../../network/history/[history_content, accumulator]
|
||||
../../../network/history/history_content
|
||||
|
||||
# According to test vectors:
|
||||
# https://github.com/ethereum/portal-network-specs/blob/master/content-keys-test-vectors.md#history-network-keys
|
||||
|
|
|
@ -14,7 +14,7 @@ import
|
|||
stint,
|
||||
eth/common/eth_types_rlp,
|
||||
../eth_data/history_data_json_store,
|
||||
../network/history/[history_content, accumulator],
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator],
|
||||
./test_helpers
|
||||
|
||||
suite "Header Accumulator":
|
||||
|
|
|
@ -12,7 +12,7 @@ import
|
|||
eth/[common, keys, rlp],
|
||||
eth/p2p/discoveryv5/[enr, node, routing_table],
|
||||
eth/p2p/discoveryv5/protocol as discv5_protocol,
|
||||
../network/history/[accumulator, history_content],
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator],
|
||||
../database/content_db
|
||||
|
||||
proc localAddress*(port: int): Address {.raises: [ValueError].} =
|
||||
|
|
|
@ -13,7 +13,8 @@ import
|
|||
eth/common/eth_types_rlp,
|
||||
eth/rlp,
|
||||
../network/wire/[portal_protocol, portal_stream, portal_protocol_config],
|
||||
../network/history/[history_network, accumulator, history_content],
|
||||
../network/history/
|
||||
[history_network, history_content, validation/historical_hashes_accumulator],
|
||||
../database/content_db,
|
||||
./test_helpers
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
{.push raises: [].}
|
||||
|
||||
import
|
||||
results, eth/common/eth_types_rlp, ../network/history/[history_content, accumulator]
|
||||
results,
|
||||
eth/common/eth_types_rlp,
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator]
|
||||
|
||||
export results, accumulator, history_content
|
||||
export results, historical_hashes_accumulator, history_content
|
||||
|
||||
proc buildHeadersWithProof*(
|
||||
blockHeaders: seq[BlockHeader], epochRecord: EpochRecordCached
|
||||
|
|
|
@ -50,7 +50,7 @@ import
|
|||
snappy,
|
||||
ncli/e2store,
|
||||
../../premix/[downloader, parser],
|
||||
../network/history/[history_content, accumulator],
|
||||
../network/history/[history_content, validation/historical_hashes_accumulator],
|
||||
../eth_data/[history_data_json_store, history_data_ssz_e2s, era1],
|
||||
eth_data_exporter/[exporter_conf, exporter_common, cl_data_exporter]
|
||||
|
||||
|
@ -200,7 +200,7 @@ proc cmdExportEra1(config: ExporterConf) =
|
|||
var group = Era1Group.init(e2, startNumber).get()
|
||||
|
||||
# Header records to build the accumulator root
|
||||
var headerRecords: seq[accumulator.HeaderRecord]
|
||||
var headerRecords: seq[historical_hashes_accumulator.HeaderRecord]
|
||||
for blockNumber in startNumber .. endNumber:
|
||||
let blck =
|
||||
try:
|
||||
|
@ -220,7 +220,7 @@ proc cmdExportEra1(config: ExporterConf) =
|
|||
break writeFileBlock
|
||||
|
||||
headerRecords.add(
|
||||
accumulator.HeaderRecord(
|
||||
historical_hashes_accumulator.HeaderRecord(
|
||||
blockHash: blck.header.blockHash(), totalDifficulty: ttd
|
||||
)
|
||||
)
|
||||
|
|
|
@ -20,8 +20,8 @@ import
|
|||
beacon_chain/beacon_clock,
|
||||
../../network/beacon/beacon_content,
|
||||
../../network/beacon/beacon_init_loader,
|
||||
../../network/history/beacon_chain_block_proof_bellatrix,
|
||||
../../network/history/experimental/beacon_chain_block_proof_capella,
|
||||
../../network/history/validation/block_proof_historical_roots,
|
||||
../../network/history/validation/block_proof_historical_summaries,
|
||||
../../network_metadata,
|
||||
../../eth_data/[yaml_utils, yaml_eth_types],
|
||||
./exporter_common
|
||||
|
@ -295,9 +295,9 @@ proc exportBeaconBlockProofBellatrix(
|
|||
let yamlTestProof = YamlTestProofBellatrix(
|
||||
execution_block_header:
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(),
|
||||
beacon_block_proof: blockProof.beaconBlockProof.toHex(array[11, string]),
|
||||
beacon_block_proof: blockProof.executionBlockProof.toHex(array[11, string]),
|
||||
beacon_block_root: blockProof.beaconBlockRoot.data.to0xHex(),
|
||||
historical_roots_proof: blockProof.historicalRootsProof.toHex(array[14, string]),
|
||||
historical_roots_proof: blockProof.beaconBlockProof.toHex(array[14, string]),
|
||||
slot: blockProof.slot.uint64,
|
||||
)
|
||||
|
||||
|
@ -405,7 +405,7 @@ proc exportBeaconBlockProofCapella(
|
|||
quit QuitFailure
|
||||
|
||||
blockRoots = getStateField(state, block_roots).data
|
||||
blockProof = beacon_chain_block_proof_capella.buildProof(
|
||||
blockProof = block_proof_historical_summaries.buildProof(
|
||||
blockRoots, beaconBlock.message
|
||||
).valueOr:
|
||||
error "Failed to build proof for Bellatrix block", slot, error
|
||||
|
@ -414,10 +414,9 @@ proc exportBeaconBlockProofCapella(
|
|||
let yamlTestProof = YamlTestProof(
|
||||
execution_block_header:
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(),
|
||||
beacon_block_proof: blockProof.beaconBlockProof.toHex(array[11, string]),
|
||||
beacon_block_proof: blockProof.executionBlockProof.toHex(array[11, string]),
|
||||
beacon_block_root: blockProof.beaconBlockRoot.data.to0xHex(),
|
||||
historical_summaries_proof:
|
||||
blockProof.historicalSummariesProof.toHex(array[13, string]),
|
||||
historical_summaries_proof: blockProof.beaconBlockProof.toHex(array[13, string]),
|
||||
slot: blockProof.slot.uint64,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue