Replies: 1 comment 4 replies
-
I will go over this in more detail this week.
Slow RPC is due to inoptimial implementation of it, switching to shared memory approach won't help here, the RPC implementation needs to be changed itself. Is problem we trying to solve is a geyser plugin? I have real doubt that it's, it is just a function call with extra jump. If our goal is to make RPC faster I would suggest fixing suboptimal RPC implementation itself.
trait IncomingUpdatesProvider {
async fn get_account_updates() -> Result<Vec<(ReplicaAccountInfoVersions, Slot, bool)>>
async fn get_slot_status_updates() -> Result<Vec<(Slot, Option<u64>, SlotStatus)>>
/// so on...
}
// or push version
trait Updater {
fn update_account(
&self,
account: ReplicaAccountInfoVersions,
slot: Slot,
is_startup: bool,
) -> Result<()>;
#[allow(unused_variables)]
fn update_slot_status(
&self,
slot: Slot,
parent: Option<u64>,
status: &SlotStatus,
) -> Result<()>;
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Request for Comments: Decoupling and Modernizing the MagicBlock Validator RPC Subsystem
Table of Contents
1. Abstract
This RFC proposes a comprehensive redesign of the MagicBlock validator’s RPC subsystem. The core objective is to decouple RPC functionality from the validator core, implementing it as an independent service that communicates with the validator via high-performance shared memory channels. This architectural separation is intended to improve maintainability, performance, and scalability, while enabling both components to evolve independently.
2. Assessment of Current Architecture
2.1 Tight Coupling
Currently, the RPC subsystem is tightly integrated with the validator core, resulting in a monolithic architecture with complex interdependencies. This tight coupling complicates maintenance, testing, and extensibility, and increases the risk of introducing bugs during development.
2.2 Outdated Technology Stack
The existing system relies on the deprecated
jsonrpc
library. While this library facilitated rapid prototyping, it introduces significant abstraction that obscures underlying mechanisms and limits opportunities for performance optimization.2.3 Inefficient Request Handling
2.3.1 HTTP Requests
HTTP request handling, though straightforward, is constrained by the limitations of the underlying libraries, resulting in suboptimal performance.
2.3.2 WebSocket Subscriptions
The current WebSocket (PubSub) implementation is particularly inefficient:
2.4 Unnecessary Overhead
All updates are routed through the Geyser plugin subsystem, despite the absence of active plugins. This introduces unnecessary computational overhead and latency without delivering tangible benefits.
3. Proposed Architecture
3.1 Core Architectural Changes
This RFC proposes a complete decoupling of the RPC subsystem from the validator core:
3.2 Technical Implementation Details
3.2.1 Shared State
Both the validator and RPC service will access the same underlying databases:
accountsdb
and theledger
. As these databases are memory-mapped, they can be opened by multiple processes:3.2.2 Communication Protocol
Communication between the validator and RPC service will utilize a shared memory queue, implemented as a fixed-length array with OS-provided synchronization. The shmemq crate provides an initial implementation. Each message type will have its own dedicated channel for efficiency. The primary message types are:
3.2.3 Validator-RPC Interface Design
For each system event, unique information will be communicated between the validator and RPC service:
accountsdb
and delivered directly to the consumer (e.g., a WebSocket subscription or Geyser plugin). Otherwise, no further action is taken.blockSubscribe
orslotSubscribe
subscriptions and notifies interested consumers directly, same applies for any registered geyser plugin.sendTransaction
orsimulateTransaction
requests, the RPC service parses and decodes the transaction, then sends it to the validator for execution or simulation.Additional Notes:
getSignatureStatuses
, the RPC service will cache recent transaction results and serve them directly, bypassing the database.3.2.4 Geyser Plugin Support
Solana provides several crates for Geyser plugin integration. The proposed RPC service will only require the interface crate, allowing it to dynamically load shared object plugins and invoke their methods as needed. If no plugins are registered, the RPC service incurs no additional overhead.
3.3 Deployment Model
The RPC service will be deployed alongside the validator on the same host, ensuring low-latency communication while maintaining process isolation.
4. Benefits
4.1 Separation of Concerns
This architectural split enforces a clear separation of responsibilities:
4.2 Independent Evolution
Decoupling the codebases allows each to evolve independently, avoiding dependency conflicts and enabling targeted optimizations. This addresses previous challenges such as dependency management issues caused by tight coupling.
4.3 Performance Improvements
The proposed architecture enables:
4.4 Improved Maintainability
Smaller, focused codebases are easier to understand, test, and maintain. This separation reduces cognitive load for developers and accelerates iteration.
5. Risks and Mitigations
5.1 Increased Deployment Complexity
Risk: Operating two processes instead of one increases operational complexity.
Mitigation: Develop comprehensive deployment tooling and documentation to ensure correct configuration and co-location of the processes.
5.2 Consistency Guarantees
Risk: In
accountsdb
, it is theoretically possible for an account to be modified by the validator while being read by the RPC service.Mitigation: Employ a synchronization primitive such as SeqLock (already integrated into the
accountsdb
storage format) to allow readers to retry reads if concurrent modifications are detected.6. Implementation Plan
The implementation will proceed in three primary stages:
The development effort is estimated at approximately three developer-weeks, with an additional two weeks for review and feedback.
7. Current Blockers
As noted, RocksDB’s limitations in shared mode present a significant blocker. A rewrite or replacement of the ledger storage layer is required before the RPC service can be fully implemented.
8. Conclusion
Decoupling the RPC subsystem from the MagicBlock validator core represents a significant architectural improvement. This approach will deliver better separation of concerns, improved maintainability, and enhanced performance, aligning with modern software engineering best practices and positioning the system for sustainable long-term evolution.
Beta Was this translation helpful? Give feedback.
All reactions