Commit b705f50
Added basic block production to Caplin. (#9796)
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.1 parent 6e66412 commit b705f50
File tree
55 files changed
+1116
-118
lines changed- cl
- beacon
- beaconhttp
- handler
- test_data
- clparams
- cltypes
- solid
- testdata
- gossip
- phase1
- core/state
- execution_client
- forkchoice
- fork_graph
- network
- stages
- sentinel
- service
- spectest/consensus_tests
- transition/impl/eth2
- utils
- cmd/caplin/caplin1
- polygon/sync
- spectest
- turbo/execution/eth1/eth1_chain_reader.go
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
55 files changed
+1116
-118
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
0 commit comments