Skip to content

Commit

Permalink
chore: correcting static audit flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed Oct 24, 2024
1 parent c25417d commit 81a5927
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 127 deletions.
140 changes: 37 additions & 103 deletions docs/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,40 @@
"artifact": "abis/0.8.20/Depository.json",
"address": "0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81"
},
{
"name": "ArbitrumDepositProcessorL1",
"artifact": "abis/0.8.25/ArbitrumDepositProcessorL1.json",
"address": "0x5e13E07006D68B097DCb5979ef5545C4f9156162"
},
{
"name": "OptimismDepositProcessorL1",
"artifact": "abis/0.8.25/OptimismDepositProcessorL1.json",
"address": "0x42BA1BbD797E4C90F386F03a544F3b62C1f917d0"
},
{
"name": "WormholeDepositProcessorL1",
"artifact": "abis/0.8.25/WormholeDepositProcessorL1.json",
"address": "0x223902b6C583f18E8dc84AF4E6a8fa523d088B78"
},
{
"name": "EthereumDepositProcessor",
"artifact": "abis/0.8.25/EthereumDepositProcessor.json",
"address": "0x15CD7fAeE048c7673aB818C9e582630F1a924593"
},
{
"name": "PolygonDepositProcessorL1",
"artifact": "abis/0.8.25/PolygonDepositProcessorL1.json",
"address": "0x4Ce43b82EF1298E1466D3b3Cee67BA6680bF82FB"
},
{
"name": "GnosisDepositProcessorL1",
"artifact": "abis/0.8.25/GnosisDepositProcessorL1.json",
"address": "0xEEf2c02cFC445bFFf1c891D486424Ef3aBc66AB0"
},
{
"name": "ArbitrumDepositProcessorL1",
"artifact": "abis/0.8.25/ArbitrumDepositProcessorL1.json",
"address": "0x5e13E07006D68B097DCb5979ef5545C4f9156162"
},
{
"name": "OptimismDepositProcessorL1",
"artifact": "abis/0.8.25/OptimismDepositProcessorL1.json",
"address": "0xAB787ceebe8F2b8dca44e3bB744D6e63003ee978"
},
{
"name": "PolygonDepositProcessorL1",
"artifact": "abis/0.8.25/PolygonDepositProcessorL1.json",
"address": "0x4Ce43b82EF1298E1466D3b3Cee67BA6680bF82FB"
"name": "OptimismDepositProcessorL1",
"artifact": "abis/0.8.25/OptimismDepositProcessorL1.json",
"address": "0x42BA1BbD797E4C90F386F03a544F3b62C1f917d0"
},
{
"name": "WormholeDepositProcessorL1",
"artifact": "abis/0.8.25/WormholeDepositProcessorL1.json",
"address": "0x223902b6C583f18E8dc84AF4E6a8fa523d088B78"
},
{
"name": "OptimismDepositProcessorL1",
Expand All @@ -81,68 +81,13 @@
]
},
{
"name": "arbitrumOne",
"chainId": "42161",
"contracts": [
{
"name": "ArbitrumTargetDispenserL2",
"artifact": "abis/0.8.25/ArbitrumTargetDispenserL2.json",
"address": "0x10c5525F77F13b28f42c5626240c001c2D57CAd4"
}
]
},
{
"name": "arbitrumSepolia",
"chainId": "421614",
"contracts": [
{
"name": "ArbitrumTargetDispenserL2",
"artifact": "abis/0.8.25/ArbitrumTargetDispenserL2.json",
"address": ""
}
]
},
{
"name": "base",
"chainId": "8453",
"contracts": [
{
"name": "OptimismTargetDispenserL2",
"artifact": "abis/0.8.25/OptimismTargetDispenserL2.json",
"address": "0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d"
}
]
},
{
"name": "baseSepolia",
"chainId": "84532",
"contracts": [
{
"name": "OptimismTargetDispenserL2",
"artifact": "abis/0.8.25/OptimismTargetDispenserL2.json",
"address": ""
}
]
},
{
"name": "celo",
"chainId": "42220",
"contracts": [
{
"name": "WormholeTargetDispenserL2",
"artifact": "abis/0.8.25/WormholeTargetDispenserL2.json",
"address": "0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"
}
]
},
{
"name": "celoAlfajores",
"chainId": "44787",
"name": "polygon",
"chainId": "137",
"contracts": [
{
"name": "WormholeTargetDispenserL2",
"artifact": "abis/0.8.25/WormholeTargetDispenserL2.json",
"address": ""
"name": "PolygonTargetDispenserL2",
"artifact": "abis/0.8.25/PolygonTargetDispenserL2.json",
"address": "0xf76953444C35F1FcE2F6CA1b167173357d3F5C17"
}
]
},
Expand All @@ -158,13 +103,13 @@
]
},
{
"name": "chiado",
"chainId": "10200",
"name": "arbitrumOne",
"chainId": "42161",
"contracts": [
{
"name": "GnosisTargetDispenserL2",
"artifact": "abis/0.8.25/GnosisTargetDispenserL2.json",
"address": ""
"name": "ArbitrumTargetDispenserL2",
"artifact": "abis/0.8.25/ArbitrumTargetDispenserL2.json",
"address": "0x10c5525F77F13b28f42c5626240c001c2D57CAd4"
}
]
},
Expand All @@ -180,41 +125,30 @@
]
},
{
"name": "optimisticSepolia",
"chainId": "11155420",
"name": "base",
"chainId": "8453",
"contracts": [
{
"name": "OptimismTargetDispenserL2",
"artifact": "abis/0.8.25/OptimismTargetDispenserL2.json",
"address": ""
}
]
},
{
"name": "polygon",
"chainId": "137",
"contracts": [
{
"name": "PolygonTargetDispenserL2",
"artifact": "abis/0.8.25/PolygonTargetDispenserL2.json",
"address": "0xf76953444C35F1FcE2F6CA1b167173357d3F5C17"
"address": "0xcDdD9D9ABaB36fFa882530D69c73FeE5D4001C2d"
}
]
},
{
"name": "polygonAmoy",
"chainId": "80002",
"name": "celo",
"chainId": "42220",
"contracts": [
{
"name": "PolygonTargetDispenserL2",
"artifact": "abis/0.8.25/PolygonTargetDispenserL2.json",
"address": ""
"name": "WormholeTargetDispenserL2",
"artifact": "abis/0.8.25/WormholeTargetDispenserL2.json",
"address": "0xb4096d181C08DDF75f1A63918cCa0d1023C4e6C7"
}
]
},
{
"name": "mode",
"chainId": "137",
"chainId": "34443",
"contracts": [
{
"name": "OptimismTargetDispenserL2",
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
chainId: 42161,
},
optimistic: {
url: "https://optimism.drpc.org",
url: "https://optimism.llamarpc.com",
accounts: accounts,
chainId: 10,
},
Expand Down
116 changes: 93 additions & 23 deletions scripts/audit_chains/audit_contracts_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ async function checkOptimismDepositProcessorL1(chainId, provider, globalsInstanc
await checkBytecode(provider, configContracts, contractName, log);

// Get the contract instance
const optimismDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName, 1);
const optimismDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + optimismDepositProcessorL1.address;
await checkDepositProcessorL1(optimismDepositProcessorL1, globalsInstance, log);
Expand Down Expand Up @@ -404,7 +404,7 @@ async function checkBaseDepositProcessorL1(chainId, provider, globalsInstance, c
await checkBytecode(provider, configContracts, contractName, log);

// Get the contract instance
const baseDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName);
const baseDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName, 1);

log += ", address: " + baseDepositProcessorL1.address;
await checkDepositProcessorL1(baseDepositProcessorL1, globalsInstance, log);
Expand All @@ -430,6 +430,38 @@ async function checkBaseDepositProcessorL1(chainId, provider, globalsInstance, c
customExpect(l2TargetDispenser, globalsInstance["baseTargetDispenserL2Address"], log + ", function: l2TargetDispenser()");
}

// Check ModeDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name
async function checkModeDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) {
// Check the bytecode
await checkBytecode(provider, configContracts, contractName, log);

// Get the contract instance
const modeDepositProcessorL1 = await findContractInstance(provider, configContracts, contractName, 2);

log += ", address: " + modeDepositProcessorL1.address;
await checkDepositProcessorL1(modeDepositProcessorL1, globalsInstance, log);

// Check L1 token relayer
const l1TokenRelayer = await modeDepositProcessorL1.l1TokenRelayer();
customExpect(l1TokenRelayer, globalsInstance["modeL1StandardBridgeProxyAddress"], log + ", function: l1TokenRelayer()");

// Check L1 message relayer
const l1MessageRelayer = await modeDepositProcessorL1.l1MessageRelayer();
customExpect(l1MessageRelayer, globalsInstance["modeL1CrossDomainMessengerProxyAddress"], log + ", function: l1MessageRelayer()");

// Check L2 target chain Id
const l2TargetChainId = await modeDepositProcessorL1.l2TargetChainId();
customExpect(l2TargetChainId.toString(), globalsInstance["modeL2TargetChainId"], log + ", function: l2TargetChainId()");

// Check L2 OLAS address
const olasL2 = await modeDepositProcessorL1.olasL2();
customExpect(olasL2, globalsInstance["modeOLASAddress"], log + ", function: olasL2()");

// Check L2 target dispenser
const l2TargetDispenser = await modeDepositProcessorL1.l2TargetDispenser();
customExpect(l2TargetDispenser, globalsInstance["modeTargetDispenserL2Address"], log + ", function: l2TargetDispenser()");
}

