You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7fd4583
Browse filesBrowse the repository at this point in the historyBrowse files
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 -->
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
17
30
18
31
## Decision
19
32
@@ -69,6 +82,7 @@ Initializes the blockchain's state based on genesis information. This method is
69
82
- Initialize rollup according to the genesis.
70
83
- Generate an initial `stateRoot` representing the genesis state of the rollup.
71
84
- Return the maximum allowable block size (`maxBytes`).
85
+
- Ensure all necessary state is initialized for subsequent operations.
72
86
73
87
#### `GetTxs`
74
88
@@ -91,6 +105,7 @@ Transactions returned by execution client will be passed by rollkit to sequencer
91
105
- Access the mempool and retrieve all available transactions.
92
106
- If no transactions are available, return an empty slice without error.
93
107
- Do not remove ("reap") transactions from mempool.
108
+
- Ensure transactions are valid and properly formatted.
94
109
95
110
#### `ExecuteTxs`
96
111
@@ -119,6 +134,7 @@ Executes a given set of transactions, updating the blockchain state.
119
134
- Enforce block size and validity limits, returning errors if constraints are violated.
120
135
- Respect the ordering of transactions.
121
136
- Update the mempool to remove all executed transactions.
137
+
- Ensure atomic execution - either all transactions succeed or none do.
122
138
123
139
#### `SetFinal`
124
140
@@ -139,12 +155,16 @@ Marks a block at the specified height as final, guaranteeing immutability for co
139
155
140
156
- Update the execution client's internal state to reflect that the specified block is final and immutable.
141
157
- 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.
142
160
143
161
#### General Notes
144
162
145
163
1.**Thread-Safety**: All methods are not expected to be thread-safe, concurrent calls are not planned.
146
164
2.**Error Handling**: All methods should follow robust error handling practices, ensuring meaningful errors are returned when issues occur.
147
165
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.
148
168
149
169
### Types
150
170
@@ -155,6 +175,61 @@ The Execution API was designed to be highly generic. As a result, the types intr
155
175
156
176
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.
157
177
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
+
158
233
### Sequence Diagrams
159
234
160
235
#### Block production
@@ -205,49 +280,6 @@ sequenceDiagram
205
280
end
206
281
```
207
282
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
-
251
283
## Status
252
284
253
285
Accepted
@@ -259,16 +291,23 @@ Accepted
259
291
1. Simplification of rollkit's logic.
260
292
2. Better separation of concerns.
261
293
3. Removal of ABCI dependencies.
294
+
4. Increased flexibility for different execution environments.
295
+
5. Cleaner architecture with well-defined boundaries.
262
296
263
297
### Negative
264
298
265
299
1. More difficult deployment (another binary is needed).
266
300
2. Need to reimplement ABCI execution environment.
301
+
3. Additional complexity in coordinating between components.
302
+
4. Potential performance overhead from additional abstraction layer.
267
303
268
304
### Neutral
269
305
270
306
1. Need to introduce new API exposed by rollkit.
307
+
2. Changes to existing deployment procedures.
308
+
3. Updates to documentation and tooling required.
271
309
272
310
## References
273
311
274
312
-[Rollkit EPIC for Execution API](https://github.com/rollkit/rollkit/issues/1802)
0 commit comments