rm unused code/type conversoins; re-enable Electra block gossip verification (#6545)
This commit is contained in:
parent
da48c6f3f4
commit
16c21e1c1e
|
@ -559,9 +559,7 @@ proc new*(T: type BeaconChainDB,
|
|||
sealedPeriods: "lc_sealed_periods")).expectDb()
|
||||
static: doAssert LightClientDataFork.high == LightClientDataFork.Electra
|
||||
|
||||
var blobs : KvStoreRef
|
||||
if cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH:
|
||||
blobs = kvStore db.openKvStore("deneb_blobs").expectDb()
|
||||
var blobs = kvStore db.openKvStore("deneb_blobs").expectDb()
|
||||
|
||||
# Versions prior to 1.4.0 (altair) stored validators in `immutable_validators`
|
||||
# which stores validator keys in compressed format - this is
|
||||
|
|
|
@ -276,10 +276,6 @@ template checkedReject(
|
|||
pool: ValidatorChangePool, error: ValidationError): untyped =
|
||||
pool.dag.checkedReject(error)
|
||||
|
||||
template checkedResult(
|
||||
pool: ValidatorChangePool, error: ValidationError): untyped =
|
||||
pool.dag.checkedResult(error)
|
||||
|
||||
template validateBeaconBlockBellatrix(
|
||||
signed_beacon_block: phase0.SignedBeaconBlock | altair.SignedBeaconBlock,
|
||||
parent: BlockRef): untyped =
|
||||
|
@ -483,7 +479,7 @@ proc validateBlobSidecar*(
|
|||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#beacon_block
|
||||
proc validateBeaconBlock*(
|
||||
dag: ChainDAGRef, quarantine: ref Quarantine,
|
||||
signed_beacon_block: phase0.SignedBeaconBlock | altair.SignedBeaconBlock | bellatrix.SignedBeaconBlock | capella.SignedBeaconBlock | deneb.SignedBeaconBlock,
|
||||
signed_beacon_block: ForkySignedBeaconBlock,
|
||||
wallTime: BeaconTime, flags: UpdateFlags): Result[void, ValidationError] =
|
||||
# In general, checks are ordered from cheap to expensive. Especially, crypto
|
||||
# verification could be quite a bit more expensive than the rest. This is an
|
||||
|
@ -673,13 +669,6 @@ proc validateBeaconBlock*(
|
|||
|
||||
ok()
|
||||
|
||||
proc validateBeaconBlock*(
|
||||
dag: ChainDAGRef, quarantine: ref Quarantine,
|
||||
signed_beacon_block: electra.SignedBeaconBlock,
|
||||
wallTime: BeaconTime, flags: UpdateFlags): Result[void, ValidationError] =
|
||||
debugComment "it's sometimes not"
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof
|
||||
proc validateAttestation*(
|
||||
|
@ -897,9 +886,7 @@ proc validateAttestation*(
|
|||
attestation = shortLog(attestation), target = shortLog(target)
|
||||
return errIgnore("Attestation: no shuffling")
|
||||
|
||||
let
|
||||
fork = pool.dag.forkAtEpoch(attestation.data.slot.epoch)
|
||||
attesting_index = get_attesting_indices_one(
|
||||
let attesting_index = get_attesting_indices_one(
|
||||
shufflingRef, slot, attestation.committee_bits,
|
||||
attestation.aggregation_bits, false)
|
||||
|
||||
|
@ -1177,11 +1164,8 @@ proc validateAggregate*(
|
|||
"Attestation: committee index not within expected range")
|
||||
idx.get()
|
||||
let
|
||||
fork = pool.dag.forkAtEpoch(aggregate.data.slot.epoch)
|
||||
attesting_indices = get_attesting_indices(
|
||||
shufflingRef, slot, committee_index, aggregate.aggregation_bits, false)
|
||||
|
||||
let
|
||||
sig =
|
||||
aggregate.signature.load().valueOr:
|
||||
return pool.checkedReject("Aggregate: unable to load signature")
|
||||
|
|
|
@ -269,7 +269,7 @@ when const_preset == "gnosis":
|
|||
for network in [gnosisMetadata, chiadoMetadata]:
|
||||
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
||||
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
||||
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||
doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||
|
||||
elif const_preset == "mainnet":
|
||||
when incbinEnabled:
|
||||
|
@ -321,7 +321,7 @@ elif const_preset == "mainnet":
|
|||
for network in [mainnetMetadata, sepoliaMetadata, holeskyMetadata]:
|
||||
doAssert network.cfg.DENEB_FORK_EPOCH < FAR_FUTURE_EPOCH
|
||||
doAssert network.cfg.ELECTRA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
||||
static: doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||
doAssert ConsensusFork.high == ConsensusFork.Electra
|
||||
|
||||
proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata =
|
||||
template loadRuntimeMetadata(): auto =
|
||||
|
|
|
@ -2271,7 +2271,7 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai
|
|||
bnStatus = BeaconNodeStatus.Stopping
|
||||
c_signal(ansi_c.SIGTERM, SIGTERMHandler)
|
||||
|
||||
if metadata.cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH:
|
||||
block:
|
||||
let res =
|
||||
if config.trustedSetupFile.isNone:
|
||||
conf.loadKzgTrustedSetup()
|
||||
|
|
|
@ -122,7 +122,7 @@ proc publishBlockV3(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
|||
let
|
||||
maybeBlock =
|
||||
try:
|
||||
await vc.produceBlockV3(slot, randao_reveal, graffiti,
|
||||
await vc.produceBlockV3(slot, randaoReveal, graffiti,
|
||||
vc.config.builderBoostFactor,
|
||||
ApiStrategyKind.Best)
|
||||
except ValidatorApiError as exc:
|
||||
|
|
|
@ -150,7 +150,6 @@ proc serveContributionAndProof*(service: SyncCommitteeServiceRef,
|
|||
vc = service.client
|
||||
startTime = Moment.now()
|
||||
slot = proof.contribution.slot
|
||||
validatorIdx = validator.index.get()
|
||||
genesisRoot = vc.beaconGenesis.genesis_validators_root
|
||||
fork = vc.forkAtEpoch(slot.epoch)
|
||||
|
||||
|
|
|
@ -22,17 +22,11 @@ import
|
|||
./logtrace
|
||||
|
||||
from std/os import changeFileExt, fileExists
|
||||
from std/sequtils import mapIt, toSeq
|
||||
from std/times import toUnix
|
||||
from ../beacon_chain/el/engine_api_conversions import asEth2Digest
|
||||
from ../beacon_chain/spec/beaconstate import initialize_beacon_state_from_eth1
|
||||
from ../tests/mocking/mock_genesis import mockEth1BlockHash
|
||||
|
||||
# Compiled version of /scripts/depositContract.v.py in this repo
|
||||
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
|
||||
const depositContractCode =
|
||||
hexToSeqByte staticRead "../beacon_chain/el/deposit_contract_code.txt"
|
||||
|
||||
# For nim-confutils, which uses this kind of init(Type, value) pattern
|
||||
func init(T: type IpAddress, ip: IpAddress): T = ip
|
||||
|
||||
|
@ -389,19 +383,6 @@ proc createEnr(rng: var HmacDrbgContext,
|
|||
])
|
||||
bootstrapEnr.tryGet()
|
||||
|
||||
proc doCreateTestnetEnr(config: CliConfig,
|
||||
rng: var HmacDrbgContext)
|
||||
{.raises: [CatchableError].} =
|
||||
let
|
||||
cfg = getRuntimeConfig(config.eth2Network)
|
||||
bootstrapEnr = parseBootstrapAddress(toSeq(lines(string config.inputBootstrapEnr))[0]).get()
|
||||
forkIdField = bootstrapEnr.tryGet(enrForkIdField, seq[byte]).get()
|
||||
enr =
|
||||
createEnr(rng, string config.enrDataDir, string config.enrNetKeyFile,
|
||||
config.enrNetKeyInsecurePassword, cfg, forkIdField,
|
||||
config.enrAddress, config.enrPort)
|
||||
stderr.writeLine(enr.toURI)
|
||||
|
||||
proc doCreateTestnet*(config: CliConfig,
|
||||
rng: var HmacDrbgContext)
|
||||
{.raises: [CatchableError].} =
|
||||
|
@ -504,6 +485,49 @@ proc doCreateTestnet*(config: CliConfig,
|
|||
writeFile(bootstrapFile, enr.toURI)
|
||||
echo "Wrote ", bootstrapFile
|
||||
|
||||
type
|
||||
DelayGenerator = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||
|
||||
func ethToWei(eth: UInt256): UInt256 =
|
||||
eth * 1000000000000000000.u256
|
||||
|
||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||
result = await newWeb3(web3Url)
|
||||
if privateKey.len != 0:
|
||||
result.privateKey = Opt.some(keys.PrivateKey.fromHex(privateKey)[])
|
||||
else:
|
||||
let accounts = await result.provider.eth_accounts()
|
||||
doAssert(accounts.len > 0)
|
||||
result.defaultAccount = accounts[0]
|
||||
|
||||
{.pop.} # TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
|
||||
|
||||
when isMainModule:
|
||||
import
|
||||
web3/confutils_defs,
|
||||
../beacon_chain/filepath
|
||||
|
||||
from std/sequtils import mapIt, toSeq
|
||||
from std/terminal import readPasswordFromStdin
|
||||
|
||||
# Compiled version of /scripts/depositContract.v.py in this repo
|
||||
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
|
||||
const depositContractCode =
|
||||
hexToSeqByte staticRead "../beacon_chain/el/deposit_contract_code.txt"
|
||||
|
||||
proc doCreateTestnetEnr(config: CliConfig,
|
||||
rng: var HmacDrbgContext)
|
||||
{.raises: [CatchableError].} =
|
||||
let
|
||||
cfg = getRuntimeConfig(config.eth2Network)
|
||||
bootstrapEnr = parseBootstrapAddress(toSeq(lines(string config.inputBootstrapEnr))[0]).get()
|
||||
forkIdField = bootstrapEnr.tryGet(enrForkIdField, seq[byte]).get()
|
||||
enr =
|
||||
createEnr(rng, string config.enrDataDir, string config.enrNetKeyFile,
|
||||
config.enrNetKeyInsecurePassword, cfg, forkIdField,
|
||||
config.enrAddress, config.enrPort)
|
||||
stderr.writeLine(enr.toURI)
|
||||
|
||||
proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} =
|
||||
let tr = TransactionArgs(
|
||||
`from`: Opt.some web3.defaultAccount,
|
||||
|
@ -527,21 +551,6 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
|
|||
to: Opt.some(to))
|
||||
web3.send(tr)
|
||||
|
||||
type
|
||||
DelayGenerator = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||
|
||||
func ethToWei(eth: UInt256): UInt256 =
|
||||
eth * 1000000000000000000.u256
|
||||
|
||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||
result = await newWeb3(web3Url)
|
||||
if privateKey.len != 0:
|
||||
result.privateKey = Opt.some(keys.PrivateKey.fromHex(privateKey)[])
|
||||
else:
|
||||
let accounts = await result.provider.eth_accounts()
|
||||
doAssert(accounts.len > 0)
|
||||
result.defaultAccount = accounts[0]
|
||||
|
||||
# TODO: async functions should note take `seq` inputs because
|
||||
# this leads to full copies.
|
||||
proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
||||
|
@ -567,7 +576,8 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
|||
SignatureBytes(@(dp.signature.toRaw())),
|
||||
FixedBytes[32](hash_tree_root(dp).data))
|
||||
|
||||
let status = await tx.send(value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||
let status = await tx.send(
|
||||
value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||
|
||||
info "Deposit sent", tx = $status
|
||||
|
||||
|
@ -579,15 +589,6 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
|||
await sleepAsync(chronos.seconds 60)
|
||||
web3 = await initWeb3(web3Url, privateKey)
|
||||
|
||||
{.pop.} # TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
|
||||
|
||||
when isMainModule:
|
||||
import
|
||||
web3/confutils_defs,
|
||||
../beacon_chain/filepath
|
||||
|
||||
from std/terminal import readPasswordFromStdin
|
||||
|
||||
proc main() {.async.} =
|
||||
var conf = try: CliConfig.load()
|
||||
except CatchableError as exc:
|
||||
|
|
|
@ -67,7 +67,7 @@ suite "Sync committee pool":
|
|||
nextPeriod = cfg.BELLATRIX_FORK_EPOCH.sync_committee_period + 1
|
||||
|
||||
bid1 = BlockId(
|
||||
slot: Slot(nextPeriod.start_slot - 2), # Committee based on `slot + 1`
|
||||
slot: nextPeriod.start_slot - 2, # Committee based on `slot + 1`
|
||||
root: eth2digest(@[1.byte]))
|
||||
|
||||
sig1 = get_sync_committee_message_signature(
|
||||
|
|
|
@ -226,7 +226,7 @@ func findValidatorIndexBruteforce(
|
|||
h2: ValidatorPubKey): Opt[ValidatorIndex] =
|
||||
for validatorIndex in bsv.extraItems:
|
||||
if validators[validatorIndex.distinctBase].pubkey == h2:
|
||||
return Opt.some validatorIndex.ValidatorIndex
|
||||
return Opt.some validatorIndex
|
||||
for validatorIndex in bsv.bucketSorted:
|
||||
if validators[validatorIndex].pubkey == h2:
|
||||
return Opt.some validatorIndex.ValidatorIndex
|
||||
|
|
Loading…
Reference in New Issue