Skip to content

Commit 7fd4583

Browse files
authored
docs: enhance Execution API documentation with block size management (#2215)
## Overview Added a section on block size management to the Execution API documentation, detailing the role of the `maxBytes` parameter in `InitChain` and `ExecuteTxs` methods. This update clarifies how the parameter aids in maintaining consistent block size constraints and its usage in Rollkit for validating block sizes before submission. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Expanded and clarified the design and rationale of the Execution API, including its support for multiple execution environments and improved modularity. - Enhanced API method specifications with detailed expected behaviors and state management guidelines. - Added a comprehensive section on block size management and its coordination across system components. - Introduced implementation guidelines covering state management, error handling, performance, and security. - Updated the consequences section with additional considerations. - Added a new reference to the relevant repository. - Removed internal refactoring, testing, and user documentation notes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 2727200 commit 7fd4583

1 file changed

Lines changed: 83 additions & 44 deletions

File tree

‎specs/lazy-adr/adr-010-exec-api.md‎

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@
33
## Changelog
44

55
- 2025.01.13: Initial draft
6+
- 2025.04.24: Various improvements
67

78
## Context
89

910
Introduction of the Execution API makes rollkit very generic and execution-environment agnostic.
1011
It removes all ABCI-centric code for full interoperability with other types of VMs.
1112

13+
The Execution API serves as a bridge between Rollkit and various execution environments (VMs),
14+
allowing Rollkit to remain agnostic to the specific implementation details of the execution layer.
15+
This separation enables:
16+
17+
1. Support for multiple VM types (EVM, WASM, etc.)
18+
2. Easier integration with different execution environments
19+
3. Cleaner separation of concerns between consensus and execution
20+
4. More flexible and maintainable architecture
21+
1222
## Alternative Approaches
1323

1424
1. Maintain current state: keep ABCI interface and implement other VMs inside ABCI application.
25+
- Pros: No changes required to existing code
26+
- Cons: ABCI-specific code remains, limiting flexibility
1527
2. Migrate to Engine API.
16-
3. Create new API generic enough to handle any arbitrary VM.
28+
- Pros: Standard interface for EVM-based chains
29+
- Cons: Too specific to EVM, not suitable for other VMs
1730

1831
## Decision
1932

@@ -69,6 +82,7 @@ Initializes the blockchain's state based on genesis information. This method is
6982
- Initialize rollup according to the genesis.
7083
- Generate an initial `stateRoot` representing the genesis state of the rollup.
7184
- Return the maximum allowable block size (`maxBytes`).
85+
- Ensure all necessary state is initialized for subsequent operations.
7286

7387
#### `GetTxs`
7488

@@ -91,6 +105,7 @@ Transactions returned by execution client will be passed by rollkit to sequencer
91105
- Access the mempool and retrieve all available transactions.
92106
- If no transactions are available, return an empty slice without error.
93107
- Do not remove ("reap") transactions from mempool.
108+
- Ensure transactions are valid and properly formatted.
94109

95110
#### `ExecuteTxs`
96111

@@ -119,6 +134,7 @@ Executes a given set of transactions, updating the blockchain state.
119134
- Enforce block size and validity limits, returning errors if constraints are violated.
120135
- Respect the ordering of transactions.
121136
- Update the mempool to remove all executed transactions.
137+
- Ensure atomic execution - either all transactions succeed or none do.
122138

123139
#### `SetFinal`
124140

@@ -139,12 +155,16 @@ Marks a block at the specified height as final, guaranteeing immutability for co
139155

140156
- Update the execution client's internal state to reflect that the specified block is final and immutable.
141157
- Ensure additional guarantees like cleaning up unnecessary resources associated with blocks deemed final.
158+
- Prevent any modifications to finalized blocks.
159+
- Optimize storage for finalized blocks if possible.
142160

143161
#### General Notes
144162

145163
1. **Thread-Safety**: All methods are not expected to be thread-safe, concurrent calls are not planned.
146164
2. **Error Handling**: All methods should follow robust error handling practices, ensuring meaningful errors are returned when issues occur.
147165
3. **Context Usage**: Methods should respect context-based deadlines and cancellations for long-running operations.
166+
4. **State Management**: The execution environment is responsible for maintaining its own state and ensuring consistency.
167+
5. **Atomicity**: Operations that modify state should be atomic - either fully succeed or fully fail.
148168

149169
### Types
150170

@@ -155,6 +175,61 @@ The Execution API was designed to be highly generic. As a result, the types intr
155175

156176
This design choice ensures maximum flexibility and allows the API to remain independent of specific implementations or formats. It facilitates interoperability across different execution environments while keeping the API lightweight and adaptable.
157177

178+
### Block Size Management
179+
180+
The Execution API includes `maxBytes` as a return value in both `InitChain` and `ExecuteTxs` methods. This parameter plays a crucial role in block size management:
181+
182+
1. **Initial Configuration**: During `InitChain`, the execution environment returns the maximum block size allowed by its genesis configuration. This value is used by Rollkit to enforce block size limits during block production.
183+
184+
2. **Dynamic Adjustment**: In `ExecuteTxs`, the execution environment can return an updated `maxBytes` value. This allows for dynamic adjustment of block size limits based on:
185+
- Network conditions
186+
- Resource availability
187+
- Protocol-specific requirements
188+
- Other runtime factors
189+
190+
3. **Implementation Requirements**:
191+
- The execution environment must ensure that blocks produced do not exceed the returned `maxBytes` value
192+
- If a block would exceed the limit, the execution environment should return an error
193+
- The value should be consistent with the execution environment's capabilities and constraints
194+
- A protocol overhead buffer is subtracted from the DA layer's max blob size to account for block headers and encoding
195+
196+
4. **System-wide Coordination**:
197+
- Rollkit gets the initial `maxBytes` value from the DA layer and passes it to the sequencer
198+
- The sequencer uses this value to limit the size of transaction batches it creates
199+
- The sequencer's `PopUpToMaxBytes` method ensures transactions don't exceed the size limit
200+
- This coordination ensures consistent block size constraints across the entire system
201+
202+
5. **Usage in Rollkit**:
203+
- Rollkit uses this value to validate block sizes before submission
204+
- Helps prevent oversized blocks from being produced
205+
- Enables dynamic adjustment of block size limits without protocol changes
206+
207+
### Implementation Guidelines
208+
209+
1. **State Management**:
210+
- Execution environments must maintain their own state
211+
- State transitions should be atomic
212+
- State should be persisted appropriately
213+
- State should be recoverable after crashes
214+
215+
2. **Error Handling**:
216+
- Return meaningful error messages
217+
- Handle context cancellations gracefully
218+
- Ensure proper cleanup on errors
219+
- Maintain state consistency even after errors
220+
221+
3. **Performance Considerations**:
222+
- Optimize for common operations
223+
- Consider caching where appropriate
224+
- Handle large state sizes efficiently
225+
- Minimize unnecessary state transitions
226+
227+
4. **Security**:
228+
- Validate all inputs thoroughly
229+
- Prevent unauthorized state modifications
230+
- Ensure proper access control
231+
- Handle sensitive data appropriately
232+
158233
### Sequence Diagrams
159234

160235
#### Block production
@@ -205,49 +280,6 @@ sequenceDiagram
205280
end
206281
```
207282

208-
### Changes in Rollkit
209-
210-
Because of improved separation of concerns, logic related to actual execution can be removed from rollkit.
211-
Rollkit will turn from fully-fledged ABCI client to kind of orchestrator, gluing together multiple modules.
212-
The role of Rollkit is coordination of Sequencer and Execution Environment and recording results in Data Availability layer.
213-
214-
Currently, Rollkit exposes ABCI and CometBFT compatible RPCs, manages genesis processing and mempool.
215-
This logic belongs to Execution Environment, and will be moved to Execution API implementations.
216-
217-
Removal of this logic from Rollkit enables further refactoring, for example removing all CometBFT dependencies.
218-
219-
#### Main changes in Rollkit packages
220-
221-
##### `block`
222-
223-
1. New processing in `Manager` - move from ABCI to Execution API oriented processing.
224-
225-
##### `node`
226-
227-
1. Simplification of `Node` interface.
228-
2. Removal of `LightClient` and `FullClient`.
229-
3. Cleanup/simplification of `FullNode` and `LightNode`.
230-
231-
##### `rpc`
232-
233-
1. Removal of ABCI and CometBFT methods.
234-
2. Introduction of Rollkit specific methods.
235-
236-
##### Other packages
237-
238-
Probably all the packages will be affected by cleanup and refactoring.
239-
240-
### Testing
241-
242-
As there is a lot of logic to be removed, corresponding tests can also be removed.
243-
Some of the other test are very ABCI-oriented and should be fixed or re-created.
244-
245-
Integration tests should be introduced to ensure that entire flow (from `InitChain` to `SetFinal`) works correctly.
246-
247-
### User documentation
248-
249-
All the tutorials needs to be updated to accommodate introduction of new binary (Execution API implementation).
250-
251283
## Status
252284

253285
Accepted
@@ -259,16 +291,23 @@ Accepted
259291
1. Simplification of rollkit's logic.
260292
2. Better separation of concerns.
261293
3. Removal of ABCI dependencies.
294+
4. Increased flexibility for different execution environments.
295+
5. Cleaner architecture with well-defined boundaries.
262296

263297
### Negative
264298

265299
1. More difficult deployment (another binary is needed).
266300
2. Need to reimplement ABCI execution environment.
301+
3. Additional complexity in coordinating between components.
302+
4. Potential performance overhead from additional abstraction layer.
267303

268304
### Neutral
269305

270306
1. Need to introduce new API exposed by rollkit.
307+
2. Changes to existing deployment procedures.
308+
3. Updates to documentation and tooling required.
271309

272310
## References
273311

274312
- [Rollkit EPIC for Execution API](https://github.com/rollkit/rollkit/issues/1802)
313+
- [go-execution repository](https://github.com/rollkit/go-execution)

0 commit comments

Comments
 (0)