// Check PolygonDepositProcessorL1: chain Id, provider, parsed globals, configuration contracts, contract name
async function checkPolygonDepositProcessorL1(chainId, provider, globalsInstance, configContracts, contractName, log) {
// Check the bytecode
Expand Down Expand Up @@ -622,6 +654,26 @@ async function checkBaseTargetDispenserL2(chainId, provider, globalsInstance, co
customExpect(l1DepositProcessor, globalsInstance["baseDepositProcessorL1Address"], log + ", function: l1DepositProcessor()");
}

// Check ModeTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name
async function checkModeTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) {
// Check the bytecode
await checkBytecode(provider, configContracts, contractName, log);

// Get the contract instance
const modeTargetDispenserL2 = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + modeTargetDispenserL2.address;
await checkTargetDispenserL2(modeTargetDispenserL2, globalsInstance, log);

// Check L2 message relayer
const l2MessageRelayer = await modeTargetDispenserL2.l2MessageRelayer();
customExpect(l2MessageRelayer, globalsInstance["modeL2CrossDomainMessengerAddress"], log + ", function: l2MessageRelayer()");

// Check L1 deposit processor
const l1DepositProcessor = await modeTargetDispenserL2.l1DepositProcessor();
customExpect(l1DepositProcessor, globalsInstance["modeDepositProcessorL1Address"], log + ", function: l1DepositProcessor()");
}

