diff --git a/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts b/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts index c9aaf70e..f2842eff 100644 --- a/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts +++ b/blockchain-watcher/src/infrastructure/repositories/RepositoriesBuilder.ts @@ -96,6 +96,7 @@ export class RepositoriesBuilder { const pools = this.createEvmProviderPools(); const repoCfg: EvmJsonRPCBlockRepositoryCfg = { chains: this.cfg.chains, + environment: this.cfg.environment, }; const moonbeamRepository = new RateLimitedEvmJsonRPCBlockRepository( diff --git a/blockchain-watcher/src/infrastructure/repositories/evm/ArbitrumEvmJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/evm/ArbitrumEvmJsonRPCBlockRepository.ts index ea79f018..eb25e816 100644 --- a/blockchain-watcher/src/infrastructure/repositories/evm/ArbitrumEvmJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/evm/ArbitrumEvmJsonRPCBlockRepository.ts @@ -63,10 +63,7 @@ export class ArbitrumEvmJsonRPCBlockRepository extends EvmJsonRPCBlockRepository this.saveAssociatedL1Block(auxPersistedBlocks, associatedL1ArbBlock, l2BlockArbNumber); // Get the latest finalized L1 block ethereum number - const latestL1BlockEthNumber: bigint = await super.getBlockHeight( - this.getL1Chain(chain), - FINALIZED - ); + const latestL1BlockEthNumber: bigint = await super.getBlockHeight(this.getL1Chain(), FINALIZED); // Search in the persisted list looking for finalized L2 block number this.searchFinalizedBlock(auxPersistedBlocks, latestL1BlockEthNumber); @@ -139,8 +136,8 @@ export class ArbitrumEvmJsonRPCBlockRepository extends EvmJsonRPCBlockRepository } } - private getL1Chain(chain: string): string { - return chain === "arbitrum" ? "ethereum" : "ethereum-sepolia"; + private getL1Chain(): string { + return this.cfg.environment === "testnet" ? "ethereum-sepolia" : "ethereum"; } } diff --git a/blockchain-watcher/src/infrastructure/repositories/evm/EvmJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/evm/EvmJsonRPCBlockRepository.ts index b08eacf3..4140ad38 100644 --- a/blockchain-watcher/src/infrastructure/repositories/evm/EvmJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/evm/EvmJsonRPCBlockRepository.ts @@ -362,6 +362,7 @@ export class EvmJsonRPCBlockRepository implements EvmBlockRepository { export type EvmJsonRPCBlockRepositoryCfg = { chains: Record; + environment: string; }; type ErrorBlock = { diff --git a/blockchain-watcher/test/infrastructure/repositories/ArbitrumEvmJsonRPCBlockRepository.test.ts b/blockchain-watcher/test/infrastructure/repositories/ArbitrumEvmJsonRPCBlockRepository.test.ts index 044610ac..c5052836 100644 --- a/blockchain-watcher/test/infrastructure/repositories/ArbitrumEvmJsonRPCBlockRepository.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/ArbitrumEvmJsonRPCBlockRepository.test.ts @@ -89,6 +89,7 @@ const givenARepo = () => { chainId: 23, }, }, + environment: "mainnet", }, { ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) }, diff --git a/blockchain-watcher/test/infrastructure/repositories/BscEvmJsonRPCBlockRepository.test.ts b/blockchain-watcher/test/infrastructure/repositories/BscEvmJsonRPCBlockRepository.test.ts index c76ef4e9..a5492542 100644 --- a/blockchain-watcher/test/infrastructure/repositories/BscEvmJsonRPCBlockRepository.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/BscEvmJsonRPCBlockRepository.test.ts @@ -45,6 +45,7 @@ const givenARepo = () => { chains: { bsc: { rpcs: [rpc], timeout: 100, name: bsc, network: "mainnet", chainId: 4 }, }, + environment: "testnet", }, { bsc: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "bsc" }) } } as any ); diff --git a/blockchain-watcher/test/infrastructure/repositories/EvmJsonRPCBlockRepository.integration.test.ts b/blockchain-watcher/test/infrastructure/repositories/EvmJsonRPCBlockRepository.integration.test.ts index 68d27326..c6339ac1 100644 --- a/blockchain-watcher/test/infrastructure/repositories/EvmJsonRPCBlockRepository.integration.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/EvmJsonRPCBlockRepository.integration.test.ts @@ -109,6 +109,7 @@ const givenARepo = () => { chains: { ethereum: { rpcs: [rpc], timeout: 100, name: "ethereum", network: "mainnet", chainId: 2 }, }, + environment: "testnet", }, { ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) }, diff --git a/blockchain-watcher/test/infrastructure/repositories/MoonbeamEvmJsonRPCBlockRepository.test.ts b/blockchain-watcher/test/infrastructure/repositories/MoonbeamEvmJsonRPCBlockRepository.test.ts index 94d6c808..8909b684 100644 --- a/blockchain-watcher/test/infrastructure/repositories/MoonbeamEvmJsonRPCBlockRepository.test.ts +++ b/blockchain-watcher/test/infrastructure/repositories/MoonbeamEvmJsonRPCBlockRepository.test.ts @@ -47,6 +47,7 @@ const givenARepo = () => { chains: { moonbeam: { rpcs: [rpc], timeout: 100, name: moonbeam, network: "mainnet", chainId: 16 }, }, + environment: "testnet", }, { moonbeam: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "moonbeam" }) }, diff --git a/deploy/blockchain-watcher/env/production-testnet.env b/deploy/blockchain-watcher/env/production-testnet.env index 35047ce0..1be18ac3 100644 --- a/deploy/blockchain-watcher/env/production-testnet.env +++ b/deploy/blockchain-watcher/env/production-testnet.env @@ -25,6 +25,7 @@ ETHEREUM_RPCS= OPTIMISM_RPCS= ARBITRUM_RPCS= POLYGON_RPCS= +MOONBEAM_RPCS= AVALANCHE_RPCS= BASE_RPCS= BSC_RPCS= diff --git a/deploy/blockchain-watcher/env/staging-testnet.env b/deploy/blockchain-watcher/env/staging-testnet.env index 43767994..0d3790e9 100644 --- a/deploy/blockchain-watcher/env/staging-testnet.env +++ b/deploy/blockchain-watcher/env/staging-testnet.env @@ -29,6 +29,7 @@ AVALANCHE_RPCS= BASE_RPCS= BSC_RPCS= CELO_RPCS= +MOONBEAM_RPCS= SOLANA_RATE_LIMIT_LIMIT=15 SOLANA_RPCS=