Skip to content

Commit 0756c69

Browse files
committed
chore(devnet): upgraded devent and review fixes
1 parent 9855dbc commit 0756c69

File tree

5 files changed

+27
-55
lines changed

5 files changed

+27
-55
lines changed

contracts/deploy/01-outbox/01-arb-sepolia-to-sepolia-outbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseEther, parseUnits } from "ethers";
1+
import { parseEther } from "ethers";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
44
import getContractAddress from "../../deploy-helpers/getContractAddress";

contracts/deploy/03-routers/03-gnosis-to-arb-router.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const deployRouter: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5050
const contractBaseName = "RouterGnosisToArb";
5151
const deploymentName = `${contractBaseName}${suffix}`;
5252

53+
if (!(RouterChains[chainId] in paramsByChainId)) {
54+
throw new Error(`Unsupported chain ID: ${chainId}`);
55+
}
56+
5357
// ----------------------------------------------------------------------------------------------
5458
const hardhatDeployer = async () => {
5559
const [veaOutbox, veaInbox] = await Promise.all([

validator-cli/src/ArbToEth/watcherArbToGnosis.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ const watch = async () => {
106106

107107
const wethAddress = (await retryOperation(() => veaOutbox.weth(), 1000, 10)) as string;
108108
const weth = getWETH(wethAddress, process.env.PRIVATE_KEY, process.env.RPC_GNOSIS);
109-
const balance = (await retryOperation(() => weth.balanceOf(watcherAddress), 1000, 10)) as BigInt;
110-
const allowance = (await retryOperation(() => weth.allowance(watcherAddress, veaOutboxAddress), 1000, 10)) as BigInt;
109+
const balance = (await retryOperation(() => weth.balanceOf(watcherAddress), 1000, 10)) as bigint;
110+
const allowance = (await retryOperation(() => weth.allowance(watcherAddress, veaOutboxAddress), 1000, 10)) as bigint;
111111

112112
// get Arb sequencer params
113113
const l2Network = await getArbitrumNetwork(providerArb);
114114
const sequencer = SequencerInbox__factory.connect(l2Network.ethBridge.sequencerInbox, providerEth);
115115
const maxDelaySeconds = Number((await retryOperation(() => sequencer.maxTimeVariation(), 1000, 10))[1] as BigInt);
116116

117117
// get vea outbox params
118-
const deposit = await retryOperation(() => veaOutbox.deposit(), 1000, 10);
118+
const deposit = (await retryOperation(() => veaOutbox.deposit(), 1000, 10)) as bigint;
119119
const epochPeriod = Number(await retryOperation(() => veaOutbox.epochPeriod(), 1000, 10));
120120
const sequencerDelayLimit = Number(await retryOperation(() => veaOutbox.sequencerDelayLimit(), 1000, 10));
121121

validator-cli/src/utils/devnet.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { BigNumber, utils } from "ethers";
2-
import { getVeaInboxArbToEthProvider, getVeaOutboxArbToEthDevnetProvider } from "../utils/ethers";
1+
import { ethers } from "ethers";
2+
import { getVeaInboxArbToEth, getVeaOutboxArbToEthDevnet } from "../utils/ethers";
33
import { VeaInboxArbToEth, VeaOutboxArbToEthDevnet } from "@kleros/vea-contracts/typechain-types";
44
import { JsonRpcProvider } from "@ethersproject/providers";
55

66
async function initialize(
77
veaOutboxAddress: string,
88
veaInboxAddress: string,
99
outboxRPCUrl: string
10-
): Promise<[VeaInboxArbToEth, number, BigNumber, VeaOutboxArbToEthDevnet, BigNumber]> {
10+
): Promise<[VeaInboxArbToEth, number, BigInt, VeaOutboxArbToEthDevnet, BigInt]> {
1111
const outboxProvider = new JsonRpcProvider(outboxRPCUrl);
12-
const veaOutbox = getVeaOutboxArbToEthDevnetProvider(veaOutboxAddress, process.env.PRIVATE_KEY, outboxProvider);
12+
const veaOutbox = getVeaOutboxArbToEthDevnet(veaOutboxAddress, process.env.PRIVATE_KEY, outboxRPCUrl);
1313

1414
const arbSepoliaProvider = new JsonRpcProvider(process.env.RPC_ARB_SEPOLIA);
15-
const veaInbox = getVeaInboxArbToEthProvider(veaInboxAddress, process.env.PRIVATE_KEY, arbSepoliaProvider);
15+
const veaInbox = getVeaInboxArbToEth(veaInboxAddress, process.env.PRIVATE_KEY, process.env.RPC_ARB_SEPOLIA);
1616

1717
const deposit = await veaOutbox.deposit();
18-
const epochPeriod = (await veaOutbox.epochPeriod()).toNumber();
18+
const epochPeriod = Number(await veaOutbox.epochPeriod());
1919
let currentTS = Math.floor(Date.now() / 1000);
2020
let claimableEpoch = Math.floor(currentTS / epochPeriod);
2121

@@ -29,57 +29,53 @@ async function initialize(
2929
// not really correct since l2 blocks are different, but just an estimate
3030
const searchBlock = Math.max(0, (await arbSepoliaProvider.getBlockNumber()) - Math.floor(1209600 / 12));
3131

32-
const logs = await arbSepoliaProvider.getLogs({
33-
address: veaInboxAddress,
34-
topics: veaInbox.filters.SnapshotSaved(null).topics,
35-
fromBlock: searchBlock,
36-
});
32+
const logs = await veaInbox.queryFilter(veaInbox.filters.SnapshotSaved(null), searchBlock);
3733

3834
let lastSavedCount =
3935
logs.length > 0
40-
? utils.defaultAbiCoder.decode(["bytes32", "uint256", "uint64"], logs[logs.length - 1].data)[2]
41-
: BigNumber.from(0);
36+
? ethers.AbiCoder.defaultAbiCoder().decode(["bytes32", "uint256", "uint64"], logs[logs.length - 1].data)[2]
37+
: BigInt(0);
4238
return [veaInbox, epochPeriod, lastSavedCount, veaOutbox, deposit];
4339
}
4440

4541
async function happyPath(
4642
veaInbox: VeaInboxArbToEth,
4743
epochPeriod: number,
48-
lastSavedCount: BigNumber,
44+
lastSavedCount: BigInt,
4945
veaOutbox: VeaOutboxArbToEthDevnet,
50-
deposit: BigNumber
51-
): Promise<BigNumber> {
46+
deposit: BigInt
47+
): Promise<BigInt> {
5248
let currentTS = Math.floor(Date.now() / 1000);
5349
let claimableEpoch = Math.floor(currentTS / epochPeriod);
5450
let newCount = lastSavedCount;
5551
const snapshot = await veaInbox.snapshots(claimableEpoch);
5652

5753
if (snapshot == "0x0000000000000000000000000000000000000000000000000000000000000000") {
5854
// check if snapshot should be taken
59-
const inboxCount = await veaInbox.count();
60-
if (inboxCount.gt(lastSavedCount)) {
55+
const inboxCount: BigInt = await veaInbox.count();
56+
if (inboxCount > lastSavedCount) {
6157
// should take snapshot
6258
console.log("inbox updated: taking snapshot. . .");
6359
const txn = await veaInbox.saveSnapshot();
6460
const receipt = await txn.wait();
6561

66-
newCount = BigNumber.from(receipt.logs[0].data);
62+
newCount = BigInt(receipt.logs[0].data);
6763

6864
const snapshot = await veaInbox.snapshots(claimableEpoch);
6965
console.log(`Snapshot Txn: ${txn.hash}`);
7066
console.log("snapshot count: ", receipt.logs[0].data);
7167
lastSavedCount = inboxCount;
72-
const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: deposit });
68+
const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: Number(deposit) });
7369
console.log(`DevnetAdvanceState Txn: ${txnOutbox.hash}`);
7470
} else {
7571
console.log("inbox not updated: not taking snapshot. . .");
7672
}
7773
} else {
7874
console.log("snapshot already taken. . .");
7975
const latestVerifiedEpoch = await veaOutbox.latestVerifiedEpoch();
80-
if (latestVerifiedEpoch.toNumber() < claimableEpoch) {
76+
if (latestVerifiedEpoch < claimableEpoch) {
8177
console.log("advancing devnet state. . .");
82-
const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: deposit });
78+
const txnOutbox = await veaOutbox.devnetAdvanceState(claimableEpoch, snapshot, { value: Number(deposit) });
8379
console.log(`DevnetAdvanceState Txn: ${txnOutbox.hash}`);
8480
}
8581
}

validator-cli/src/utils/ethers.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import {
33
VeaOutboxArbToEth__factory,
44
VeaOutboxArbToGnosis__factory,
55
VeaOutboxArbToEthDevnet__factory,
6-
VeaOutboxArbToGnosisDevnet__factory,
7-
VeaOutboxMultiChallenge__factory,
86
VeaInboxArbToEth__factory,
97
VeaInboxArbToGnosis__factory,
108
IWETH__factory,
@@ -24,26 +22,6 @@ function getVeaInboxArbToEth(veaInboxAddress: string, privateKey: string, web3Pr
2422
return VeaInboxArbToEth__factory.connect(veaInboxAddress, getWallet(privateKey, web3ProviderURL));
2523
}
2624

27-
function getVeaInboxArbToEthProvider(veaInboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
28-
return VeaInboxArbToEth__factory.connect(veaInboxAddress, getWalletRPC(privateKey, rpc));
29-
}
30-
31-
function getVeaOutboxArbToEthProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
32-
return VeaOutboxArbToEth__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc));
33-
}
34-
35-
function getVeaOutboxMultiChallengeProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
36-
return VeaOutboxMultiChallenge__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc));
37-
}
38-
39-
function getVeaOutboxArbToGnosisProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
40-
return VeaOutboxArbToGnosis__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc));
41-
}
42-
43-
function getVeaInboxArbToGnosisProvider(veaInboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
44-
return VeaInboxArbToGnosis__factory.connect(veaInboxAddress, getWalletRPC(privateKey, rpc));
45-
}
46-
4725
function getWETH(WETH: string, privateKey: string, web3ProviderURL: string) {
4826
return IWETH__factory.connect(WETH, getWallet(privateKey, web3ProviderURL));
4927
}
@@ -52,10 +30,6 @@ function getVeaOutboxArbToEth(veaOutboxAddress: string, privateKey: string, web3
5230
return VeaOutboxArbToEth__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL));
5331
}
5432

55-
function getVeaOutboxArbToEthDevnetProvider(veaOutboxAddress: string, privateKey: string, rpc: JsonRpcProvider) {
56-
return VeaOutboxArbToEthDevnet__factory.connect(veaOutboxAddress, getWalletRPC(privateKey, rpc));
57-
}
58-
5933
function getVeaOutboxArbToEthDevnet(veaOutboxAddress: string, privateKey: string, web3ProviderURL: string) {
6034
return VeaOutboxArbToEthDevnet__factory.connect(veaOutboxAddress, getWallet(privateKey, web3ProviderURL));
6135
}
@@ -79,10 +53,8 @@ export {
7953
getVeaOutboxArbToEth,
8054
getWalletRPC,
8155
getWallet,
82-
getVeaOutboxArbToEthDevnetProvider,
56+
getVeaOutboxArbToEthDevnet,
8357
getVeaInboxArbToEth,
84-
getVeaInboxArbToEthProvider,
85-
getVeaOutboxArbToEthProvider,
8658
getVeaOutboxArbToGnosis,
8759
getVeaInboxArbToGnosis,
8860
getVeaRouterArbToGnosis,

0 commit comments

Comments
 (0)