Skip to content

Commit

Permalink
fix: allow for disabling filtering in fetch_logs
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Felipe da Silva <gfsilva.eng@gmail.com>
  • Loading branch information
frenzox committed Dec 20, 2024
1 parent 29c1c86 commit 467b1fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async fn try_build_and_push_event_with_data(
solana_rpc_client: Arc<RpcClient>,
mut amplifier_channel: UnboundedSender<AmplifierCommand>,
) -> Result<(), CallContractOffchainDataError> {
let solana_transaction = fetch_logs(signature, &solana_rpc_client).await?;
let solana_transaction = fetch_logs(signature, &solana_rpc_client, true).await?;
let hash = solana_sdk::keccak::hash(&data).to_bytes();
let match_context = MatchContext::new(&axelar_solana_gateway::id().to_string());
let invocations = gateway_event_stack::build_program_event_stack(
Expand Down
3 changes: 2 additions & 1 deletion crates/solana-gateway-task-processor/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ async fn process_task(
source: ref _source,
signature,
}) => {
let tx = solana_listener::fetch_logs(signature, solana_rpc_client).await?;
let tx = solana_listener::fetch_logs(signature, solana_rpc_client, false)
.await?;
message_executed_event(
signature,
source_chain,
Expand Down
6 changes: 4 additions & 2 deletions crates/solana-listener/src/component/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) async fn fetch_and_send(
let rpc_client = Arc::clone(&rpc_client);
let mut signature_sender = signature_sender.clone();
async move {
let tx = fetch_logs(signature, &rpc_client).await?;
let tx = fetch_logs(signature, &rpc_client, true).await?;
signature_sender.send(tx).await?;
Result::<_, eyre::Report>::Ok(())
}
Expand All @@ -48,6 +48,7 @@ pub(crate) async fn fetch_and_send(
pub async fn fetch_logs(
signature: Signature,
rpc_client: &RpcClient,
successful_only: bool,
) -> eyre::Result<SolanaTransaction> {
use solana_client::rpc_config::RpcTransactionConfig;
let config = RpcTransactionConfig {
Expand All @@ -71,7 +72,8 @@ pub async fn fetch_logs(
let OptionSerializer::Some(logs) = meta.log_messages else {
eyre::bail!("logs not included");
};
if meta.err.is_some() {

if successful_only && meta.err.is_some() {
eyre::bail!("tx was not successful");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(crate) async fn process_realtime_logs(
// Process the first item
if first_item.value.err.is_none() {
if let Ok(sig) = Signature::from_str(&first_item.value.signature) {
let t2_signature = fetch_logs(sig, &rpc_client).await?;
let t2_signature = fetch_logs(sig, &rpc_client, true).await?;

// Fetch missed batches
signature_batch_scanner::fetch_batches_in_range(
Expand Down Expand Up @@ -98,7 +98,7 @@ pub(crate) async fn process_realtime_logs(
// Push fetch_logs future into fetch_futures
let rpc_client = Arc::clone(&rpc_client);
let fetch_future = async move {
let log_item = fetch_logs(sig, &rpc_client).await?;
let log_item = fetch_logs(sig, &rpc_client, true).await?;
tracing::info!(item = ?log_item.signature, "found tx");
eyre::Result::Ok(log_item)
};
Expand Down

0 comments on commit 467b1fa

Please sign in to comment.