Skip to content

Commit 8374f92

Browse files
committed
Merge branch 'dev' into pcv/l2-stake-migration
2 parents 6dc8876 + 3f0f113 commit 8374f92

20 files changed

+345
-217
lines changed

addresses.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@
828828
"txHash": "0xca363c6bc841b43bd896b6d2098434679884d200a28013dedb48a2c95028ce40"
829829
}
830830
},
831-
"Curation": {
831+
"L2Curation": {
832832
"address": "0x22d78fb4bc72e191C765807f8891B5e1785C8014",
833833
"initArgs": [
834834
"0x0a8491544221dd212964fbb96487467291b2C97e",
@@ -862,7 +862,7 @@
862862
"runtimeCodeHash": "0x7216e736a8a8754e88688fbf5c0c7e9caf35c55ecc3a0c5a597b951c56cf7458",
863863
"txHash": "0x4334bd64938c1c5c604bde96467a8601875046569f738e6860851594c91681ff"
864864
},
865-
"GNS": {
865+
"L2GNS": {
866866
"address": "0xec9A7fb6CbC2E41926127929c2dcE6e9c5D33Bec",
867867
"initArgs": [
868868
"0x0a8491544221dd212964fbb96487467291b2C97e",
@@ -1047,7 +1047,7 @@
10471047
"txHash": "0x2d6043d89a5f5c4f3d0df0f50264ab7efebc898be0b5d358a00715ba9f657a89"
10481048
}
10491049
},
1050-
"Curation": {
1050+
"L2Curation": {
10511051
"address": "0x7080AAcC4ADF4b1E72615D6eb24CDdE40a04f6Ca",
10521052
"initArgs": [
10531053
"0x7f734E995010Aa8d28b912703093d532C37b6EAb",
@@ -1081,7 +1081,7 @@
10811081
"runtimeCodeHash": "0x7216e736a8a8754e88688fbf5c0c7e9caf35c55ecc3a0c5a597b951c56cf7458",
10821082
"txHash": "0xc11917ffedda6867648fa2cb62cca1df3c0ed485a0a0885284e93a2c5d33455c"
10831083
},
1084-
"GNS": {
1084+
"L2GNS": {
10851085
"address": "0x6bf9104e054537301cC23A1023Ca30A6Df79eB21",
10861086
"initArgs": [
10871087
"0x7f734E995010Aa8d28b912703093d532C37b6EAb",
@@ -1093,10 +1093,10 @@
10931093
"txHash": "0x3c2509730e06249d970818319bb507185d4fdea13d5600cef87928a718950c19",
10941094
"proxy": true,
10951095
"implementation": {
1096-
"address": "0x7eCb82A9Cf9B370d3fC2Ef66E38F38EDFAeaa125",
1097-
"creationCodeHash": "0xb0be24e926bb24420bb5a8d3f7bd0b70a545fdddbf8cb177a42478adf4435aae",
1098-
"runtimeCodeHash": "0x4cb62b9def5b691e43ed06808b18efe682fcefb7739909be0d6c87f1eda724cd",
1099-
"txHash": "0xf1d41fc99ed716a0c890ea62e13ee108ddcb4ecfc74efb715a4ef05605ce449b"
1096+
"address": "0x80A6500EFD52C66820dB0E8014088B4eBf8B8f52",
1097+
"creationCodeHash": "0xd2aa0d4e2d6ca8d0b2067d249d3202a340b13291a65e23c46f5c04df703bfc0e",
1098+
"runtimeCodeHash": "0xa88669e10cde56141250596f6f034629b1bf55086a3ed21ebb0e2bd3b3fca991",
1099+
"txHash": "0x3bb004adf949e9c896e85f6e3124ecea0c223470e3a091e42539613d52679c4d"
11001100
}
11011101
},
11021102
"L2Staking": {

cli/env.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,32 @@ export const displayGasOverrides = (): Overrides => {
3131
return r
3232
}
3333

34+
function isMnemonic(mnemonic) {
35+
return mnemonic.split(' ').length >= 12 && mnemonic.split(' ').length <= 24
36+
}
37+
38+
function isPrivateKey(privateKey) {
39+
try {
40+
utils.getAddress(utils.computeAddress(privateKey))
41+
return true
42+
} catch (error) {
43+
return false
44+
}
45+
}
46+
3447
export const loadEnv = async (argv: CLIArgs, wallet?: Wallet): Promise<CLIEnvironment> => {
3548
if (!wallet) {
36-
wallet = Wallet.fromMnemonic(argv.mnemonic, `m/44'/60'/0'/0/${argv.accountNumber}`).connect(
37-
getProvider(argv.providerUrl),
38-
)
49+
if (isPrivateKey(argv.mnemonic)) {
50+
wallet = new Wallet(argv.mnemonic, getProvider(argv.providerUrl))
51+
} else if (isMnemonic(argv.mnemonic)) {
52+
wallet = Wallet.fromMnemonic(argv.mnemonic, `m/44'/60'/0'/0/${argv.accountNumber}`).connect(
53+
getProvider(argv.providerUrl),
54+
)
55+
} else {
56+
throw new Error(
57+
'A wallet was not provided, please complete the `mnemonic` argument with a valid value',
58+
)
59+
}
3960
}
4061

4162
const balance = await wallet.getBalance()

config/graph.arbitrum-goerli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ contracts:
6868
controller: "${{Controller.address}}"
6969
curationTokenMaster: "${{GraphCurationToken.address}}"
7070
curationTaxPercentage: 10000 # in parts per million
71-
minimumCurationDeposit: "1000000000000000000" # in wei
71+
minimumCurationDeposit: "1" # in wei
7272
calls:
7373
- fn: "syncAllContracts"
7474
DisputeManager:

config/graph.arbitrum-localhost.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ contracts:
6868
controller: "${{Controller.address}}"
6969
curationTokenMaster: "${{GraphCurationToken.address}}"
7070
curationTaxPercentage: 10000 # in parts per million
71-
minimumCurationDeposit: "1000000000000000000" # in wei
71+
minimumCurationDeposit: "1" # in wei
7272
calls:
7373
- fn: "syncAllContracts"
7474
DisputeManager:

config/graph.arbitrum-one.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ contracts:
6868
controller: "${{Controller.address}}"
6969
curationTokenMaster: "${{GraphCurationToken.address}}"
7070
curationTaxPercentage: 10000 # in parts per million
71-
minimumCurationDeposit: "1000000000000000000" # in wei
71+
minimumCurationDeposit: "1" # in wei
7272
calls:
7373
- fn: "syncAllContracts"
7474
DisputeManager:

contracts/discovery/L1GNS.sol

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { L1GNSV1Storage } from "./L1GNSStorage.sol";
2020
* human-readable names. All human readable names emitted in events.
2121
* The contract implements a multicall behaviour to support batching multiple calls in a single
2222
* transaction.
23-
* This L1GNS variant includes some functions to allow migrating subgraphs to L2.
23+
* This L1GNS variant includes some functions to allow transferring subgraphs to L2.
2424
*/
2525
contract L1GNS is GNS, L1GNSV1Storage {
2626
using SafeMathUpgradeable for uint256;
@@ -44,6 +44,8 @@ contract L1GNS is GNS, L1GNSV1Storage {
4444
/**
4545
* @notice Send a subgraph's data and tokens to L2.
4646
* Use the Arbitrum SDK to estimate the L2 retryable ticket parameters.
47+
* Note that any L2 gas/fee refunds will be lost, so the function only accepts
48+
* the exact amount of ETH to cover _maxSubmissionCost + _maxGas * _gasPriceBid.
4749
* @param _subgraphID Subgraph ID
4850
* @param _l2Owner Address that will own the subgraph in L2 (could be the L1 owner, but could be different if the L1 owner is an L1 contract)
4951
* @param _maxGas Max gas to use for the L2 retryable ticket
@@ -57,13 +59,17 @@ contract L1GNS is GNS, L1GNSV1Storage {
5759
uint256 _gasPriceBid,
5860
uint256 _maxSubmissionCost
5961
) external payable notPartialPaused {
60-
require(!subgraphMigratedToL2[_subgraphID], "ALREADY_DONE");
62+
require(!subgraphTransferredToL2[_subgraphID], "ALREADY_DONE");
63+
require(
64+
msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)),
65+
"INVALID_ETH_VALUE"
66+
);
6167

6268
SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID);
63-
// This is just like onlySubgraphAuth, but we want it to run after the subgraphMigratedToL2 check
69+
// This is just like onlySubgraphAuth, but we want it to run after the subgraphTransferredToL2 check
6470
// to revert with a nicer message in that case:
6571
require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized");
66-
subgraphMigratedToL2[_subgraphID] = true;
72+
subgraphTransferredToL2[_subgraphID] = true;
6773

6874
uint256 curationTokens = curation().burn(
6975
subgraphData.subgraphDeploymentID,
@@ -75,7 +81,7 @@ contract L1GNS is GNS, L1GNSV1Storage {
7581

7682
// We send only the subgraph owner's tokens and nsignal to L2,
7783
// and for everyone else we set the withdrawableGRT so that they can choose
78-
// to withdraw or migrate their signal.
84+
// to withdraw or transfer their signal.
7985
uint256 ownerNSignal = subgraphData.curatorNSignal[msg.sender];
8086
uint256 totalSignal = subgraphData.nSignal;
8187

@@ -108,13 +114,15 @@ contract L1GNS is GNS, L1GNSV1Storage {
108114

109115
/**
110116
* @notice Send the balance for a curator's signal in a subgraph that was
111-
* migrated to L2, using the L1GraphTokenGateway.
117+
* transferred to L2, using the L1GraphTokenGateway.
112118
* The balance will be claimed for a beneficiary address, as this method can be
113119
* used by curators that use a contract address in L1 that may not exist in L2.
114120
* This will set the curator's signal on L1 to zero, so the caller must ensure
115121
* that the retryable ticket is redeemed before expiration, or the signal will be lost.
116-
* It is up to the caller to verify that the subgraph migration was finished in L2,
122+
* It is up to the caller to verify that the subgraph transfer was finished in L2,
117123
* but if it wasn't, the tokens will be sent to the beneficiary in L2.
124+
* Note that any L2 gas/fee refunds will be lost, so the function only accepts
125+
* the exact amount of ETH to cover _maxSubmissionCost + _maxGas * _gasPriceBid.
118126
* @dev Use the Arbitrum SDK to estimate the L2 retryable ticket parameters.
119127
* @param _subgraphID Subgraph ID
120128
* @param _beneficiary Address that will receive the tokens in L2
@@ -129,8 +137,11 @@ contract L1GNS is GNS, L1GNSV1Storage {
129137
uint256 _gasPriceBid,
130138
uint256 _maxSubmissionCost
131139
) external payable notPartialPaused {
132-
require(subgraphMigratedToL2[_subgraphID], "!MIGRATED");
133-
140+
require(subgraphTransferredToL2[_subgraphID], "!TRANSFERRED");
141+
require(
142+
msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)),
143+
"INVALID_ETH_VALUE"
144+
);
134145
// The Arbitrum bridge will check this too, we just check here for an early exit
135146
require(_maxSubmissionCost != 0, "NO_SUBMISSION_COST");
136147

contracts/discovery/L1GNSStorage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pragma abicoder v2;
1010
* reduce the size of the gap accordingly.
1111
*/
1212
abstract contract L1GNSV1Storage {
13-
/// True for subgraph IDs that have been migrated to L2
14-
mapping(uint256 => bool) public subgraphMigratedToL2;
13+
/// True for subgraph IDs that have been transferred to L2
14+
mapping(uint256 => bool) public subgraphTransferredToL2;
1515
/// @dev Storage gap to keep storage slots fixed in future versions
1616
uint256[50] private __gap;
1717
}

contracts/gateway/L1GraphTokenGateway.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
417417
}
418418

419419
/**
420-
* @notice Decodes calldata required for migration of tokens
420+
* @notice Decodes calldata required for transfer of tokens to L2
421421
* @dev Data must include maxSubmissionCost, extraData can be left empty. When the router
422422
* sends an outbound message, data also contains the from address.
423423
* @param _data encoded callhook data

contracts/l2/curation/IL2Curation.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface IL2Curation {
99
/**
1010
* @notice Deposit Graph Tokens in exchange for signal of a SubgraphDeployment curation pool.
1111
* @dev This function charges no tax and can only be called by GNS in specific scenarios (for now
12-
* only during an L1-L2 migration).
12+
* only during an L1-L2 transfer).
1313
* @param _subgraphDeploymentID Subgraph deployment pool from where to mint signal
1414
* @param _tokensIn Amount of Graph Tokens to deposit
1515
* @return Signal minted

contracts/l2/curation/L2Curation.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation {
3535
uint32 private constant MAX_PPM = 1000000;
3636

3737
/// @dev Amount of signal you get with your minimum token deposit
38-
uint256 private constant SIGNAL_PER_MINIMUM_DEPOSIT = 1e18; // 1 signal as 18 decimal number
38+
uint256 private constant SIGNAL_PER_MINIMUM_DEPOSIT = 1; // 1e-18 signal as 18 decimal number
3939

4040
/// @dev Reserve ratio for all subgraphs set to 100% for a flat bonding curve
4141
uint32 private immutable fixedReserveRatio = MAX_PPM;
@@ -227,7 +227,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation {
227227
/**
228228
* @notice Deposit Graph Tokens in exchange for signal of a SubgraphDeployment curation pool.
229229
* @dev This function charges no tax and can only be called by GNS in specific scenarios (for now
230-
* only during an L1-L2 migration).
230+
* only during an L1-L2 transfer).
231231
* @param _subgraphDeploymentID Subgraph deployment pool from where to mint signal
232232
* @param _tokensIn Amount of Graph Tokens to deposit
233233
* @return Signal minted

0 commit comments

Comments
 (0)