Incorporate preloaded bpf loader
This commit is contained in:
parent
21eae981f9
commit
d5f20980eb
|
@ -1,5 +1,5 @@
|
||||||
use bincode::{deserialize, serialize};
|
use bincode::{deserialize, serialize};
|
||||||
// use bpf_loader;
|
use bpf_loader;
|
||||||
use bs58;
|
use bs58;
|
||||||
use budget_program::BudgetState;
|
use budget_program::BudgetState;
|
||||||
use budget_transaction::BudgetTransaction;
|
use budget_transaction::BudgetTransaction;
|
||||||
|
@ -11,7 +11,6 @@ use elf;
|
||||||
use fullnode::Config;
|
use fullnode::Config;
|
||||||
use hash::Hash;
|
use hash::Hash;
|
||||||
use loader_transaction::LoaderTransaction;
|
use loader_transaction::LoaderTransaction;
|
||||||
use native_loader;
|
|
||||||
use ring::rand::SystemRandom;
|
use ring::rand::SystemRandom;
|
||||||
use ring::signature::Ed25519KeyPair;
|
use ring::signature::Ed25519KeyPair;
|
||||||
use rpc_request::RpcRequest;
|
use rpc_request::RpcRequest;
|
||||||
|
@ -30,7 +29,6 @@ use std::{error, fmt, mem};
|
||||||
use system_transaction::SystemTransaction;
|
use system_transaction::SystemTransaction;
|
||||||
use transaction::Transaction;
|
use transaction::Transaction;
|
||||||
|
|
||||||
// TODO: put these somewhere more logical
|
|
||||||
const PLATFORM_SECTION_C: &str = ".text.entrypoint";
|
const PLATFORM_SECTION_C: &str = ".text.entrypoint";
|
||||||
const USERDATA_CHUNK_SIZE: usize = 256;
|
const USERDATA_CHUNK_SIZE: usize = 256;
|
||||||
|
|
||||||
|
@ -354,11 +352,9 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||||
// Cancel a contract by contract Pubkey
|
// Cancel a contract by contract Pubkey
|
||||||
WalletCommand::Cancel(pubkey) => {
|
WalletCommand::Cancel(pubkey) => {
|
||||||
let last_id = get_last_id(&config)?;
|
let last_id = get_last_id(&config)?;
|
||||||
|
|
||||||
let tx =
|
let tx =
|
||||||
Transaction::budget_new_signature(&config.id, pubkey, config.id.pubkey(), last_id);
|
Transaction::budget_new_signature(&config.id, pubkey, config.id.pubkey(), last_id);
|
||||||
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
||||||
|
|
||||||
Ok(signature_str.to_string())
|
Ok(signature_str.to_string())
|
||||||
}
|
}
|
||||||
// Confirm the last client transaction by signature
|
// Confirm the last client transaction by signature
|
||||||
|
@ -387,7 +383,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||||
.make_rpc_request(&config.rpc_addr, 1, Some(params))?
|
.make_rpc_request(&config.rpc_addr, 1, Some(params))?
|
||||||
.as_i64();
|
.as_i64();
|
||||||
if let Some(tokens) = balance {
|
if let Some(tokens) = balance {
|
||||||
if tokens < 2 {
|
if tokens < 1 {
|
||||||
Err(WalletError::DynamicProgramError(
|
Err(WalletError::DynamicProgramError(
|
||||||
"Insufficient funds".to_string(),
|
"Insufficient funds".to_string(),
|
||||||
))?
|
))?
|
||||||
|
@ -407,45 +403,13 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||||
})?.data
|
})?.data
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
// Loader instance for testing; REMOVE
|
|
||||||
let loader = Keypair::new();
|
|
||||||
let tx = Transaction::system_create(
|
|
||||||
&config.id,
|
|
||||||
loader.pubkey(),
|
|
||||||
last_id,
|
|
||||||
1,
|
|
||||||
56,
|
|
||||||
native_loader::id(),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
let _signature_str = serialize_and_send_tx(&config, &tx)?;
|
|
||||||
|
|
||||||
let name = String::from("bpf_loader");
|
|
||||||
let tx = Transaction::write(
|
|
||||||
&loader,
|
|
||||||
native_loader::id(),
|
|
||||||
0,
|
|
||||||
name.as_bytes().to_vec(),
|
|
||||||
last_id,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
let _signature_str = serialize_and_send_tx(&config, &tx)?;
|
|
||||||
|
|
||||||
let tx = Transaction::finalize(&loader, native_loader::id(), last_id, 0);
|
|
||||||
let _signature_str = serialize_and_send_tx(&config, &tx)?;
|
|
||||||
|
|
||||||
let tx = Transaction::system_spawn(&loader, last_id, 0);
|
|
||||||
let _signature_str = serialize_and_send_tx(&config, &tx)?;
|
|
||||||
// end loader instance
|
|
||||||
|
|
||||||
let tx = Transaction::system_create(
|
let tx = Transaction::system_create(
|
||||||
&config.id,
|
&config.id,
|
||||||
program.pubkey(),
|
program.pubkey(),
|
||||||
last_id,
|
last_id,
|
||||||
1,
|
1,
|
||||||
program_userdata.len() as u64,
|
program_userdata.len() as u64,
|
||||||
// bpf_loader::id(),
|
bpf_loader::id(),
|
||||||
loader.pubkey(),
|
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
||||||
|
@ -461,8 +425,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||||
.map(|chunk| {
|
.map(|chunk| {
|
||||||
let tx = Transaction::write(
|
let tx = Transaction::write(
|
||||||
&program,
|
&program,
|
||||||
// bpf_loader::id(),
|
bpf_loader::id(),
|
||||||
loader.pubkey(),
|
|
||||||
offset,
|
offset,
|
||||||
chunk.to_vec(),
|
chunk.to_vec(),
|
||||||
last_id,
|
last_id,
|
||||||
|
@ -476,13 +439,7 @@ pub fn process_command(config: &WalletConfig) -> Result<String, Box<error::Error
|
||||||
|
|
||||||
if write_result {
|
if write_result {
|
||||||
let last_id = get_last_id(&config)?;
|
let last_id = get_last_id(&config)?;
|
||||||
let tx = Transaction::finalize(
|
let tx = Transaction::finalize(&program, bpf_loader::id(), last_id, 0);
|
||||||
&program,
|
|
||||||
// bpf_loader::id(),
|
|
||||||
loader.pubkey(),
|
|
||||||
last_id,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
let signature_str = serialize_and_send_tx(&config, &tx)?;
|
||||||
if !confirm_tx(&config, &signature_str)? {
|
if !confirm_tx(&config, &signature_str)? {
|
||||||
Err(WalletError::DynamicProgramError(
|
Err(WalletError::DynamicProgramError(
|
||||||
|
|
Loading…
Reference in New Issue