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