diff --git a/ampd/src/handlers/stacks_verify_msg.rs b/ampd/src/handlers/stacks_verify_msg.rs index e672bc69a..63990fc94 100644 --- a/ampd/src/handlers/stacks_verify_msg.rs +++ b/ampd/src/handlers/stacks_verify_msg.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; use std::convert::TryInto; use async_trait::async_trait; +use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; use axelar_wasm_std::voting::{PollId, Vote}; use cosmrs::cosmwasm::MsgExecuteContract; use cosmrs::tx::Msg; @@ -14,12 +15,13 @@ use futures::future; use router_api::ChainName; use serde::Deserialize; use tokio::sync::watch::Receiver; -use tracing::info; +use tracing::{info, info_span}; +use valuable::Valuable; use voting_verifier::msg::ExecuteMsg; use crate::event_processor::EventHandler; use crate::handlers::errors::Error; -use crate::stacks::http_client::{Client, Transaction}; +use crate::stacks::http_client::Client; use crate::stacks::verifier::verify_message; use crate::types::{Hash, TMAddress}; @@ -27,10 +29,9 @@ type Result = error_stack::Result; #[derive(Deserialize, Debug)] pub struct Message { - pub tx_id: Hash, - pub event_index: u32, + pub message_id: HexTxHashAndEventIndex, pub destination_address: String, - pub destination_chain: router_api::ChainName, + pub destination_chain: ChainName, pub source_address: String, pub payload_hash: Hash, } @@ -132,29 +133,55 @@ impl EventHandler for Handler { return Ok(vec![]); } - let tx_hashes: HashSet<_> = messages.iter().map(|message| message.tx_id).collect(); + let tx_hashes: HashSet = messages + .iter() + .map(|message| message.message_id.tx_hash.into()) + .collect(); let transactions = self.http_client.get_transactions(tx_hashes).await; - let futures = messages.iter().map(|msg| async { - match transactions.get(&msg.tx_id) { - Some(transaction) => { - verify_message( - &source_chain, - &source_gateway_address, - &self.its_address, - transaction, - msg, - &self.http_client, - &self.reference_native_interchain_token_code, - &self.reference_token_manager_code, - ) - .await + let message_ids = messages + .iter() + .map(|message| message.message_id.to_string()) + .collect::>(); + + let votes = info_span!( + "verify messages in poll", + poll_id = poll_id.to_string(), + source_chain = source_chain.to_string(), + message_ids = message_ids.as_value() + ) + .in_scope(|| async { + info!("ready to verify messages in poll",); + + let futures = messages.iter().map(|msg| async { + match transactions.get(&msg.message_id.tx_hash.into()) { + Some(transaction) => { + verify_message( + &source_chain, + &source_gateway_address, + &self.its_address, + transaction, + msg, + &self.http_client, + &self.reference_native_interchain_token_code, + &self.reference_token_manager_code, + ) + .await + } + None => Vote::NotFound, } - None => Vote::NotFound, - } - }); + }); - let votes: Vec = future::join_all(futures).await; + let votes: Vec = future::join_all(futures).await; + + info!( + votes = votes.as_value(), + "ready to vote for messages in poll" + ); + + votes + }) + .await; Ok(vec![self .vote_msg(poll_id, votes) @@ -168,6 +195,7 @@ mod tests { use std::collections::HashMap; use std::convert::TryInto; + use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; use cosmrs::cosmwasm::MsgExecuteContract; use cosmrs::tx::Msg; use cosmwasm_std; @@ -176,7 +204,7 @@ mod tests { use tokio::test as async_test; use voting_verifier::events::{PollMetadata, PollStarted, TxEventConfirmation}; - use super::{Handler, PollStartedEvent}; + use super::{Handler, Message, PollStartedEvent}; use crate::event_processor::EventHandler; use crate::handlers::tests::into_structured_event; use crate::stacks::http_client::{Client, ContractInfo}; @@ -201,15 +229,9 @@ mod tests { == "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway" ); - let message = event.messages.first().unwrap(); + let message: &Message = event.messages.first().unwrap(); - assert!( - message.tx_id - == "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(), - ); - assert!(message.event_index == 1u32); + assert!(message.message_id.event_index == 1u64); assert!(message.destination_chain == "ethereum"); assert!(message.source_address == "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM"); } @@ -369,6 +391,8 @@ mod tests { } fn poll_started_event(participants: Vec) -> PollStarted { + let msg_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); + PollStarted::Messages { metadata: PollMetadata { poll_id: "100".parse().unwrap(), @@ -383,15 +407,11 @@ mod tests { .map(|addr| cosmwasm_std::Addr::unchecked(addr.to_string())) .collect(), }, + #[allow(deprecated)] // TODO: The below events use the deprecated tx_id and event_index fields. Remove this attribute when those fields are removed messages: vec![TxEventConfirmation { - tx_id: "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(), - event_index: 1, - message_id: "0xdfaf64de66510723f2efbacd7ead3c4f8c856aed1afc2cb30254552aeda47312-1" - .to_string() - .parse() - .unwrap(), + tx_id: msg_id.tx_hash_as_hex(), + event_index: u32::try_from(msg_id.event_index).unwrap(), + message_id: msg_id.to_string().parse().unwrap(), source_address: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM".parse().unwrap(), destination_chain: "ethereum".parse().unwrap(), destination_address: format!("0x{:x}", EVMAddress::random()).parse().unwrap(), diff --git a/ampd/src/handlers/stacks_verify_verifier_set.rs b/ampd/src/handlers/stacks_verify_verifier_set.rs index 666051000..051b6444d 100644 --- a/ampd/src/handlers/stacks_verify_verifier_set.rs +++ b/ampd/src/handlers/stacks_verify_verifier_set.rs @@ -1,6 +1,7 @@ use std::convert::TryInto; use async_trait::async_trait; +use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; use axelar_wasm_std::voting::{PollId, Vote}; use cosmrs::cosmwasm::MsgExecuteContract; use cosmrs::tx::Msg; @@ -20,12 +21,11 @@ use crate::event_processor::EventHandler; use crate::handlers::errors::Error; use crate::stacks::http_client::Client; use crate::stacks::verifier::verify_verifier_set; -use crate::types::{Hash, TMAddress}; +use crate::types::TMAddress; #[derive(Deserialize, Debug)] pub struct VerifierSetConfirmation { - pub tx_id: Hash, - pub event_index: u32, + pub message_id: HexTxHashAndEventIndex, pub verifier_set: VerifierSet, } @@ -110,13 +110,13 @@ impl EventHandler for Handler { let transaction = self .http_client - .get_valid_transaction(&verifier_set.tx_id) + .get_valid_transaction(&verifier_set.message_id.tx_hash.into()) .await; let vote = info_span!( "verify a new verifier set for Stacks", poll_id = poll_id.to_string(), - id = format!("{}_{}", verifier_set.tx_id, verifier_set.event_index) + id = verifier_set.message_id.to_string(), ) .in_scope(|| { info!("ready to verify a new worker set in poll"); @@ -143,6 +143,7 @@ impl EventHandler for Handler { mod tests { use std::convert::TryInto; + use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; use cosmrs::cosmwasm::MsgExecuteContract; use cosmrs::tx::Msg; use cosmwasm_std; @@ -158,7 +159,7 @@ mod tests { use crate::event_processor::EventHandler; use crate::handlers::tests::into_structured_event; use crate::stacks::http_client::Client; - use crate::types::TMAddress; + use crate::types::{Hash, TMAddress}; use crate::PREFIX; #[test] @@ -181,13 +182,7 @@ mod tests { let verifier_set = event.verifier_set; - assert!( - verifier_set.tx_id - == "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap() - ); - assert!(verifier_set.event_index == 1u32); + assert!(verifier_set.message_id.event_index == 1u64); assert!(verifier_set.verifier_set.signers.len() == 3); assert_eq!(verifier_set.verifier_set.threshold, Uint128::from(2u128)); @@ -322,6 +317,8 @@ mod tests { participants: Vec, expires_at: u64, ) -> PollStarted { + let msg_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); + PollStarted::VerifierSet { metadata: PollMetadata { poll_id: "100".parse().unwrap(), @@ -336,15 +333,11 @@ mod tests { .map(|addr| cosmwasm_std::Addr::unchecked(addr.to_string())) .collect(), }, + #[allow(deprecated)] // TODO: The below events use the deprecated tx_id and event_index fields. Remove this attribute when those fields are removed verifier_set: VerifierSetConfirmation { - tx_id: "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(), - event_index: 1, - message_id: "0xdfaf64de66510723f2efbacd7ead3c4f8c856aed1afc2cb30254552aeda47312-1" - .to_string() - .parse() - .unwrap(), + tx_id: msg_id.tx_hash_as_hex(), + event_index: u32::try_from(msg_id.event_index).unwrap(), + message_id: msg_id.to_string().parse().unwrap(), verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()), }, } diff --git a/ampd/src/stacks/http_client.rs b/ampd/src/stacks/http_client.rs index 721534b96..0d8856b0f 100644 --- a/ampd/src/stacks/http_client.rs +++ b/ampd/src/stacks/http_client.rs @@ -37,7 +37,7 @@ pub struct ContractLog { #[derive(Debug, Deserialize, Default)] pub struct TransactionEvents { - pub event_index: u32, + pub event_index: u64, pub tx_id: String, pub contract_log: Option, } diff --git a/ampd/src/stacks/its_verifier.rs b/ampd/src/stacks/its_verifier.rs index a75aef6d7..2908e127c 100644 --- a/ampd/src/stacks/its_verifier.rs +++ b/ampd/src/stacks/its_verifier.rs @@ -467,15 +467,16 @@ async fn its_verify_token_manager( #[cfg(test)] mod tests { - use axelar_wasm_std::voting::Vote; - use router_api::ChainName; - use tokio::test as async_test; - use crate::handlers::stacks_verify_msg::Message; use crate::stacks::http_client::{ Client, ContractInfo, ContractLog, ContractLogValue, Transaction, TransactionEvents, }; use crate::stacks::verifier::verify_message; + use crate::types::Hash; + use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; + use axelar_wasm_std::voting::Vote; + use router_api::ChainName; + use tokio::test as async_test; // test verify message its hub #[async_test] @@ -625,7 +626,7 @@ mod tests { }) }); - let (source_chain, gateway_address, its_address, tx, mut msg) = + let (source_chain, gateway_address, its_address, tx, msg) = get_matching_its_verify_interchain_token_msg_and_tx(); assert_eq!( @@ -655,7 +656,7 @@ mod tests { }) }); - let (source_chain, gateway_address, its_address, tx, mut msg) = + let (source_chain, gateway_address, its_address, tx, msg) = get_matching_its_verify_interchain_token_msg_and_tx(); assert_eq!( @@ -683,7 +684,7 @@ mod tests { }) }); - let (source_chain, gateway_address, its_address, tx, mut msg) = + let (source_chain, gateway_address, its_address, tx, msg) = get_matching_its_verify_token_manager_msg_and_tx(); assert_eq!( @@ -713,7 +714,7 @@ mod tests { }) }); - let (source_chain, gateway_address, its_address, tx, mut msg) = + let (source_chain, gateway_address, its_address, tx, msg) = get_matching_its_verify_token_manager_msg_and_tx(); assert_eq!( @@ -737,13 +738,11 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.interchain-token-service"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: its_address.to_string(), destination_chain: "axelar".parse().unwrap(), destination_address: "cosmwasm".to_string(), @@ -754,7 +753,7 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -775,7 +774,7 @@ mod tests { */ let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -786,7 +785,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), @@ -807,13 +806,11 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.interchain-token-service"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: its_address.to_string(), destination_chain: "axelar".parse().unwrap(), destination_address: "0x00".to_string(), @@ -824,7 +821,7 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -845,7 +842,7 @@ mod tests { */ let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -856,7 +853,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), @@ -877,13 +874,11 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.interchain-token-service"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: its_address.to_string(), destination_chain: "axelar".parse().unwrap(), destination_address: "cosmwasm".to_string(), @@ -894,7 +889,7 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -913,7 +908,7 @@ mod tests { */ let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -924,7 +919,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), @@ -945,13 +940,11 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.interchain-token-service"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: its_address.to_string(), destination_chain: "stacks".parse().unwrap(), destination_address: its_address.to_string(), @@ -962,7 +955,7 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -975,7 +968,7 @@ mod tests { */ let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -986,7 +979,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), @@ -1007,13 +1000,11 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.interchain-token-service"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new(Hash::random(), 1u64); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: its_address.to_string(), destination_chain: "stacks".parse().unwrap(), destination_address: its_address.to_string(), @@ -1024,7 +1015,7 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -1037,7 +1028,7 @@ mod tests { */ let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -1048,7 +1039,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), diff --git a/ampd/src/stacks/verifier.rs b/ampd/src/stacks/verifier.rs index 7ed2f4f9f..6eb1d20d2 100644 --- a/ampd/src/stacks/verifier.rs +++ b/ampd/src/stacks/verifier.rs @@ -177,7 +177,7 @@ impl VerifierSetConfirmation { fn find_event<'a>( transaction: &'a Transaction, gateway_address: &String, - log_index: u32, + log_index: u64, ) -> Option<&'a TransactionEvents> { let event = transaction .events @@ -201,11 +201,11 @@ pub async fn verify_message( reference_native_interchain_token_code: &String, reference_token_manager_code: &String, ) -> Vote { - if message.tx_id != transaction.tx_id { + if message.message_id.tx_hash != transaction.tx_id.as_bytes() { return Vote::NotFound; } - match find_event(transaction, gateway_address, message.event_index) { + match find_event(transaction, gateway_address, message.message_id.event_index) { Some(event) => { // In case message is not from ITS if &message.source_address != its_address { @@ -255,11 +255,11 @@ pub fn verify_verifier_set( transaction: &Transaction, verifier_set: VerifierSetConfirmation, ) -> Vote { - if verifier_set.tx_id != transaction.tx_id { + if verifier_set.message_id.tx_hash != transaction.tx_id.as_bytes() { return Vote::NotFound; } - match find_event(transaction, gateway_address, verifier_set.event_index) { + match find_event(transaction, gateway_address, verifier_set.message_id.event_index) { Some(event) if verifier_set.eq_event(event).unwrap_or(false) => Vote::SucceededOnChain, _ => Vote::NotFound, } @@ -275,22 +275,22 @@ mod tests { use multisig::test::common::{build_verifier_set, ecdsa_test_data}; use router_api::ChainName; use tokio::test as async_test; - + use axelar_wasm_std::msg_id::HexTxHashAndEventIndex; use crate::handlers::stacks_verify_msg::Message; use crate::handlers::stacks_verify_verifier_set::VerifierSetConfirmation; use crate::stacks::http_client::{ Client, ContractLog, ContractLogValue, Transaction, TransactionEvents, }; use crate::stacks::verifier::{verify_message, verify_verifier_set, SIGNERS_ROTATED_TYPE}; + use crate::types::Hash; // test verify message #[async_test] async fn should_not_verify_tx_id_does_not_match() { let (source_chain, gateway_address, its_address, tx, mut msg) = get_matching_msg_and_tx(); - msg.tx_id = "ffaf64de66510723f2efbacd7ead3c4f8c856aed1afc2cb30254552aeda47313" - .parse() - .unwrap(); + msg.message_id.tx_hash = Hash::random().into(); + assert_eq!( verify_message( &source_chain, @@ -311,7 +311,7 @@ mod tests { async fn should_not_verify_no_log_for_event_index() { let (source_chain, gateway_address, its_address, tx, mut msg) = get_matching_msg_and_tx(); - msg.event_index = 2; + msg.message_id.event_index = 2; assert_eq!( verify_message( @@ -333,7 +333,7 @@ mod tests { async fn should_not_verify_event_index_does_not_match() { let (source_chain, gateway_address, its_address, tx, mut msg) = get_matching_msg_and_tx(); - msg.event_index = 0; + msg.message_id.event_index = 0; assert_eq!( verify_message( @@ -547,9 +547,8 @@ mod tests { fn should_not_verify_verifier_set_if_tx_id_does_not_match() { let (gateway_address, tx, mut verifier_set) = get_matching_verifier_set_and_tx(); - verifier_set.tx_id = "ffaf64de66510723f2efbacd7ead3c4f8c856aed1afc2cb30254552aeda47313" - .parse() - .unwrap(); + verifier_set.message_id.tx_hash = Hash::random().into(); + assert_eq!( verify_verifier_set(&gateway_address, &tx, verifier_set), Vote::NotFound @@ -560,7 +559,8 @@ mod tests { fn should_not_verify_verifier_set_if_no_log_for_event_index() { let (gateway_address, tx, mut verifier_set) = get_matching_verifier_set_and_tx(); - verifier_set.event_index = 2; + verifier_set.message_id.event_index = 2; + assert_eq!( verify_verifier_set(&gateway_address, &tx, verifier_set), Vote::NotFound @@ -571,7 +571,8 @@ mod tests { fn should_not_verify_verifier_set_if_event_index_does_not_match() { let (gateway_address, tx, mut verifier_set) = get_matching_verifier_set_and_tx(); - verifier_set.event_index = 0; + verifier_set.message_id.event_index = 0; + assert_eq!( verify_verifier_set(&gateway_address, &tx, verifier_set), Vote::NotFound @@ -654,13 +655,14 @@ mod tests { let source_chain = "stacks"; let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; let its_address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B.its"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + + let message_id = HexTxHashAndEventIndex::new( + Hash::random(), + 1u64, + ); let msg = Message { - tx_id, - event_index: 1, + message_id: message_id.clone(), source_address: "ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG".to_string(), destination_chain: "Destination".parse().unwrap(), destination_address: "0x123abc".to_string(), @@ -671,13 +673,13 @@ mod tests { let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -688,7 +690,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(), @@ -706,20 +708,20 @@ mod tests { fn get_matching_verifier_set_and_tx() -> (String, Transaction, VerifierSetConfirmation) { let gateway_address = "SP2N959SER36FZ5QT1CX9BR63W3E8X35WQCMBYYWC.axelar-gateway"; - let tx_id = "0xee0049faf8dde5507418140ed72bd64f73cc001b08de98e0c16a3a8d9f2c38cf" - .parse() - .unwrap(); + let message_id = HexTxHashAndEventIndex::new( + Hash::random(), + 1u64, + ); let mut verifier_set_confirmation = VerifierSetConfirmation { - tx_id, - event_index: 1, + message_id: message_id.clone(), verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()), }; verifier_set_confirmation.verifier_set.created_at = 5; let wrong_event = TransactionEvents { event_index: 0, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: None, }; @@ -744,7 +746,7 @@ mod tests { let event = TransactionEvents { event_index: 1, - tx_id: tx_id.to_string(), + tx_id: message_id.tx_hash_as_hex().to_string(), contract_log: Some(ContractLog { contract_id: gateway_address.to_string(), topic: "print".to_string(), @@ -755,7 +757,7 @@ mod tests { }; let transaction = Transaction { - tx_id, + tx_id: message_id.tx_hash.into(), nonce: 1, sender_address: "whatever".to_string(), tx_status: "success".to_string(),