Skip to content

Commit

Permalink
watcher: fix terra block path
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed May 1, 2024
1 parent 796917d commit 61f19d5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 47 deletions.
3 changes: 1 addition & 2 deletions watcher/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export const RPCS_BY_CHAIN: { [key in Network]: { [key in Chain]?: string } } =
Aptos: process.env.APTOS_RPC || 'https://fullnode.mainnet.aptoslabs.com/',
Near: process.env.NEAR_RPC || 'https://rpc.mainnet.near.org',
Xpla: process.env.XPLA_RPC || 'https://dimension-lcd.xpla.dev',
Terra2: process.env.TERRA2_RPC || 'https://phoenix-lcd.terra.dev',
// Terra: 'https://columbus-fcd.terra.dev',
Terra2: process.env.TERRA2_RPC || 'https://terra-lcd.publicnode.com',
Terra: process.env.TERRA_RPC || 'https://terra-classic-fcd.publicnode.com',
Injective: process.env.INJECTIVE_RPC || 'https://sentry.exchange.grpc-web.injective.network',
Solana: process.env.SOLANA_RPC || 'https://api.mainnet-beta.solana.com',
Expand Down
12 changes: 7 additions & 5 deletions watcher/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ const createBaseLogger = (): WormholeLogger => {
})
);
}
console.log(
`watcher is logging to ${logPath ?? 'the console'} ${
usingLoki ? 'and loki' : ''
} at level ${logLevel}`
);
if (process.env.CI !== 'true') {
console.log(
`watcher is logging to ${logPath ?? 'the console'} ${
usingLoki ? 'and loki' : ''
} at level ${logLevel}`
);
}

const loggerConfig: LoggerOptions = {
level: logLevel,
Expand Down
4 changes: 2 additions & 2 deletions watcher/src/watchers/CosmwasmWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class CosmwasmWatcher extends Watcher {
if (!this.rpc) {
throw new Error(`${this.chain} RPC is not defined!`);
}
this.latestBlockTag = 'blocks/latest';
this.getBlockTag = 'blocks/';
this.latestBlockTag = 'cosmos/base/tendermint/v1beta1/blocks/latest';
this.getBlockTag = 'cosmos/base/tendermint/v1beta1/blocks/';
this.hashTag = 'cosmos/tx/v1beta1/txs/';
this.latestBlockHeight = 0;
if (chain === 'Sei') {
Expand Down
47 changes: 9 additions & 38 deletions watcher/src/watchers/__tests__/CosmwasmWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,31 @@ test('getFinalizedBlockNumber(terra2)', async () => {

test('getMessagesForBlocks(terra2)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Terra2');
const vaasByBlock = await watcher.getMessagesForBlocks(3165191, 3165192);
const vaasByBlock = await watcher.getMessagesForBlocks(10094466, 10094467);
const entries = Object.entries(vaasByBlock);
expect(entries.length).toEqual(2);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 2).length).toEqual(0);
expect(vaasByBlock['3165191/2023-01-03T12:12:54.922Z']).toBeDefined();
expect(vaasByBlock['3165191/2023-01-03T12:12:54.922Z'].length).toEqual(1);
expect(vaasByBlock['3165191/2023-01-03T12:12:54.922Z'][0]).toEqual(
'4FF15C860D78E65AA25DC41F634E158CC4D79BBD4EB5F72C0D09A1F6AC25810C:18/a463ad028fb79679cfc8ce1efba35ac0e77b35080a1abe9bebe83461f176b0a3/651'
expect(vaasByBlock['10094466/2024-04-28T18:26:24.793Z']).toBeDefined();
expect(vaasByBlock['10094466/2024-04-28T18:26:24.793Z'].length).toEqual(1);
expect(vaasByBlock['10094466/2024-04-28T18:26:24.793Z'][0]).toEqual(
'BA2A1A38B3E8C30626B9E2DD0308163CC72463B099A9CE18DBAC98805C69447E:18/a463ad028fb79679cfc8ce1efba35ac0e77b35080a1abe9bebe83461f176b0a3/3416'
);
});

test('getMessagesForBlocks(terra2)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Terra2');
const vaasByBlock = await watcher.getMessagesForBlocks(5635710, 5635712);
const vaasByBlock = await watcher.getMessagesForBlocks(10094467, 10094469);
const entries = Object.entries(vaasByBlock);
// console.log(entries); // Leave this in for future debugging
expect(entries.length).toEqual(3);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(3);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(0);
expect(entries.filter(([block, vaas]) => vaas.length === 2).length).toEqual(0);
expect(vaasByBlock['5635710/2023-06-23T12:54:10.949Z']).toBeDefined();
expect(vaasByBlock['5635711/2023-06-23T12:54:16.979Z']).toBeDefined();
expect(vaasByBlock['5635712/2023-06-23T12:54:23.010Z']).toBeDefined();
});

