Skip to content

Commit 5e18e16

Browse files
committed
feat: add Arbitrum GRT bridge
Deployment commands in the CLI are also updated to include an L2 deployment. Configuration and address book entries for Arbitrum are added as well.
1 parent 5272f4a commit 5e18e16

38 files changed

+3749
-292
lines changed

.solcover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const skipFiles = ['bancor', 'ens', 'erc1056']
1+
const skipFiles = ['bancor', 'ens', 'erc1056', 'arbitrum', 'tests/arbitrum']
22

33
module.exports = {
44
providerOptions: {

arbitrum-graph.config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
general:
2+
arbitrator: &arbitrator "0x113DC95e796836b8F0Fa71eE7fB42f221740c3B0" # Arbitration Council
3+
governor: &governor "0x3e43EF77fAAd296F65eF172E8eF06F8231c9DeAd" # Graph Council
4+
authority: &authority "0x79fd74da4c906509862c8fe93e87a9602e370bc4" # Authority that signs payment vouchers
5+
6+
contracts:
7+
Controller:
8+
calls:
9+
- fn: "setContractProxy"
10+
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
11+
contractAddress: "${{L2GraphToken.address}}"
12+
- fn: "setContractProxy"
13+
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
14+
contractAddress: "${{L2GraphTokenGateway.address}}"
15+
L2GraphToken:
16+
proxy: true
17+
init:
18+
owner: *governor
19+
initialSupply: "0"
20+
L2GraphTokenGateway:
21+
proxy: true
22+
init:
23+
controller: "${{Controller.address}}"

cli/commands/migrate.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,35 @@ let allContracts = [
3232
'RewardsManager',
3333
'DisputeManager',
3434
'AllocationExchange',
35+
'L1GraphTokenGateway',
36+
'BridgeEscrow',
3537
]
3638

39+
// This is all we'll want to deploy to L2 eventually:
40+
// const l2Contracts = [
41+
// 'GraphProxyAdmin',
42+
// 'BancorFormula',
43+
// 'Controller',
44+
// 'EpochManager',
45+
// 'L2GraphToken',
46+
// 'GraphCurationToken',
47+
// 'ServiceRegistry',
48+
// 'Curation',
49+
// 'SubgraphNFTDescriptor',
50+
// 'SubgraphNFT',
51+
// 'GNS',
52+
// 'Staking',
53+
// 'RewardsManager',
54+
// 'DisputeManager',
55+
// 'AllocationExchange',
56+
// 'L2GraphTokenGateway',
57+
// ]
58+
//
59+
// But for now we'll only include a subset:
60+
const l2Contracts = ['GraphProxyAdmin', 'Controller', 'L2GraphToken', 'L2GraphTokenGateway']
61+
62+
const l2ChainIds = [42161, 421611]
63+
3764
export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
3865
const graphConfigPath = cliArgs.graphConfig
3966
const force = cliArgs.force
@@ -42,6 +69,8 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
4269

4370
if (chainId == 1337) {
4471
allContracts = ['EthereumDIDRegistry', ...allContracts]
72+
} else if (l2ChainIds.includes(chainId)) {
73+
allContracts = l2Contracts
4574
}
4675

4776
logger.info(`>>> Migrating contracts <<<\n`)

config/graph.mainnet.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ contracts:
2727
- fn: "setContractProxy"
2828
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
2929
contractAddress: "${{GraphToken.address}}"
30+
- fn: "setContractProxy"
31+
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
32+
contractAddress: "${{L1GraphTokenGateway.address}}"
3033
ServiceRegistry:
3134
proxy: true
3235
init:
@@ -112,3 +115,11 @@ contracts:
112115
authority: *authority
113116
calls:
114117
- fn: "approveAll"
118+
L1GraphTokenGateway:
119+
proxy: true
120+
init:
121+
controller: "${{Controller.address}}"
122+
BridgeEscrow:
123+
proxy: true
124+
init:
125+
controller: "${{Controller.address}}"

contracts/arbitrum/IArbToken.sol

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/*
4+
* Copyright 2020, Offchain Labs, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Originally copied from:
19+
* https://github.com/OffchainLabs/arbitrum/tree/e3a6307ad8a2dc2cad35728a2a9908cfd8dd8ef9/packages/arb-bridge-peripherals
20+
*
21+
* MODIFIED from Offchain Labs' implementation:
22+
* - Changed solidity version to 0.7.6 ([email protected])
23+
*
24+
*/
25+
26+
/**
27+
* @title Minimum expected interface for L2 token that interacts with the L2 token bridge (this is the interface necessary
28+
* for a custom token that interacts with the bridge, see TestArbCustomToken.sol for an example implementation).
29+
*/
30+
pragma solidity ^0.7.6;
31+
32+
interface IArbToken {
33+
/**
34+
* @notice should increase token supply by amount, and should (probably) only be callable by the L1 bridge.
35+
*/
36+
function bridgeMint(address account, uint256 amount) external;
37+
38+
/**
39+
* @notice should decrease token supply by amount, and should (probably) only be callable by the L1 bridge.
40+
*/
41+
function bridgeBurn(address account, uint256 amount) external;
42+
43+
/**
44+
* @return address of layer 1 token
45+
*/
46+
function l1Address() external view returns (address);
47+
}

contracts/arbitrum/IBridge.sol

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/*
4+
* Copyright 2021, Offchain Labs, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Originally copied from:
19+
* https://github.com/OffchainLabs/arbitrum/tree/e3a6307ad8a2dc2cad35728a2a9908cfd8dd8ef9/packages/arb-bridge-eth
20+
*
21+
* MODIFIED from Offchain Labs' implementation:
22+
* - Changed solidity version to 0.7.6 ([email protected])
23+
*
24+
*/
25+
26+
pragma solidity ^0.7.6;
27+
28+
interface IBridge {
29+
event MessageDelivered(
30+
uint256 indexed messageIndex,
31+
bytes32 indexed beforeInboxAcc,
32+
address inbox,
33+
uint8 kind,
34+
address sender,
35+
bytes32 messageDataHash
36+
);
37+
38+
event BridgeCallTriggered(
39+
address indexed outbox,
40+
address indexed destAddr,
41+
uint256 amount,
42+
bytes data
43+
);
44+
45+
event InboxToggle(address indexed inbox, bool enabled);
46+
47+
event OutboxToggle(address indexed outbox, bool enabled);
48+
49+
function deliverMessageToInbox(
50+
uint8 kind,
51+
address sender,
52+
bytes32 messageDataHash
53+
) external payable returns (uint256);
54+
55+
function executeCall(
56+
address destAddr,
57+
uint256 amount,
58+
bytes calldata data
59+
) external returns (bool success, bytes memory returnData);
60+
61+
// These are only callable by the admin
62+
function setInbox(address inbox, bool enabled) external;
63+
64+
function setOutbox(address inbox, bool enabled) external;
65+
66+
// View functions
67+
68+
function activeOutbox() external view returns (address);
69+
70+
function allowedInboxes(address inbox) external view returns (bool);
71+
72+
function allowedOutboxes(address outbox) external view returns (bool);
73+
74+
function inboxAccs(uint256 index) external view returns (bytes32);
75+
76+
function messageCount() external view returns (uint256);
77+
}

contracts/arbitrum/IInbox.sol

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/*
4+
* Copyright 2021, Offchain Labs, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Originally copied from:
19+
* https://github.com/OffchainLabs/arbitrum/tree/e3a6307ad8a2dc2cad35728a2a9908cfd8dd8ef9/packages/arb-bridge-eth
20+
*
21+
* MODIFIED from Offchain Labs' implementation:
22+
* - Changed solidity version to 0.7.6 ([email protected])
23+
*
24+
*/
25+
26+
pragma solidity ^0.7.6;
27+
28+
import "./IBridge.sol";
29+
import "./IMessageProvider.sol";
30+
31+
interface IInbox is IMessageProvider {
32+
function sendL2Message(bytes calldata messageData) external returns (uint256);
33+
34+
function sendUnsignedTransaction(
35+
uint256 maxGas,
36+
uint256 gasPriceBid,
37+
uint256 nonce,
38+
address destAddr,
39+
uint256 amount,
40+
bytes calldata data
41+
) external returns (uint256);
42+
43+
function sendContractTransaction(
44+
uint256 maxGas,
45+
uint256 gasPriceBid,
46+
address destAddr,
47+
uint256 amount,
48+
bytes calldata data
49+
) external returns (uint256);
50+
51+
function sendL1FundedUnsignedTransaction(
52+
uint256 maxGas,
53+
uint256 gasPriceBid,
54+
uint256 nonce,
55+
address destAddr,
56+
bytes calldata data
57+
) external payable returns (uint256);
58+
59+
function sendL1FundedContractTransaction(
60+
uint256 maxGas,
61+
uint256 gasPriceBid,
62+
address destAddr,
63+
bytes calldata data
64+
) external payable returns (uint256);
65+
66+
function createRetryableTicket(
67+
address destAddr,
68+
uint256 arbTxCallValue,
69+
uint256 maxSubmissionCost,
70+
address submissionRefundAddress,
71+
address valueRefundAddress,
72+
uint256 maxGas,
73+
uint256 gasPriceBid,
74+
bytes calldata data
75+
) external payable returns (uint256);
76+
77+
function depositEth(uint256 maxSubmissionCost) external payable returns (uint256);
78+
79+
function bridge() external view returns (IBridge);
80+
81+
function pauseCreateRetryables() external;
82+
83+
function unpauseCreateRetryables() external;
84+
85+
function startRewriteAddress() external;
86+
87+
function stopRewriteAddress() external;
88+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/*
4+
* Copyright 2021, Offchain Labs, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Originally copied from:
19+
* https://github.com/OffchainLabs/arbitrum/tree/e3a6307ad8a2dc2cad35728a2a9908cfd8dd8ef9/packages/arb-bridge-eth
20+
*
21+
* MODIFIED from Offchain Labs' implementation:
22+
* - Changed solidity version to 0.7.6 ([email protected])
23+
*
24+
*/
25+
26+
pragma solidity ^0.7.6;
27+
28+
interface IMessageProvider {
29+
event InboxMessageDelivered(uint256 indexed messageNum, bytes data);
30+
31+
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum);
32+
}

0 commit comments

Comments
 (0)