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
49 changes: 37 additions & 12 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ juniper_codegen = { version = "0.16.0", default-features = false }
juniper_graphql_ws = { version = "0.4.0", default-features = false }
lazy_static = "1.5.0"
libloading = "0.7.4"
litesvm = { version = "0.10.0", features = ["nodejs-internal"] }
litesvm-token = "0.10.0"
litesvm = { version = "0.11.0", features = ["nodejs-internal"] }
litesvm-token = "0.11.0"
log = "0.4.27"
mime_guess = { version = "2.0.4", default-features = false }
mustache = "0.9.0"
Expand Down Expand Up @@ -112,7 +112,7 @@ solana-commitment-config = { version = "3.1", default-features = false }
solana-compute-budget-interface = { version = "3.0", default-features = false }
solana-epoch-info = { version = "3.1", default-features = false }
solana-epoch-schedule = { version = "3.0", default-features = false }
solana-feature-gate-interface = { version = "3.0", default-features = false }
solana-feature-gate-interface = { version = "3.1", default-features = false }
solana-genesis-config = { version = "3.0", default-features = false }
# solana-geyser-plugin-manager = { version = "=3.1.6", default-features = false } # Disabled: version conflicts with litesvm 0.9.1 (requires solana-instruction =3.0.0 vs ~3.1)
solana-hash = { version = "3.1", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ impl StartSimnet {
} else {
Some(self.log_bytes_limit)
},
feature_config: self.feature_config(),
skip_signature_verification: self.skip_signature_verification,
surfnet_id: self.surfnet_id.clone(),
snapshot,
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/rpc/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,7 @@ mod tests {
#[test]
fn test_request_airdrop() {
let pk = Pubkey::new_unique();
let lamports = 1000;
let lamports = 1_000_000;
let setup = TestSetup::new(SurfpoolFullRpc);
let res = setup
.rpc
Expand Down
34 changes: 3 additions & 31 deletions crates/core/src/surfnet/locker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,7 @@ impl SurfnetSvmLocker {
/// Retrieves a local account from the SVM cache, returning a contextualized result.
pub fn get_account_local(&self, pubkey: &Pubkey) -> SvmAccessContext<GetAccountResult> {
self.with_contextualized_svm_reader(|svm_reader| {
let result = svm_reader.inner.get_account_result(pubkey).unwrap();

if result.is_none() {
return match svm_reader.get_account_from_feature_set(pubkey) {
Some(account) => {
GetAccountResult::FoundAccount(
*pubkey, account,
// mark this as an account to insert into the SVM, since the feature is activated and LiteSVM doesn't
// automatically insert activated feature accounts
// TODO: mark as false once https://github.com/LiteSVM/litesvm/pull/308 is released
true,
)
}
None => GetAccountResult::None(*pubkey),
};
} else {
return result;
}
return svm_reader.inner.get_account_result(pubkey).unwrap();
})
}

Expand Down Expand Up @@ -357,19 +340,8 @@ impl SurfnetSvmLocker {
let mut accounts = vec![];

for pubkey in pubkeys {
let mut result = svm_reader.inner.get_account_result(pubkey).unwrap();
if result.is_none() {
result = match svm_reader.get_account_from_feature_set(pubkey) {
Some(account) => GetAccountResult::FoundAccount(
*pubkey, account,
// mark this as an account to insert into the SVM, since the feature is activated and LiteSVM doesn't
// automatically insert activated feature accounts
// TODO: mark as false once https://github.com/LiteSVM/litesvm/pull/308 is released
true,
),
None => GetAccountResult::None(*pubkey),
}
};
let result = svm_reader.inner.get_account_result(pubkey).unwrap();
if result.is_none() {};
accounts.push(result);
}
accounts
Expand Down
53 changes: 32 additions & 21 deletions crates/core/src/surfnet/surfnet_lite_svm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use crate::{
surfnet::{GetAccountResult, locker::is_supported_token_program},
};

pub const LAMPORTS_PER_SOL: u64 = 1_000_000_000;

#[derive(Clone)]
pub struct SurfnetLiteSvm {
pub svm: LiteSVM,
Expand All @@ -31,7 +33,7 @@ pub struct SurfnetLiteSvm {
impl SurfnetLiteSvm {
pub fn new() -> Self {
Self {
svm: LiteSVM::new(),
svm: LiteSVM::default(),
db: None,
}
}
Expand All @@ -49,16 +51,37 @@ impl SurfnetLiteSvm {
}
}

/// Initializes LiteSVM with as few settings as possible; for initial startup of VM
/// that will be overriden later when more context is available.
fn base_litesvm_settings() -> LiteSVM {
LiteSVM::default()
.with_feature_set(FeatureSet::default()) // start with all features enabled, but don't load feature accounts
.with_builtins()
.with_lamports(1_000_000u64.wrapping_mul(LAMPORTS_PER_SOL))
.with_sysvars()
.with_default_programs()
.with_blockhash_check(false)
.with_sigverify(false)
}

/// Initializes LiteSVM with full settings; starts with base settings, then adds in
/// features and other setup that depends on the feature set.
fn full_litesvm_settings(feature_set: FeatureSet) -> LiteSVM {
Self::base_litesvm_settings()
.with_feature_set(feature_set)
.with_feature_accounts()
.with_builtins()
.with_sysvars()
.with_default_programs()
}

pub fn initialize(
mut self,
feature_set: FeatureSet,
// feature_set: FeatureSet,
database_url: Option<&str>,
surfnet_id: &str,
) -> SurfpoolResult<Self> {
self.svm = LiteSVM::new()
.with_blockhash_check(false)
.with_sigverify(false)
.with_feature_set(feature_set);
self.svm = Self::base_litesvm_settings();

create_native_mint(&mut self);

Expand All @@ -79,10 +102,7 @@ impl SurfnetLiteSvm {
}

pub fn reset(&mut self, feature_set: FeatureSet) -> SurfpoolResult<()> {
self.svm = LiteSVM::new()
.with_blockhash_check(false)
.with_sigverify(false)
.with_feature_set(feature_set);
self.svm = Self::full_litesvm_settings(feature_set);

create_native_mint(self);

Expand Down Expand Up @@ -111,10 +131,7 @@ impl SurfnetLiteSvm {
let clock = self.svm.get_sysvar::<Clock>();

// todo: this is also resetting the log bytes limit and airdrop keypair, would be nice to avoid
self.svm = LiteSVM::new()
.with_blockhash_check(false)
.with_sigverify(false)
.with_feature_set(feature_set);
self.svm = Self::full_litesvm_settings(feature_set);

create_native_mint(self);

Expand All @@ -125,13 +142,7 @@ impl SurfnetLiteSvm {
}

pub fn apply_feature_config(&mut self, feature_set: FeatureSet) -> &mut Self {
self.svm = LiteSVM::new()
.with_blockhash_check(false)
.with_sigverify(false)
.with_feature_set(feature_set)
.with_builtins()
.with_sysvars()
.with_default_programs();
self.svm = Self::full_litesvm_settings(feature_set);

create_native_mint(self);
self
Expand Down
Loading
Loading