Skip to content

Commit f662a50

Browse files
committed
add docs
1 parent d6ba01d commit f662a50

3 files changed

Lines changed: 59 additions & 10 deletions

File tree

block/internal/syncing/da_retriever.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func isEmptyDataExpected(header *types.SignedHeader) bool {
360360
}
361361

362362
// createEmptyDataForHeader creates empty data for a header
363-
func createEmptyDataForHeader(ctx context.Context, header *types.SignedHeader) *types.Data {
363+
func createEmptyDataForHeader(_ context.Context, header *types.SignedHeader) *types.Data {
364364
return &types.Data{
365365
Txs: make(types.Txs, 0),
366366
Metadata: &types.Metadata{

block/internal/syncing/syncer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,8 @@ func (s *Syncer) TrySyncNextBlock(ctx context.Context, event *common.DAHeightEve
758758
// Persist DA height mapping for blocks synced from DA
759759
// This ensures consistency with the sequencer's submitter which also persists this mapping
760760
// Note: P2P hints are already persisted via store_adapter.Append when items have DAHint set
761-
if event.Source == common.SourceDA && event.DaHeight > 0 {
761+
// But DaHeight from events always take precedence as they are authoritative (comes from DA)
762+
if event.DaHeight > 0 {
762763
daHeightBytes := make([]byte, 8)
763764
binary.LittleEndian.PutUint64(daHeightBytes, event.DaHeight)
764765

docs/learn/specs/header-sync.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
The nodes in the P2P network sync headers and data using separate sync services that implement the [go-header][go-header] interface. Evolve uses a header/data separation architecture where headers and transaction data are synchronized independently through parallel services. Each sync service consists of several components as listed below.
66

7-
|Component|Description|
8-
|---|---|
9-
|store| a prefixed [datastore][datastore] where synced items are stored (`headerSync` prefix for headers, `dataSync` prefix for data)|
10-
|subscriber| a [libp2p][libp2p] node pubsub subscriber for the specific data type|
11-
|P2P server| a server for handling requests between peers in the P2P network|
12-
|exchange| a client that enables sending in/out-bound requests from/to the P2P network|
13-
|syncer| a service for efficient synchronization. When a P2P node falls behind and wants to catch up to the latest network head via P2P network, it can use the syncer.|
7+
| Component | Description |
8+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9+
| store | a prefixed [datastore][datastore] where synced items are stored (`headerSync` prefix for headers, `dataSync` prefix for data) |
10+
| subscriber | a [libp2p][libp2p] node pubsub subscriber for the specific data type |
11+
| P2P server | a server for handling requests between peers in the P2P network |
12+
| exchange | a client that enables sending in/out-bound requests from/to the P2P network |
13+
| syncer | a service for efficient synchronization. When a P2P node falls behind and wants to catch up to the latest network head via P2P network, it can use the syncer. |
1414

1515
## Details
1616

@@ -22,7 +22,7 @@ Evolve implements two separate sync services:
2222
- Used by all node types (sequencer, full, and light)
2323
- Essential for maintaining the canonical view of the chain
2424

25-
### Data Sync Service
25+
### Data Sync Service
2626

2727
- Synchronizes `Data` structures containing transaction data
2828
- Used only by full nodes and sequencers
@@ -90,6 +90,54 @@ The block components integrate with both services through:
9090
- The Executor component publishes headers and data through broadcast channels
9191
- Separate stores and channels manage header and data synchronization
9292

93+
## DA Height Hints
94+
95+
DA Height Hints (DAHint) provide an optimization for P2P synchronization by indicating which DA layer height contains a block's header or data. This allows syncing nodes to fetch missing DA data directly instead of performing sequential DA scanning.
96+
97+
### Naming Considerations
98+
99+
The naming convention follows this pattern:
100+
101+
| Name | Usage |
102+
| ----------------- | ---------------------------------------------------------- |
103+
| `DAHeightHint` | Internal struct field storing the hint value |
104+
| `DAHint()` | Getter method returning the DA height hint |
105+
| `SetDAHint()` | Setter method for the DA height hint |
106+
| `P2PSignedHeader` | Wrapper around `SignedHeader` that includes `DAHeightHint` |
107+
| `P2PData` | Wrapper around `Data` that includes `DAHeightHint` |
108+
109+
The term "hint" is used deliberately because:
110+
111+
1. **It's advisory, not authoritative**: The hint suggests where to find data on the DA layer, but the authoritative source is always the DA layer itself
112+
2. **It may be absent**: Hints are only populated during certain sync scenarios (see below)
113+
3. **It optimizes but doesn't replace**: Nodes can still function without hints by scanning the DA layer sequentially
114+
115+
### When DAHints Are Populated
116+
117+
DAHints are **only populated when a node catches up from P2P** and is not yet synced to the head. When a node is already synced to the head:
118+
119+
- The executor broadcasts headers/data immediately after block creation
120+
- At this point, DA submission has not occurred yet (it happens later in the flow)
121+
- Therefore, the broadcasted P2P messages do not contain DA hints
122+
123+
This means:
124+
125+
- **Syncing nodes** (catching up): Receive headers/data with DA hints populated
126+
- **Synced nodes** (at head): Receive headers/data without DA hints
127+
128+
The DA hints are set by the DA submitter after successful inclusion on the DA layer and stored for later P2P propagation to syncing peers.
129+
130+
### Implementation Details
131+
132+
The P2P wrapper types (`P2PSignedHeader` and `P2PData`) extend the base types with an optional `DAHeightHint`.
133+
134+
The hint is:
135+
136+
1. **Set by the DA Submitter** when headers/data are successfully included on the DA layer
137+
2. **Stored in the P2P store** alongside the header/data
138+
3. **Propagated via P2P** when syncing nodes request blocks
139+
4. **Used by the Syncer** to trigger targeted DA retrieval instead of sequential scanning
140+
93141
## References
94142

95143
[1] [Header Sync][sync-service]

0 commit comments

Comments
 (0)