attempt to fix ci
This commit is contained in:
parent
231e56d59b
commit
490d8964aa
|
@ -344,7 +344,7 @@ type
|
||||||
template OnBlockAddedCallback*(kind: static ConsensusFork): auto =
|
template OnBlockAddedCallback*(kind: static ConsensusFork): auto =
|
||||||
when kind == ConsensusFork.Fulu:
|
when kind == ConsensusFork.Fulu:
|
||||||
typedesc[OnFuluBlockAdded]
|
typedesc[OnFuluBlockAdded]
|
||||||
when kind == ConsensusFork.Electra:
|
elif kind == ConsensusFork.Electra:
|
||||||
typedesc[OnElectraBlockAdded]
|
typedesc[OnElectraBlockAdded]
|
||||||
elif kind == ConsensusFork.Deneb:
|
elif kind == ConsensusFork.Deneb:
|
||||||
typedesc[OnDenebBlockAdded]
|
typedesc[OnDenebBlockAdded]
|
||||||
|
|
|
@ -248,6 +248,8 @@ proc installApiHandlers*(node: SigningNodeRef) =
|
||||||
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||||
|
of ConsensusFork.Fulu:
|
||||||
|
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||||
|
|
||||||
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
||||||
return errorResponse(Http400, MissingMerkleProofError)
|
return errorResponse(Http400, MissingMerkleProofError)
|
||||||
|
|
|
@ -168,6 +168,9 @@ func noRollback*(state: var deneb.HashedBeaconState) =
|
||||||
func noRollback*(state: var electra.HashedBeaconState) =
|
func noRollback*(state: var electra.HashedBeaconState) =
|
||||||
trace "Skipping rollback of broken Electra state"
|
trace "Skipping rollback of broken Electra state"
|
||||||
|
|
||||||
|
func noRollback*(state: var fulu.HashedBeaconState) =
|
||||||
|
trace "Skipping rollback of broken Fulu state"
|
||||||
|
|
||||||
func maybeUpgradeStateToAltair(
|
func maybeUpgradeStateToAltair(
|
||||||
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
|
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
|
||||||
# Both process_slots() and state_transition_block() call this, so only run it
|
# Both process_slots() and state_transition_block() call this, so only run it
|
||||||
|
|
|
@ -144,6 +144,50 @@ proc makeSimulationBlock(
|
||||||
|
|
||||||
ok(blck)
|
ok(blck)
|
||||||
|
|
||||||
|
proc makeSimulationBlock(
|
||||||
|
cfg: RuntimeConfig,
|
||||||
|
state: var fulu.HashedBeaconState,
|
||||||
|
proposer_index: ValidatorIndex,
|
||||||
|
randao_reveal: ValidatorSig,
|
||||||
|
eth1_data: Eth1Data,
|
||||||
|
graffiti: GraffitiBytes,
|
||||||
|
attestations: seq[electra.Attestation],
|
||||||
|
deposits: seq[Deposit],
|
||||||
|
exits: BeaconBlockValidatorChanges,
|
||||||
|
sync_aggregate: SyncAggregate,
|
||||||
|
execution_payload: fulu.ExecutionPayloadForSigning,
|
||||||
|
bls_to_execution_changes: SignedBLSToExecutionChangeList,
|
||||||
|
rollback: RollbackHashedProc[fulu.HashedBeaconState],
|
||||||
|
cache: var StateCache,
|
||||||
|
# TODO:
|
||||||
|
# `verificationFlags` is needed only in tests and can be
|
||||||
|
# removed if we don't use invalid signatures there
|
||||||
|
verificationFlags: UpdateFlags = {}): Result[fulu.BeaconBlock, cstring] =
|
||||||
|
## Create a block for the given state. The latest block applied to it will
|
||||||
|
## be used for the parent_root value, and the slot will be take from
|
||||||
|
## state.slot meaning process_slots must be called up to the slot for which
|
||||||
|
## the block is to be created.
|
||||||
|
|
||||||
|
# To create a block, we'll first apply a partial block to the state, skipping
|
||||||
|
# some validations.
|
||||||
|
|
||||||
|
var blck = partialBeaconBlock(
|
||||||
|
cfg, state, proposer_index, randao_reveal, eth1_data, graffiti,
|
||||||
|
attestations, deposits, exits, sync_aggregate, execution_payload,
|
||||||
|
default(ExecutionRequests))
|
||||||
|
|
||||||
|
let res = process_block(
|
||||||
|
cfg, state.data, blck.asSigVerified(), verificationFlags, cache)
|
||||||
|
|
||||||
|
if res.isErr:
|
||||||
|
rollback(state)
|
||||||
|
return err(res.error())
|
||||||
|
|
||||||
|
state.root = hash_tree_root(state.data)
|
||||||
|
blck.state_root = state.root
|
||||||
|
|
||||||
|
ok(blck)
|
||||||
|
|
||||||
# TODO confutils is an impenetrable black box. how can a help text be added here?
|
# TODO confutils is an impenetrable black box. how can a help text be added here?
|
||||||
cli do(slots = SLOTS_PER_EPOCH * 7,
|
cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
validators = SLOTS_PER_EPOCH * 500,
|
validators = SLOTS_PER_EPOCH * 500,
|
||||||
|
@ -369,6 +413,8 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
addr state.denebData
|
addr state.denebData
|
||||||
elif T is electra.SignedBeaconBlock:
|
elif T is electra.SignedBeaconBlock:
|
||||||
addr state.electraData
|
addr state.electraData
|
||||||
|
elif T is fulu.SignedBeaconBlock:
|
||||||
|
addr state.fuluData
|
||||||
else:
|
else:
|
||||||
static: doAssert false
|
static: doAssert false
|
||||||
message = makeSimulationBlock(
|
message = makeSimulationBlock(
|
||||||
|
@ -383,6 +429,8 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
default(GraffitiBytes),
|
default(GraffitiBytes),
|
||||||
when T is electra.SignedBeaconBlock:
|
when T is electra.SignedBeaconBlock:
|
||||||
attPool.getElectraAttestationsForBlock(state, cache)
|
attPool.getElectraAttestationsForBlock(state, cache)
|
||||||
|
elif T is fulu.SignedBeaconBlock:
|
||||||
|
attPool.getElectraAttestationsForBlock(state, cache)
|
||||||
else:
|
else:
|
||||||
attPool.getAttestationsForBlock(state, cache),
|
attPool.getAttestationsForBlock(state, cache),
|
||||||
eth1ProposalData.deposits,
|
eth1ProposalData.deposits,
|
||||||
|
@ -390,6 +438,8 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
(when T is electra.SignedBeaconBlock:
|
(when T is electra.SignedBeaconBlock:
|
||||||
default(electra.ExecutionPayloadForSigning)
|
default(electra.ExecutionPayloadForSigning)
|
||||||
|
elif T is fulu.SignedBeaconBlock:
|
||||||
|
default(fulu.ExecutionPayloadForSigning)
|
||||||
elif T is deneb.SignedBeaconBlock:
|
elif T is deneb.SignedBeaconBlock:
|
||||||
default(deneb.ExecutionPayloadForSigning)
|
default(deneb.ExecutionPayloadForSigning)
|
||||||
else:
|
else:
|
||||||
|
@ -461,6 +511,28 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
do:
|
do:
|
||||||
raiseAssert "withUpdatedState failed"
|
raiseAssert "withUpdatedState failed"
|
||||||
|
|
||||||
|
proc proposeFuluBlock(slot: Slot) =
|
||||||
|
if rand(r, 1.0) > blockRatio:
|
||||||
|
return
|
||||||
|
|
||||||
|
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
|
||||||
|
let
|
||||||
|
newBlock = getNewBlock[fulu.SignedBeaconBlock](updatedState, slot, cache)
|
||||||
|
added = dag.addHeadBlock(verifier, newBlock) do (
|
||||||
|
blckRef: BlockRef, signedBlock: fulu.TrustedSignedBeaconBlock,
|
||||||
|
epochRef: EpochRef, unrealized: FinalityCheckpoints):
|
||||||
|
# Callback add to fork choice if valid
|
||||||
|
attPool.addForkChoice(
|
||||||
|
epochRef, blckRef, unrealized, signedBlock.message,
|
||||||
|
blckRef.slot.start_beacon_time)
|
||||||
|
|
||||||
|
dag.updateHead(added[], quarantine[], [])
|
||||||
|
if dag.needStateCachesAndForkChoicePruning():
|
||||||
|
dag.pruneStateCachesDAG()
|
||||||
|
attPool.prune()
|
||||||
|
do:
|
||||||
|
raiseAssert "withUpdatedState failed"
|
||||||
|
|
||||||
var
|
var
|
||||||
lastEth1BlockAt = genesisTime
|
lastEth1BlockAt = genesisTime
|
||||||
eth1BlockNum = 1000
|
eth1BlockNum = 1000
|
||||||
|
@ -501,6 +573,7 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
if blockRatio > 0.0:
|
if blockRatio > 0.0:
|
||||||
withTimer(timers[t]):
|
withTimer(timers[t]):
|
||||||
case dag.cfg.consensusForkAtEpoch(slot.epoch)
|
case dag.cfg.consensusForkAtEpoch(slot.epoch)
|
||||||
|
of ConsensusFork.Fulu: proposeFuluBlock(slot)
|
||||||
of ConsensusFork.Electra: proposeElectraBlock(slot)
|
of ConsensusFork.Electra: proposeElectraBlock(slot)
|
||||||
of ConsensusFork.Deneb: proposeDenebBlock(slot)
|
of ConsensusFork.Deneb: proposeDenebBlock(slot)
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Capella:
|
of ConsensusFork.Phase0 .. ConsensusFork.Capella:
|
||||||
|
|
|
@ -19,7 +19,7 @@ import
|
||||||
../../../beacon_chain/spec/datatypes/[
|
../../../beacon_chain/spec/datatypes/[
|
||||||
altair,
|
altair,
|
||||||
deneb,
|
deneb,
|
||||||
eip7594],
|
fulu],
|
||||||
# Status libraries
|
# Status libraries
|
||||||
snappy,
|
snappy,
|
||||||
# Test utilities
|
# Test utilities
|
||||||
|
|
|
@ -47,6 +47,13 @@ func readValue*(r: var JsonReader, a: var seq[byte]) =
|
||||||
func genesisTestRuntimeConfig*(consensusFork: ConsensusFork): RuntimeConfig =
|
func genesisTestRuntimeConfig*(consensusFork: ConsensusFork): RuntimeConfig =
|
||||||
var res = defaultRuntimeConfig
|
var res = defaultRuntimeConfig
|
||||||
case consensusFork
|
case consensusFork
|
||||||
|
of ConsensusFork.Fulu:
|
||||||
|
res.FULU_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.ELECTRA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.CAPELLA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.BELLATRIX_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
res.ALTAIR_FORK_EPOCH = GENESIS_EPOCH
|
||||||
of ConsensusFork.Electra:
|
of ConsensusFork.Electra:
|
||||||
res.ELECTRA_FORK_EPOCH = GENESIS_EPOCH
|
res.ELECTRA_FORK_EPOCH = GENESIS_EPOCH
|
||||||
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
res.DENEB_FORK_EPOCH = GENESIS_EPOCH
|
||||||
|
|
|
@ -15,7 +15,7 @@ import
|
||||||
kzg4844/[kzg_abi, kzg],
|
kzg4844/[kzg_abi, kzg],
|
||||||
./consensus_spec/[os_ops, fixtures_utils],
|
./consensus_spec/[os_ops, fixtures_utils],
|
||||||
../beacon_chain/spec/[helpers, eip7594_helpers],
|
../beacon_chain/spec/[helpers, eip7594_helpers],
|
||||||
../beacon_chain/spec/datatypes/[eip7594, deneb]
|
../beacon_chain/spec/datatypes/[fulu, deneb]
|
||||||
|
|
||||||
from std/strutils import rsplit
|
from std/strutils import rsplit
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,9 @@ proc addTestBlock*(
|
||||||
deposit_count: forkyState.data.eth1_deposit_index + deposits.lenu64,
|
deposit_count: forkyState.data.eth1_deposit_index + deposits.lenu64,
|
||||||
block_hash: eth1_data.block_hash),
|
block_hash: eth1_data.block_hash),
|
||||||
graffiti,
|
graffiti,
|
||||||
when consensusFork == ConsensusFork.Electra or
|
when consensusFork == ConsensusFork.Electra:
|
||||||
consensusFork == ConsensusFork.Fulu:
|
electraAttestations
|
||||||
|
elif consensusFork == ConsensusFork.Fulu:
|
||||||
electraAttestations
|
electraAttestations
|
||||||
else:
|
else:
|
||||||
attestations,
|
attestations,
|
||||||
|
|
|
@ -79,7 +79,7 @@ proc getTestStates*(
|
||||||
info = ForkedEpochInfo()
|
info = ForkedEpochInfo()
|
||||||
cfg = defaultRuntimeConfig
|
cfg = defaultRuntimeConfig
|
||||||
|
|
||||||
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
static: doAssert high(ConsensusFork) == ConsensusFork.Fulu
|
||||||
if consensusFork >= ConsensusFork.Altair:
|
if consensusFork >= ConsensusFork.Altair:
|
||||||
cfg.ALTAIR_FORK_EPOCH = 1.Epoch
|
cfg.ALTAIR_FORK_EPOCH = 1.Epoch
|
||||||
if consensusFork >= ConsensusFork.Bellatrix:
|
if consensusFork >= ConsensusFork.Bellatrix:
|
||||||
|
@ -90,6 +90,8 @@ proc getTestStates*(
|
||||||
cfg.DENEB_FORK_EPOCH = 4.Epoch
|
cfg.DENEB_FORK_EPOCH = 4.Epoch
|
||||||
if consensusFork >= ConsensusFork.Electra:
|
if consensusFork >= ConsensusFork.Electra:
|
||||||
cfg.ELECTRA_FORK_EPOCH = 5.Epoch
|
cfg.ELECTRA_FORK_EPOCH = 5.Epoch
|
||||||
|
if consensusFork >= ConsensusFork.Fulu:
|
||||||
|
cfg.ELECTRA_FORK_EPOCH = 6.Epoch
|
||||||
|
|
||||||
for i, epoch in stateEpochs:
|
for i, epoch in stateEpochs:
|
||||||
let slot = epoch.Epoch.start_slot
|
let slot = epoch.Epoch.start_slot
|
||||||
|
@ -109,7 +111,8 @@ from std/sequtils import allIt
|
||||||
from ".."/beacon_chain/spec/beaconstate import get_expected_withdrawals
|
from ".."/beacon_chain/spec/beaconstate import get_expected_withdrawals
|
||||||
|
|
||||||
proc checkPerValidatorBalanceCalc*(
|
proc checkPerValidatorBalanceCalc*(
|
||||||
state: deneb.BeaconState | electra.BeaconState): bool =
|
state: deneb.BeaconState | electra.BeaconState |
|
||||||
|
fulu.BeaconState): bool =
|
||||||
var
|
var
|
||||||
info: altair.EpochInfo
|
info: altair.EpochInfo
|
||||||
cache: StateCache
|
cache: StateCache
|
||||||
|
|
Loading…
Reference in New Issue