Skip to content

feat(governance/remote_executor): add mantis testnet #1823

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

Merged
merged 5 commits into from
Sep 19, 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
17 changes: 14 additions & 3 deletions governance/remote_executor/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ fn main() -> Result<()> {
let wormhole_config_data =
Config::try_from_slice(&rpc_client.get_account_data(&wormhole_config)?)?;

let guardian_set_data_offset = if cli.chain == 26 { 0 } else { 8 }; // Pythnet's guardian set account has no discriminator
let guardian_set = GuardianSet::key(&wormhole, wormhole_config_data.guardian_set_index);
let guardian_set_data =
GuardianSet::try_from_slice(&rpc_client.get_account_data(&guardian_set)?)?;
let guardian_set_data = GuardianSet::try_from_slice(
&rpc_client.get_account_data(&guardian_set)?[guardian_set_data_offset..],
)?;

let signature_set_keypair = Keypair::new();

Expand Down Expand Up @@ -167,9 +169,18 @@ fn main() -> Result<()> {
let wormhole_config_data =
Config::try_from_slice(&rpc_client.get_account_data(&wormhole_config)?)?;

let executor_key = Pubkey::find_program_address(
&[EXECUTOR_KEY_SEED.as_bytes(), &payer.pubkey().to_bytes()],
&ID,
)
.0;
let payload = ExecutorPayload {
header: GovernanceHeader::executor_governance_header(cli.chain),
instructions: vec![],
instructions: vec![InstructionData::from(&system_instruction::transfer(
&executor_key,
&payer.pubkey(),
1,
))],
}
.try_to_vec()?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pythtest = []
eclipse_devnet = []
eclipse_testnet = []
eclipse_mainnet = []
mantis_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 @@ -20,6 +20,7 @@ pub const CHAIN_ID_ARRAY: &[(&str, u16)] = &[
("eclipse_devnet", 40001),
("eclipse_testnet", 40002),
("eclipse_mainnet", 40003),
("mantis_testnet", 40004),
];

#[cfg(any(feature = "pythnet", feature = "pythtest"))]
Expand All @@ -34,6 +35,9 @@ pub const CHAIN_ID: u16 = 40002;
#[cfg(feature = "eclipse_mainnet")]
pub const CHAIN_ID: u16 = 40003;

#[cfg(feature = "mantis_testnet")]
pub const CHAIN_ID: u16 = 40004;

#[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 @@ -23,7 +23,8 @@ impl Owner for AnchorVaa {
#[cfg(any(
feature = "eclipse_devnet",
feature = "eclipse_testnet",
feature = "eclipse_mainnet"
feature = "eclipse_mainnet",
feature = "mantis_testnet",
))]
fn owner() -> Pubkey {
Pubkey::from_str("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ").unwrap()
Expand Down
8 changes: 5 additions & 3 deletions target_chains/solana/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ pub enum Action {
InitializeWormholeReceiver {},
InitializePythReceiver {
#[clap(short = 'f', long, help = "Fee in lmaports")]
fee: u64,
fee: u64,
#[clap(short = 'e', long, parse(try_from_str = Pubkey::from_str), help = "Source emitter")]
emitter: Pubkey,
emitter: Pubkey,
#[clap(short = 'c', long, help = "Source chain")]
chain: u16,
chain: u16,
#[clap(short = 'a', long, parse(try_from_str = Pubkey::from_str), help = "Governance authority")]
governance_authority: Pubkey,
},
}
5 changes: 3 additions & 2 deletions target_chains/solana/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fn main() -> Result<()> {
fee,
emitter,
chain,
governance_authority,
} => {
let rpc_client = RpcClient::new(url);
let payer =
Expand All @@ -179,7 +180,7 @@ fn main() -> Result<()> {
pyth_solana_receiver::instruction::Initialize::populate(
&payer.pubkey(),
pyth_solana_receiver_sdk::config::Config {
governance_authority: payer.pubkey(),
governance_authority,
target_governance_authority: None,
wormhole,
valid_data_sources: vec![DataSource { chain, emitter }],
Expand Down Expand Up @@ -480,7 +481,7 @@ pub fn process_transaction(
let transaction_signature_res = rpc_client
.send_and_confirm_transaction_with_spinner_and_config(
&transaction,
CommitmentConfig::finalized(),
CommitmentConfig::confirmed(),
RpcSendTransactionConfig {
skip_preflight: true,
..Default::default()
Expand Down
Loading