Commit a62e120a authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #1390 from ethereum-optimism/develop

Develop To Master PR
parents 506295cd 27e4077e
---
"@eth-optimism/core-utils": patch
---
Watcher: Make blocks to fetch a config option
---
"@eth-optimism/core-utils": patch
---
Lower NUM_BLOCKS_TO_FETCH in Watcher
...@@ -11,13 +11,14 @@ export interface WatcherOptions { ...@@ -11,13 +11,14 @@ export interface WatcherOptions {
l1: Layer l1: Layer
l2: Layer l2: Layer
pollInterval?: number pollInterval?: number
blocksToFetch?: number
} }
export class Watcher { export class Watcher {
public l1: Layer public l1: Layer
public l2: Layer public l2: Layer
public pollInterval = 3000 public pollInterval = 3000
public NUM_BLOCKS_TO_FETCH = 10_000_000 public blocksToFetch = 2000
constructor(opts: WatcherOptions) { constructor(opts: WatcherOptions) {
this.l1 = opts.l1 this.l1 = opts.l1
...@@ -25,6 +26,9 @@ export class Watcher { ...@@ -25,6 +26,9 @@ export class Watcher {
if (opts.pollInterval) { if (opts.pollInterval) {
this.pollInterval = opts.pollInterval this.pollInterval = opts.pollInterval
} }
if (opts.blocksToFetch) {
this.blocksToFetch = opts.blocksToFetch
}
} }
public async getMessageHashesFromL1Tx(l1TxHash: string): Promise<string[]> { public async getMessageHashesFromL1Tx(l1TxHash: string): Promise<string[]> {
...@@ -83,7 +87,7 @@ export class Watcher { ...@@ -83,7 +87,7 @@ export class Watcher {
// scan for transaction with specified message // scan for transaction with specified message
while (matches.length === 0) { while (matches.length === 0) {
const blockNumber = await layer.provider.getBlockNumber() const blockNumber = await layer.provider.getBlockNumber()
const startingBlock = Math.max(blockNumber - this.NUM_BLOCKS_TO_FETCH, 0) const startingBlock = Math.max(blockNumber - this.blocksToFetch, 0)
const successFilter: ethers.providers.Filter = { const successFilter: ethers.providers.Filter = {
address: layer.messengerAddress, address: layer.messengerAddress,
topics: [ethers.utils.id(`RelayedMessage(bytes32)`)], topics: [ethers.utils.id(`RelayedMessage(bytes32)`)],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment