diff --git a/contracts/deploy/01-outbox/01-arb-sepolia-to-sepolia-outbox.ts b/contracts/deploy/01-outbox/01-arb-sepolia-to-sepolia-outbox.ts index 892f8d44..19b82fca 100644 --- a/contracts/deploy/01-outbox/01-arb-sepolia-to-sepolia-outbox.ts +++ b/contracts/deploy/01-outbox/01-arb-sepolia-to-sepolia-outbox.ts @@ -1,4 +1,4 @@ -import { parseEther, parseUnits } from "ethers"; +import { parseEther } from "ethers"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import { DeployFunction } from "hardhat-deploy/types"; import getContractAddress from "../../deploy-helpers/getContractAddress"; diff --git a/contracts/deploy/03-routers/03-gnosis-to-arb-router.ts b/contracts/deploy/03-routers/03-gnosis-to-arb-router.ts index de780075..66c88076 100644 --- a/contracts/deploy/03-routers/03-gnosis-to-arb-router.ts +++ b/contracts/deploy/03-routers/03-gnosis-to-arb-router.ts @@ -50,6 +50,10 @@ const deployRouter: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const contractBaseName = "RouterGnosisToArb"; const deploymentName = `${contractBaseName}${suffix}`; + if (!(RouterChains[chainId] in paramsByChainId)) { + throw new Error(`Unsupported chain ID: ${chainId}`); + } + // ---------------------------------------------------------------------------------------------- const hardhatDeployer = async () => { const [veaOutbox, veaInbox] = await Promise.all([ diff --git a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts index 776b0142..40f946ec 100644 --- a/validator-cli/src/ArbToEth/watcherArbToGnosis.ts +++ b/validator-cli/src/ArbToEth/watcherArbToGnosis.ts @@ -106,8 +106,8 @@ const watch = async () => { const wethAddress = (await retryOperation(() => veaOutbox.weth(), 1000, 10)) as string; const weth = getWETH(wethAddress, process.env.PRIVATE_KEY, process.env.RPC_GNOSIS); - const balance = (await retryOperation(() => weth.balanceOf(watcherAddress), 1000, 10)) as BigInt; - const allowance = (await retryOperation(() => weth.allowance(watcherAddress, veaOutboxAddress), 1000, 10)) as BigInt; + const balance = (await retryOperation(() => weth.balanceOf(watcherAddress), 1000, 10)) as bigint; + const allowance = (await retryOperation(() => weth.allowance(watcherAddress, veaOutboxAddress), 1000, 10)) as bigint; // get Arb sequencer params const l2Network = await getArbitrumNetwork(providerArb); @@ -115,7 +115,7 @@ const watch = async () => { const maxDelaySeconds = Number((await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1] as BigInt); // get vea outbox params - const deposit = await retryOperation(() => veaOutbox.deposit(), 1000, 10); + const deposit = (await retryOperation(() => veaOutbox.deposit(), 1000, 10)) as bigint; const epochPeriod = Number(await retryOperation(() => veaOutbox.epochPeriod(), 1000, 10)); const sequencerDelayLimit = Number(await retryOperation(() => veaOutbox.sequencerDelayLimit(), 1000, 10)); diff --git a/validator-cli/src/utils/devnet.ts b/validator-cli/src/utils/devnet.ts index b263605a..2097f06b 100644 --- a/validator-cli/src/utils/devnet.ts +++ b/validator-cli/src/utils/devnet.ts @@ -1,5 +1,5 @@ -import { BigNumber, utils } from "ethers"; -import { getVeaInboxArbToEthProvider, getVeaOutboxArbToEthDevnetProvider } from "../utils/ethers"; +import { ethers } from "ethers"; +import { getVeaInboxArbToEth, getVeaOutboxArbToEthDevnet } from "../utils/ethers"; import { VeaInboxArbToEth, VeaOutboxArbToEthDevnet } from "@kleros/vea-contracts/typechain-types"; import { JsonRpcProvider } from "@ethersproject/providers"; @@ -7,15 +7,15 @@ async function initialize( veaOutboxAddress: string, veaInboxAddress: string, outboxRPCUrl: string -): Promise<[VeaInboxArbToEth, number, BigNumber, VeaOutboxArbToEthDevnet, BigNumber]> { +): Promise<[VeaInboxArbToEth, number, BigInt, VeaOutboxArbToEthDevnet, BigInt]> { const outboxProvider = new JsonRpcProvider(outboxRPCUrl); - const veaOutbox = getVeaOutboxArbToEthDevnetProvider(veaOutboxAddress, process.env.PRIVATE_KEY, outboxProvider); + const veaOutbox = getVeaOutboxArbToEthDevnet(veaOutboxAddress, process.env.PRIVATE_KEY, outboxRPCUrl); const arbSepoliaProvider = new JsonRpcProvider(process.env.RPC_ARB_SEPOLIA); - const veaInbox = getVeaInboxArbToEthProvider(veaInboxAddress, process.env.PRIVATE_KEY, arbSepoliaProvider); + const veaInbox = getVeaInboxArbToEth(veaInboxAddress, process.env.PRIVATE_KEY, process.env.RPC_ARB_SEPOLIA); const deposit = await veaOutbox.deposit(); - const epochPeriod = (await veaOutbox.epochPeriod()).toNumber(); + const epochPeriod = Number(await veaOutbox.epochPeriod()); let currentTS = Math.floor(Date.now() / 1000); let claimableEpoch = Math.floor(currentTS / epochPeriod); @@ -29,26 +29,22 @@ async function initialize( // not really correct since l2 blocks are different, but just an estimate const searchBlock = Math.max(0, (await arbSepoliaProvider.getBlockNumber()) - Math.floor(1209600 / 12)); - const logs = await arbSepoliaProvider.getLogs({ - address: veaInboxAddress, - topics: veaInbox.filters.SnapshotSaved(null).topics, - fromBlock: searchBlock, - }); + const logs = await veaInbox.queryFilter(veaInbox.filters.SnapshotSaved(null), searchBlock); let lastSavedCount = logs.length > 0 - ? utils.defaultAbiCoder.decode(["bytes32", "uint256", "uint64"], logs[logs.length - 1].data)[2] - : BigNumber.from(0); + ? ethers.AbiCoder.defaultAbiCoder().decode(["bytes32", "uint256", "uint64"], logs[logs.length - 1].data)[2] + : BigInt(0); return [veaInbox, epochPeriod, lastSavedCount, veaOutbox, deposit]; } async function happyPath( veaInbox: VeaInboxArbToEth, epochPeriod: number, - lastSavedCount: BigNumber, + lastSavedCount: BigInt, veaOutbox: VeaOutboxArbToEthDevnet, - deposit: BigNumber -): Promise { + deposit: BigInt +): Promise { let currentTS = Math.floor(Date.now() / 1000); let claimableEpoch = Math.floor(currentTS / epochPeriod); let newCount = lastSavedCount; @@ -56,20 +52,20 @@ async function happyPath( if (snapshot == "0x0000000000000000000000000000000000000000000000000000000000000000") { // check if snapshot should be taken - const inboxCount = await veaInbox.count(); - if (inboxCount.gt(lastSavedCount)) { + const inboxCount: BigInt = await veaInbox.count(); + if (inboxCount > lastSavedCount) { // should take snapshot console.log("inbox updated: taking snapshot. . ."); const txn = await veaInbox.saveSnapshot(); const receipt = await txn.wait(); - newCount = BigNumber.from(receipt.logs[0].data); + newCount = BigInt(receipt.logs[0].data); const snapshot = await veaInbox.snapshots(claimableEpoch); console.log(`Snapshot Txn: ${txn.hash}`); console.log("snapshot count: ", receipt.logs[0].data); lastSavedCount = inboxCount; - const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: deposit }); + const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: Number(deposit) }); console.log(`DevnetAdvanceState Txn: ${txnOutbox.hash}`); } else { console.log("inbox not updated: not taking snapshot. . ."); @@ -77,9 +73,9 @@ async function happyPath( } else { console.log("snapshot already taken. . ."); const latestVerifiedEpoch = await veaOutbox.latestVerifiedEpoch(); - if (latestVerifiedEpoch.toNumber() < claimableEpoch) { + if (latestVerifiedEpoch < claimableEpoch) { console.log("advancing devnet state. . ."); - const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: deposit }); + const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: Number(deposit) }); console.log(`DevnetAdvanceState Txn: ${txnOutbox.hash}`); } } diff --git a/validator-cli/src/utils/ethers.ts b/validator-cli/src/utils/ethers.ts index 9316969a..48b542e0 100644 --- a/validator-cli/src/utils/ethers.ts +++ b/validator-cli/src/utils/ethers.ts @@ -3,8 +3,6 @@ import { VeaOutboxArbToEth__factory, VeaOutboxArbToGnosis__factory, VeaOutboxArbToEthDevnet__factory, - VeaOutboxArbToGnosisDevnet__factory, - VeaOutboxMultiChallenge__factory, VeaInboxArbToEth__factory, VeaInboxArbToGnosis__factory, IWETH__factory, @@ -24,26 +22,6 @@ function getVeaInboxArbToEth(veaInboxAddress: string, privateKey: string, web3Pr return VeaInboxArbToEth__factory.connect(veaInboxAddress, getWallet(privateKey, web3ProviderURL)); } -function getVeaInboxArbToEthProvider(veaInboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaInboxArbToEth__factory.connect(veaInboxAddress, getWalletRPC(privateKey, rpc)); -} - -function getVeaOutboxArbToEthProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaOutboxArbToEth__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc)); -} - -function getVeaOutboxMultiChallengeProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaOutboxMultiChallenge__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc)); -} - -function getVeaOutboxArbToGnosisProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaOutboxArbToGnosis__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc)); -} - -function getVeaInboxArbToGnosisProvider(veaInboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaInboxArbToGnosis__factory.connect(veaInboxAddress, getWalletRPC(privateKey, rpc)); -} - function getWETH(WETH: string, privateKey: string, web3ProviderURL: string) { return IWETH__factory.connect(WETH, getWallet(privateKey, web3ProviderURL)); } @@ -52,10 +30,6 @@ function getVeaOutboxArbToEth(veaOutboxAddress: string, privateKey: string, web3 return VeaOutboxArbToEth__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL)); } -function getVeaOutboxArbToEthDevnetProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) { - return VeaOutboxArbToEthDevnet__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc)); -} - function getVeaOutboxArbToEthDevnet(veaOutboxAddress: string, privateKey: string, web3ProviderURL: string) { return VeaOutboxArbToEthDevnet__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL)); } @@ -79,10 +53,8 @@ export { getVeaOutboxArbToEth, getWalletRPC, getWallet, - getVeaOutboxArbToEthDevnetProvider, + getVeaOutboxArbToEthDevnet, getVeaInboxArbToEth, - getVeaInboxArbToEthProvider, - getVeaOutboxArbToEthProvider, getVeaOutboxArbToGnosis, getVeaInboxArbToGnosis, getVeaRouterArbToGnosis,