Replies: 1 comment 1 reply
-
Impressive proposals, here is some of my feedback and questions raised:
If I'm not mistaken, the non-forking assumption comes from the assumption that the security mechanism will not use optimistic proofs. This could work if real-time zero-knowledge proofs were possible, but that is still far from a reality. Are we sure this assumption will hold with future security mechanisms? (e.g., rollbacks might happen with optimistic proofs)
Do superblocks contain some form of snapshot of the state at the start of the block? That would really make them self-contained and could help the proving of most security mechanisms. MDBX focuses on the local-only setting. Wouldn't it make sense to prepare for a case where a single operator runs a distributed cluster of validators sharing a private key and writing to the same storage?
Why rkyv over bytemuck? Bytemuck has more recent updates, is less verbose (rkyv seems to use a new proc-macro), but has strict alignment enforcement.
Distributed storage would come with multiple writers, which could help solve contention of these separate parts of the data. Moreover, distributed DB often claim to have the highest throughput (although I'm not sure about their consistency properties)
I don't understand this: Where is the data flushed? Does that imply flushing pending transactions that are not processed yet? What's the connection between the flush and the checkpoint? |
Beta Was this translation helpful? Give feedback.
-
MIMD-0007: MagicBlock Ledger Redesign
Table of Contents
Abstract
The current MagicBlock validator ledger implementation is inherited from the
Solana codebase. While robust, this implementation is overengineered for
MagicBlock’s operational model, resulting in code bloat, suboptimal
performance—especially in hot write paths—and maintenance challenges due to
unused or irrelevant code. This MagicBlock Improvement Document (MIMD) proposes
a radical redesign of the blockstore, leveraging the non-forking, append-only
nature of the MagicBlock ledger. The new design aims to maximize throughput,
scalability, and maintainability by introducing a custom storage engine,
optimized data formats, and efficient indexing strategies.
1. Motivation
The inherited Solana ledger implementation is tailored for a different
consensus and operational paradigm, where forking and random access are common.
MagicBlock, by contrast, operates as an ephemeral rollup with strictly
append-only, non-forking semantics. This mismatch leads to several
inefficiencies and limitations:
compaction are unnecessary and unused.
storage engine and serialization overhead, especially in single-threaded hot
paths.
cognitive load and risk of bugs, making future improvements harder.
access the same database concurrently, making it unusable with standalone
services like RPC or analytics.
A purpose-built ledger can address these issues, unlocking higher throughput,
simpler operations, and a more maintainable codebase.
2. Current Implementation Overview
2.1 Storage Engine
2.2 Storage Format
Multiple column families are used, each with custom key/value formats:
2.3 Write Behavior
3. Proposed Design
3.1 Custom Storage Engine
3.1.1 Overview
designed specifically for append-only, non-forking workloads.
a contiguous range of blocks. This segmentation allows for efficient
management, rotation, and truncation of ledger data.
files) storing serialized blocks, transactions, and metadata in append-only,
interleaved fashion. Each superblock is self-contained, a mini-ledger in essense, and can be managed
independently.
3.1.2 Superblock Structure
3.1.3 Advantages
3.1.4 Account Data Modifications
3.2 Storage Format
SanitizedTransaction
andTransactionStatusMeta
. These bundles are written sequentially at preconfigured alignments, and a sequence of these is delimited by block data, allowing efficient block and transaction retrieval.3.3 Index Structures
3.3.1 Block Index
3.3.2 Transaction Index
3.3.3 Address Signatures Index
rkyv-serialized, along with a boolean flag indicating whether the account was
writable in that transaction.
3.4 High Level Diagram
4. Operational Considerations
4.1 Hot/Cold Data Management
4.2 Truncation and Archival
4.3 Multi-process and Service Access
5. Open Questions & Future Work
presence of high write concurrency? As MDBX has a single writer model, in
order to increase write efficiency and decrease transaction creation
overhead, multiple (potentially thousands under high load) inserts can be
batched together from a single inserter thread. The Address signatures
index writes can be deferred to another thread,
as this index is used primarily for the convenience of explorers and thus
doesn't require atomicity with other writes. To avoid lock contention with
the Transaction index, this index can be moved to a
separate MDBX environment.
durability? After each block insert, a system-wide flush will be issued, thus
creating a checkpoint for later ledger replay in case a crash occurs. This
ensures that the ledger can always be recovered to a consistent state.
inserts per second. As we only have one primary index (Transactions
index), this number directly translates to TPS, as block
inserts should be relatively infrequent in comparison, and writes to Address
signatures index can happen in deferred fashion
in the background. Thus, achieving around 100K TPS should be well within the
realm of possibilities.
ledger to the new superblock-based design will be required, including data
conversion, downtime minimization, and rollback strategies.
benchmarks must be defined and executed to validate the new implementation
under realistic workloads.
6. Conclusion
This proposal outlines a comprehensive redesign of the MagicBlock ledger,
tailored to its unique operational model. By leveraging append-only,
non-forking semantics, a custom storage engine, and faster and cheaper
serialization, the new design promises significant improvements in throughput,
scalability, and maintainability. The proposed architecture not only addresses
the current bottlenecks and inefficiencies but also lays a solid foundation for
future enhancements, operational flexibility, and ease of integration with
external services.
Beta Was this translation helpful? Give feedback.
All reactions