Skip to content

Commit 6d15686

Browse files
authored
implement execution_payload_available event (#8043)
* implement execution payload available event * review * Revert "review" This reverts commit 02b4686.
1 parent 2d0f2aa commit 6d15686

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

beacon_chain/consensus_object_pools/envelope_quarantine.nim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import std/tables
1111
import ../spec/[digest, forks]
1212

1313
type
14+
OnExecutionPayloadCallback* = proc(
15+
data: ExecutionPayloadInfoObject) {.gcsafe, raises: [].}
16+
1417
EnvelopeQuarantine* = object
1518
orphans*: Table[Eth2Digest, Table[uint64, SignedExecutionPayloadEnvelope]]
1619
## Envelopes that we have received but did not have a block yet. In the
@@ -22,12 +25,19 @@ type
2225
## have not got yet. Missing envelopes should usually be found when we
2326
## received a block, blob or data column.
2427

25-
func init*(T: typedesc[EnvelopeQuarantine]): T =
26-
T()
28+
onEnvelopeCallback*: OnExecutionPayloadCallback
29+
30+
func init*(T: typedesc[EnvelopeQuarantine],
31+
onEnvelopeCallback: OnExecutionPayloadCallback = nil): T =
32+
T(onEnvelopeCallback: onEnvelopeCallback)
2733

2834
template root(v: SignedExecutionPayloadEnvelope): Eth2Digest =
2935
v.message.beacon_block_root
3036

37+
template onExecutionPayloadCallback*(
38+
quarantine: EnvelopeQuarantine): OnExecutionPayloadCallback =
39+
quarantine.onEnvelopeCallback
40+
3141
func addMissing*(
3242
self: var EnvelopeQuarantine,
3343
root: Eth2Digest) =

beacon_chain/gossip_processing/gossip_validation.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,13 @@ proc validateExecutionPayload*(
11191119
return dag.checkedReject("ExecutionPayload: invalid builder signature")
11201120
else:
11211121
return dag.checkedReject("ExecutionPayload: invalid fork")
1122+
1123+
let onExecutionPayloadCallback =
1124+
envelopeQuarantine[].onExecutionPayloadCallback()
1125+
if not isNil(onExecutionPayloadCallback):
1126+
onExecutionPayloadCallback ExecutionPayloadInfoObject(
1127+
slot: envelope.slot,
1128+
block_root: envelope.beacon_block_root)
11221129

11231130
ok()
11241131

beacon_chain/nimbus_beacon_node.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ proc initFullNode(
493493
else:
494494
data
495495
node.eventBus.reorgQueue.emit(eventData)
496+
proc onEnvelopeAdded(data: ExecutionPayloadInfoObject) =
497+
node.eventBus.execPayloadAvlQueue.emit(data)
496498
proc makeOnFinalizationCb(
497499
# This `nimcall` functions helps for keeping track of what
498500
# needs to be captured by the onFinalization closure.
@@ -552,7 +554,7 @@ proc initFullNode(
552554
let
553555
quarantine = newClone(
554556
Quarantine.init(dag.cfg))
555-
envelopeQuarantine = newClone(EnvelopeQuarantine.init())
557+
envelopeQuarantine = newClone(EnvelopeQuarantine.init(onEnvelopeAdded))
556558
attestationPool = newClone(AttestationPool.init(
557559
dag, quarantine, getBeaconTime(), onSingleAttestationReceived))
558560
syncCommitteeMsgPool = newClone(

0 commit comments

Comments
 (0)