Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
cctdaniel committed Oct 28, 2024
1 parent ba27ebf commit 64d6c0e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
43 changes: 38 additions & 5 deletions governance/remote_executor/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ use {
EXECUTOR_KEY_SEED,
ID,
},
solana_client::rpc_client::RpcClient,
solana_client::{
rpc_client::RpcClient,
rpc_config::RpcSendTransactionConfig,
},
solana_sdk::{
instruction::{
AccountMeta,
Expand Down Expand Up @@ -273,10 +276,40 @@ pub fn process_transaction(
) -> Result<()> {
let mut transaction =
Transaction::new_with_payer(instructions.as_slice(), Some(&signers[0].pubkey()));
transaction.sign(signers, rpc_client.get_latest_blockhash()?);
let transaction_signature =
rpc_client.send_and_confirm_transaction_with_spinner(&transaction)?;
println!("Transaction successful : {transaction_signature:?}");
let recent_blockhash = rpc_client.get_latest_blockhash()?;
transaction.sign(signers, recent_blockhash);

// Simulate the transaction
let simulation_result = rpc_client.simulate_transaction(&transaction)?;

// Check if simulation was successful
if let Some(err) = simulation_result.value.err {
println!("Transaction simulation failed: {:?}", err);
if let Some(logs) = simulation_result.value.logs {
println!("Simulation logs:");
for (i, log) in logs.iter().enumerate() {
println!(" {}: {}", i, log);
}
}
return Err(anyhow::anyhow!("Transaction simulation failed"));
}

// If simulation was successful, send the actual transaction
let config = RpcSendTransactionConfig {
skip_preflight: true,
..RpcSendTransactionConfig::default()
};
let transaction_signature = rpc_client.send_transaction_with_config(&transaction, config)?;
println!("Transaction sent: {transaction_signature:?}");

// Wait for confirmation
rpc_client.confirm_transaction_with_spinner(
&transaction_signature,
&recent_blockhash,
rpc_client.commitment(),
)?;

println!("Transaction confirmed: {transaction_signature:?}");
Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ eclipse_mainnet = []
mantis_testnet = []
sonic_devnet = []
sonic_testnet = []
atlas_testnet = []

[dependencies]
anchor-lang = {version = "0.25.0", features = ["init-if-needed"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub const CHAIN_ID_ARRAY: &[(&str, u16)] = &[
("mantis_testnet", 40004),
("sonic_devnet", 40005),
("sonic_testnet", 40006),
("atlas_testnet", 40007),
];

#[cfg(any(feature = "pythnet", feature = "pythtest"))]
Expand All @@ -46,6 +47,9 @@ pub const CHAIN_ID: u16 = 40005;
#[cfg(feature = "sonic_testnet")]
pub const CHAIN_ID: u16 = 40006;

#[cfg(feature = "atlas_testnet")]
pub const CHAIN_ID: u16 = 40007;

#[derive(AnchorDeserialize, AnchorSerialize, Debug, PartialEq, Eq)]
pub struct ExecutorPayload {
pub header: GovernanceHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl Owner for AnchorVaa {
feature = "mantis_testnet",
feature = "sonic_devnet",
feature = "sonic_testnet",
feature = "atlas_testnet",
))]
fn owner() -> Pubkey {
Pubkey::from_str("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ").unwrap()
Expand Down

0 comments on commit 64d6c0e

Please sign in to comment.