rm beacon_chain/spec/deposit_snapshots.nim
This commit is contained in:
parent
8f22b9454a
commit
796db86d66
|
@ -5,8 +5,7 @@ import
|
|||
serialization, snappy,
|
||||
eth/db/[kvstore, kvstore_sqlite3],
|
||||
./networking/network_metadata,
|
||||
./spec/[deposit_snapshots,
|
||||
eth2_ssz_serialization,
|
||||
./spec/[eth2_ssz_serialization,
|
||||
eth2_merkleization,
|
||||
forks,
|
||||
presets,
|
||||
|
@ -17,7 +16,7 @@ from ./spec/datatypes/capella import BeaconState
|
|||
from ./spec/datatypes/deneb import TrustedSignedBeaconBlock
|
||||
export
|
||||
eth2_ssz_serialization, eth2_merkleization, kvstore,
|
||||
kvstore_sqlite3, deposit_snapshots
|
||||
kvstore_sqlite3
|
||||
type
|
||||
DbSeq[T] = object
|
||||
insertStmt: SqliteStmt[openArray[byte], void]
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[options, unicode, uri],
|
||||
confutils, confutils/defs, confutils/std/net,
|
||||
stew/[io2, byteutils],
|
||||
json_serialization, web3/[primitives, confutils_defs],
|
||||
json_serialization,
|
||||
./spec/[keystore, crypto],
|
||||
./spec/datatypes/base,
|
||||
./networking/network_metadata
|
||||
|
@ -271,48 +269,6 @@ type
|
|||
desc: "SSZ file specifying the genesis state of the network (for networks without a built-in genesis state)"
|
||||
name: "genesis-state" .}: Option[InputFile]
|
||||
|
||||
genesisStateUrl* {.
|
||||
desc: "URL for obtaining the genesis state of the network (for networks without a built-in genesis state)"
|
||||
name: "genesis-state-url" .}: Option[Uri]
|
||||
|
||||
finalizedDepositTreeSnapshot* {.
|
||||
desc: "SSZ file specifying a recent finalized EIP-4881 deposit tree snapshot"
|
||||
name: "finalized-deposit-tree-snapshot" .}: Option[InputFile]
|
||||
|
||||
finalizedCheckpointBlock* {.
|
||||
hidden
|
||||
desc: "SSZ file specifying a recent finalized block"
|
||||
name: "finalized-checkpoint-block" .}: Option[InputFile]
|
||||
|
||||
nodeName* {.
|
||||
desc: "A name for this node that will appear in the logs. " &
|
||||
"If you set this to 'auto', a persistent automatically generated ID will be selected for each --data-dir folder"
|
||||
defaultValue: ""
|
||||
name: "node-name" .}: string
|
||||
|
||||
graffiti* {.
|
||||
desc: "The graffiti value that will appear in proposed blocks. " &
|
||||
"You can use a 0x-prefixed hex encoded string to specify raw bytes"
|
||||
name: "graffiti" .}: Option[GraffitiBytes]
|
||||
|
||||
strictVerification* {.
|
||||
hidden
|
||||
desc: "Specify whether to verify finalization occurs on schedule (debug only)"
|
||||
defaultValue: false
|
||||
name: "verify-finalization" .}: bool
|
||||
|
||||
stopAtEpoch* {.
|
||||
hidden
|
||||
desc: "The wall-time epoch at which to exit the program. (for testing purposes)"
|
||||
defaultValue: 0
|
||||
name: "debug-stop-at-epoch" .}: uint64
|
||||
|
||||
stopAtSyncedEpoch* {.
|
||||
hidden
|
||||
desc: "The synced epoch at which to exit the program. (for testing purposes)"
|
||||
defaultValue: 0
|
||||
name: "stop-at-synced-epoch" .}: uint64
|
||||
|
||||
AnyConf* = BeaconNodeConf
|
||||
|
||||
proc defaultDataDir*[Conf](config: Conf): string =
|
||||
|
|
|
@ -3,7 +3,6 @@ import
|
|||
chronos,
|
||||
stew/io2,
|
||||
./spec/datatypes/[altair, bellatrix, phase0],
|
||||
./spec/deposit_snapshots,
|
||||
./validators/[keystore_management, beacon_validators],
|
||||
"."/[
|
||||
beacon_node,
|
||||
|
@ -61,14 +60,6 @@ proc init*(T: type BeaconNode,
|
|||
else:
|
||||
nil
|
||||
|
||||
if config.finalizedDepositTreeSnapshot.isSome:
|
||||
let
|
||||
depositTreeSnapshotPath = config.finalizedDepositTreeSnapshot.get.string
|
||||
discard try:
|
||||
SSZ.loadFile(depositTreeSnapshotPath, DepositTreeSnapshot)
|
||||
except CatchableError:
|
||||
quit 1
|
||||
|
||||
var networkGenesisValidatorsRoot = metadata.bakedGenesisValidatorsRoot
|
||||
|
||||
var genesisState = checkpointState
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018-2024 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).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
from stew/objects import isZeroMemory
|
||||
|
||||
import ./eth2_merkleization
|
||||
from ./datatypes/base import Eth1Data, DepositContractState
|
||||
from ./digest import Eth2Digest
|
||||
|
||||
export
|
||||
depositCountBytes, depositCountU64
|
||||
|
||||
type
|
||||
OldDepositContractSnapshot* = object
|
||||
eth1Block*: Eth2Digest
|
||||
depositContractState*: DepositContractState
|
||||
|
||||
DepositTreeSnapshot* = object
|
||||
## https://eips.ethereum.org/EIPS/eip-4881
|
||||
eth1Block*: Eth2Digest
|
||||
depositContractState*: DepositContractState
|
||||
blockHeight*: uint64
|
||||
|
||||
func toDepositTreeSnapshot*(d: OldDepositContractSnapshot,
|
||||
blockHeight: uint64): DepositTreeSnapshot =
|
||||
DepositTreeSnapshot(
|
||||
eth1Block: d.eth1Block,
|
||||
depositContractState: d.depositContractState,
|
||||
blockHeight: blockHeight)
|
||||
|
||||
func toOldDepositContractSnapshot*(d: DepositTreeSnapshot): OldDepositContractSnapshot =
|
||||
OldDepositContractSnapshot(eth1Block: d.eth1Block,
|
||||
depositContractState: d.depositContractState)
|
||||
|
||||
template getDepositCountU64*(d: OldDepositContractSnapshot |
|
||||
DepositTreeSnapshot): uint64 =
|
||||
depositCountU64(d.depositContractState.deposit_count)
|
||||
|
||||
func getDepositRoot*(d: OldDepositContractSnapshot |
|
||||
DepositTreeSnapshot): Eth2Digest =
|
||||
var merk = DepositsMerkleizer.init(d.depositContractState)
|
||||
let hash = merk.getFinalHash()
|
||||
# TODO: mixInLength should accept unsigned int instead of int as
|
||||
# this right now cuts in half the theoretical number of deposits.
|
||||
return mixInLength(hash, int(merk.getChunkCount()))
|
||||
|
||||
func isValid*(d: DepositTreeSnapshot, wantedDepositRoot: Eth2Digest): bool =
|
||||
## `isValid` requires the snapshot to be self-consistent and
|
||||
## to point to a specific Ethereum block
|
||||
return not (d.eth1Block.isZeroMemory or
|
||||
d.blockHeight == 0 or
|
||||
d.getDepositRoot() != wantedDepositRoot)
|
||||
|
||||
func matches*(snapshot: DepositTreeSnapshot, eth1_data: Eth1Data): bool =
|
||||
snapshot.getDepositCountU64() == eth1_data.deposit_count and
|
||||
snapshot.getDepositRoot() == eth1_data.deposit_root
|
Loading…
Reference in New Issue