Skip to content

Commit 4906143

Browse files
tac0turtletac0turtlecoderabbitai[bot]
authored
chore: update specs (#2459)
<!-- 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. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview This pr updates specs with the changes from v1 refactor <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Expanded and restructured documentation for block manager, block validity, full node, header sync, and store components. * Added detailed architectural diagrams and descriptions of new internal components and services. * Clarified header/data separation, block production modes, synchronization processes, and storage prefixes. * Updated validation rules and data structures to reflect a single signer model and independent header/data validation. * Introduced comprehensive metrics and configuration options in the documentation. * Refined release order numbering in package release documentation. * Updated changelog baseline comparison to reflect new version reference. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: tac0turtle <you@example.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 8b96bc5 commit 4906143

7 files changed

Lines changed: 594 additions & 127 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ Pre-release versions: 0.x.y (anything may change)
109109
-->
110110

111111
<!-- Links -->
112-
[Unreleased]: https://github.com/rollkit/rollkit/compare/v0.0.0...HEAD
112+
[Unreleased]: https://github.com/rollkit/rollkit/compare/v1.0.0-beta.1...HEAD

RELEASE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,39 @@ Packages must be released in the following order to ensure dependencies are sati
4444

4545
These packages only depend on `core` and can be released in parallel after `core`:
4646

47-
2. **github.com/rollkit/rollkit/da**
47+
1. **github.com/rollkit/rollkit/da**
4848
- Path: `./da`
4949
- Dependencies: `rollkit/core`
5050

51-
3. **github.com/rollkit/rollkit**
51+
2. **github.com/rollkit/rollkit**
5252
- Path: `./` (root)
5353
- Dependencies: `rollkit/core`
5454

55-
4. **github.com/rollkit/rollkit/execution/evm**
55+
3. **github.com/rollkit/rollkit/execution/evm**
5656
- Path: `./execution/evm`
5757
- Dependencies: `rollkit/core`
5858

5959
### Phase 3: Sequencer Packages
6060

6161
These packages depend on both `core` and the main `rollkit` package:
6262

63-
5. **github.com/rollkit/rollkit/sequencers/based**
63+
1. **github.com/rollkit/rollkit/sequencers/based**
6464
- Path: `./sequencers/based`
6565
- Dependencies: `rollkit/core`, `rollkit`
6666

67-
6. **github.com/rollkit/rollkit/sequencers/single**
67+
2. **github.com/rollkit/rollkit/sequencers/single**
6868
- Path: `./sequencers/single`
6969
- Dependencies: `rollkit/core`, `rollkit`
7070

7171
### Phase 4: Application Packages
7272

7373
These packages have the most dependencies and should be released last:
7474

75-
7. **github.com/rollkit/rollkit/apps/evm/based**
75+
1. **github.com/rollkit/rollkit/apps/evm/based**
7676
- Path: `./apps/evm/based`
7777
- Dependencies: `rollkit/core`, `rollkit/da`, `rollkit/execution/evm`, `rollkit`, `rollkit/sequencers/based`
7878

79-
8. **github.com/rollkit/rollkit/apps/evm/single**
79+
2. **github.com/rollkit/rollkit/apps/evm/single**
8080
- Path: `./apps/evm/single`
8181
- Dependencies: `rollkit/core`, `rollkit/da`, `rollkit/execution/evm`, `rollkit`, `rollkit/sequencers/single`
8282

specs/src/specs/block-manager.md

Lines changed: 416 additions & 31 deletions
Large diffs are not rendered by default.

specs/src/specs/block-validity.md

Lines changed: 75 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,83 +12,96 @@ Verifying a block/header is done in 3 parts:
1212

1313
3. Perform verification of the new block against the previously accepted block
1414

15+
Rollkit uses a header/data separation architecture where headers and data can be validated independently. The system has moved from a multi-validator model to a single signer model for simplified sequencer management.
16+
1517
## Basic Validation
1618

17-
Each type contains a `.ValidateBasic()` method, which verifies that certain basic invariants hold. The `ValidateBasic()` calls are nested, starting from the `Block` struct, all the way down to each subfield.
19+
Each type contains a `.ValidateBasic()` method, which verifies that certain basic invariants hold. The `ValidateBasic()` calls are nested for each structure.
20+
21+
### SignedHeader Validation
22+
23+
```go
24+
SignedHeader.ValidateBasic()
25+
// Make sure the SignedHeader's Header passes basic validation
26+
Header.ValidateBasic()
27+
verify ProposerAddress not nil
28+
// Make sure the SignedHeader's signature passes basic validation
29+
Signature.ValidateBasic()
30+
// Ensure that someone signed the header
31+
verify len(c.Signatures) not 0
32+
// For based rollups (sh.Signer.IsEmpty()), pass validation
33+
If !sh.Signer.IsEmpty():
34+
// Verify the signer matches the proposer address
35+
verify sh.Signer.Address == sh.ProposerAddress
36+
// Verify signature using custom verifier if set, otherwise use default
37+
if sh.verifier != nil:
38+
verify sh.verifier(sh) == nil
39+
else:
40+
verify sh.Signature.Verify(sh.Signer.PubKey, sh.Header.MarshalBinary())
41+
```
1842

19-
The nested basic validation, and validation checks, are called as follows:
43+
### SignedData Validation
2044

2145
```go
22-
Block.ValidateBasic()
23-
// Make sure the block's SignedHeader passes basic validation
24-
SignedHeader.ValidateBasic()
25-
// Make sure the SignedHeader's Header passes basic validation
26-
Header.ValidateBasic()
27-
verify ProposerAddress not nil
28-
// Make sure the SignedHeader's signature passes basic validation
29-
Signature.ValidateBasic()
30-
// Ensure that someone signed the block
31-
verify len(c.Signatures) not 0
32-
If sh.Validators is nil, or len(sh.Validators.Validators) is 0, assume based rollup, pass validation, and skip all remaining checks.
33-
Validators.ValidateBasic()
34-
// github.com/rollkit/cometbft/blob/main/types/validator.go#L37
35-
verify sh.Validators is not nil, and len(sh.Validators.Validators) != 0
36-
// apply basic validation to all Validators
37-
for each validator:
38-
validator.ValidateBasic()
39-
validate not nil
40-
validator.PubKey not nil
41-
validator.Address == correct size
42-
// apply ValidateBasic to the proposer field:
43-
sh.Validators.Proposer.ValidateBasic()
44-
validate not nil
45-
validator.PubKey not nil
46-
validator.Address == correct size
47-
Assert that SignedHeader.Validators.Hash() == SignedHeader.AggregatorsHash
48-
Verify SignedHeader.Signature
46+
SignedData.ValidateBasic()
47+
// Always passes basic validation for the Data itself
4948
Data.ValidateBasic() // always passes
50-
// make sure the SignedHeader's DataHash is equal to the hash of the actual data in the block.
51-
Data.Hash() == SignedHeader.DataHash
49+
// Make sure the signature is valid
50+
Signature.ValidateBasic()
51+
verify len(c.Signatures) not 0
52+
// Verify the signer
53+
If !sd.Signer.IsEmpty():
54+
verify sd.Signature.Verify(sd.Signer.PubKey, sd.Data.MarshalBinary())
5255
```
5356

54-
## Verification Against Previous Block
57+
### Block Validation
58+
59+
Blocks are composed of SignedHeader and Data:
5560

5661
```go
57-
// code does not match spec: see https://github.com/rollkit/rollkit/issues/1277
58-
Block.Verify()
59-
SignedHeader.Verify(untrustH *SignedHeader)
60-
// basic validation removed in #1231, because go-header already validates it
61-
//untrustH.ValidateBasic()
62-
Header.Verify(untrustH *SignedHeader)
63-
if untrustH.Height == h.Height + 1, then apply the following check:
64-
untrstH.AggregatorsHash[:], h.NextAggregatorsHash[:]
65-
if untrustH.Height > h.Height + 1:
66-
soft verification failure
67-
// We should know they're adjacent now,
68-
// verify the link to previous.
69-
untrustH.LastHeaderHash == h.Header.Hash()
70-
// Verify LastCommit hash
71-
untrustH.LastCommitHash == sh.Signature.GetCommitHash(...)
62+
// Block validation happens by validating header and data separately
63+
// then ensuring data hash matches
64+
verify SignedHeader.ValidateBasic() == nil
65+
verify Data.Hash() == SignedHeader.DataHash
66+
```
67+
68+
## Verification Against Previous Block
7269

70+
```go
71+
SignedHeader.Verify(untrustedHeader *SignedHeader)
72+
// Basic validation is handled by go-header before this
73+
Header.Verify(untrustedHeader)
74+
// Verify height sequence
75+
if untrustedHeader.Height != h.Height + 1:
76+
if untrustedHeader.Height > h.Height + 1:
77+
return soft verification failure
78+
return error "headers are not adjacent"
79+
// Verify the link to previous header
80+
verify untrustedHeader.LastHeaderHash == h.Header.Hash()
81+
// Verify LastCommit hash matches previous signature
82+
verify untrustedHeader.LastCommitHash == sh.Signature.GetCommitHash(...)
83+
// Note: ValidatorHash field exists for compatibility but is not validated
7384
```
7485

75-
## [Data](https://github.com/rollkit/rollkit/blob/main/types/data.go#L25)
86+
## [Data](https://github.com/rollkit/rollkit/blob/main/types/data.go)
7687

7788
| **Field Name** | **Valid State** | **Validation** |
7889
|----------------|-----------------------------------------|------------------------------------|
79-
| Data | Transaction data of the block | Data.Hash == SignedHeader.DataHash |
90+
| Txs | Transaction data of the block | Data.Hash() == SignedHeader.DataHash |
91+
| Metadata | Optional p2p gossiping metadata | Not validated |
8092

81-
## [SignedHeader](https://github.com/rollkit/rollkit/blob/main/types/signed_header.go#L16)
93+
## [SignedHeader](https://github.com/rollkit/rollkit/blob/main/types/signed_header.go)
8294

8395
| **Field Name** | **Valid State** | **Validation** |
8496
|----------------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
8597
| Header | Valid header for the block | `Header` passes `ValidateBasic()` and `Verify()` |
86-
| Signature | 1 valid signature from the single sequencer | `Signature` passes `ValidateBasic()`, with additional checks in `SignedHeader.ValidateBasic()` |
87-
| Validators | Array of Aggregators, must have length exactly 1. | `Validators` passes `ValidateBasic()` |
98+
| Signature | Valid signature from the single sequencer | `Signature` passes `ValidateBasic()`, verified against signer |
99+
| Signer | Information about who signed the header | Must match ProposerAddress if not empty (based rollup case) |
100+
| verifier | Optional custom signature verification function | Used instead of default verification if set |
88101

89-
## [Header](https://github.com/rollkit/rollkit/blob/main/types/header.go#L39)
102+
## [Header](https://github.com/rollkit/rollkit/blob/main/types/header.go)
90103

91-
***Note***: The `AggregatorsHash` and `NextAggregatorsHash` fields have been removed. Rollkit vA should ignore all Valset updates from the ABCI app, and always enforce that the proposer is the single sequencer set as the 1 validator in the genesis block.
104+
***Note***: Rollkit has moved to a single signer model. The multi-validator architecture has been replaced with a simpler single sequencer approach.
92105

93106
| **Field Name** | **Valid State** | **Validation** |
94107
|---------------------|--------------------------------------------------------------------------------------------|---------------------------------------|
@@ -104,12 +117,14 @@ Block.Verify()
104117
| ConsensusHash | unused | |
105118
| AppHash | The correct state root after executing the block's transactions against the accepted state | checked during block execution |
106119
| LastResultsHash | Correct results from executing transactions | checked during block execution |
107-
| ProposerAddress | Address of the expected proposer | checked in the `Verify()` step |
108-
| Signature | Signature of the expected proposer | signature verification occurs in the `ValidateBasic()` step |
120+
| ProposerAddress | Address of the expected proposer | Must match Signer.Address in SignedHeader |
121+
| ValidatorHash | Compatibility field for Tendermint light client | Not validated |
122+
123+
## [Signer](https://github.com/rollkit/rollkit/blob/main/types/signed_header.go)
109124

110-
## [ValidatorSet](https://github.com/cometbft/cometbft/blob/main/types/validator_set.go#L51)
125+
The Signer type replaces the previous ValidatorSet for single sequencer operation:
111126

112127
| **Field Name** | **Valid State** | **Validation** |
113-
|--------------|-----------------------------------------------------------------|-----------------------------|
114-
| Validators | Array of validators, each must pass `Validator.ValidateBasic()` | `Validator.ValidateBasic()` |
115-
| Proposer | Must pass `Validator.ValidateBasic()` | `Validator.ValidateBasic()` |
128+
|----------------|-----------------------------------------------------------------|-----------------------------|
129+
| PubKey | Public key of the signer | Must not be nil if Signer is not empty |
130+
| Address | Address derived from the public key | Must match ProposerAddress |

specs/src/specs/full_node.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,26 @@ The [Store] is initialized with `DefaultStore`, an implementation of the [store
3232

3333
### blockManager
3434

35-
The [Block Manager] is responsible for managing the operations related to blocks such as creating and validating blocks.
35+
The [Block Manager] is responsible for managing block-related operations including:
36+
37+
- Block production (normal and lazy modes)
38+
- Header and data submission to DA layer
39+
- Block retrieval and synchronization
40+
- State updates and finalization
41+
42+
It implements a header/data separation architecture where headers and transaction data are handled independently.
3643

3744
### dalc
3845

3946
The [Data Availability Layer Client][dalc] is used to interact with the data availability layer. It is initialized with the DA Layer and DA Config specified in the node configuration.
4047

41-
### hExService
48+
### hSyncService
4249

43-
The [Header Sync Service] is used for syncing block headers between nodes over P2P.
50+
The [Header Sync Service] is used for syncing signed headers between nodes over P2P. It operates independently from data sync to support light clients.
4451

45-
### bSyncService
52+
### dSyncService
4653

47-
The [Block Sync Service] is used for syncing blocks between nodes over P2P.
54+
The [Data Sync Service] is used for syncing transaction data between nodes over P2P. This service is only used by full nodes, not light nodes.
4855

4956
## Message Structure/Communication Format
5057

@@ -78,7 +85,7 @@ See [full node]
7885

7986
[9] [Header Sync Service][Header Sync Service]
8087

81-
[10] [Block Sync Service][Block Sync Service]
88+
[10] [Data Sync Service][Data Sync Service]
8289

8390
[full node]: https://github.com/rollkit/rollkit/blob/main/node/full.go
8491
[genesis]: https://github.com/cometbft/cometbft/blob/main/spec/core/genesis.md
@@ -89,4 +96,4 @@ See [full node]
8996
[Block Manager]: https://github.com/rollkit/rollkit/blob/main/block/manager.go
9097
[dalc]: https://github.com/rollkit/rollkit/blob/main/core/da/da.go
9198
[Header Sync Service]: https://github.com/rollkit/rollkit/blob/main/pkg/sync/sync_service.go
92-
[Block Sync Service]: https://github.com/rollkit/rollkit/blob/main/pkg/sync/sync_service.go
99+
[Data Sync Service]: https://github.com/rollkit/rollkit/blob/main/pkg/sync/sync_service.go

0 commit comments

Comments
 (0)