Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(governance/remote_executor): add atlas testnet #2071

Merged
merged 1 commit into from
Oct 28, 2024
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
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:?}");
Comment on lines +279 to +312
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more logs to troubleshoot when tx fails

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
Loading