-
Notifications
You must be signed in to change notification settings - Fork 0
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: ampd deployment k8s #16
base: solana
Are you sure you want to change the base?
Changes from 1 commit
057b195
fa5264e
b99d5db
9f59867
1b1d891
1192a03
f085785
89c1c6e
e77d253
5a1809b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
use std::borrow::Cow; | ||
use std::convert::TryInto; | ||
|
||
use axelar_message_primitives::command::TransferOperatorshipCommand; | ||
use cosmrs::cosmwasm::MsgExecuteContract; | ||
use error_stack::ResultExt; | ||
use serde::Deserialize; | ||
|
@@ -194,10 +196,17 @@ where | |
|
||
let gw_event = parse_gateway_event(&sol_tx).map_err(|_| Error::DeserializeEvent)?; | ||
|
||
let pub_key = match gw_event { | ||
GatewayEvent::OperatorshipTransferred { | ||
info_account_address, | ||
} => info_account_address, | ||
let operators = match gw_event { | ||
GatewayEvent::OperatorshipTransferred(Cow::Owned(TransferOperatorshipCommand { | ||
operators, | ||
weights, | ||
quorum, | ||
.. | ||
})) => axelar_message_primitives::command::Operators::new( | ||
operators, | ||
weights.into_iter().map(axelar_message_primitives::command::U256::from).collect(), | ||
axelar_message_primitives::command::U256::from(quorum), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am mapping the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, they are the same thing 👍 |
||
), | ||
_ => { | ||
error!( | ||
tx_signature = sol_tx_signature.to_string(), | ||
|
@@ -208,21 +217,7 @@ where | |
} | ||
}; | ||
|
||
let account_data = match self.rpc_client.get_account_data(&pub_key).await { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems (if this is correct) we already have all needed information coming from the initial Solana tx for verifying the workerset. So we can remove the extra RPC call to fetch the account data. |
||
Ok(data) => data, | ||
Err(err) => { | ||
error!( | ||
tx_signature = sol_tx_signature.to_string(), | ||
pub_key = pub_key.to_string(), | ||
poll_id = poll_id.to_string(), | ||
err = format!("Error fetching account data: {}", err), | ||
); | ||
return self.broadcast_vote(poll_id, Vote::FailedOnChain).await; | ||
} | ||
}; | ||
|
||
let vote = | ||
verify_worker_set(&source_gateway_address, &sol_tx, &worker_set, &account_data).await; | ||
let vote = verify_worker_set(&source_gateway_address, &sol_tx, &worker_set, &operators).await; | ||
self.broadcast_vote(poll_id, vote).await | ||
} | ||
} | ||
|
@@ -299,7 +294,7 @@ mod tests { | |
let handler = Handler::new( | ||
worker.clone(), | ||
voting_verifier.clone(), | ||
ChainName::from_str("not_matching_chain").unwrap(), | ||
ChainName::from_str("notmatchingchain").unwrap(), | ||
rpc_client, | ||
broadcast_client, | ||
rx, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
use axelar_wasm_std::voting::Vote; | ||
use gmp_gateway::events::GatewayEvent; | ||
use gmp_gateway::events::{CallContract, GatewayEvent}; | ||
use solana_transaction_status::{ | ||
option_serializer::OptionSerializer, EncodedConfirmedTransactionWithStatusMeta, | ||
}; | ||
use std::sync::Arc; | ||
use std::{borrow::Cow, sync::Arc}; | ||
use tracing::error; | ||
|
||
use crate::handlers::solana_verify_msg::Message; | ||
|
||
impl PartialEq<&Message> for GatewayEvent { | ||
impl PartialEq<&Message> for GatewayEvent<'_> { | ||
fn eq(&self, msg: &&Message) -> bool { | ||
match self { | ||
GatewayEvent::CallContract { | ||
GatewayEvent::CallContract(Cow::Owned(CallContract { | ||
sender, | ||
destination_chain, | ||
destination_address, | ||
payload: _, | ||
payload_hash, | ||
} => { | ||
})) => { | ||
let event_dest_addr = String::from_utf8(destination_address.to_owned()); | ||
let event_dest_chain = String::from_utf8(destination_chain.to_owned()); | ||
|
||
|
@@ -31,6 +31,10 @@ impl PartialEq<&Message> for GatewayEvent { | |
_ => false, | ||
} | ||
} | ||
|
||
fn ne(&self, other: &&Message) -> bool { | ||
!self.eq(other) | ||
} | ||
} | ||
|
||
pub fn verify_message( | ||
|
@@ -137,7 +141,6 @@ fn find_first_log_message_match( | |
mod tests { | ||
use base64::{engine::general_purpose, Engine}; | ||
use borsh::BorshSerialize; | ||
use gmp_gateway::types::PubkeyWrapper; | ||
|
||
use std::str::FromStr; | ||
|
||
|
@@ -172,7 +175,6 @@ mod tests { | |
let payload_hash: [u8; 32] = [0; 32]; | ||
let source_gateway_address: String = "sol_gateway_addr".to_string(); | ||
let source_pubkey = Pubkey::from([0; 32]); | ||
let source_address = PubkeyWrapper::from(source_pubkey); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No more |
||
|
||
// Code below helps on generating the program log line for adding in the | ||
// tests/solana_tx.json file and use it as test fixture. See the "logMessages" field | ||
|
@@ -199,27 +201,27 @@ mod tests { | |
event_index: 0, | ||
destination_address: destination_address.clone(), | ||
destination_chain: ChainName::from_str(&destination_chain).unwrap(), | ||
source_address: source_address.to_string(), | ||
source_address: source_pubkey.to_string(), | ||
payload_hash, | ||
}; | ||
|
||
(source_gateway_address, tx_id, tx, message) | ||
} | ||
|
||
fn get_tx_log_message( | ||
sender: PubkeyWrapper, | ||
sender: Pubkey, | ||
destination_chain: Vec<u8>, | ||
destination_address: Vec<u8>, | ||
payload: Vec<u8>, | ||
payload_hash: [u8; 32], | ||
) -> String { | ||
let event = gmp_gateway::events::GatewayEvent::CallContract { | ||
let event = gmp_gateway::events::GatewayEvent::CallContract(Cow::Owned(CallContract { | ||
sender, | ||
destination_chain, | ||
destination_address, | ||
payload, | ||
payload_hash, | ||
}; | ||
})); | ||
|
||
let mut event_data = Vec::new(); | ||
event.serialize(&mut event_data).unwrap(); | ||
|
@@ -253,7 +255,7 @@ mod tests { | |
#[test] | ||
fn should_not_verify_msg_if_destination_chain_does_not_match() { | ||
let (gateway_address, _, tx, mut msg) = get_matching_msg_and_tx_block(); | ||
msg.destination_chain = ChainName::from_str("bad_chain").unwrap(); | ||
msg.destination_chain = ChainName::from_str("badchain").unwrap(); | ||
assert_eq!( | ||
Vote::FailedOnChain, | ||
verify_message(&gateway_address, Arc::new(tx), &msg) | ||
|
@@ -263,7 +265,7 @@ mod tests { | |
#[test] | ||
fn should_not_verify_msg_if_source_address_does_not_match() { | ||
let (source_gateway_address, _, tx, mut msg) = get_matching_msg_and_tx_block(); | ||
msg.source_address = PubkeyWrapper::from(Pubkey::from([13; 32])).to_string(); | ||
msg.source_address = Pubkey::from([13; 32]).to_string(); | ||
assert_eq!( | ||
Vote::FailedOnChain, | ||
verify_message(&source_gateway_address, Arc::new(tx), &msg) | ||
|
@@ -318,7 +320,7 @@ mod tests { | |
|
||
fn not_matching_tx_log_message(msg: &Message) -> String { | ||
get_tx_log_message( | ||
PubkeyWrapper::from(Pubkey::from_str(&msg.source_address).unwrap()), | ||
Pubkey::from_str(&msg.source_address).unwrap(), | ||
"abr".as_bytes().to_vec(), | ||
msg.destination_address.clone().into_bytes(), | ||
Vec::new(), | ||
|
@@ -328,7 +330,7 @@ mod tests { | |
|
||
fn matching_tx_log_message(msg: &Message) -> String { | ||
get_tx_log_message( | ||
PubkeyWrapper::from(Pubkey::from_str(&msg.source_address).unwrap()), | ||
Pubkey::from_str(&msg.source_address).unwrap(), | ||
msg.destination_chain.to_string().into_bytes(), | ||
msg.destination_address.clone().into_bytes(), | ||
Vec::new(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some validations are taking place now in the axelar codebase.