Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions contracts/MerkleLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library MerkleLib {
bytes32 root,
HubPoolInterface.PoolRebalanceLeaf memory rebalance,
bytes32[] memory proof
) public pure returns (bool) {
) internal pure returns (bool) {
return MerkleProof.verify(proof, root, keccak256(abi.encode(rebalance)));
}

Expand All @@ -33,7 +33,7 @@ library MerkleLib {
bytes32 root,
SpokePoolInterface.RelayerRefundLeaf memory refund,
bytes32[] memory proof
) public pure returns (bool) {
) internal pure returns (bool) {
return MerkleProof.verify(proof, root, keccak256(abi.encode(refund)));
}

Expand All @@ -47,7 +47,7 @@ library MerkleLib {
bytes32 root,
SpokePoolInterface.RelayData memory slowRelayFulfillment,
bytes32[] memory proof
) public pure returns (bool) {
) internal pure returns (bool) {
return MerkleProof.verify(proof, root, keccak256(abi.encode(slowRelayFulfillment)));
}

Expand All @@ -60,7 +60,7 @@ library MerkleLib {
* @param index the index to check in the bitmap.
* @return bool indicating if the index within the claimedBitMap has been marked as claimed.
*/
function isClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) public view returns (bool) {
function isClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) internal view returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
Expand All @@ -73,7 +73,7 @@ library MerkleLib {
* @param claimedBitMap a simple uint256 mapping in storage used as a bitmap.
* @param index the index to mark in the bitmap.
*/
function setClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) public {
function setClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) internal {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
Expand All @@ -85,7 +85,7 @@ library MerkleLib {
* @param index the index to check in the bitmap.
\* @return bool indicating if the index within the claimedBitMap has been marked as claimed.
*/
function isClaimed1D(uint256 claimedBitMap, uint256 index) public pure returns (bool) {
function isClaimed1D(uint256 claimedBitMap, uint256 index) internal pure returns (bool) {
uint256 mask = (1 << index);
return claimedBitMap & mask == mask;
}
Expand All @@ -95,7 +95,7 @@ library MerkleLib {
* @param claimedBitMap a simple uint256 mapping in storage used as a bitmap.
* @param index the index to mark in the bitmap.
*/
function setClaimed1D(uint256 claimedBitMap, uint256 index) public pure returns (uint256) {
function setClaimed1D(uint256 claimedBitMap, uint256 index) internal pure returns (uint256) {
require(index <= 255, "Index out of bounds");
return claimedBitMap | (1 << index % 256);
}
Expand Down
9 changes: 2 additions & 7 deletions contracts/Optimism_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@ contract Optimism_SpokePool is CrossDomainEnabled, SpokePoolInterface, SpokePool
// "l1Gas" parameter used in call to bridge tokens from this contract back to L1 via `IL2ERC20Bridge`.
uint32 public l1Gas = 5_000_000;

address public l1EthWrapper;

address public l2Eth;
address public l2Eth = address(Lib_PredeployAddresses.OVM_ETH);

event OptimismTokensBridged(address indexed l2Token, address target, uint256 numberOfTokensBridged, uint256 l1Gas);
event SetL1Gas(uint32 indexed newL1Gas);

constructor(
address _l1EthWrapper,
address _l2Eth,
address _crossDomainAdmin,
address _hubPool,
address _wethAddress,
address timerAddress
)
CrossDomainEnabled(Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER)
SpokePool(_crossDomainAdmin, _hubPool, _wethAddress, timerAddress)
SpokePool(_crossDomainAdmin, _hubPool, 0x4200000000000000000000000000000000000006, timerAddress)
{}

/**************************************
Expand Down
27 changes: 27 additions & 0 deletions deploy/001_deploy_hubpool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { L1_ADDRESS_MAP } from "./consts";

const func = async function (hre: any) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const chainId = await getChainId();

const lpTokenFactory = await deploy("LpTokenFactory", { from: deployer, log: true, skipIfAlreadyDeployed: true });

await deploy("HubPool", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
lpTokenFactory.address,
L1_ADDRESS_MAP[chainId].finder,
L1_ADDRESS_MAP[chainId].weth,
"0x0000000000000000000000000000000000000000",
],
libraries: { MerkleLib: lpTokenFactory.address },
});
};
module.exports = func;
func.tags = ["hubpool"];
31 changes: 31 additions & 0 deletions deploy/002_deploy_optimism_adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Cross Domain Messengers grabbed from
// https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments

import { L1_ADDRESS_MAP } from "./consts";

const func = async function (hre: any) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy, get } = deployments;

const { deployer } = await getNamedAccounts();

const hubPoolAddress = (await get("HubPool")).address;

const chainId = await getChainId();

await deploy("Optimism_Adapter", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
L1_ADDRESS_MAP[chainId].weth,
hubPoolAddress,
L1_ADDRESS_MAP[chainId].optimismCrossDomainMessenger,
L1_ADDRESS_MAP[chainId].optimismStandardBridge,
],
});
};

module.exports = func;
func.dependencies = ["HubPool"];
func.tags = ["optimism-adapter"];
26 changes: 26 additions & 0 deletions deploy/003_deploy_optimism_spokepool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const func = async function (hre: any) {
const { deployments, getNamedAccounts, companionNetworks } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

// Grab L1 addresses:
const { deployments: l1Deployments } = companionNetworks.l1;
const adapter = await l1Deployments.get("Optimism_Adapter");
console.log(`Using l1 adapter @ ${adapter.address}`);
const hubPool = await l1Deployments.get("HubPool");
console.log(`Using l1 hub pool @ ${hubPool.address}`);

await deploy("Optimism_SpokePool", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
adapter.address, // Set adapter as cross domain admin
hubPool.address,
"0x0000000000000000000000000000000000000000",
],
});
};
module.exports = func;
func.tags = ["optimism-spokepool"];
17 changes: 17 additions & 0 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Source: // https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments
// Note that L2 optimism addresses are deterministic and constant, so they usually don't need an
// address map like this.
export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string } } = {
1: {
optimismCrossDomainMessenger: "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1",
weth: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
optimismStandardBridge: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
finder: "0x40f941E48A552bF496B154Af6bf55725f18D77c3",
},
42: {
optimismCrossDomainMessenger: "0x4361d0F75A0186C05f971c566dC6bEa5957483fD",
weth: "0xd0A1E359811322d97991E03f863a0C30C2cF029C",
optimismStandardBridge: "0x22F24361D548e5FaAfb36d1437839f080363982B",
finder: "0xeD0169a88d267063184b0853BaAAAe66c3c154B2",
},
};
1 change: 1 addition & 0 deletions deployments/kovan/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
Loading