Skip to content

Commit 462ead7

Browse files
cctdanielguibescos
andauthored
feat(governance/remote_executor): add mantis testnet (#1823)
* add mantis testnet * revert default feature * improve-cli * ship * go --------- Co-authored-by: Guillermo Bescos <[email protected]>
1 parent d63f933 commit 462ead7

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

governance/remote_executor/cli/src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ fn main() -> Result<()> {
8787
let wormhole_config_data =
8888
Config::try_from_slice(&rpc_client.get_account_data(&wormhole_config)?)?;
8989

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

9496
let signature_set_keypair = Keypair::new();
9597

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

172+
let executor_key = Pubkey::find_program_address(
173+
&[EXECUTOR_KEY_SEED.as_bytes(), &payer.pubkey().to_bytes()],
174+
&ID,
175+
)
176+
.0;
170177
let payload = ExecutorPayload {
171178
header: GovernanceHeader::executor_governance_header(cli.chain),
172-
instructions: vec![],
179+
instructions: vec![InstructionData::from(&system_instruction::transfer(
180+
&executor_key,
181+
&payer.pubkey(),
182+
1,
183+
))],
173184
}
174185
.try_to_vec()?;
175186

governance/remote_executor/programs/remote-executor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pythtest = []
2424
eclipse_devnet = []
2525
eclipse_testnet = []
2626
eclipse_mainnet = []
27+
mantis_testnet = []
2728

2829
[dependencies]
2930
anchor-lang = {version = "0.25.0", features = ["init-if-needed"]}

governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub const CHAIN_ID_ARRAY: &[(&str, u16)] = &[
2020
("eclipse_devnet", 40001),
2121
("eclipse_testnet", 40002),
2222
("eclipse_mainnet", 40003),
23+
("mantis_testnet", 40004),
2324
];
2425

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

38+
#[cfg(feature = "mantis_testnet")]
39+
pub const CHAIN_ID: u16 = 40004;
40+
3741
#[derive(AnchorDeserialize, AnchorSerialize, Debug, PartialEq, Eq)]
3842
pub struct ExecutorPayload {
3943
pub header: GovernanceHeader,

governance/remote_executor/programs/remote-executor/src/state/posted_vaa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ impl Owner for AnchorVaa {
2323
#[cfg(any(
2424
feature = "eclipse_devnet",
2525
feature = "eclipse_testnet",
26-
feature = "eclipse_mainnet"
26+
feature = "eclipse_mainnet",
27+
feature = "mantis_testnet",
2728
))]
2829
fn owner() -> Pubkey {
2930
Pubkey::from_str("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ").unwrap()

target_chains/solana/cli/src/cli.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ pub enum Action {
5757
InitializeWormholeReceiver {},
5858
InitializePythReceiver {
5959
#[clap(short = 'f', long, help = "Fee in lmaports")]
60-
fee: u64,
60+
fee: u64,
6161
#[clap(short = 'e', long, parse(try_from_str = Pubkey::from_str), help = "Source emitter")]
62-
emitter: Pubkey,
62+
emitter: Pubkey,
6363
#[clap(short = 'c', long, help = "Source chain")]
64-
chain: u16,
64+
chain: u16,
65+
#[clap(short = 'a', long, parse(try_from_str = Pubkey::from_str), help = "Governance authority")]
66+
governance_authority: Pubkey,
6567
},
6668
}

target_chains/solana/cli/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ fn main() -> Result<()> {
170170
fee,
171171
emitter,
172172
chain,
173+
governance_authority,
173174
} => {
174175
let rpc_client = RpcClient::new(url);
175176
let payer =
@@ -179,7 +180,7 @@ fn main() -> Result<()> {
179180
pyth_solana_receiver::instruction::Initialize::populate(
180181
&payer.pubkey(),
181182
pyth_solana_receiver_sdk::config::Config {
182-
governance_authority: payer.pubkey(),
183+
governance_authority,
183184
target_governance_authority: None,
184185
wormhole,
185186
valid_data_sources: vec![DataSource { chain, emitter }],
@@ -480,7 +481,7 @@ pub fn process_transaction(
480481
let transaction_signature_res = rpc_client
481482
.send_and_confirm_transaction_with_spinner_and_config(
482483
&transaction,
483-
CommitmentConfig::finalized(),
484+
CommitmentConfig::confirmed(),
484485
RpcSendTransactionConfig {
485486
skip_preflight: true,
486487
..Default::default()

0 commit comments

Comments
 (0)