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
19 changes: 10 additions & 9 deletions magicblock-api/src/fund_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ pub(crate) fn fund_account_with_data(
lamports: u64,
size: usize,
) {
let account = if let Some(mut acc) = accountsdb.get_account(pubkey) {
acc.set_lamports(lamports);
acc.set_data(vec![0; size]);
acc
} else {
AccountSharedData::new(lamports, size, &Default::default())
};
if accountsdb.get_account(pubkey).is_some() {
return;
}
let account = AccountSharedData::new(lamports, size, &Default::default());
let _ = accountsdb.insert_account(pubkey, &account);
}

Expand Down Expand Up @@ -70,16 +67,20 @@ pub(crate) fn funded_faucet(
}

pub(crate) fn fund_magic_context(accountsdb: &AccountsDb) {
const CONTEXT_LAMPORTS: u64 = u64::MAX;

fund_account_with_data(
Comment thread
bmuddha marked this conversation as resolved.
accountsdb,
&magic_program::MAGIC_CONTEXT_PUBKEY,
u64::MAX,
CONTEXT_LAMPORTS,
MagicContext::SIZE,
);
let mut magic_context = accountsdb
.get_account(&magic_program::MAGIC_CONTEXT_PUBKEY)
.unwrap();
.expect("magic context should have been created");
Comment thread
taco-paco marked this conversation as resolved.
magic_context.set_delegated(true);
magic_context.set_owner(magic_program::ID);

let _ = accountsdb
.insert_account(&magic_program::MAGIC_CONTEXT_PUBKEY, &magic_context);
}
Expand Down
2 changes: 1 addition & 1 deletion magicblock-api/src/genesis_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use solana_rent::Rent;
use solana_signer::Signer;

// Default amount received by the validator
const VALIDATOR_LAMPORTS: u64 = 42;
const VALIDATOR_LAMPORTS: u64 = u64::MAX / 2;

pub struct GenesisConfigInfo {
pub genesis_config: GenesisConfig,
Expand Down
5 changes: 4 additions & 1 deletion magicblock-api/src/magic_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use magicblock_accounts::{
scheduled_commits_processor::ScheduledCommitsProcessorImpl,
ScheduledCommitsProcessor,
};
use magicblock_accounts_db::AccountsDb;
use magicblock_accounts_db::{traits::AccountsBank, AccountsDb};
use magicblock_aperture::{
initialize_aperture,
state::{NodeContext, SharedState},
Expand Down Expand Up @@ -168,6 +168,9 @@ impl MagicValidator {
AccountsDb::new(&config.accountsdb, &config.storage, last_slot)?;
log_timing("startup", "accountsdb_init", step_start);
for (pubkey, account) in genesis_config.accounts {
if accountsdb.get_account(&pubkey).is_some() {
continue;
}
Comment thread
GabrielePicco marked this conversation as resolved.
let _ = accountsdb.insert_account(&pubkey, &account.into());
}

Expand Down