remove some debugRaiseAsserts and fill in Electra functionality (#6179)
This commit is contained in:
parent
0d534224b3
commit
27921406e9
|
@ -1005,8 +1005,11 @@ proc applyBlock(
|
|||
dag.cfg, state, data, cache, info,
|
||||
dag.updateFlags + {slotProcessed}, noRollback)
|
||||
of ConsensusFork.Electra:
|
||||
debugRaiseAssert "electra applyblock missing"
|
||||
return ok()
|
||||
let data = getBlock(dag, bid, electra.TrustedSignedBeaconBlock).valueOr:
|
||||
return err("Block load failed")
|
||||
? state_transition(
|
||||
dag.cfg, state, data, cache, info,
|
||||
dag.updateFlags + {slotProcessed}, noRollback)
|
||||
|
||||
ok()
|
||||
|
||||
|
|
|
@ -380,9 +380,9 @@ proc runProposalForkchoiceUpdated*(
|
|||
debug "Fork-choice updated for proposal", status
|
||||
|
||||
static: doAssert high(ConsensusFork) == ConsensusFork.Electra
|
||||
when consensusFork >= ConsensusFork.Electra:
|
||||
debugRaiseAssert "foobar"
|
||||
elif consensusFork >= ConsensusFork.Deneb:
|
||||
when consensusFork >= ConsensusFork.Deneb:
|
||||
# https://github.com/ethereum/execution-apis/blob/90a46e9137c89d58e818e62fa33a0347bba50085/src/engine/prague.md
|
||||
# does not define any new forkchoiceUpdated, so reuse V3 from Dencun
|
||||
callForkchoiceUpdated(PayloadAttributesV3(
|
||||
timestamp: Quantity timestamp,
|
||||
prevRandao: FixedBytes[32] randomData,
|
||||
|
|
|
@ -794,7 +794,10 @@ proc getPayloadFromSingleEL(
|
|||
prevRandao: FixedBytes[32] randomData.data,
|
||||
suggestedFeeRecipient: suggestedFeeRecipient,
|
||||
withdrawals: withdrawals))
|
||||
elif GetPayloadResponseType is engine_api.GetPayloadV3Response:
|
||||
elif GetPayloadResponseType is engine_api.GetPayloadV3Response or
|
||||
GetPayloadResponseType is engine_api.GetPayloadV4Response:
|
||||
# https://github.com/ethereum/execution-apis/blob/90a46e9137c89d58e818e62fa33a0347bba50085/src/engine/prague.md
|
||||
# does not define any new forkchoiceUpdated, so reuse V3 from Dencun
|
||||
let response = await rpcClient.forkchoiceUpdated(
|
||||
ForkchoiceStateV1(
|
||||
headBlockHash: headBlock.asBlockHash,
|
||||
|
@ -806,9 +809,6 @@ proc getPayloadFromSingleEL(
|
|||
suggestedFeeRecipient: suggestedFeeRecipient,
|
||||
withdrawals: withdrawals,
|
||||
parentBeaconBlockRoot: consensusHead.asBlockHash))
|
||||
elif GetPayloadResponseType is engine_api.GetPayloadV4Response:
|
||||
debugRaiseAssert "electra"
|
||||
let response = default(ForkchoiceUpdatedResponse)
|
||||
else:
|
||||
static: doAssert false
|
||||
|
||||
|
|
|
@ -238,8 +238,7 @@ proc installApiHandlers*(node: SigningNodeRef) =
|
|||
of ConsensusFork.Deneb:
|
||||
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||
of ConsensusFork.Electra:
|
||||
debugRaiseAssert "electra signing node missing"
|
||||
(GeneralizedIndex(801*42), request.beaconBlockHeader.data)
|
||||
(GeneralizedIndex(801), request.beaconBlockHeader.data)
|
||||
|
||||
if request.proofs.isNone() or len(request.proofs.get()) == 0:
|
||||
return errorResponse(Http400, MissingMerkleProofError)
|
||||
|
|
|
@ -3525,8 +3525,16 @@ proc decodeBody*(
|
|||
[version, $exc.msg]))
|
||||
ok(RestPublishedSignedBeaconBlock(ForkedSignedBeaconBlock.init(blck)))
|
||||
of ConsensusFork.Electra:
|
||||
debugRaiseAssert "electra"
|
||||
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError))
|
||||
let blck =
|
||||
try:
|
||||
SSZ.decode(body.data, electra.SignedBeaconBlock)
|
||||
except SerializationError as exc:
|
||||
return err(RestErrorMessage.init(Http400, UnableDecodeError,
|
||||
[version, exc.formatMsg("<data>")]))
|
||||
except CatchableError as exc:
|
||||
return err(RestErrorMessage.init(Http400, UnexpectedDecodeError,
|
||||
[version, $exc.msg]))
|
||||
ok(RestPublishedSignedBeaconBlock(ForkedSignedBeaconBlock.init(blck)))
|
||||
else:
|
||||
err(RestErrorMessage.init(Http415, "Invalid content type",
|
||||
[version, $body.contentType]))
|
||||
|
|
|
@ -412,7 +412,9 @@ template BeaconState*(kind: static ConsensusFork): auto =
|
|||
static: raiseAssert "Unreachable"
|
||||
|
||||
template BeaconBlock*(kind: static ConsensusFork): auto =
|
||||
when kind == ConsensusFork.Deneb:
|
||||
when kind == ConsensusFork.Electra:
|
||||
typedesc[electra.BeaconBlock]
|
||||
elif kind == ConsensusFork.Deneb:
|
||||
typedesc[deneb.BeaconBlock]
|
||||
elif kind == ConsensusFork.Capella:
|
||||
typedesc[capella.BeaconBlock]
|
||||
|
|
|
@ -295,10 +295,7 @@ proc state_transition_block*(
|
|||
doAssert not rollback.isNil, "use noRollback if it's ok to mess up state"
|
||||
|
||||
let res = withState(state):
|
||||
when consensusFork == ConsensusFork.Electra:
|
||||
debugRaiseAssert "electra state_transition_block"
|
||||
err("no")
|
||||
elif consensusFork == type(signedBlock).kind:
|
||||
when consensusFork == type(signedBlock).kind:
|
||||
state_transition_block_aux(cfg, forkyState, signedBlock, cache, flags)
|
||||
else:
|
||||
err("State/block fork mismatch")
|
||||
|
@ -383,6 +380,8 @@ func partialBeaconBlock*(
|
|||
when consensusFork >= ConsensusFork.Deneb:
|
||||
res.body.blob_kzg_commitments = execution_payload.blobsBundle.commitments
|
||||
|
||||
debugRaiseAssert "check for new fields or conditions to ensure in electra"
|
||||
|
||||
res
|
||||
|
||||
proc makeBeaconBlockWithRewards*(
|
||||
|
@ -486,7 +485,9 @@ proc makeBeaconBlockWithRewards*(
|
|||
of ConsensusFork.Deneb: makeBeaconBlock(deneb)
|
||||
else: raiseAssert "Attempt to use Deneb payload with non-Deneb state"
|
||||
elif payloadFork == ConsensusFork.Electra:
|
||||
debugRaiseAssert "Electra block production missing"
|
||||
case state.kind
|
||||
of ConsensusFork.Electra: makeBeaconBlock(electra)
|
||||
else: raiseAssert "Attempt to use Electra payload with non-Electra state"
|
||||
else:
|
||||
{.error: "Unsupported fork".}
|
||||
|
||||
|
|
|
@ -1025,9 +1025,9 @@ proc process_block*(
|
|||
total_active_balance = get_total_active_balance(state, cache)
|
||||
base_reward_per_increment =
|
||||
get_base_reward_per_increment(total_active_balance)
|
||||
operations_rewards = ? process_operations(
|
||||
var operations_rewards = ? process_operations(
|
||||
cfg, state, blck.body, base_reward_per_increment, flags, cache)
|
||||
? process_sync_aggregate(
|
||||
operations_rewards.sync_aggregate = ? process_sync_aggregate(
|
||||
state, blck.body.sync_aggregate, total_active_balance, flags, cache)
|
||||
|
||||
ok(operations_rewards)
|
||||
|
|
Loading…
Reference in New Issue