Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat #145: started adding monitor config to exploit 1 of cross chain #146

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 50 additions & 19 deletions CI/tests/Bridge.exploit1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const chalk = require('chalk');
const {
extractSolcVersion,
compileWithVersion,
deployContract
deployContract,
getContractABI,
} = require('@lib/web3/deploy');
const setupAvalancheEnv = require('@envs/avalanche-subnet');
const setupAnvilEnv = require('@envs/anvil');
Expand All @@ -15,6 +16,8 @@ const { sleep } = require('@lib/os/process');
const Monitor = require('@monitor/multi-chain-monitor');
const getLogger = require('@lib/logging/logger').getLogger;
const bridgeTestLogger = getLogger('bridgetest');
const { getActivities } = require('@lib/dcr/info');


async function sequence(contractsA, contractsB, web3A, web3B){

Expand Down Expand Up @@ -135,22 +138,59 @@ async function startUp() {
let envAvalanche = await setupAvalancheEnv();
bridgeTestLogger.debug("Finished running Avalanche");



bridgeTestLogger.debug("Web3 A: " + envAnvil.envInfo.rpcAddress);
bridgeTestLogger.debug("Web3 B: " + envAvalanche.envInfo.rpcAddress);

let contractsA = await deployBridge(envAnvil.web3, envAnvil.envInfo, 'A', 'ETH', 'EthRouterVulnerability1', 'EthVaultOracle', 'Oracle', 'eth_bridgeForwards', 'eth_bridgeForwardsERC20');
let contractsB = await deployBridge(envAvalanche.web3, envAvalanche.envInfo, 'B', 'AVAX', 'AvaxRouter', 'AvaxVaultOracle', 'Oracle', 'avax_bridgeForwards', 'avax_bridgeForwardsERC20');

let routerSourceA = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'EthRouterVulnerability1.sol'), 'utf8');
let routerABIA = await getContractABI(routerSourceA, 'EthRouterVulnerability1', 'EthRouterVulnerability1');
console.log(routerABIA);

let vaultSourceA = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'EthVaultOracle.sol'), 'utf8');
let vaultABIA = await getContractABI(vaultSourceA, 'EthVaultOracle', 'EthVaultOracle');

let routerSourceB = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'AvaxRouter.sol'), 'utf8');
let routerABIB = await getContractABI(routerSourceB, 'AvaxRouter', 'AvaxRouter');

let vaultSourceB = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'AvaxVaultOracle.sol'), 'utf8');
let vaultABIB = await getContractABI(vaultSourceB, 'AvaxVaultOracle', 'AvaxVaultOracle');

// Let's start the monitor here
let configs = {
"contracts": [{
web3: envAnvil.web3,
contractAddress: contractsA.router._address,
contractFileName: 'EthRouter',
contractName: 'EthRouter',
contractABI: contractABIA,
contractAddress: contractsA.vault._address,
contractFileName: 'EthVaultOracle',
contractName: 'EthVaultOracle',
contractABI: vaultABIA,
modelFunctionParams: null,
},
{
},
{
web3: envAnvil.web3,
contractAddress: contractsA.router._address,
contractFileName: 'EthRouter',
contractName: 'EthRouter',
contractABI: contractABIA,
contractFileName: 'EthRouterVulnerability1',
contractName: 'EthRouterVulnerability1',
contractABI: routerABIA,
modelFunctionParams: null,
},
{
web3: envAvalanche.web3,
contractAddress: contractsB.vault._address,
contractFileName: 'AvaxVaultOracle',
contractName: 'AvaxVaultOracle',
contractABI: vaultABIB,
modelFunctionParams: null,
},
{
web3: envAvalanche.web3,
contractAddress: contractsB.router._address,
contractFileName: 'AvaxRouter',
contractName: 'AvaxRouter',
contractABI: routerABIB,
modelFunctionParams: null,
}],
activities: await getActivities(1823976),
Expand All @@ -160,15 +200,6 @@ async function startUp() {
};
let monitor = new Monitor(configs);

bridgeTestLogger.debug("Web3 A: " + envAnvil.envInfo.rpcAddress);
bridgeTestLogger.debug("Web3 B: " + envAvalanche.envInfo.rpcAddress);

let contractsA = await deployBridge(envAnvil.web3, envAnvil.envInfo, 'A', 'ETH', 'EthRouterVulnerability1', 'EthVaultOracle', 'Oracle', 'eth_bridgeForwards', 'eth_bridgeForwardsERC20');
let contractsB = await deployBridge(envAvalanche.web3, envAvalanche.envInfo, 'B', 'AVAX', 'AvaxRouter', 'AvaxVaultOracle', 'Oracle', 'avax_bridgeForwards', 'avax_bridgeForwardsERC20');

let contractSourceA = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'EthRouter.sol'), 'utf8');

let contractSourceB = fs.readFileSync(path.join('contracts', 'src', 'cross-chain', 'AvaxRouter.sol'), 'utf8');

bridgeTestLogger.debug("Executing sequence");
let execution = await sequence(contractsA, contractsB, envAnvil.web3, envAvalanche.web3);
Expand Down
Loading