Skip to content

Instantly share code, notes, and snippets.

@blazejkrzak
Last active March 4, 2021 09:27
Show Gist options
  • Save blazejkrzak/56d09cc79ef91b5fdb6e6d633a9f1372 to your computer and use it in GitHub Desktop.
Save blazejkrzak/56d09cc79ef91b5fdb6e6d633a9f1372 to your computer and use it in GitHub Desktop.
Symbiotic block creation with Pandora and Vanguard orchestrated

Block creation

Pandora and Vanguard orchestration when producing a new block.

Terminology

Orchestrator - client written in go. Its responsibility is to orchestrate the Pandora and Vanguard to produce block.

Pandora - modified fork of go-ethereum where Pandora engine exists. Its responsibility is to create valid execution layer block. P2P is enabled to txpool share and block propagation. Although it requires symbiotic connection with the vanguard. Also known as geth

Vanguard - modified fork of prysm client. Its responsibility is to run consensus algorithm (CASPER) with execution layer on shard0. Also known as beacon chain

Connection

Clients should be connected via ipc socket (secure) or rpc(troublesome). Its design is driven by the event approach. Each party should subscribe and emit events to cross communicate.

Pandora is having sub-network of p2p (execution layer)

Vanguard is having sub-network of p2p (beacon chain)

Process of block creation

@currentSlot @synchronizedEpochList
Given as a Vanguard I want to produce consensus block
  And I have notified about validators that will be signing current epoch
  And in current slot I should create the block

When Pandora prepares the execution block for signature
  And notifies about it

Then Vanguard signs the block
  And Vanguard notifies about it
  And Vanguard asynchronously push this block to consensus peers
  And Pandora asynchronously push this block to execution peers

List of supported events

Naming convention $EMITTER_$ACTION

0a - pandora_up
0b - pandora_create_unix_socket
0c - vanguard_up
1a - vanguard_epoch_reveal
3a - vanguard_block_emit (ASYNC)
3b - pandora_block_emit (ASYNC)
4a - pandora_block_produce
4c - vanguard_block_seal
4e - pandora_block_seal
5a - orchestrator_block_confirmed

Block creation flow

Block creation flow

Miro assigned to this board: https://miro.com/app/board/o9J_lZKrGXE=/?moveToWidget=3074457354346973365&cot=14

List of events and its consumption

## Register
0a -  [ORCHESTRATOR][EXEC]: pandora_up
0b  - [PANDORA][EXEC] pandora_create_unix_socket
0c -  [ORCHESTRATOR][EXEC] vanguard_up
## Notify about an epoch. It passes the validators in an array of public bls keys for needed epoch.
1a -  [VANGUARD][EXEC] vanguard_epoch_reveal
1b -  [PANDORA][CONSUME] vanguard_epoch_reveal
## Stay synchronized with the sub networks. Constant process
2a -  [VANGUARD][CONSUME] received block from vanguard network (ASYNC)
2b -  [PANDORA][CONSUME] received block from pandora network (ASYNC)
## Emission of blocks. Constant process
3a -  [VANGUARD][EMIT] vanguard_block_emit (ASYNC)
3b -  [PANDORA][EMIT] pandora_block_emit (ASYNC)
## Consumption of blocks. Constant process
3c -  [PANDORA][CONSUME] vanguard_block_emit (ASYNC)
3c -  [ORCHESTRATOR][CONSUME] vanguard_block_emit (ASYNC)
3d -  [VANGUARD][CONSUME] pandora_block_emit (ASYNC)
## Pandora knows every information it needs to produce a block on certain slot.
## Validation of any received block also can be done by verifying the bls signature from validators array.
## Pandora starts to produce a block for a certain slot. It should have max 1 / 4 time of the slot to perform it.
4a -  [PANDORA][EMIT] pandora_block_produce
## Vanguard receives the header of pandora.
4b -  [VANGUARD][CONSUME] pandora_block_produce
## Orchestrator receives the information about successful execution
4b -  [ORCHESTRATOR][CONSUME] pandora_block_produce
## Vanguard signs `extraData` and `stateRoot` by private bls key of current validator.
4c -  [VANGUARD][EMIT] vanguard_block_seal
## Pandora gets the signed header and insert it into database
4d -  [PANDORA][CONSUME] vanguard_block_seal
## Orchestrator gets the information that vanguard sealed the block
4d -  [ORCHESTRATOR][CONSUME] vanguard_block_seal
## Pandora replaces its header with the header signed by Vanguard and pushes it to own peers.
4e -  [PANDORA][EMIT] pandora_block_seal
## Orchestrator is notified about a block production lifecycle end.
4f -  [ORCHESTRATOR][CONSUME] pandora_block_seal
## Orchestrator emits an event for pandora and vanguard that whole process of block creation ended and is valid.
5a -  [ORCHESTRATOR][EMIT] orchestrator_block_confirmed
## Pandora and Vanguard are aware of the fact that process of block production ended on both sides.
## If its symbiosis breaks, they get slashed
5b -  [PANDORA][CONSUME]  orchestrator_block_confirmed (ASYNC)
5b -  [VANGUARD][CONSUME]  orchestrator_block_confirmed (ASYNC)

Notification schema

BlockCreationSchema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment