feat(consensus): beacon consensus engine#1845
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1845 +/- ##
===========================================
+ Coverage 61.41% 73.12% +11.70%
===========================================
Files 418 423 +5
Lines 51340 51803 +463
===========================================
+ Hits 31532 37882 +6350
+ Misses 19808 13921 -5887
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 150 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
onbjerg
left a comment
There was a problem hiding this comment.
Looks good to me overall, very simple. Some minor nits and a question
| /// While the pipeline is syncing, the controller will keep processing messages from the receiver | ||
| /// and forwarding them to the blockchain tree. |
There was a problem hiding this comment.
Does this mean that all new payloads etc. are sent to the blockchain tree while we sync? My worry here is that if you start sync from block 0 to e.g. 16m on mainnet that blockchain tree will grow unbounded in that period since the state in the tree is never flushed. However, this assumes that CL will send us new payloads if we are not synced yet, which might not be true.
There was a problem hiding this comment.
Yeah I would consider dropping messages as long as we're still syncing - beyond the first msg
There was a problem hiding this comment.
I would just buffer the last N.
This is needed when the pipeline is close to the tip and the transition to the tree needs to be made, buffering blocks would make the transition better.
There was a problem hiding this comment.
@onbjerg it doesn't forward if the pipeline is syncing
| } | ||
| } | ||
|
|
||
| /// Consume the pipeline and run it. Return the pipeline and its result as a future. |
There was a problem hiding this comment.
I would add more docs here and on run that line out the distinction between the two and when to use one over the other (for crate consumers)
gakonst
left a comment
There was a problem hiding this comment.
Took a close look. I really like this. What is the integration point with Engine API going to look like, and how/where are we going to instantiate this?
Other thoughts:
- Maybe we can clone a handle to the txpool in this to support block building
- We might want a Pending / InMempool state provider separately
| /// While the pipeline is syncing, the controller will keep processing messages from the receiver | ||
| /// and forwarding them to the blockchain tree. |
There was a problem hiding this comment.
Yeah I would consider dropping messages as long as we're still syncing - beyond the first msg
| // Get next pipeline state. | ||
| this.next_pipeline_state(pipeline, tip) |
There was a problem hiding this comment.
If the current pipeline tip is the same as tip should this set the state to Idle?
gakonst
left a comment
There was a problem hiding this comment.
Generally LGTM. Clean. I would add some more tests for the happy cases, e.g. newPayload -> newPayload -> FCU
rakita
left a comment
There was a problem hiding this comment.
lgtm, did you maybe try it on testnet?
mattsse
left a comment
There was a problem hiding this comment.
looks pretty good, could follow easily.
left some nits, suggestions.
| { | ||
| type Output = Result<(), BeaconEngineError>; | ||
|
|
||
| fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
There was a problem hiding this comment.
this logic seems ok:
drain all messages
poll pipeline
repeat if pipeline not pending
gakonst
left a comment
There was a problem hiding this comment.
Alright. Full send, given our existing testing is solid and it looks like running CL <> EL correctly makes the EL get driven by the CL's headers. We can iterate as we run this live etc.
| None => { | ||
| let warn_msg = "No tip specified. \ | ||
| reth cannot communicate with consensus clients, \ | ||
| so a tip must manually be provided for the online stages with --debug.tip <HASH>."; | ||
| warn!(target: "reth::cli", warn_msg); | ||
| None |
There was a problem hiding this comment.
We should probably remove this warning if a CL is detected
Replacement for #1662
Closes #1528
This PR introduces the Beacon Consensus Engine.
The Beacon Consensus Engine is responsible for initiating the historical sync and driving the real-time sync by consuming messages from the Engine API. The consensus engine will start syncing as soon as it receives first
ForkchoiceUpdatedmessage from the CL (or manually set forkchoice through--debug.tipcli argument).