// Check CeloTargetDispenserL2: chain Id, provider, parsed globals, configuration contracts, contract name
async function checkCeloTargetDispenserL2(chainId, provider, globalsInstance, configContracts, contractName, log) {
// Check the bytecode
Expand Down Expand Up @@ -686,7 +738,8 @@ async function main() {
"arbitrumOne": "scripts/deployment/staking/arbitrum/globals_arbitrum_one.json",
"optimistic": "scripts/deployment/staking/optimistic/globals_optimistic_mainnet.json",
"base": "scripts/deployment/staking/base/globals_base_mainnet.json",
"celo": "scripts/deployment/staking/celo/globals_celo_mainnet.json"
"celo": "scripts/deployment/staking/celo/globals_celo_mainnet.json",
"mode": "scripts/deployment/staking/mode/globals_mode_mainnet.json"
};

const globals = new Array();
Expand All @@ -706,7 +759,8 @@ async function main() {
"arbitrumOne": "https://arb1.arbitrum.io/rpc",
"optimistic": "https://optimism.drpc.org",
"base": "https://mainnet.base.org",
"celo": "https://forno.celo.org"
"celo": "https://forno.celo.org",
"mode": "https://mainnet.mode.network"
};

const providers = new Array();
Expand Down Expand Up @@ -761,42 +815,58 @@ async function main() {
log = initLog + ", contract: " + "CeloDepositProcessorL1";
await checkCeloDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "WormholeDepositProcessorL1", log);

log = initLog + ", contract: " + "ModeDepositProcessorL1";
await checkModeDepositProcessorL1(configs[0]["chainId"], providers[0], globalsStaking, configs[0]["contracts"], "OptimismDepositProcessorL1", log);

// L2 contracts
let chainNumber = 1

Check failure on line 822 in scripts/audit_chains/audit_contracts_setup.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
// Polygon
console.log("\n######## Verifying setup on CHAIN ID", configs[11]["chainId"]);
initLog = "ChainId: " + configs[11]["chainId"] + ", network: " + configs[11]["name"];
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "PolygonTargetDispenserL2";
await checkPolygonTargetDispenserL2(configs[11]["chainId"], providers[1], globals[1], configs[11]["contracts"], "PolygonTargetDispenserL2", log);
await checkPolygonTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "PolygonTargetDispenserL2", log);
chainNumber++;

