Skip to content

Commit 9a29126

Browse files
committed
add comments warn & add bridgeLib
1 parent becaf0b commit 9a29126

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

src/genesis-hardhat/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ export const GENESIS_CONTRACT_NAMES = {
3333
AGGORACLE_COMMITTEE: 'AggOracleCommittee',
3434
AGGORACLE_COMMITTEE_IMPLEMENTATION: 'AggOracleCommittee implementation',
3535
AGGORACLE_COMMITTEE_PROXY: 'AggOracleCommittee proxy',
36+
BRIDGE_LIB: 'BridgeLib',
3637
};

src/genesis-hardhat/create-genesis-hardhat.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
165165
const sovereignChainBridgeContract = (await ethers.getContractAt(
166166
GENESIS_CONTRACT_NAMES.SOVEREIGN_BRIDGE,
167167
bridgeDeploymentResult.proxy,
168+
deployer,
168169
)) as unknown as BridgeL2SovereignChain;
169170

170171
// Get addresses from bridge deployment
@@ -173,6 +174,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
173174
const tokenWrappedAddress = (
174175
await sovereignChainBridgeContract.getWrappedTokenBridgeImplementation()
175176
).toLocaleLowerCase();
177+
const bridgeLibAddress = (await sovereignChainBridgeContract.bridgeLib()).toLowerCase();
176178

177179
// deploy GlobalExitRootManagerL2SovereignChain
178180
const gerDeploymentResult = await deployGlobalExitRootManagerL2SovereignChain(
@@ -843,6 +845,24 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
843845
);
844846
}
845847

848+
/// /////////////////////////
849+
/// BRIDGE LIB /////////////
850+
/// /////////////////////////
851+
logger.info('Updating BytecodeStorer in genesis file...');
852+
const bridgeLib = _genesisBase.genesis.find(function (obj) {
853+
return obj.contractName === GENESIS_CONTRACT_NAMES.BRIDGE_LIB;
854+
});
855+
856+
genesisInfo.push({
857+
contractName: GENESIS_CONTRACT_NAMES.BRIDGE_LIB,
858+
genesisObject: bridgeLib,
859+
address: bridgeLibAddress,
860+
});
861+
862+
if (bridgeLib) {
863+
expect(bridgeLib.bytecode).to.equal(await ethers.provider.getCode(bridgeLibAddress));
864+
}
865+
846866
// If useAggOracleCommittee is true, we add AggOracleCommittee implementation and proxy to the genesis
847867
if (initializeParams.useAggOracleCommittee === true) {
848868
/// //////////////////////////////

src/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/* eslint-disable no-console */
44
import { ethers, upgrades } from 'hardhat';
55
import { execSync } from 'child_process';
6-
import fs from 'fs';
76

87
/**
98
* Adjusts the multiplier gas and/or the maxFeePer gas of the provider depending on the parameters values and returns the adjusted provider
@@ -173,8 +172,6 @@ export async function getStorageWrites(trace, addressInfo) {
173172
// Update actual address
174173
stackAddressesStorage.push(calculatedAddress);
175174
} else if (log.op === 'CREATE2') {
176-
// eslint-disable-next-line no-await-in-loop
177-
await fs.writeFileSync('log.json', JSON.stringify(log, null, 1));
178175
// Get actual address (create is with this address)
179176
const actualAddress = stackAddressesStorage[stackAddressesStorage.length - 1];
180177
const parameters = log.stack.slice(-4);

tools/createSovereignGenesisHardhat/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
> ⚠️ **Warning:** This code has not been audited yet.
3+
14
# Create sovereign genesis
25
Script to generate the genesis file for a rollup with `SovereignContracts`. This genesis is aimed to be used for chains that are run with vanilla clients.
36
This script should be run after the rollup is created, so its `rollupID` and the bridge initialization parameters are known.

tools/createSovereignGenesisHardhat/create-sovereign-genesis-hardhat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dotenv.config({ path: path.resolve(__dirname, '../../.env') });
2828
const dateStr = new Date().toISOString();
2929

3030
async function main() {
31+
logger.warn('This code has not been audited yet.');
3132
logger.info('Start create-sovereign-genesis tool');
3233

3334
/// //////////////////////////

0 commit comments

Comments
 (0)