Skip to content

Commit 1c915cf

Browse files
Move header sync to block and create symlink in specs (#1251)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview Closes: #1249 Also, fixes `markdown-lint` CI checks. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords Co-authored-by: Ganesha Upadhyaya <ganeshrvce@gmail.com>
1 parent 5819a12 commit 1c915cf

2 files changed

Lines changed: 57 additions & 56 deletions

File tree

block/header-sync.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Header Sync
2+
3+
## Abstract
4+
5+
The nodes in the P2P network sync headers using the header sync service that implements the [go-header][go-header] interface. The header sync service consists of several components as listed below.
6+
7+
|Component|Description|
8+
|---|---|
9+
|store| a `headerEx` prefixed [datastore][datastore] where synced headers are stored|
10+
|subscriber | a [libp2p][libp2p] node pubsub subscriber|
11+
|P2P server| a server for handling header requests between peers in the P2P network|
12+
|exchange| a client that enables sending in/out-bound header requests from/to the P2P network|
13+
|syncer| a service for efficient synchronization for headers. When a P2P node falls behind and wants to catch up to the latest network head via P2P network, it can use the syncer.|
14+
15+
## Details
16+
17+
All three types of nodes (sequencer, full, and light) run the header sync service to maintain the cannonical view of the rollup chain (with respect to the P2P network).
18+
19+
The header sync service inherits the `ConnectionGater` from the node's P2P client which enables blocking and allowing peers as needed by specifying the `P2PConfig.BlockedPeers` and `P2PConfig.AllowedPeers`.
20+
21+
`NodeConfig.BlockTime` is used to configure the syncer such that it can effectively decide the outdated headers while it receives headers from the P2P network.
22+
23+
Both header and block sync utilizes [go-header][go-header] library and runs two separate sync services, for the headers and blocks. This distinction is mainly to serve light nodes which do not store blocks, but only headers synced from the P2P network.
24+
25+
### Consumption of Header Sync
26+
27+
The sequencer node, upon successfully creating the block, publishes the signed block header to the P2P network using the header sync service. The full/light nodes run the header sync service in the background to receive and store the signed headers from the P2P network. Currently the full/light nodes do not consume the P2P synced headers, however they have future utilities in performing certain checks.
28+
29+
## Assumptions
30+
31+
* The header sync store is created by prefixing `headerSync` the main datastore.
32+
* The genesis `ChainID` is used to create the `PubsubTopicID` in [go-header][go-header]. For example, for ChainID `gm`, the pubsub topic id is `/gm/header-sub/v0.0.1`. Refer to go-header specs for further details.
33+
* The header store must be initialized with genesis header before starting the syncer service. The genesis header can be loaded by passing the genesis header hash via `NodeConfig.TrustedHash` configuration parameter or by querying the P2P network. This imposes a time constraint that full/light nodes have to wait for the sequencer to publish the genesis header to the P2P network before starting the header sync service.
34+
* The Header Sync works only when the node is connected to the P2P network by specifying the initial seeds to connect to via the `P2PConfig.Seeds` configuration parameter.
35+
* The node's context is passed down to all the components of the P2P header sync to control shutting down the service either abruptly (in case of failure) or gracefully (during successful scenarios).
36+
37+
## Implementation
38+
39+
The header sync implementation can be found in [node/header_sync.go][header sync]. The full and light nodes create and start the header sync service under [full][fullnode] and [light][lightnode].
40+
41+
## References
42+
43+
[1] [Header Sync][header sync]
44+
45+
[2] [Full Node][fullnode]
46+
47+
[3] [Light Node][lightnode]
48+
49+
[4] [go-header][go-header]
50+
51+
[header sync]: https://github.com/rollkit/rollkit/blob/main/block/header_sync.go
52+
[fullnode]: https://github.com/rollkit/rollkit/blob/main/node/full.go
53+
[lightnode]: https://github.com/rollkit/rollkit/blob/main/node/light.go
54+
[go-header]: https://github.com/celestiaorg/go-header
55+
[libp2p]: https://github.com/libp2p/go-libp2p
56+
[datastore]: https://github.com/ipfs/go-datastore

specs/src/specs/header-sync.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

specs/src/specs/header-sync.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../block/header-sync.md

0 commit comments

Comments
 (0)