Skip to content

Commit

Permalink
[Blockchain Watcher] (FIX) Validate tx logs to process correctly (#1704)
Browse files Browse the repository at this point in the history
* Improve standard relayer mapper

* Improve standard relayer mapper

* Filter logs by topic

* Create random key for sns message

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Air.local>
  • Loading branch information
julianmerlo95 and julian merlo committed Sep 18, 2024
1 parent a96572e commit 39d952b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
16 changes: 10 additions & 6 deletions blockchain-watcher/src/domain/actions/evm/GetEvmTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ export function populateTransaction(
evmBlocks: Record<string, EvmBlock>,
transactionReceipts: Record<string, ReceiptTransaction>,
filterTransactions: EvmTransaction[],
populatedTransactions: EvmTransaction[]
populatedTransactions: EvmTransaction[],
topics: string[]
) {
filterTransactions.forEach((transaction) => {
if (transactionReceipts[transaction.hash]) {
transaction.effectiveGasPrice = transactionReceipts[transaction.hash].effectiveGasPrice;
transaction.gasUsed = transactionReceipts[transaction.hash].gasUsed;
const txReceipt = transactionReceipts[transaction.hash];
if (txReceipt) {
transaction.effectiveGasPrice = txReceipt.effectiveGasPrice;
transaction.gasUsed = txReceipt.gasUsed;
transaction.timestamp = evmBlocks[transaction.blockHash].timestamp;
transaction.status = transactionReceipts[transaction.hash].status;
transaction.logs = transactionReceipts[transaction.hash].logs;
transaction.status = txReceipt.status;
transaction.logs = txReceipt.logs.filter((log) =>
log.topics.some((topic) => topics.includes(topic))
);
transaction.environment = opts.environment;
transaction.chainId = opts.chainId;
transaction.chain = opts.chain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class GetTransactionsByBlocksStrategy implements GetTransactions {
evmBlocks,
transactionReceipts,
transactionsByAddressConfigured,
populatedTransactions
populatedTransactions,
filter.topics
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class GetTransactionsByLogFiltersStrategy implements GetTransactions {
evmBlocks,
transactionReceipts,
filterTransactions,
populatedTransactions
populatedTransactions,
filter.topics
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { LogFoundEvent } from "../../../domain/entities";
import { v4 as uuidv4 } from "uuid";
import winston from "../../log";
import crypto from "node:crypto";
import {
SNSClient,
PublishBatchCommand,
PublishBatchCommandInput,
PublishBatchRequestEntry,
PublishBatchCommand,
SNSClient,
} from "@aws-sdk/client-sns";
import winston from "../../log";

const CHUNK_SIZE = 10;

Expand Down Expand Up @@ -127,7 +128,7 @@ export class SnsEvent {

static fromLogFoundEvent<T>(logFoundEvent: LogFoundEvent<T>): SnsEvent {
return new SnsEvent(
`chain-event-${logFoundEvent.txHash}-${logFoundEvent.blockHeight}`,
`chain-event-${uuidv4()}-${logFoundEvent.txHash}`,
"blockchain-watcher",
logFoundEvent.name,
new Date().toISOString(),
Expand Down
2 changes: 1 addition & 1 deletion deploy/blockchain-watcher/env/production-mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ OPTIMISM_RPCS='["https://rpc.ankr.com/optimism/${token_ankr}","https://op-pokt.n
ARBITRUM_RPCS='["https://rpc.ankr.com/arbitrum/${token_ankr}","https://arb1.arbitrum.io/rpc"]'
POLYGON_RPCS='["https://rpc.ankr.com/polygon/${token_ankr}","https://rpc-mainnet.matic.quiknode.pro","https://polygon-rpc.com"]'
AVALANCHE_RPCS='["https://rpc.ankr.com/avalanche/${token_ankr}","https://avalanche.blockpi.network/v1/rpc/public","https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com","https://endpoints.omniatech.io/v1/avax/mainnet/public", "https://avalanche-c-chain.publicnode.com"]'
MOONBEAM_RPCS='["https://rpc.ankr.com/moonbeam/${token_ankr}","https://rpc.api.moonbeam.network","https://1rpc.io/glmr"]'
MOONBEAM_RPCS='["https://rpc.ankr.com/moonbeam/${token_ankr}","https://rpc.api.moonbeam.network"]'
BSC_RPCS='["https://rpc.ankr.com/bsc/${token_ankr}","https://bscrpc.com"]'
CELO_RPCS='["https://rpc.ankr.com/celo/${token_ankr}","https://forno.celo.org","https://1rpc.io/celo"]'
SCROLL_RPCS='["https://rpc.ankr.com/scroll/${token_ankr}","https://scroll-mainnet-public.unifra.io","https://rpc.scroll.io","https://scroll-mainnet.chainstacklabs.com"]'
Expand Down
2 changes: 1 addition & 1 deletion deploy/blockchain-watcher/env/staging-mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ OPTIMISM_RPCS='["https://rpc.ankr.com/optimism/${token_ankr}","https://op-pokt.n
ARBITRUM_RPCS='["https://rpc.ankr.com/arbitrum/${token_ankr}","https://arb1.arbitrum.io/rpc"]'
POLYGON_RPCS='["https://rpc.ankr.com/polygon/${token_ankr}","https://rpc-mainnet.matic.quiknode.pro","https://polygon-rpc.com"]'
AVALANCHE_RPCS='["https://rpc.ankr.com/avalanche/${token_ankr}","https://avalanche.blockpi.network/v1/rpc/public","https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com","https://endpoints.omniatech.io/v1/avax/mainnet/public", "https://avalanche-c-chain.publicnode.com"]'
MOONBEAM_RPCS='["https://rpc.ankr.com/moonbeam/${token_ankr}","https://rpc.api.moonbeam.network","https://1rpc.io/glmr"]'
MOONBEAM_RPCS='["https://rpc.ankr.com/moonbeam/${token_ankr}","https://rpc.api.moonbeam.network"]'
BSC_RPCS='["https://rpc.ankr.com/bsc/${token_ankr}","https://bscrpc.com"]'
CELO_RPCS='["https://rpc.ankr.com/celo/${token_ankr}","https://forno.celo.org","https://1rpc.io/celo"]'
SCROLL_RPCS='["https://rpc.ankr.com/scroll/${token_ankr}","https://scroll-mainnet-public.unifra.io","https://rpc.scroll.io","https://scroll-mainnet.chainstacklabs.com"]'
Expand Down

0 comments on commit 39d952b

Please sign in to comment.