test.skip('getFinalizedBlockNumber(terra)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Terra');
const blockNumber = await watcher.getFinalizedBlockNumber();
expect(blockNumber).toBeGreaterThan(10980872);
});

// flaky rpc, skip
test.skip('getMessagesForBlocks(terra)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Terra');
const vaasByBlock = await watcher.getMessagesForBlocks(10974196, 10974197);
const entries = Object.entries(vaasByBlock);
expect(entries.length).toEqual(2);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 2).length).toEqual(0);
expect(vaasByBlock['10974196/2023-01-06T04:23:21.045Z']).toBeDefined();
expect(vaasByBlock['10974196/2023-01-06T04:23:21.045Z'].length).toEqual(1);
expect(vaasByBlock['10974196/2023-01-06T04:23:21.045Z'][0]).toEqual(
'8A31CDE56ED3ACB7239D705949BD6C164747210A6C4C69D98756E0CF6D22C9EB:3/0000000000000000000000007cf7b764e38a0a5e967972c1df77d432510564e2/256813'
);
expect(vaasByBlock['10094467/2024-04-28T18:26:31.162Z']).toBeDefined();
expect(vaasByBlock['10094468/2024-04-28T18:26:37.231Z']).toBeDefined();
expect(vaasByBlock['10094469/2024-04-28T18:26:43.063Z']).toBeDefined();
});

test('getFinalizedBlockNumber(terra explorer)', async () => {
Expand All @@ -72,7 +50,6 @@ test('getFinalizedBlockNumber(terra explorer)', async () => {
expect(blockNumber).toBeGreaterThan(10980872);
});

// flaky rpc, skip
test('getMessagesForBlocks(terra explorer)', async () => {
const watcher = new TerraExplorerWatcher('Mainnet', 'Terra');
const vaasByBlock = await watcher.getMessagesForBlocks(14506733, 14506740);
Expand Down Expand Up @@ -146,7 +123,6 @@ test.skip('getMessagesForBlocks(injective)', async () => {
test.skip('getFinalizedBlockNumber(sei)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Sei');
const blockNumber = await watcher.getFinalizedBlockNumber();
console.log(blockNumber);
expect(blockNumber).toBeGreaterThan(0);
});

Expand All @@ -155,7 +131,6 @@ test.skip('getMessagesForBlocks(sei)', async () => {
const watcher = new CosmwasmWatcher('Mainnet', 'Sei');
const vaasByBlock = await watcher.getMessagesForBlocks(18907686, 18907687);
const entries = Object.entries(vaasByBlock);
console.log(entries);
expect(entries.length).toEqual(2);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(0);
Expand All @@ -171,7 +146,6 @@ test.skip('getMessagesForBlocks(sei)', async () => {
test('getFinalizedBlockNumber(sei explorer)', async () => {
const watcher = new SeiExplorerWatcher('Mainnet');
const blockNumber = await watcher.getFinalizedBlockNumber();
console.log(blockNumber);
expect(blockNumber).toBeGreaterThan(0);
});

Expand All @@ -180,7 +154,6 @@ test.skip('getMessagesForBlocks(sei explorer)', async () => {
const watcher = new SeiExplorerWatcher('Mainnet');
const vaasByBlock = await watcher.getMessagesForBlocks(19061244, 19061245);
const entries = Object.entries(vaasByBlock);
console.log(entries);
expect(entries.length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(0);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(1);
Expand All @@ -195,7 +168,6 @@ test.skip('getMessagesForBlocks(sei explorer)', async () => {
test('getFinalizedBlockNumber(wormchain)', async () => {
const watcher = new WormchainWatcher('Mainnet');
const blockNumber = await watcher.getFinalizedBlockNumber();
console.log(blockNumber);
expect(blockNumber).toBeGreaterThan(
Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN['Mainnet'].Wormchain)
);
Expand All @@ -205,7 +177,6 @@ test('getMessagesForBlocks(wormchain)', async () => {
const watcher = new WormchainWatcher('Mainnet');
const vaasByBlock = await watcher.getMessagesForBlocks(4510119, 4510119);
const entries = Object.entries(vaasByBlock);
console.log(entries);
expect(entries.length).toEqual(1);
expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(0);
expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(1);
Expand Down

0 comments on commit 61f19d5

Please sign in to comment.