// Gnosis
console.log("\n######## Verifying setup on CHAIN ID", configs[7]["chainId"]);
initLog = "ChainId: " + configs[7]["chainId"] + ", network: " + configs[7]["name"];
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "GnosisTargetDispenserL2";
await checkGnosisTargetDispenserL2(configs[7]["chainId"], providers[2], globals[2], configs[7]["contracts"], "GnosisTargetDispenserL2", log);
await checkGnosisTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "GnosisTargetDispenserL2", log);
chainNumber++;

// Arbitrum
console.log("\n######## Verifying setup on CHAIN ID", configs[1]["chainId"]);
initLog = "ChainId: " + configs[1]["chainId"] + ", network: " + configs[1]["name"];
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "ArbitrumTargetDispenserL2";
await checkArbitrumTargetDispenserL2(configs[1]["chainId"], providers[3], globals[3], configs[1]["contracts"], "ArbitrumTargetDispenserL2", log);
await checkArbitrumTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "ArbitrumTargetDispenserL2", log);
chainNumber++;

// Optimism
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
// initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];

Check failure on line 846 in scripts/audit_chains/audit_contracts_setup.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 0
// log = initLog + ", contract: " + "OptimismTargetDispenserL2";

Check failure on line 847 in scripts/audit_chains/audit_contracts_setup.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 0
// await checkOptimismTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "OptimismTargetDispenserL2", log);

Check failure on line 848 in scripts/audit_chains/audit_contracts_setup.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 0
chainNumber++;

// Base
console.log("\n######## Verifying setup on CHAIN ID", configs[3]["chainId"]);
initLog = "ChainId: " + configs[3]["chainId"] + ", network: " + configs[3]["name"];
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "BaseTargetDispenserL2";
await checkBaseTargetDispenserL2(configs[3]["chainId"], providers[5], globals[5], configs[3]["contracts"], "OptimismTargetDispenserL2", log);
await checkBaseTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "OptimismTargetDispenserL2", log);
chainNumber++;

// Celo
console.log("\n######## Verifying setup on CHAIN ID", configs[5]["chainId"]);
initLog = "ChainId: " + configs[5]["chainId"] + ", network: " + configs[5]["name"];
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "CeloTargetDispenserL2";
await checkCeloTargetDispenserL2(configs[5]["chainId"], providers[6], globals[6], configs[5]["contracts"], "WormholeTargetDispenserL2", log);
await checkCeloTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "WormholeTargetDispenserL2", log);
chainNumber++;

// Optimism
console.log("\n######## Verifying setup on CHAIN ID", configs[9]["chainId"]);
initLog = "ChainId: " + configs[9]["chainId"] + ", network: " + configs[9]["name"];
// Mode
console.log("\n######## Verifying setup on CHAIN ID", configs[chainNumber]["chainId"]);
initLog = "ChainId: " + configs[chainNumber]["chainId"] + ", network: " + configs[chainNumber]["name"];
log = initLog + ", contract: " + "OptimismTargetDispenserL2";
await checkOptimismTargetDispenserL2(configs[9]["chainId"], providers[4], globals[4], configs[9]["contracts"], "OptimismTargetDispenserL2", log);
await checkModeTargetDispenserL2(configs[chainNumber]["chainId"], providers[chainNumber], globals[chainNumber], configs[chainNumber]["contracts"], "OptimismTargetDispenserL2", log);
// ################################# /VERIFY CONTRACTS SETUP #################################
}

Expand Down

0 comments on commit 81a5927

Please sign in to comment.