Skip to content

Feat/challenge path 4 with merkle root #81

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

Merged
merged 23 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3e9433c
feat: merkle tree refactoring
shotaronowhere May 30, 2022
ea383e2
feat: updated mock AMB
shotaronowhere May 30, 2022
d5c6a04
feat: refactoring single-message bridge
shotaronowhere May 30, 2022
edf750b
feat: updated arbitrum mock bridge
shotaronowhere May 30, 2022
ec86be4
chore: removing single message bridge artifacts
shotaronowhere May 30, 2022
9983389
feat: batched message fast bridge
shotaronowhere May 30, 2022
4575f3b
feat: batched fast bridge tests
shotaronowhere May 31, 2022
dadd82e
style: clear variable names
shotaronowhere May 31, 2022
dbec0dd
style: alligned statements
shotaronowhere May 31, 2022
e23c66d
fix: no inheritance
shotaronowhere Jun 1, 2022
f88ec08
fix(tests): updated events
shotaronowhere Jun 1, 2022
b4ef1d3
feat(bridge): removed inheritance
shotaronowhere Jun 6, 2022
1912924
feat(bridge): updated message encoding
shotaronowhere Jun 9, 2022
f5afbcf
Merge remote-tracking branch 'origin/master' into feat/challenge-path…
shotaronowhere Jun 10, 2022
351df7d
style(tests): fixed code smell
shotaronowhere Jun 10, 2022
e635cca
Merge remote-tracking branch 'origin/master' into feat/challenge-path…
jaybuidl Jun 21, 2022
bd9cd94
feat(bridge): addition + changes for polygon
hrishibhat Jul 3, 2022
047c657
fix: file imports correction
hrishibhat Jul 3, 2022
c6e9faa
fix: minor changes
hrishibhat Jul 4, 2022
de4de6d
refactor: moved the 3rd party code from the canonical bridges
jaybuidl Jul 16, 2022
54119fa
feat: guards against corner cases in FB receivers, refactors, typo fixes
jaybuidl Jul 16, 2022
81e6621
feat: improved FastBridgeReceiver events, expanded the integration te…
jaybuidl Jul 16, 2022
121ce42
refactor: separation of the app-agnostic gateway interfaces and the K…
jaybuidl Jul 27, 2022
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
32 changes: 16 additions & 16 deletions contracts/deploy/01-foreign-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ enum ForeignChains {
}
const paramsByChainId = {
1: {
claimDeposit: parseEther("0.1"),
challengeDuration: 86400, // 1 day
deposit: parseEther("0.1"),
epochPeriod: 86400, // 24 hours
challengePeriod: 14400, // 4 hours
homeChainId: 42161,
arbitrumInbox: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
},
4: {
claimDeposit: parseEther("0.1"),
challengeDuration: 120, // 2 min
deposit: parseEther("0.1"),
epochPeriod: 86400, // 24 hours
challengePeriod: 14400, // 4 hours
homeChainId: 421611,
arbitrumInbox: "0x578BAde599406A8fE3d24Fd7f7211c0911F5B29e",
},
31337: {
claimDeposit: parseEther("0.1"),
challengeDuration: 120, // 2 min
deposit: parseEther("0.1"),
epochPeriod: 86400, // 24 hours
challengePeriod: 14400, // 4 hours
homeChainId: 31337,
arbitrumInbox: "0x00",
},
Expand Down Expand Up @@ -59,9 +62,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
nonce = await homeChainProvider.getTransactionCount(deployer);
nonce += 1; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
}
const { claimDeposit, challengeDuration, homeChainId, arbitrumInbox } = paramsByChainId[chainId];
const challengeDeposit = claimDeposit;
const bridgeAlpha = 5000;
const { deposit, epochPeriod, challengePeriod, homeChainId, arbitrumInbox } = paramsByChainId[chainId];
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);

const homeGatewayAddress = getContractAddress(deployer, nonce);
Expand All @@ -71,27 +72,26 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
const fastBridgeSenderAddress = getContractAddress(deployer, nonce);
console.log("calculated future FastSender for nonce %d: %s", nonce, fastBridgeSenderAddress);

nonce += 5;
nonce += 4;

