-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added basic block production to Caplin. #9796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
bayram98
approved these changes
Mar 25, 2024
yperbasis
pushed a commit
that referenced
this pull request
Mar 27, 2024
This PR also does the following additional things:
* Introduces correct JSON marshalling/unmarshalling to all objects
* BaseFeePerGas marshalled as integer on json caplin-wise
* Reduced dumpSlotsStates from 32 to 4 for better performance during
reorgs
* Added full lock for `OnAttestation`
## Block Production
This section highlights how `GET eth/v3/validator/blocks/{slot}` creates
a block and then publishes it.
The validator client will do execute 2 steps when producing a beacon
block.
1) Production step: tell the beacon client to create a block and return
it.
2) Publishing step: Sign the block with the proposer private key, and
send it back for publishing to other nodes.
### Block creation
Let's first look at how block creation happens.
So Caplin needs to do 2 things to successfully create a block:
1) Asking the Execution Layer for the Execution block
2) Retrieve Consensus Operations to include in the block
(Attestations/VoluntaryExits, etc...)
#### Execution block
For the execution block, it is quite simple, we ask Erigon to produce us
a block through the `AssembleBlock` function avaiable on the Erigon
`Eth1` API. We treat erigon as a black box so we do not need to worry
too much about this. However, we also need to handle **Blob** bundles,
so that later, when we need to publish a block. we can publish the
bundles alongside the block (it is important that peers both receive
block and the blob or we will fail a check). (Erigon will also gives us
the bundle). Right now, we store the blob bundle in an `LRU` which has
size set to 8 blocks worth of blobs. **Note: we use an LRU for the
convenient eviction policy**.
#### Operations
TODO.
Operations inclusion has not been implemented yet, the execution block
is the only thing being delivered.
### Block publishing
After we produce the beacon block, we will send it back to the Validator
Client, which will sign it and re-forward it to the rest of the network.
The flow is straightforward, when we receive the block we simply:
1) pack the block with the blobs the Execution Layer gave caplin during
block production
2) Start a separate thread where we import the block into Caplin's
database and forkchoice alongside the blobs..
3) Publish blobs and blocks to the P2P.
yperbasis
added a commit
that referenced
this pull request
Mar 27, 2024
Cherry pick PR #9796 into the release Co-authored-by: Giulio rebuffo <giulio.rebuffo@gmail.com>
Kakkarrot
pushed a commit
to covalenthq/erigon
that referenced
this pull request
Apr 17, 2024
Cherry pick PR erigontech#9796 into the release Co-authored-by: Giulio rebuffo <giulio.rebuffo@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

This PR also does the following additional things:
OnAttestationBlock Production
This section highlights how
GET eth/v3/validator/blocks/{slot}creates a block and then publishes it.The validator client will do execute 2 steps when producing a beacon block.
Block creation
Let's first look at how block creation happens.
So Caplin needs to do 2 things to successfully create a block:
Execution block
For the execution block, it is quite simple, we ask Erigon to produce us a block through the
AssembleBlockfunction avaiable on the ErigonEth1API. We treat erigon as a black box so we do not need to worry too much about this. However, we also need to handle Blob bundles, so that later, when we need to publish a block. we can publish the bundles alongside the block (it is important that peers both receive block and the blob or we will fail a check). (Erigon will also gives us the bundle). Right now, we store the blob bundle in anLRUwhich has size set to 8 blocks worth of blobs. Note: we use an LRU for the convenient eviction policy.Operations
TODO.
Operations inclusion has not been implemented yet, the execution block is the only thing being delivered.
Block publishing
After we produce the beacon block, we will send it back to the Validator Client, which will sign it and re-forward it to the rest of the network.
The flow is straightforward, when we receive the block we simply: