Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 150 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ members = [
"magicblock-task-scheduler",
"magicblock-version",
"programs/magicblock",
"storage-proto"
"storage-proto",
]

# This prevents a Travis CI error when building for Windows.
Expand All @@ -47,9 +47,7 @@ version = "0.15.4"
magicblock-aml = { path = "magicblock-aml" }
magicblock-aperture = { path = "magicblock-aperture" }
magicblock-chainlink = { path = "magicblock-chainlink" }
magicblock-committor-program = { path = "magicblock-committor-program", features = [
"no-entrypoint"
] }
magicblock-committor-program = { path = "magicblock-committor-program", features = ["no-entrypoint"] }
magicblock-committor-service = { path = "magicblock-committor-service" }
magicblock-config = { path = "magicblock-config" }
magicblock-core = { path = "magicblock-core" }
Expand Down Expand Up @@ -104,6 +102,7 @@ git-version = "0.3.9"
helius-laserstream = { git = "https://github.com/magicblock-labs/laserstream-sdk.git", branch = "mbv-4.0+conn-fix" }
http-body-util = "0.1.5"
humantime = { version = "1.1.1", package = "humantime-serde" }
hydra-api = "0.2"
hyper = "1.11.1"
hyper-util = "0.1.20"
isocountry = "0.3.2"
Expand Down Expand Up @@ -186,12 +185,8 @@ solana-instructions-sysvar = { version = "4.0" }
solana-keypair = { version = "3.1" }
solana-loader-v3-interface = { version = "7.0" }
solana-loader-v4-interface = { version = "3.1" }
solana-log-collector = { package = "solana-svm-log-collector", version = "=4.2.2", features = [
"agave-unstable-api"
] }
solana-measure = { package = "solana-svm-measure", version = "=4.2.2", features = [
"agave-unstable-api"
] }
solana-log-collector = { package = "solana-svm-log-collector", version = "=4.2.2", features = ["agave-unstable-api"] }
solana-measure = { package = "solana-svm-measure", version = "=4.2.2", features = ["agave-unstable-api"] }
solana-message = { version = ">=4.2.3,<4.5.0" }
solana-metrics = { version = "=4.2.2", features = ["agave-unstable-api"] }
solana-native-token = { version = "3.0" }
Expand Down
1 change: 1 addition & 0 deletions bins/magicblock-validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ solana-pubkey = { workspace = true }
solana-rpc-client = { workspace = true }
solana-rpc-client-api = { workspace = true }
solana-signer = { workspace = true }
solana-system-interface = { workspace = true, features = ["bincode"] }
solana-transaction = { workspace = true }
solana-transaction-error = { workspace = true }
thiserror = { workspace = true }
Expand Down
8 changes: 3 additions & 5 deletions bins/magicblock-validator/src/leader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use magicblock_services::{
actions_callback_service::ActionsCallbackService,
undelegation_request_service::UndelegationRequestService,
};
use magicblock_task_scheduler::{SchedulerDatabase, TaskSchedulerService};
use magicblock_task_scheduler::TaskSchedulerService;
use nucleus::{
metrics::EventTimer,
shutdown::{Service, ShutdownManager, ShutdownReason},
Expand Down Expand Up @@ -168,12 +168,10 @@ impl Leader {
rpc_shutdown.terminate(reason);
});

let task_scheduler_db_path = SchedulerDatabase::path(&engine_ledger);
debug!(path = %task_scheduler_db_path.display(), "Initializing task scheduler");
debug!("Initializing task scheduler");
let task_scheduler = Some(TaskSchedulerService::new(
&task_scheduler_db_path,
&config.task_scheduler,
engine.clone(),
config.aperture.listen.http(),
config.engine.blockstore.blocktime,
)?);
timer.record("Task scheduler initialized");
Expand Down
27 changes: 0 additions & 27 deletions config.validator.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -232,33 +232,6 @@ request-timeout = "5s"
# Env: MBV_CHAINLINK__RISK__CHECK_STRATEGY
check-strategy = "all-signers"

# ==============================================================================
# Internal Task Scheduler
# ==============================================================================
[task-scheduler]
# If true, clears all pending scheduled tasks on startup.
# Default: false
# Env: MBV_TASK_SCHEDULER__RESET
reset = false

# The minimum interval between task executions.
# Supports humantime (e.g. "10ms", "1s").
# Default: "10ms"
# Env: MBV_TASK_SCHEDULER__MIN_INTERVAL
min-interval = "10ms"

# How long failed task executions and failed scheduling records are retained.
# Supports humantime (e.g. "1h", "7d").
# Default: "14d"
# Env: MBV_TASK_SCHEDULER__FAILED_TASK_RETENTION
failed-task-retention = "14d"

# How often old failed task executions and failed scheduling records are deleted.
# Supports humantime (e.g. "1m", "1h").
# Default: "1h"
# Env: MBV_TASK_SCHEDULER__FAILED_TASK_CLEANUP_INTERVAL
failed-task-cleanup-interval = "1h"

# ==============================================================================
# Pre-loaded Programs
# ==============================================================================
Expand Down
2 changes: 0 additions & 2 deletions magicblock-config/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod grpc;
pub mod ledger;
pub mod metrics;
pub mod program;
pub mod scheduler;

pub use aperture::ApertureConfig;
pub use chain::{
Expand All @@ -17,4 +16,3 @@ pub use engine::{EngineConfig, FollowerReplication, LeaderReplication};
pub use grpc::GrpcConfig;
pub use ledger::LedgerConfig;
pub use program::LoadableProgram;
pub use scheduler::TaskSchedulerConfig;
42 changes: 0 additions & 42 deletions magicblock-config/src/config/scheduler.rs

This file was deleted.

7 changes: 0 additions & 7 deletions magicblock-config/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ pub const DEFAULT_METRICS_ADDR: &str = "0.0.0.0:9000";
/// Default frequency of metrics collection in seconds
pub const DEFAULT_METRICS_COLLECT_FREQUENCY_SEC: u64 = 30;

// Task Scheduler Defaults
pub const DEFAULT_TASK_SCHEDULER_MIN_INTERVAL_MILLIS: u64 = 10;
pub const DEFAULT_TASK_SCHEDULER_FAILED_TASK_RETENTION_SECS: u64 =
14 * 24 * 60 * 60; // 14 days
pub const DEFAULT_TASK_SCHEDULER_FAILED_TASK_CLEANUP_INTERVAL_SECS: u64 =
60 * 60; // 1 hour

// ChainLink Defaults
/// Default delay in milliseconds between resubscribing to accounts after a pubsub reconnection
pub const DEFAULT_RESUBSCRIPTION_DELAY_MS: u64 = 50;
Expand Down
6 changes: 1 addition & 5 deletions magicblock-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ mod tests;
pub mod types;

use crate::{
config::{
ChainLinkConfig, CommittorConfig, LedgerConfig, LoadableProgram,
TaskSchedulerConfig,
},
config::{ChainLinkConfig, CommittorConfig, LedgerConfig, LoadableProgram},
types::Remote,
};

Expand Down Expand Up @@ -74,7 +71,6 @@ pub struct LeaderParams {
pub commit: CommittorConfig,
pub ledger: LedgerConfig,
pub chainlink: ChainLinkConfig,
pub task_scheduler: TaskSchedulerConfig,
pub programs: Vec<LoadableProgram>,
}

Expand Down
13 changes: 13 additions & 0 deletions magicblock-magic-program-api/src/ephemeral.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use solana_instruction::error::InstructionError;

use crate::{EPHEMERAL_ACCOUNT_STATIC_SIZE, EPHEMERAL_RENT_PER_BYTE};

/// Calculates rent for an ephemeral account based on its data length.
pub fn rent_for(data_len: u32) -> Result<u64, InstructionError> {
let total_size = u64::from(data_len)
.checked_add(EPHEMERAL_ACCOUNT_STATIC_SIZE)
.ok_or(InstructionError::ArithmeticOverflow)?;
total_size
.checked_mul(EPHEMERAL_RENT_PER_BYTE)
.ok_or(InstructionError::ArithmeticOverflow)
}
16 changes: 4 additions & 12 deletions magicblock-magic-program-api/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,10 @@ pub enum MagicBlockInstruction {
/// | `1` | Account. Account to evict. | WRITE |
EvictAccount { pubkey: Pubkey },

/// Executes a crank
///
/// # Account references
/// | Index | Account | Access |
/// | --- | --- | --- |
/// | `0` | Validator Authority. Authorizes crank execution. | SIGNER |
/// | `1` | Crank signer PDA. PDA signer used by embedded instructions. | - |
/// | `2..n` | Instruction accounts. Accounts required by the embedded instructions. | - |
ExecuteCrank {
authority: Pubkey,
instructions: Vec<Instruction>,
},
/// Reserved: crank execution moved to hydra. The variant is kept so
/// `CloseMagicAta` retains its wire discriminant for existing clients
/// (MagicRoot / eSPL).
_ExecuteCrank,

/// Closes a drained Magic ATA previously created via
/// `CreateMagicAta`. No-op unless the account matches the
Expand Down
9 changes: 9 additions & 0 deletions magicblock-magic-program-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub mod args;
pub mod compat;
pub mod ephemeral;
pub mod instruction;
pub mod pda;
pub mod response;
Expand Down Expand Up @@ -37,3 +38,11 @@ pub const MAGIC_CONTEXT_SIZE: usize = 1024 * 1024 * 5; // 5 MB
/// Rent rate for ephemeral accounts: 32 lamports per byte.
/// This is ~109x cheaper than Solana's base rent (3,480 lamports/byte).
pub const EPHEMERAL_RENT_PER_BYTE: u64 = 32;

/// Fixed per-account storage overhead charged as rent on top of the data.
///
/// Rent is a policy of the magic program rather than of the account layout, so
/// the value is pinned here: lamports (8) + owner (32) + slot (8) + flags (4) +
/// data capacity (4) + data length (4). It previously came from the account
/// crate, which no longer publishes its static size.
pub const EPHEMERAL_ACCOUNT_STATIC_SIZE: u64 = 60;
9 changes: 0 additions & 9 deletions magicblock-magic-program-api/src/pda.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
use crate::Pubkey;

pub const CRANK_SEED: &[u8] = b"crank-executor";
pub fn crank_signer_pda(authority: &Pubkey) -> Pubkey {
Pubkey::find_program_address(
&[CRANK_SEED, authority.as_ref()],
&crate::CRANK_PROGRAM_ID,
)
.0
}

/// Callback signer PDA info
pub const CALLBACK_SEED: &[u8] = b"callback-executor";
const CALLBACK_SIGNER_PDA: ([u8; 32], u8) =
Expand Down
6 changes: 1 addition & 5 deletions magicblock-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{collections::HashMap, fs, path::PathBuf};
use keeper::builder::KeeperBuilder;
use magicblock_config::config::{EngineConfig, LoadableProgram};
use magicblock_program::magicblock_processor::{
CallbackEntrypoint, CrankEntrypoint, Entrypoint, EphemeralSystemEntrypoint,
CallbackEntrypoint, Entrypoint, EphemeralSystemEntrypoint,
};
use solana_program_runtime::{
invoke_context::BuiltinFunctionWithContext,
Expand Down Expand Up @@ -57,10 +57,6 @@ fn builtins() -> HashMap<Pubkey, BuiltinFunctionWithContext> {
magicblock_program::ID,
(Entrypoint::vm, Entrypoint::codegen),
);
builtins.insert(
magicblock_program::CRANK_PROGRAM_ID,
(CrankEntrypoint::vm, CrankEntrypoint::codegen),
);
builtins.insert(
magicblock_program::CALLBACK_PROGRAM_ID,
(CallbackEntrypoint::vm, CallbackEntrypoint::codegen),
Expand Down
17 changes: 8 additions & 9 deletions magicblock-task-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ repository.workspace = true
version.workspace = true

[dependencies]
chrono = { workspace = true }
engine = { workspace = true }
futures-util = { workspace = true }
hydra-api = { workspace = true, features = ["client", "ephemeral"] }
keeper = { workspace = true }
magicblock-config = { workspace = true }
magicblock-program = { workspace = true }
nucleus = { workspace = true }
rusqlite = { workspace = true }
solana-account = { workspace = true }
solana-instruction = { workspace = true, features = ["wincode"] }
solana-message = { workspace = true }
solana-keypair = { workspace = true }
solana-pubkey = { workspace = true }
solana-rpc-client-api = { workspace = true }
solana-signature = { workspace = true }
solana-sha256-hasher = { workspace = true }
solana-signer = { workspace = true }
solana-system-interface = { workspace = true, features = ["bincode"] }
solana-transaction = { workspace = true }
solana-transaction-error = { workspace = true }
solana-rpc-client = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tokio-util = { workspace = true, features = ["time"] }
tokio-util = { workspace = true }
tracing = { workspace = true }
wincode = { workspace = true }

Expand Down
Loading
Loading