system_program must be a static lib as it allocates Account memory
This commit is contained in:
parent
8597701b0f
commit
59e6bd115e
|
@ -15,5 +15,9 @@ solana-sdk = { path = "../../../sdk", version = "0.11.0" }
|
|||
|
||||
[lib]
|
||||
name = "solana_system_program"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
# Must be a static lib instead of cdylib because `SystemInstruction::CreateAccount`
|
||||
# allocates Rust memory.
|
||||
# cc: https://github.com/solana-labs/solana/issues/2004#issuecomment-444570081
|
||||
crate-type = ["lib"]
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
extern crate bincode;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
|
@ -11,21 +10,14 @@ use solana_sdk::native_program::ProgramError;
|
|||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::system_instruction::SystemInstruction;
|
||||
use solana_sdk::system_program;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(
|
||||
pub fn entrypoint(
|
||||
_program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
data: &[u8],
|
||||
_tick_height: u64,
|
||||
) -> Result<(), ProgramError> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
INIT.call_once(|| {
|
||||
// env_logger can only be initialized once
|
||||
env_logger::init();
|
||||
});
|
||||
|
||||
if let Ok(syscall) = deserialize(data) {
|
||||
trace!("process_instruction: {:?}", syscall);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
|
|
|
@ -113,6 +113,7 @@ extern crate socket2;
|
|||
extern crate solana_drone;
|
||||
extern crate solana_jsonrpc_core as jsonrpc_core;
|
||||
extern crate solana_jsonrpc_http_server as jsonrpc_http_server;
|
||||
extern crate solana_system_program;
|
||||
#[macro_use]
|
||||
extern crate solana_jsonrpc_macros as jsonrpc_macros;
|
||||
extern crate solana_jsonrpc_pubsub as jsonrpc_pubsub;
|
||||
|
|
|
@ -4,6 +4,7 @@ use solana_sdk::native_program::ProgramError;
|
|||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::system_program;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_system_program;
|
||||
|
||||
/// Reasons the runtime might have rejected a transaction.
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
@ -36,12 +37,21 @@ fn process_instruction(
|
|||
.collect();
|
||||
keyed_accounts.append(&mut keyed_accounts2);
|
||||
|
||||
if system_program::check_id(&program_id) {
|
||||
solana_system_program::entrypoint(
|
||||
&program_id,
|
||||
&mut keyed_accounts[1..],
|
||||
&tx.instructions[instruction_index].userdata,
|
||||
tick_height,
|
||||
)
|
||||
} else {
|
||||
native_loader::process_instruction(
|
||||
&program_id,
|
||||
&mut keyed_accounts,
|
||||
&tx.instructions[instruction_index].userdata,
|
||||
tick_height,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn verify_instruction(
|
||||
|
|
Loading…
Reference in New Issue