Skip to content

Commit 50b6b56

Browse files
authored
feat: Redstone deployment (#570)
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.
1 parent 01728d3 commit 50b6b56

24 files changed

+4447
-8
lines changed

contracts/Redstone_SpokePool.sol

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol";
4+
5+
import "./Ovm_SpokePool.sol";
6+
import "./external/interfaces/CCTPInterfaces.sol";
7+
8+
/**
9+
* @notice Redstone Spoke pool.
10+
* @custom:security-contact bugs@across.to
11+
*/
12+
contract Redstone_SpokePool is Ovm_SpokePool {
13+
/// @custom:oz-upgrades-unsafe-allow constructor
14+
constructor(
15+
address _wrappedNativeTokenAddress,
16+
uint32 _depositQuoteTimeBuffer,
17+
uint32 _fillDeadlineBuffer,
18+
IERC20 _l2Usdc,
19+
ITokenMessenger _cctpTokenMessenger
20+
)
21+
Ovm_SpokePool(
22+
_wrappedNativeTokenAddress,
23+
_depositQuoteTimeBuffer,
24+
_fillDeadlineBuffer,
25+
_l2Usdc,
26+
_cctpTokenMessenger
27+
)
28+
{} // solhint-disable-line no-empty-blocks
29+
30+
/**
31+
* @notice Construct the OVM Redstone SpokePool.
32+
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
33+
* relay hash collisions.
34+
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
35+
* @param _hubPool Hub pool address to set. Can be changed by admin.
36+
*/
37+
function initialize(
38+
uint32 _initialDepositId,
39+
address _crossDomainAdmin,
40+
address _hubPool
41+
) public initializer {
42+
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
43+
}
44+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import "./interfaces/AdapterInterface.sol";
5+
import "../external/interfaces/WETH9Interface.sol";
6+
7+
// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need
8+
// this contract's state variables to be `immutable` because of the delegateCall call.
9+
import "./CrossDomainEnabled.sol";
10+
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";
11+
12+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
13+
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
14+
15+
import "../libraries/CircleCCTPAdapter.sol";
16+
import "../external/interfaces/CCTPInterfaces.sol";
17+
18+
/**
19+
* @notice Contract containing logic to send messages from L1 to Redstone. This is a clone of the Base/Mode adapter
20+
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
21+
* called via delegatecall, which will execute this contract's logic within the context of the originating contract.
22+
* For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
23+
* that call this contract's logic guard against reentrancy.
24+
* @custom:security-contact bugs@across.to
25+
*/
26+
27+
// solhint-disable-next-line contract-name-camelcase
28+
contract Redstone_Adapter is CrossDomainEnabled, AdapterInterface, CircleCCTPAdapter {
29+
using SafeERC20 for IERC20;
30+
uint32 public constant L2_GAS_LIMIT = 200_000;
31+
32+
WETH9Interface public immutable L1_WETH;
33+
34+
IL1StandardBridge public immutable L1_STANDARD_BRIDGE;
35+
36+
/**
37+
* @notice Constructs new Adapter.
38+
* @param _l1Weth WETH address on L1.
39+
* @param _crossDomainMessenger XDomainMessenger Redstone system contract.
40+
* @param _l1StandardBridge Standard bridge contract.
41+
* @param _l1Usdc USDC address on L1.
42+
*/
43+
constructor(
44+
WETH9Interface _l1Weth,
45+
address _crossDomainMessenger,
46+
IL1StandardBridge _l1StandardBridge,
47+
IERC20 _l1Usdc
48+
)
49+
CrossDomainEnabled(_crossDomainMessenger)
50+
CircleCCTPAdapter(
51+
_l1Usdc,
52+
// Hardcode cctp messenger to 0x0 to disable CCTP bridging.
53+
ITokenMessenger(address(0)),
54+
CircleDomainIds.UNINTIALIZED
55+
)
56+
{
57+
L1_WETH = _l1Weth;
58+
L1_STANDARD_BRIDGE = _l1StandardBridge;
59+
}
60+
61+
/**
62+
* @notice Send cross-chain message to target on Redstone.
63+
* @param target Contract on Redstone that will receive message.
64+
* @param message Data to send to target.
65+
*/
66+
function relayMessage(address target, bytes calldata message) external payable override {
67+
sendCrossDomainMessage(target, L2_GAS_LIMIT, message);
68+
emit MessageRelayed(target, message);
69+
}
70+
71+
/**
72+
* @notice Bridge tokens to Redstone.
73+
* @param l1Token L1 token to deposit.
74+
* @param l2Token L2 token to receive.
75+
* @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
76+
* @param to Bridge recipient.
77+
*/
78+
function relayTokens(
79+
address l1Token,
80+
address l2Token,
81+
uint256 amount,
82+
address to
83+
) external payable override {
84+
// If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge.
85+
if (l1Token == address(L1_WETH)) {
86+
L1_WETH.withdraw(amount);
87+
L1_STANDARD_BRIDGE.depositETHTo{ value: amount }(to, L2_GAS_LIMIT, "");
88+
}
89+
// Check if this token is USDC, which requires a custom bridge via CCTP.
90+
else if (_isCCTPEnabled() && l1Token == address(usdcToken)) {
91+
_transferUsdc(to, amount);
92+
} else {
93+
IL1StandardBridge _l1StandardBridge = L1_STANDARD_BRIDGE;
94+
95+
IERC20(l1Token).safeIncreaseAllowance(address(_l1StandardBridge), amount);
96+
_l1StandardBridge.depositERC20To(l1Token, l2Token, to, amount, L2_GAS_LIMIT, "");
97+
}
98+
emit TokensRelayed(l1Token, l2Token, amount, to);
99+
}
100+
}

contracts/handlers/MulticallHandler.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
1111
* @title Across Multicall contract that allows a user to specify a series of calls that should be made by the handler
1212
* via the message field in the deposit.
1313
* @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.
14-
* @custom:security-contact bugs@across.to
1514
*/
1615
contract MulticallHandler is AcrossMessageHandler, ReentrancyGuard {
1716
using SafeERC20 for IERC20;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ZERO_ADDRESS } from "@uma/common";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
4+
import { L1_ADDRESS_MAP, WETH } from "./consts";
5+
6+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7+
const { deployments, getNamedAccounts, getChainId, network } = hre;
8+
const { deploy } = deployments;
9+
10+
const { deployer } = await getNamedAccounts();
11+
12+
const chainId = parseInt(await getChainId());
13+
14+
await deploy("Redstone_Adapter", {
15+
from: deployer,
16+
log: true,
17+
skipIfAlreadyDeployed: true,
18+
args: [
19+
WETH[chainId],
20+
L1_ADDRESS_MAP[chainId].redstoneCrossDomainMessenger,
21+
L1_ADDRESS_MAP[chainId].redstoneStandardBridge,
22+
ZERO_ADDRESS,
23+
],
24+
});
25+
};
26+
27+
module.exports = func;
28+
func.tags = ["RedstoneAdapter", "mainnet"];
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { DeployFunction } from "hardhat-deploy/types";
2+
import { HardhatRuntimeEnvironment } from "hardhat/types";
3+
import { ZERO_ADDRESS } from "@uma/common";
4+
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
5+
import { CHAIN_IDs } from "../utils";
6+
import { WETH } from "./consts";
7+
8+
const { REDSTONE } = CHAIN_IDs;
9+
10+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
11+
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
12+
13+
const initArgs = [
14+
1,
15+
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
16+
hubPool.address,
17+
hubPool.address,
18+
];
19+
// Construct this spokepool with a:
20+
// * A WETH address of the WETH address
21+
// * A depositQuoteTimeBuffer of 1 hour
22+
// * A fillDeadlineBuffer of 6 hours
23+
// * Native USDC address on L2
24+
// * CCTP token messenger address on L2
25+
const constructorArgs = [
26+
WETH[spokeChainId],
27+
3600,
28+
21600,
29+
ZERO_ADDRESS,
30+
// L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
31+
// For now, we are not using the CCTP bridge and can disable by setting
32+
// the cctpTokenMessenger to the zero address.
33+
ZERO_ADDRESS,
34+
];
35+
await deployNewProxy("Redstone_SpokePool", constructorArgs, initArgs, spokeChainId === REDSTONE);
36+
};
37+
module.exports = func;
38+
func.tags = ["spokepool", "redstone"];

