-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the deployment details for Redstone. Some notes: - A comment recently added to the MulticallHandler contract had to be backed out because it affects the resulting bytecode and subsequently the deployed address. - The current version of the SpokePoolVerifier is not audited. Both the current and previous versions have been deployed, but the previous version is used, such that its deployment addresses matches all other currently-used SpokePoolVerifier addresses.
- Loading branch information
Showing
24 changed files
with
4,447 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol"; | ||
|
||
import "./Ovm_SpokePool.sol"; | ||
import "./external/interfaces/CCTPInterfaces.sol"; | ||
|
||
/** | ||
* @notice Redstone Spoke pool. | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract Redstone_SpokePool is Ovm_SpokePool { | ||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor( | ||
address _wrappedNativeTokenAddress, | ||
uint32 _depositQuoteTimeBuffer, | ||
uint32 _fillDeadlineBuffer, | ||
IERC20 _l2Usdc, | ||
ITokenMessenger _cctpTokenMessenger | ||
) | ||
Ovm_SpokePool( | ||
_wrappedNativeTokenAddress, | ||
_depositQuoteTimeBuffer, | ||
_fillDeadlineBuffer, | ||
_l2Usdc, | ||
_cctpTokenMessenger | ||
) | ||
{} // solhint-disable-line no-empty-blocks | ||
|
||
/** | ||
* @notice Construct the OVM Redstone SpokePool. | ||
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate | ||
* relay hash collisions. | ||
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin. | ||
* @param _hubPool Hub pool address to set. Can be changed by admin. | ||
*/ | ||
function initialize( | ||
uint32 _initialDepositId, | ||
address _crossDomainAdmin, | ||
address _hubPool | ||
) public initializer { | ||
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import "./interfaces/AdapterInterface.sol"; | ||
import "../external/interfaces/WETH9Interface.sol"; | ||
|
||
// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need | ||
// this contract's state variables to be `immutable` because of the delegateCall call. | ||
import "./CrossDomainEnabled.sol"; | ||
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol"; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
import "../libraries/CircleCCTPAdapter.sol"; | ||
import "../external/interfaces/CCTPInterfaces.sol"; | ||
|
||
/** | ||
* @notice Contract containing logic to send messages from L1 to Redstone. This is a clone of the Base/Mode adapter | ||
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be | ||
* called via delegatecall, which will execute this contract's logic within the context of the originating contract. | ||
* For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods | ||
* that call this contract's logic guard against reentrancy. | ||
* @custom:security-contact [email protected] | ||
*/ | ||
|
||
// solhint-disable-next-line contract-name-camelcase | ||
contract Redstone_Adapter is CrossDomainEnabled, AdapterInterface, CircleCCTPAdapter { | ||
using SafeERC20 for IERC20; | ||
uint32 public constant L2_GAS_LIMIT = 200_000; | ||
|
||
WETH9Interface public immutable L1_WETH; | ||
|
||
IL1StandardBridge public immutable L1_STANDARD_BRIDGE; | ||
|
||
/** | ||
* @notice Constructs new Adapter. | ||
* @param _l1Weth WETH address on L1. | ||
* @param _crossDomainMessenger XDomainMessenger Redstone system contract. | ||
* @param _l1StandardBridge Standard bridge contract. | ||
* @param _l1Usdc USDC address on L1. | ||
*/ | ||
constructor( | ||
WETH9Interface _l1Weth, | ||
address _crossDomainMessenger, | ||
IL1StandardBridge _l1StandardBridge, | ||
IERC20 _l1Usdc | ||
) | ||
CrossDomainEnabled(_crossDomainMessenger) | ||
CircleCCTPAdapter( | ||
_l1Usdc, | ||
// Hardcode cctp messenger to 0x0 to disable CCTP bridging. | ||
ITokenMessenger(address(0)), | ||
CircleDomainIds.UNINTIALIZED | ||
) | ||
{ | ||
L1_WETH = _l1Weth; | ||
L1_STANDARD_BRIDGE = _l1StandardBridge; | ||
} | ||
|
||
/** | ||
* @notice Send cross-chain message to target on Redstone. | ||
* @param target Contract on Redstone that will receive message. | ||
* @param message Data to send to target. | ||
*/ | ||
function relayMessage(address target, bytes calldata message) external payable override { | ||
sendCrossDomainMessage(target, L2_GAS_LIMIT, message); | ||
emit MessageRelayed(target, message); | ||
} | ||
|
||
/** | ||
* @notice Bridge tokens to Redstone. | ||
* @param l1Token L1 token to deposit. | ||
* @param l2Token L2 token to receive. | ||
* @param amount Amount of L1 tokens to deposit and L2 tokens to receive. | ||
* @param to Bridge recipient. | ||
*/ | ||
function relayTokens( | ||
address l1Token, | ||
address l2Token, | ||
uint256 amount, | ||
address to | ||
) external payable override { | ||
// If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge. | ||
if (l1Token == address(L1_WETH)) { | ||
L1_WETH.withdraw(amount); | ||
L1_STANDARD_BRIDGE.depositETHTo{ value: amount }(to, L2_GAS_LIMIT, ""); | ||
} | ||
// Check if this token is USDC, which requires a custom bridge via CCTP. | ||
else if (_isCCTPEnabled() && l1Token == address(usdcToken)) { | ||
_transferUsdc(to, amount); | ||
} else { | ||
IL1StandardBridge _l1StandardBridge = L1_STANDARD_BRIDGE; | ||
|
||
IERC20(l1Token).safeIncreaseAllowance(address(_l1StandardBridge), amount); | ||
_l1StandardBridge.depositERC20To(l1Token, l2Token, to, amount, L2_GAS_LIMIT, ""); | ||
} | ||
emit TokensRelayed(l1Token, l2Token, amount, to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; | |
* @title Across Multicall contract that allows a user to specify a series of calls that should be made by the handler | ||
* via the message field in the deposit. | ||
* @dev This contract makes the calls blindly. The contract will send any remaining tokens The caller should ensure that the tokens recieved by the handler are completely consumed. | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract MulticallHandler is AcrossMessageHandler, ReentrancyGuard { | ||
using SafeERC20 for IERC20; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ZERO_ADDRESS } from "@uma/common"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { L1_ADDRESS_MAP, WETH } from "./consts"; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, getChainId, network } = hre; | ||
const { deploy } = deployments; | ||
|
||
const { deployer } = await getNamedAccounts(); | ||
|
||
const chainId = parseInt(await getChainId()); | ||
|
||
await deploy("Redstone_Adapter", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: [ | ||
WETH[chainId], | ||
L1_ADDRESS_MAP[chainId].redstoneCrossDomainMessenger, | ||
L1_ADDRESS_MAP[chainId].redstoneStandardBridge, | ||
ZERO_ADDRESS, | ||
], | ||
}); | ||
}; | ||
|
||
module.exports = func; | ||
func.tags = ["RedstoneAdapter", "mainnet"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { ZERO_ADDRESS } from "@uma/common"; | ||
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre"; | ||
import { CHAIN_IDs } from "../utils"; | ||
import { WETH } from "./consts"; | ||
|
||
const { REDSTONE } = CHAIN_IDs; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre); | ||
|
||
const initArgs = [ | ||
1, | ||
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic. | ||
hubPool.address, | ||
hubPool.address, | ||
]; | ||
// Construct this spokepool with a: | ||
// * A WETH address of the WETH address | ||
// * A depositQuoteTimeBuffer of 1 hour | ||
// * A fillDeadlineBuffer of 6 hours | ||
// * Native USDC address on L2 | ||
// * CCTP token messenger address on L2 | ||
const constructorArgs = [ | ||
WETH[spokeChainId], | ||
3600, | ||
21600, | ||
ZERO_ADDRESS, | ||
// L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger, | ||
// For now, we are not using the CCTP bridge and can disable by setting | ||
// the cctpTokenMessenger to the zero address. | ||
ZERO_ADDRESS, | ||
]; | ||
await deployNewProxy("Redstone_SpokePool", constructorArgs, initArgs, spokeChainId === REDSTONE); | ||
}; | ||
module.exports = func; | ||
func.tags = ["spokepool", "redstone"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.