diff --git a/crates/solana-gateway-task-processor/src/component.rs b/crates/solana-gateway-task-processor/src/component.rs index cc12043..b2be03b 100644 --- a/crates/solana-gateway-task-processor/src/component.rs +++ b/crates/solana-gateway-task-processor/src/component.rs @@ -18,6 +18,7 @@ use axelar_solana_encoding::types::execute_data::{ExecuteData, MerkleisedPayload use axelar_solana_encoding::types::messages::{CrossChainId, Message}; use axelar_solana_gateway::error::GatewayError; use axelar_solana_gateway::state::incoming_message::command_id; +use axelar_solana_gateway::BytemuckedPda as _; use effective_tx_sender::ComputeBudgetError; use eyre::{Context as _, OptionExt as _}; use futures::stream::{FusedStream as _, FuturesOrdered, FuturesUnordered}; @@ -84,8 +85,10 @@ impl SolanaTxPusher { async fn process_internal(self) -> eyre::Result<()> { let config_metadata = Arc::new(self.get_config_metadata()); let state = self.state.clone(); - let keypair = Arc::new(self.config.signing_keypair.insecure_clone()); + + ensure_gas_service_authority(&keypair.pubkey(), &self.rpc_client, &config_metadata).await?; + let mut futures_ordered = FuturesOrdered::new(); let mut rx = self.task_receiver.receiver.fuse(); let mut task_stream = futures::stream::poll_fn(move |cx| { @@ -154,6 +157,24 @@ impl SolanaTxPusher { } } +async fn ensure_gas_service_authority( + key: &Pubkey, + solana_rpc_client: &RpcClient, + metadata: &ConfigMetadata, +) -> eyre::Result<()> { + let account_data = solana_rpc_client + .get_account_data(&metadata.gas_service_config_pda) + .await?; + let config = axelar_solana_gas_service::state::Config::read(&account_data) + .ok_or_eyre("gas service config PDA account not initialized")?; + + if config.authority != *key { + eyre::bail!("relayer is not the gas service authority") + } + + Ok(()) +} + struct ConfigMetadata { name_of_the_solana_chain: String, gateway_root_pda: Pubkey,