deploy/consts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils";
2+
3+
export const WETH = TOKEN_SYMBOLS_MAP.WETH.addresses;
4+
15
export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string } } = {
26
1: {
37
optimismCrossDomainMessenger: "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1", // Source: https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments
@@ -37,6 +41,8 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
3741
liskStandardBridge: "0x2658723Bf70c7667De6B25F99fcce13A16D25d08",
3842
blastYieldManager: "0xa230285d5683C74935aD14c446e137c8c8828438",
3943
blastDaiRetriever: "0x98Dd57048d7d5337e92D9102743528ea4Fea64aB",
44+
redstoneCrossDomainMessenger: "0x592C1299e0F8331D81A28C0FC7352Da24eDB444a",
45+
redstoneStandardBridge: "0xc473ca7E02af24c129c2eEf51F2aDf0411c1Df69",
4046
},
4147
4: {
4248
weth: "0xc778417E063141139Fce010982780140Aa0cD5Ab",

deployments/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
| Blast_SpokePool | [0x2D509190Ed0172ba588407D4c2df918F955Cc6E1](https://blastscan.io/address/0x2D509190Ed0172ba588407D4c2df918F955Cc6E1) |
8989
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://blastscan.io/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |
9090

91+
## Redstone mainnet (690)
92+
93+
| Contract Name | Address |
94+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
95+
| Redstone_SpokePool | [0x28077B47Cd03326De7838926A63699849DD4fa87](https://explorer.redstone.xyz/address/0x28077B47Cd03326De7838926A63699849DD4fa87) |
96+
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://explorer.redstone.xyz/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |
97+
9198
## Scroll mainnet (534352)
9299

93100
| Contract Name | Address |

deployments/deployments.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"Blast_Adapter": { "address": "0xF2bEf5E905AAE0295003ab14872F811E914EdD81", "blockNumber": 20221494 },
2525
"Scroll_Adapter": { "address": "0xb6129Ab69aEA75e6884c2D6ecf25293C343C519F", "blockNumber": 20318360 },
2626
"Blast_DaiRetriever": { "address": "0x98Dd57048d7d5337e92D9102743528ea4Fea64aB", "blockNumber": 20378862 },
27-
"Blast_RescueAdapter": { "address": "0xE5Dea263511F5caC27b15cBd58Ff103F4Ce90957", "blockNumber": 20378872 }
27+
"Blast_RescueAdapter": { "address": "0xE5Dea263511F5caC27b15cBd58Ff103F4Ce90957", "blockNumber": 20378872 },
28+
"Redstone_Adapter": { "address": "0x188F8C95B7cfB7993B53a4F643efa687916f73fA", "blockNumber": 20432774 }
2829
},
2930
"4": {
3031
"Arbitrum_Adapter": { "address": "0x18F4D98C7CeA6Ab934F2976c2a98009A529d8F49", "blockNumber": 10367195 },
@@ -95,6 +96,11 @@
9596
"MulticallHandler": { "address": "0x863859ef502F0Ee9676626ED5B418037252eFeb2", "blockNumber": 36906393 }
9697
},
9798
"420": { "SpokePool": { "address": "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4", "blockNumber": 17025501 } },
99+
"690": {
100+
"SpokePool": { "address": "0x28077B47Cd03326De7838926A63699849DD4fa87", "blockNumber": 5158526 },
101+
"SpokePoolVerifier": { "address": "0xB4A8d45647445EA9FC3E1058096142390683dBC2", "blockNumber": 5161326 },
102+
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 5159031 }
103+
},
98104
"919": {
99105
"SpokePool": { "address": "0xbd886FC0725Cc459b55BbFEb3E4278610331f83b", "blockNumber": 13999465 },
100106
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 15826581 }

0 commit comments

Comments
 (0)