Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
josojo committed Jan 4, 2024
1 parent fb453e0 commit 40a89c7
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 130 deletions.
61 changes: 28 additions & 33 deletions src/deployment/4_deployL1Applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved, no-restricted-syntax */
const path = require('path');
const fs = require('fs');
const { expect } = require('chai');
const { ethers, upgrades } = require('hardhat');
const { ethers } = require('hardhat');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

const pathOutputJson = path.join(__dirname, './deploy_output_l1_applications.json');
Expand All @@ -12,10 +11,7 @@ const pathOngoingDeploymentJson = path.join(__dirname, './deploy_ongoing_l1_appl
// const deployParameters = require('./deploy_parameters.json');
const deployParameters = {};

const delay = ms => new Promise(res => setTimeout(res, ms));

async function main() {

// Check if there's an ongoing deployment
let ongoingDeployment = {};
if (fs.existsSync(pathOngoingDeploymentJson)) {
Expand All @@ -27,18 +23,18 @@ async function main() {
* Check that every necessary parameter is fullfilled
*/
/*
const mandatoryDeploymentParameters = [
];
for (const parameterName of mandatoryDeploymentParameters) {
if (deployParameters[parameterName] === undefined || deployParameters[parameterName] === '') {
throw new Error(`Missing parameter: ${parameterName}`);
}
}
const {
} = deployParameters;
*/
*const mandatoryDeploymentParameters = [
*];
*
*for (const parameterName of mandatoryDeploymentParameters) {
* if (deployParameters[parameterName] === undefined || deployParameters[parameterName] === '') {
* throw new Error(`Missing parameter: ${parameterName}`);
* }
*}
*
*const {
*} = deployParameters;
*/

// Load provider
let currentProvider = ethers.provider;
Expand Down Expand Up @@ -77,10 +73,10 @@ async function main() {
} else {
[deployer] = (await ethers.getSigners());
}
let deployerBalance = await currentProvider.getBalance(deployer.address);
const deployerBalance = await currentProvider.getBalance(deployer.address);
console.log('using deployer: ', deployer.address, 'balance is ', deployerBalance.toString());

// ../../contracts/L1GlobalChainInfoPublisher.sol ../../contracts/L1GlobalForkRequester.sol
// ../../contracts/L1GlobalChainInfoPublisher.sol ../../contracts/L1GlobalForkRequester.sol

const L1GlobalChainInfoPublisherFactory = await ethers.getContractFactory('L1GlobalChainInfoPublisher', {
signer: deployer,
Expand All @@ -94,7 +90,6 @@ async function main() {
// save an ongoing deployment
ongoingDeployment.l1GlobalChainInfoPublisherContract = l1GlobalChainInfoPublisherContract.address;
fs.writeFileSync(pathOngoingDeploymentJson, JSON.stringify(ongoingDeployment, null, 1));

} else {
l1GlobalChainInfoPublisherContract = ChainIdManagerFactory.attach(ongoingDeployment.l1GlobalChainInfoPublisher);
console.log('#######################\n');
Expand All @@ -106,18 +101,18 @@ async function main() {
});

/*
let newDeployerBalance;
while (!newDeployerBalance || newDeployerBalance.eq(deployerBalance)) {
newDeployerBalance = await currentProvider.getBalance(deployer.address);
if (newDeployerBalance.lt(deployerBalance)) {
break;
} else {
console.log('Waiting for RPC node to notice account balance change before trying next deployment');
await delay(5000);
}
}
console.log('continue using deployer: ', deployer.address, 'balance is now', deployerBalance.toString());
*/
*let newDeployerBalance;
*while (!newDeployerBalance || newDeployerBalance.eq(deployerBalance)) {
* newDeployerBalance = await currentProvider.getBalance(deployer.address);
* if (newDeployerBalance.lt(deployerBalance)) {
* break;
* } else {
* console.log('Waiting for RPC node to notice account balance change before trying next deployment');
* await delay(5000);
* }
*}
*console.log('continue using deployer: ', deployer.address, 'balance is now', deployerBalance.toString());
*/

if (!ongoingDeployment.l1GlobalForkRequester) {
l1GlobalForkRequesterContract = await L1GlobalForkRequesterFactory.deploy();
Expand All @@ -135,7 +130,7 @@ async function main() {

const outputJson = {
l1GlobalChainInfoPublisher: l1GlobalChainInfoPublisherContract.address,
l1GlobalForkRequester: l1GlobalForkRequesterContract.address
l1GlobalForkRequester: l1GlobalForkRequesterContract.address,
};
fs.writeFileSync(pathOutputJson, JSON.stringify(outputJson, null, 1));

Expand Down
60 changes: 23 additions & 37 deletions src/deployment/5_deployL2Applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved, no-restricted-syntax */
const path = require('path');
const fs = require('fs');
const { expect } = require('chai');
const { ethers, upgrades } = require('hardhat');
const { ethers } = require('hardhat');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });

const pathGenesisJson = path.join(__dirname, './genesis.json');
Expand All @@ -15,10 +14,7 @@ const pathOngoingDeploymentJson = path.join(__dirname, './deploy_ongoing_l2_appl

const deployParameters = require('./deploy_application_parameters.json');

const delay = ms => new Promise(res => setTimeout(res, ms));

async function main() {

// Check that we already have the L1 settings we need
if (!fs.existsSync(pathOutputJsonL1Applications)) {
throw new Error('No l1 application addresses found. Deploy l1 applications first.');
Expand All @@ -28,15 +24,13 @@ async function main() {
}

const l1ApplicationAddresses = require(pathOutputJsonL1Applications);
const l1SystemAddresses = require(pathOutputJsonL1System);

const genesisJSON = require(pathGenesisJson);
const genesisEntries = genesisJSON.genesis;
let l2BridgeAddress;
for(const genesisIdx in genesisEntries) {
const genesisEntry = genesisEntries[genesisIdx];
if (genesisEntry.contractName == "PolygonZkEVMBridge proxy") {
l2BridgeAddress = genesisEntry.address;
for (const [, genesisEntry] of Object.entries(genesisEntries)) {
if (genesisEntry.contractName === 'PolygonZkEVMBridge proxy') {
l2BridgeAddress = genesisEntry.address;
break;
}
}
Expand All @@ -46,18 +40,16 @@ async function main() {

const {
l1GlobalChainInfoPublisher,
l1GlobalForkRequester
l1GlobalForkRequester,
} = l1ApplicationAddresses;

if (!l1GlobalForkRequester) {
throw new Error("Missing l1GlobalForkRequester address");
throw new Error('Missing l1GlobalForkRequester address');
}
if (!l1GlobalChainInfoPublisher) {
throw new Error("Missing l1GlobalChainInfoPublisher address");
throw new Error('Missing l1GlobalChainInfoPublisher address');
}

const forkonomicTokenAddress = l1SystemAddresses.maticTokenAddress;

// Check if there's an ongoing deployment
let ongoingDeployment = {};
if (fs.existsSync(pathOngoingDeploymentJson)) {
Expand All @@ -71,7 +63,7 @@ async function main() {
const mandatoryDeploymentParameters = [
'adjudicationFrameworkDisputeFee',
'arbitratorDisputeFee',
'forkArbitratorDisputeFee'
'forkArbitratorDisputeFee',
];

for (const parameterName of mandatoryDeploymentParameters) {
Expand All @@ -81,21 +73,19 @@ async function main() {
}

let {
adjudicationFrameworkDisputeFee,
forkArbitratorDisputeFee,
arbitratorDisputeFee,
arbitratorOwner,
realityETHAddress, // This is optional, it will be deployed if not supplied
initialArbitratorAddresses // This can be an empty array
initialArbitratorAddresses, // This can be an empty array
} = deployParameters;

// Load provider
let currentProvider = ethers.provider;
const currentProvider = ethers.provider;

//const feeData = await currentProvider.getFeeData();
//console.log('feeData', feeData);
//const block = await currentProvider.getBlock('latest');
//console.log('latest block', block);
/*
* const feeData = await currentProvider.getFeeData();
* console.log('feeData', feeData);
* const block = await currentProvider.getBlock('latest');
* console.log('latest block', block);
*/

// Load deployer
let deployer;
Expand All @@ -108,15 +98,15 @@ async function main() {
} else {
[deployer] = (await ethers.getSigners());
}
let deployerBalance = await currentProvider.getBalance(deployer.address);
const deployerBalance = await currentProvider.getBalance(deployer.address);
console.log('using deployer: ', deployer.address, 'balance is ', deployerBalance.toString());

if (!realityETHAddress && ongoingDeployment.realityETH) {
realityETHAddress = ongoingDeployment.realityETH;
}

// NB If we deploy then we only do 1 initial arbitrator. But there may be multiple in the config.
if (initialArbitratorAddresses.length == 0 && ongoingDeployment.initialArbitrator) {
if (initialArbitratorAddresses.length === 0 && ongoingDeployment.initialArbitrator) {
initialArbitratorAddresses = [ongoingDeployment.initialArbitrator];
}

Expand All @@ -143,8 +133,7 @@ async function main() {
signer: deployer,
});

if (initialArbitratorAddresses.length == 0) {

if (initialArbitratorAddresses.length === 0) {
if (!ongoingDeployment.initialArbitrator) {
const arbitratorContract = await arbitratorFactory.deploy();
console.log('#######################\n');
Expand All @@ -158,7 +147,6 @@ async function main() {
fs.writeFileSync(pathOngoingDeploymentJson, JSON.stringify(ongoingDeployment, null, 1));

initialArbitratorAddresses = [arbitratorContract.address];

} else {
arbitratorContract = arbitratorFactory.attach(initialArbitratorAddresses[0]);
console.log('#######################\n');
Expand All @@ -167,7 +155,6 @@ async function main() {
}
}


const l2ChainInfoFactory = await ethers.getContractFactory('L2ChainInfo', {
signer: deployer,
});
Expand All @@ -176,7 +163,7 @@ async function main() {
if (!ongoingDeployment.l2ChainInfo) {
l2ChainInfoContract = await l2ChainInfoFactory.deploy(
l2BridgeAddress,
l1GlobalChainInfoPublisher
l1GlobalChainInfoPublisher,
);
console.log('#######################\n');
console.log('L2ChainInfo deployed to:', l2ChainInfoContract.address);
Expand All @@ -202,7 +189,7 @@ async function main() {
realityETHContract.address,
l2ChainInfoContract.address,
l1GlobalForkRequester,
forkArbitratorDisputeFee
forkArbitratorDisputeFee,
);
console.log('#######################\n');
console.log('L2ForkArbitrator deployed to:', l2ForkArbitratorContract.address);
Expand All @@ -216,7 +203,6 @@ async function main() {
console.log('L2ForkArbitrator already deployed on: ', l2ForkArbitratorContract.address);
}


const adjudicationFrameworkFactory = await ethers.getContractFactory('AdjudicationFramework', {
signer: deployer,
});
Expand All @@ -229,7 +215,7 @@ async function main() {
realityETHContract.address,
adjudicationFrameworkDisputeFee,
l2ForkArbitratorContract.address,
initialArbitratorAddresses
initialArbitratorAddresses,
);
console.log('#######################\n');
console.log('AdjudicationFramework deployed to:', adjudicationFrameworkContract.address);
Expand All @@ -248,7 +234,7 @@ async function main() {
arbitrators: initialArbitratorAddresses,
l2ChainInfo: l2ChainInfoContract.address,
l2ForkArbitrator: l2ForkArbitratorContract.address,
adjudicationFramework: adjudicationFrameworkContract.address
adjudicationFramework: adjudicationFrameworkContract.address,
};
fs.writeFileSync(pathOutputJsonL2Applications, JSON.stringify(outputJson, null, 1));

Expand Down
11 changes: 7 additions & 4 deletions src/deployment/6_chainInfoUpdate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-await-in-loop, import/no-dynamic-require */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */

const path = require('path');
Expand All @@ -14,7 +14,6 @@ const l2Applications = require(pathOutputJsonL2Applications);
const l1SystemAddresses = require(pathOutputJsonL1System);

async function main() {

const currentProvider = ethers.provider;
let deployer;
if (process.env.PVTKEY) {
Expand All @@ -35,9 +34,13 @@ async function main() {
const l1GlobalChainInfoPublisher = l1GlobalChainInfoPublisherFactory.attach(l1Applications.l1GlobalChainInfoPublisher);

console.log('sending chain info update with addresses', l1BridgeAddress, l2Applications.l2ChainInfo);
const result = await l1GlobalChainInfoPublisher.updateL2ChainInfo(l1BridgeAddress, l2Applications.l2ChainInfo, ethers.constants.AddressZero, ethers.constants.AddressZero);
const result = await l1GlobalChainInfoPublisher.updateL2ChainInfo(
l1BridgeAddress,
l2Applications.l2ChainInfo,
ethers.constants.AddressZero,
ethers.constants.AddressZero,
);
console.log('sent tx, hash is', result.hash);

}

main().catch((e) => {
Expand Down
Loading

0 comments on commit 40a89c7

Please sign in to comment.