Skip to content
Closed
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ rand = "0.8.5"
rayon = "1.10.0"
rusqlite = { version = "0.34.0", features = ["bundled"] } # bundled sqlite 3.44
rustc_version = "0.4"
rustc-hash = "2.1"
scc = "2.4"
semver = "1.0.22"
serde = "1.0.217"
Expand Down
2 changes: 2 additions & 0 deletions magicblock-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ magicblock-program = { workspace = true }
magicblock-validator-admin = { workspace = true }
magic-domain-program = { workspace = true }

num_cpus = { workspace = true }

solana-feature-set = { workspace = true }
solana-inline-spl = { workspace = true }
solana-rpc = { workspace = true }
Expand Down
10 changes: 8 additions & 2 deletions magicblock-api/src/magic_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,14 @@ impl MagicValidator {
base_fee: config.validator.base_fees.unwrap_or_default(),
featureset: txn_scheduler_state.environment.feature_set.clone(),
};
let transaction_scheduler =
TransactionScheduler::new(1, txn_scheduler_state);
// We dedicate half of the available resources to the execution
// runtime, -1 is taken up by the transaction scheduler itself
let transaction_executors =
(num_cpus::get() / 2).saturating_sub(1).max(1) as u32;
let transaction_scheduler = TransactionScheduler::new(
transaction_executors,
txn_scheduler_state,
);
transaction_scheduler.spawn();

let shared_state = SharedState::new(
Expand Down
3 changes: 3 additions & 0 deletions magicblock-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ solana-transaction = { workspace = true }
solana-transaction-status = { workspace = true }
solana-transaction-error = { workspace = true }

rustc-hash = { workspace = true }

[dev-dependencies]
guinea = { workspace = true }
solana-keypair = { workspace = true }
solana-signature = { workspace = true }
solana-signer = { workspace = true }
test-kit = { workspace = true }
11 changes: 6 additions & 5 deletions magicblock-processor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use solana_svm::transaction_processor::{
use tokio::{runtime::Builder, sync::mpsc::Sender};

use crate::{
builtins::BUILTINS, scheduler::state::TransactionSchedulerState, WorkerId,
builtins::BUILTINS,
scheduler::{locks::ExecutorId, state::TransactionSchedulerState},
};

/// A dedicated, single-threaded worker responsible for processing transactions using
Expand All @@ -30,7 +31,7 @@ use crate::{
/// executors can be spawned to process transactions in parallel.
pub(super) struct TransactionExecutor {
/// A unique identifier for this worker instance.
id: WorkerId,
id: ExecutorId,
/// A handle to the global accounts database for reading and writing account state.
accountsdb: Arc<AccountsDb>,
/// A handle to the global ledger for writing committed transaction history.
Expand All @@ -50,7 +51,7 @@ pub(super) struct TransactionExecutor {
/// A channel to send out account state updates after processing.
accounts_tx: AccountUpdateTx,
/// A back-channel to notify the `TransactionScheduler` that this worker is ready for more work.
ready_tx: Sender<WorkerId>,
ready_tx: Sender<ExecutorId>,
/// A read lock held during a slot's processing to synchronize with critical global
/// operations like `AccountsDb` snapshots.
sync: StWLock,
Expand All @@ -65,10 +66,10 @@ impl TransactionExecutor {
/// with a globally shared one. This allows updates made by one executor to be immediately
/// visible to all others, preventing redundant program loads.
pub(super) fn new(
id: WorkerId,
id: ExecutorId,
state: &TransactionSchedulerState,
rx: TransactionToProcessRx,
ready_tx: Sender<WorkerId>,
ready_tx: Sender<ExecutorId>,
index: Arc<AtomicUsize>,
programs_cache: Arc<RwLock<ProgramCache<SimpleForkGraph>>>,
) -> Self {
Expand Down
2 changes: 0 additions & 2 deletions magicblock-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use solana_program::feature;
use solana_rent_collector::RentCollector;
use solana_svm::transaction_processor::TransactionProcessingEnvironment;

type WorkerId = u8;

/// Initialize an SVM enviroment for transaction processing
pub fn build_svm_env(
accountsdb: &AccountsDb,
Expand Down
157 changes: 0 additions & 157 deletions magicblock-processor/src/scheduler.rs

This file was deleted.

Loading
Loading