const inboxAddress = chainId === ForeignChains.HARDHAT ? getContractAddress(deployer, nonce) : arbitrumInbox;
console.log("calculated future inboxAddress for nonce %d: %s", nonce, inboxAddress);

const fastBridgeReceiver = await deploy("FastBridgeReceiverOnEthereum", {
from: deployer,
args: [
deployer,
deposit,
epochPeriod,
challengePeriod,
fastBridgeSenderAddress,
inboxAddress,
claimDeposit,
challengeDeposit,
challengeDuration,
bridgeAlpha,
inboxAddress
],
log: true,
});

const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
from: deployer,
contract: "ForeignGateway",
args: [
deployer,
fastBridgeReceiver.address,
Expand Down
78 changes: 27 additions & 51 deletions contracts/deploy/02-home-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
import { ethers } from "hardhat";

const HOME_CHAIN_IDS = [42161, 421611, 31337]; // ArbOne, ArbRinkeby, Hardhat
const epochPeriod = 86400; // 24 hours

// TODO: use deterministic deployments

Expand All @@ -22,7 +23,8 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const fastBridgeSender = await deploy("FastBridgeSenderToEthereumMock", {
from: deployer,
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero, arbSysMock.address],
contract: "FastBridgeSenderMock",
args: [epochPeriod, fastBridgeReceiver.address, arbSysMock.address],
log: true,
}); // nonce+0

Expand All @@ -32,44 +34,29 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const homeGateway = await deploy("HomeGatewayToEthereum", {
from: deployer,
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
contract: "HomeGateway",
args: [deployer, klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
gasLimit: 4000000,
log: true,
}); // nonce+1

const fastSender = await hre.ethers
.getContractAt("FastBridgeSenderToEthereumMock", fastBridgeSender.address)
.then((contract) => contract.fastBridgeSender());

if (fastSender === ethers.constants.AddressZero) {
await execute(
"FastBridgeSenderToEthereumMock",
{
from: deployer,
log: true,
},
"changeFastSender",
homeGateway.address
);

const outbox = await deploy("OutboxMock", {
from: deployer,
args: [fastBridgeSender.address],
log: true,
});

const bridge = await deploy("BridgeMock", {
from: deployer,
args: [outbox.address],
log: true,
});

await deploy("InboxMock", {
from: deployer,
args: [bridge.address],
log: true,
});
}
const outbox = await deploy("OutboxMock", {
from: deployer,
args: [fastBridgeSender.address],
log: true,
});

const bridge = await deploy("BridgeMock", {
from: deployer,
args: [outbox.address],
log: true,
});

await deploy("InboxMock", {
from: deployer,
args: [bridge.address],
log: true,
});
};

// ----------------------------------------------------------------------------------------------
Expand All @@ -78,7 +65,8 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)

const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
from: deployer,
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero],
contract: "FastBridgeSender",
args: [epochPeriod, fastBridgeReceiver.address],
log: true,
}); // nonce+0

Expand All @@ -87,22 +75,10 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
const foreignChainId = Number(await hre.companionNetworks.foreign.getChainId());
const homeGateway = await deploy("HomeGatewayToEthereum", {
from: deployer,
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
contract: "HomeGateway",
args: [deployer, klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
log: true,
}); // nonce+1

const fastSender = await hre.ethers
.getContractAt("FastBridgeSenderToEthereum", fastBridgeSender.address)
.then((contract) => contract.fastBridgeSender());

if (fastSender === ethers.constants.AddressZero) {
await execute(
"FastBridgeSenderToEthereum",
{ from: deployer, log: true },
"changeFastSender",
homeGateway.address
);
}
}); // nonce+
};

// ----------------------------------------------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ const config: HardhatUserConfig = {
relayer: {
default: 1,
},
bridger: {
default: 2,
},
challenger: {
default: 3,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
enabled: process.env.REPORT_GAS !== undefined ? process.env.REPORT_GAS === "true" : false,
currency: "USD",
},
verify: {
Expand All @@ -166,7 +172,7 @@ const config: HardhatUserConfig = {
},
},
docgen: {
path: './docs',
path: "./docs",
clear: true,
runOnCompile: false,
},
Expand Down
Loading