`withUpdatedState` injects `updatedState` rather than `state` template (#4375)
This commit is contained in:
parent
7878e8083b
commit
474b0d8502
|
@ -749,9 +749,8 @@ func getAggregatedAttestation*(pool: var AttestationPool,
|
|||
index: CommitteeIndex): Opt[Attestation] =
|
||||
## Select the attestation that has the most votes going for it in the given
|
||||
## slot/index
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/validator.md#construct-aggregate
|
||||
let
|
||||
candidateIdx = pool.candidateIdx(slot)
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/validator.md#construct-aggregate
|
||||
let candidateIdx = pool.candidateIdx(slot)
|
||||
if candidateIdx.isNone:
|
||||
return Opt.none(Attestation)
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ type
|
|||
## committee messages will be rejected
|
||||
|
||||
optimisticRoots*: HashSet[Eth2Digest]
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/sync/optimistic.md#helpers
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/sync/optimistic.md#helpers
|
||||
|
||||
EpochKey* = object
|
||||
## The epoch key fully determines the shuffling for proposers and
|
||||
|
|
|
@ -76,7 +76,7 @@ template withUpdatedState*(
|
|||
var cache {.inject.} = StateCache()
|
||||
if updateState(dag, stateParam, bsi, false, cache):
|
||||
template bid(): BlockId {.inject, used.} = bsi.bid
|
||||
template state(): ForkedHashedBeaconState {.inject, used.} = stateParam
|
||||
template updatedState(): ForkedHashedBeaconState {.inject, used.} = stateParam
|
||||
okBody
|
||||
else:
|
||||
failureBody
|
||||
|
@ -710,7 +710,7 @@ proc currentSyncCommitteeForPeriod*(
|
|||
syncCommitteeSlot = max(periodStartSlot, lowSlot)
|
||||
bsi = ? dag.getBlockIdAtSlot(syncCommitteeSlot)
|
||||
dag.withUpdatedState(tmpState, bsi) do:
|
||||
withState(state):
|
||||
withState(updatedState):
|
||||
when stateFork >= BeaconStateFork.Altair:
|
||||
ok forkyState.data.current_sync_committee
|
||||
else: err()
|
||||
|
|
|
@ -121,7 +121,7 @@ proc syncCommitteeRootForPeriod(
|
|||
syncCommitteeSlot = max(periodStartSlot, lowSlot)
|
||||
bsi = ? dag.getExistingBlockIdAtSlot(syncCommitteeSlot)
|
||||
dag.withUpdatedExistingState(tmpState, bsi) do:
|
||||
withState(state):
|
||||
withState(updatedState):
|
||||
when stateFork >= BeaconStateFork.Altair:
|
||||
ok forkyState.syncCommitteeRoot
|
||||
else: raiseAssert "Unreachable"
|
||||
|
@ -324,7 +324,7 @@ proc initLightClientUpdateForPeriod(
|
|||
continue
|
||||
finalizedEpoch = block:
|
||||
dag.withUpdatedExistingState(tmpState[], attestedBid.atSlot) do:
|
||||
withState(state):
|
||||
withState(updatedState):
|
||||
when stateFork >= BeaconStateFork.Altair:
|
||||
forkyState.data.finalized_checkpoint.epoch
|
||||
else: raiseAssert "Unreachable"
|
||||
|
@ -356,7 +356,7 @@ proc initLightClientUpdateForPeriod(
|
|||
let bdata = dag.getExistingForkedBlock(bid).valueOr:
|
||||
dag.handleUnexpectedLightClientError(bid.slot)
|
||||
return err()
|
||||
withStateAndBlck(state, bdata):
|
||||
withStateAndBlck(updatedState, bdata):
|
||||
when stateFork >= BeaconStateFork.Altair:
|
||||
update.attested_header = blck.toBeaconBlockHeader()
|
||||
update.next_sync_committee = forkyState.data.next_sync_committee
|
||||
|
@ -851,7 +851,7 @@ proc getLightClientBootstrap*(
|
|||
let bsi = ? dag.getExistingBlockIdAtSlot(slot)
|
||||
var tmpState = assignClone(dag.headState)
|
||||
dag.withUpdatedExistingState(tmpState[], bsi) do:
|
||||
branch = withState(state):
|
||||
branch = withState(updatedState):
|
||||
when stateFork >= BeaconStateFork.Altair:
|
||||
forkyState.data.build_proof(
|
||||
altair.CURRENT_SYNC_COMMITTEE_INDEX).get
|
||||
|
|
|
@ -584,7 +584,7 @@ proc processBlock(
|
|||
# - MUST NOT optimistically import the block.
|
||||
# - MUST NOT apply the block to the fork choice store.
|
||||
# - MAY queue the block for later processing.
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/sync/optimistic.md#execution-engine-errors
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/sync/optimistic.md#execution-engine-errors
|
||||
await sleepAsync(chronos.seconds(1))
|
||||
self[].addBlock(
|
||||
entry.src, entry.blck, entry.resfut, entry.validationDur)
|
||||
|
|
|
@ -2536,7 +2536,7 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
|
|||
debug "Stability subnets changed; updated ENR attnets", attnets
|
||||
|
||||
proc updateSyncnetsMetadata*(node: Eth2Node, syncnets: SyncnetBits) =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
if node.metadata.syncnets == syncnets:
|
||||
return
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ proc installNimbusApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
proposalState[],
|
||||
head.atSlot(wallSlot).toBlockSlotId().expect("not nil")):
|
||||
return RestApiResponse.jsonResponse(
|
||||
node.getBlockProposalEth1Data(state))
|
||||
node.getBlockProposalEth1Data(updatedState))
|
||||
do:
|
||||
return RestApiResponse.jsonError(Http400, PrunedStateError)
|
||||
|
||||
|
|
|
@ -140,10 +140,10 @@ const
|
|||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/validator.md#broadcast-aggregate
|
||||
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#prepare-sync-committee-message
|
||||
syncCommitteeMessageSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
syncContributionSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||
|
|
|
@ -134,7 +134,7 @@ func initiate_validator_exit*(
|
|||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
func get_slashing_penalty*(state: ForkyBeaconState,
|
||||
validator_effective_balance: Gwei): Gwei =
|
||||
# TODO Consider whether this is better than splitting the functions apart; in
|
||||
|
@ -170,7 +170,7 @@ func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): G
|
|||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
proc slash_validator*(
|
||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||
slashed_index: ValidatorIndex, cache: var StateCache):
|
||||
|
|
|
@ -94,7 +94,7 @@ type
|
|||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||
aggregate_pubkey*: ValidatorPubKey
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#synccommitteemessage
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#synccommitteemessage
|
||||
SyncCommitteeMessage* = object
|
||||
slot*: Slot
|
||||
## Slot to which this contribution pertains
|
||||
|
@ -157,30 +157,30 @@ type
|
|||
NextSyncCommitteeBranch* =
|
||||
array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
||||
LightClientBootstrap* = object
|
||||
header*: BeaconBlockHeader
|
||||
## The requested beacon block header
|
||||
## Header matching the requested beacon block root
|
||||
|
||||
current_sync_committee*: SyncCommittee
|
||||
## Current sync committee corresponding to `header`
|
||||
## Current sync committee corresponding to `header.state_root`
|
||||
current_sync_committee_branch*: CurrentSyncCommitteeBranch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||
LightClientUpdate* = object
|
||||
attested_header*: BeaconBlockHeader
|
||||
## The beacon block header that is attested to by the sync committee
|
||||
## Header attested to by the sync committee
|
||||
|
||||
next_sync_committee*: SyncCommittee
|
||||
## Next sync committee corresponding to `attested_header`,
|
||||
## if signature is from current sync committee
|
||||
## Next sync committee corresponding to `attested_header.state_root`
|
||||
next_sync_committee_branch*: NextSyncCommitteeBranch
|
||||
|
||||
# The finalized beacon block header attested to by Merkle branch
|
||||
# Finalized header corresponding to `attested_header.state_root`
|
||||
finalized_header*: BeaconBlockHeader
|
||||
finality_branch*: FinalityBranch
|
||||
|
||||
sync_aggregate*: SyncAggregate
|
||||
## Sync committee aggregate signature
|
||||
signature_slot*: Slot
|
||||
## Slot at which the aggregate signature was created (untrusted)
|
||||
|
||||
|
@ -224,13 +224,13 @@ type
|
|||
LightClientBootstrap |
|
||||
SomeLightClientUpdate
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#lightclientstore
|
||||
LightClientStore* = object
|
||||
finalized_header*: BeaconBlockHeader
|
||||
## Beacon block header that is finalized
|
||||
## Header that is finalized
|
||||
|
||||
current_sync_committee*: SyncCommittee
|
||||
## Sync committees corresponding to the header
|
||||
## Sync committees corresponding to the finalized header
|
||||
next_sync_committee*: SyncCommittee
|
||||
|
||||
best_valid_update*: Option[LightClientUpdate]
|
||||
|
|
|
@ -32,7 +32,7 @@ const
|
|||
FORKCHOICEUPDATED_TIMEOUT* = 8.seconds
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#custom-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#custom-types
|
||||
Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION]
|
||||
|
||||
ExecutionAddress* = object
|
||||
|
@ -43,7 +43,7 @@ type
|
|||
|
||||
PayloadID* = array[8, byte]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
parent_hash*: Eth2Digest
|
||||
fee_recipient*: ExecutionAddress # 'beneficiary' in the yellow paper
|
||||
|
@ -62,7 +62,7 @@ type
|
|||
block_hash*: Eth2Digest # Hash of execution block
|
||||
transactions*: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#executionpayloadheader
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#executionpayloadheader
|
||||
ExecutionPayloadHeader* = object
|
||||
parent_hash*: Eth2Digest
|
||||
fee_recipient*: ExecutionAddress
|
||||
|
@ -84,7 +84,7 @@ type
|
|||
ExecutePayload* = proc(
|
||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/fork-choice.md#powblock
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/fork-choice.md#powblock
|
||||
PowBlock* = object
|
||||
block_hash*: Eth2Digest
|
||||
parent_hash*: Eth2Digest
|
||||
|
|
|
@ -43,7 +43,7 @@ type
|
|||
from_bls_pubkey*: ValidatorPubKey
|
||||
to_execution_address*: ExecutionAddress
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#signedblstoexecutionchange
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#signedblstoexecutionchange
|
||||
SignedBLSToExecutionChange* = object
|
||||
message*: BLSToExecutionChange
|
||||
signature*: ValidatorSig
|
||||
|
@ -220,7 +220,7 @@ type
|
|||
state_root*: Eth2Digest
|
||||
body*: TrustedBeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#beaconblockbody
|
||||
BeaconBlockBody* = object
|
||||
randao_reveal*: ValidatorSig
|
||||
eth1_data*: Eth1Data
|
||||
|
|
|
@ -10,7 +10,7 @@ type
|
|||
Epoch* = distinct uint64
|
||||
SyncCommitteePeriod* = distinct uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#custom-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#custom-types
|
||||
WithdrawalIndex* = uint64
|
||||
|
||||
DomainType* = distinct array[4, byte]
|
||||
|
|
|
@ -216,7 +216,7 @@ template is_finality_update*(update: SomeLightClientUpdate): bool =
|
|||
else:
|
||||
false
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
||||
template is_next_sync_committee_known*(store: LightClientStore): bool =
|
||||
not isZeroMemory(store.next_sync_committee)
|
||||
|
||||
|
@ -327,7 +327,7 @@ func is_merge_transition_complete*(
|
|||
default(typeof(state.latest_execution_payload_header))
|
||||
state.latest_execution_payload_header != defaultExecutionPayloadHeader
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/sync/optimistic.md#helpers
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/sync/optimistic.md#helpers
|
||||
func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
||||
when typeof(blck).toFork >= BeaconBlockFork.Bellatrix:
|
||||
const defaultExecutionPayload =
|
||||
|
|
|
@ -187,7 +187,7 @@ func getTargetGossipState*(
|
|||
raiseAssert "Unknown target gossip state"
|
||||
|
||||
func nearSyncCommitteePeriod*(epoch: Epoch): Option[uint64] =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
if epoch.is_sync_committee_period():
|
||||
return some 0'u64
|
||||
let epochsBefore =
|
||||
|
@ -206,7 +206,7 @@ func getSyncSubnets*(
|
|||
if not nodeHasPubkey(pubkey):
|
||||
continue
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#broadcast-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#broadcast-sync-committee-message
|
||||
# The first quarter of the pubkeys map to subnet 0, the second quarter to
|
||||
# subnet 1, the third quarter to subnet 2 and the final quarter to subnet
|
||||
# 3.
|
||||
|
|
|
@ -284,7 +284,7 @@ proc verify_sync_committee_signature*(
|
|||
|
||||
blsFastAggregateVerify(pubkeys, signing_root.data, signature)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#aggregation-selection
|
||||
func compute_sync_committee_selection_proof_signing_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
slot: Slot, subcommittee_index: SyncSubcommitteeIndex): Eth2Digest =
|
||||
|
|
|
@ -342,7 +342,7 @@ template partialBeaconBlock*(
|
|||
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
||||
voluntary_exits: exits.voluntary_exits))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#preparing-a-beaconblock
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#preparing-a-beaconblock
|
||||
template partialBeaconBlock*(
|
||||
cfg: RuntimeConfig,
|
||||
state: var altair.HashedBeaconState,
|
||||
|
|
|
@ -632,7 +632,7 @@ func is_fully_withdrawable_validator(
|
|||
has_eth1_withdrawal_credential(validator) and
|
||||
validator.withdrawable_epoch <= epoch and balance > 0
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#is_partially_withdrawable_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#is_partially_withdrawable_validator
|
||||
func is_partially_withdrawable_validator(
|
||||
validator: Validator, balance: Gwei): bool =
|
||||
## Check if ``validator`` is partially withdrawable.
|
||||
|
|
|
@ -1529,7 +1529,7 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
|
|||
updateValidatorMetrics(node) # the important stuff is done, update the vanity numbers
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# Wait 2 / 3 of the slot time to allow messages to propagate, then collect
|
||||
# the result in aggregates
|
||||
static:
|
||||
|
|
|
@ -459,7 +459,7 @@ proc getSyncCommitteeMessage*(v: AttachedValidator,
|
|||
)
|
||||
)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#aggregation-selection
|
||||
proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
slot: Slot,
|
||||
|
|
|
@ -449,7 +449,7 @@ proc cmdRewindState(conf: DbConf, cfg: RuntimeConfig) =
|
|||
dag.withUpdatedState(
|
||||
tmpState[], dag.atSlot(bid, Slot(conf.slot)).expect("block found")) do:
|
||||
echo "Writing state..."
|
||||
withState(state):
|
||||
withState(updatedState):
|
||||
dump("./", forkyState)
|
||||
do: raiseAssert "withUpdatedState failed"
|
||||
|
||||
|
@ -536,7 +536,7 @@ proc cmdExportEra(conf: DbConf, cfg: RuntimeConfig) =
|
|||
|
||||
withTimer(timers[tState]):
|
||||
dag.withUpdatedState(tmpState[], eraBid) do:
|
||||
withState(state):
|
||||
withState(updatedState):
|
||||
group.finish(e2, forkyState.data).get()
|
||||
do:
|
||||
echo "Unable to load historical state - export requires fully indexed history node - see https://nimbus.guide/trusted-node-sync.html#recreate-historical-state-access-indices"
|
||||
|
|
|
@ -294,20 +294,20 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
|||
|
||||
dag.withUpdatedState(tmpState[], attestationHead.toBlockSlotId.expect("not nil")) do:
|
||||
let
|
||||
fork = getStateField(state, fork)
|
||||
genesis_validators_root = getStateField(state, genesis_validators_root)
|
||||
fork = getStateField(updatedState, fork)
|
||||
genesis_validators_root = getStateField(updatedState, genesis_validators_root)
|
||||
committees_per_slot =
|
||||
get_committee_count_per_slot(state, slot.epoch, cache)
|
||||
get_committee_count_per_slot(updatedState, slot.epoch, cache)
|
||||
|
||||
for committee_index in get_committee_indices(committees_per_slot):
|
||||
let committee = get_beacon_committee(
|
||||
state, slot, committee_index, cache)
|
||||
updatedState, slot, committee_index, cache)
|
||||
|
||||
for index_in_committee, validator_index in committee:
|
||||
if rand(r, 1.0) <= attesterRatio:
|
||||
let
|
||||
data = makeAttestationData(
|
||||
state, slot, committee_index, bid.root)
|
||||
updatedState, slot, committee_index, bid.root)
|
||||
sig =
|
||||
get_attestation_signature(
|
||||
fork, genesis_validators_root, data,
|
||||
|
@ -494,7 +494,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
|||
|
||||
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
|
||||
let
|
||||
newBlock = getNewBlock[phase0.SignedBeaconBlock](state, slot, cache)
|
||||
newBlock = getNewBlock[phase0.SignedBeaconBlock](updatedState, slot, cache)
|
||||
added = dag.addHeadBlock(verifier, newBlock) do (
|
||||
blckRef: BlockRef, signedBlock: phase0.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef, unrealized: FinalityCheckpoints):
|
||||
|
@ -516,7 +516,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
|||
|
||||
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
|
||||
let
|
||||
newBlock = getNewBlock[altair.SignedBeaconBlock](state, slot, cache)
|
||||
newBlock = getNewBlock[altair.SignedBeaconBlock](updatedState, slot, cache)
|
||||
added = dag.addHeadBlock(verifier, newBlock) do (
|
||||
blckRef: BlockRef, signedBlock: altair.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef, unrealized: FinalityCheckpoints):
|
||||
|
@ -538,7 +538,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
|||
|
||||
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
|
||||
let
|
||||
newBlock = getNewBlock[bellatrix.SignedBeaconBlock](state, slot, cache)
|
||||
newBlock = getNewBlock[bellatrix.SignedBeaconBlock](updatedState, slot, cache)
|
||||
added = dag.addHeadBlock(verifier, newBlock) do (
|
||||
blckRef: BlockRef, signedBlock: bellatrix.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef, unrealized: FinalityCheckpoints):
|
||||
|
@ -560,7 +560,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
|||
|
||||
dag.withUpdatedState(tmpState[], dag.getBlockIdAtSlot(slot).expect("block")) do:
|
||||
let
|
||||
newBlock = getNewBlock[capella.SignedBeaconBlock](state, slot, cache)
|
||||
newBlock = getNewBlock[capella.SignedBeaconBlock](updatedState, slot, cache)
|
||||
added = dag.addHeadBlock(verifier, newBlock) do (
|
||||
blckRef: BlockRef, signedBlock: capella.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef, unrealized: FinalityCheckpoints):
|
||||
|
|
Loading…
Reference in New Issue