Skip to content

Commit c75ceae

Browse files
committed
Merge branch 'dev' into ab/snapshot-on-collect
2 parents 079fec4 + ed86d23 commit c75ceae

File tree

78 files changed

+9980
-2224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+9980
-2224
lines changed

.solcover.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ module.exports = {
77
},
88
skipFiles,
99
istanbulFolder: './reports/coverage',
10+
configureYulOptimizer: true,
1011
}

addresses.json

Lines changed: 81 additions & 57 deletions
Large diffs are not rendered by default.

cli/commands/migrate.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ let allContracts = [
2929
'Curation',
3030
'SubgraphNFTDescriptor',
3131
'SubgraphNFT',
32-
'GNS',
33-
'Staking',
32+
'L1GNS',
33+
'StakingExtension',
34+
'L1Staking',
3435
'RewardsManager',
3536
'DisputeManager',
3637
'AllocationExchange',
@@ -40,17 +41,17 @@ let allContracts = [
4041

4142
const l2Contracts = [
4243
'GraphProxyAdmin',
43-
'BancorFormula',
4444
'Controller',
4545
'EpochManager',
4646
'L2GraphToken',
4747
'GraphCurationToken',
4848
'ServiceRegistry',
49-
'Curation',
49+
'L2Curation',
5050
'SubgraphNFTDescriptor',
5151
'SubgraphNFT',
52-
'GNS',
53-
'Staking',
52+
'L2GNS',
53+
'StakingExtension',
54+
'L2Staking',
5455
'RewardsManager',
5556
'DisputeManager',
5657
'AllocationExchange',

cli/contracts.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import { getContractAt } from './network'
1818

1919
import { EpochManager } from '../build/types/EpochManager'
2020
import { DisputeManager } from '../build/types/DisputeManager'
21-
import { Staking } from '../build/types/Staking'
21+
import { L1Staking } from '../build/types/L1Staking'
22+
import { L2Staking } from '../build/types/L2Staking'
2223
import { ServiceRegistry } from '../build/types/ServiceRegistry'
2324
import { Curation } from '../build/types/Curation'
2425
import { RewardsManager } from '../build/types/RewardsManager'
2526
import { GNS } from '../build/types/GNS'
27+
import { L1GNS } from '../build/types/L1GNS'
28+
import { L2GNS } from '../build/types/L2GNS'
2629
import { GraphProxyAdmin } from '../build/types/GraphProxyAdmin'
2730
import { GraphToken } from '../build/types/GraphToken'
2831
import { Controller } from '../build/types/Controller'
@@ -37,15 +40,21 @@ import { L1GraphTokenGateway } from '../build/types/L1GraphTokenGateway'
3740
import { L2GraphToken } from '../build/types/L2GraphToken'
3841
import { L2GraphTokenGateway } from '../build/types/L2GraphTokenGateway'
3942
import { BridgeEscrow } from '../build/types/BridgeEscrow'
43+
import { L2Curation } from '../build/types/L2Curation'
44+
import { IL1Staking } from '../build/types/IL1Staking'
45+
import { IL2Staking } from '../build/types/IL2Staking'
46+
import { Interface } from 'ethers/lib/utils'
47+
import { loadArtifact } from './artifacts'
4048

4149
export interface NetworkContracts {
4250
EpochManager: EpochManager
4351
DisputeManager: DisputeManager
44-
Staking: Staking
52+
Staking: IL1Staking | IL2Staking
4553
ServiceRegistry: ServiceRegistry
46-
Curation: Curation
54+
Curation: Curation | L2Curation
55+
L2Curation: L2Curation
4756
RewardsManager: RewardsManager
48-
GNS: GNS
57+
GNS: GNS | L1GNS | L2GNS
4958
GraphProxyAdmin: GraphProxyAdmin
5059
GraphToken: GraphToken
5160
Controller: Controller
@@ -60,6 +69,10 @@ export interface NetworkContracts {
6069
BridgeEscrow: BridgeEscrow
6170
L2GraphToken: L2GraphToken
6271
L2GraphTokenGateway: L2GraphTokenGateway
72+
L1GNS: L1GNS
73+
L2GNS: L2GNS
74+
L1Staking: IL1Staking
75+
L2Staking: IL2Staking
6376
}
6477

6578
export const loadAddressBookContract = (
@@ -91,6 +104,15 @@ export const loadContracts = (
91104
contract.connect = getWrappedConnect(contract, contractName)
92105
contract = wrapCalls(contract, contractName)
93106
}
107+
if (contractName == 'L1Staking') {
108+
// Hack the contract into behaving like an IL1Staking
109+
const iface = new Interface(loadArtifact('IL1Staking').abi)
110+
contract = new Contract(contract.address, iface) as unknown as IL1Staking
111+
} else if (contractName == 'L2Staking') {
112+
// Hack the contract into behaving like an IL2Staking
113+
const iface = new Interface(loadArtifact('IL2Staking').abi)
114+
contract = new Contract(contract.address, iface) as unknown as IL2Staking
115+
}
94116
contracts[contractName] = contract
95117

96118
if (signerOrProvider) {
@@ -101,6 +123,21 @@ export const loadContracts = (
101123
if (chainIdIsL2(chainId) && contractName == 'L2GraphToken') {
102124
contracts['GraphToken'] = contracts[contractName]
103125
}
126+
if (signerOrProvider && chainIdIsL2(chainId) && contractName == 'L2GNS') {
127+
contracts['GNS'] = contracts[contractName]
128+
}
129+
if (signerOrProvider && chainIdIsL2(chainId) && contractName == 'L2Staking') {
130+
contracts['Staking'] = contracts[contractName]
131+
}
132+
if (signerOrProvider && chainIdIsL2(chainId) && contractName == 'L2Curation') {
133+
contracts['Curation'] = contracts[contractName]
134+
}
135+
if (signerOrProvider && !chainIdIsL2(chainId) && contractName == 'L1GNS') {
136+
contracts['GNS'] = contracts[contractName]
137+
}
138+
if (signerOrProvider && !chainIdIsL2(chainId) && contractName == 'L1Staking') {
139+
contracts['Staking'] = contracts[contractName]
140+
}
104141
} catch (err) {
105142
logger.warn(`Could not load contract ${contractName} - ${err.message}`)
106143
}

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()

cli/network.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { AddressBook } from './address-book'
1818
import { loadArtifact } from './artifacts'
1919
import { defaultOverrides } from './defaults'
2020
import { GraphToken } from '../build/types/GraphToken'
21+
import { Interface } from 'ethers/lib/utils'
22+
import { IL1Staking } from '../build/types/IL1Staking'
23+
import { IL2Staking } from '../build/types/IL2Staking'
2124

2225
const { keccak256, randomBytes, parseUnits, hexlify } = utils
2326

@@ -197,7 +200,7 @@ export const deployContract = async (
197200

198201
// Deploy
199202
const factory = getContractFactory(name, libraries)
200-
const contract = await factory.connect(sender).deploy(...args)
203+
let contract = await factory.connect(sender).deploy(...args)
201204
const txHash = contract.deployTransaction.hash
202205
logger.info(`> Deploy ${name}, txHash: ${txHash}`)
203206
await sender.provider.waitForTransaction(txHash)
@@ -209,6 +212,15 @@ export const deployContract = async (
209212
logger.info(`= RuntimeCodeHash: ${runtimeCodeHash}`)
210213
logger.info(`${name} has been deployed to address: ${contract.address}`)
211214

215+
if (name == 'L1Staking') {
216+
// Hack the contract into behaving like an IL1Staking
217+
const iface = new Interface(loadArtifact('IL1Staking').abi)
218+
contract = new Contract(contract.address, iface, sender) as unknown as IL1Staking
219+
} else if (name == 'L2Staking') {
220+
// Hack the contract into behaving like an IL2Staking
221+
const iface = new Interface(loadArtifact('IL2Staking').abi)
222+
contract = new Contract(contract.address, iface, sender) as unknown as IL2Staking
223+
}
212224
return { contract, creationCodeHash, runtimeCodeHash, txHash, libraries }
213225
}
214226

config/graph.arbitrum-goerli.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ contracts:
1111
calls:
1212
- fn: "setContractProxy"
1313
id: "0xe6876326c1291dfcbbd3864a6816d698cd591defc7aa2153d7f9c4c04016c89f" # keccak256('Curation')
14-
contractAddress: "${{Curation.address}}"
14+
contractAddress: "${{L2Curation.address}}"
1515
- fn: "setContractProxy"
1616
id: "0x39605a6c26a173774ca666c67ef70cf491880e5d3d6d0ca66ec0a31034f15ea3" # keccak256('GNS')
17-
contractAddress: "${{GNS.address}}"
17+
contractAddress: "${{L2GNS.address}}"
1818
- fn: "setContractProxy"
1919
id: "0xf942813d07d17b56de9a9afc8de0ced6e8c053bbfdcc87b7badea4ddcf27c307" # keccak256('DisputeManager')
2020
contractAddress: "${{DisputeManager.address}}"
@@ -26,7 +26,7 @@ contracts:
2626
contractAddress: "${{RewardsManager.address}}"
2727
- fn: "setContractProxy"
2828
id: "0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034" # keccak256('Staking')
29-
contractAddress: "${{Staking.address}}"
29+
contractAddress: "${{L2Staking.address}}"
3030
- fn: "setContractProxy"
3131
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
3232
contractAddress: "${{L2GraphToken.address}}"
@@ -62,15 +62,13 @@ contracts:
6262
- fn: "renounceMinter"
6363
- fn: "transferOwnership"
6464
owner: *governor
65-
Curation:
65+
L2Curation:
6666
proxy: true
6767
init:
6868
controller: "${{Controller.address}}"
69-
bondingCurve: "${{BancorFormula.address}}"
7069
curationTokenMaster: "${{GraphCurationToken.address}}"
71-
reserveRatio: 1000000 # in parts per million
7270
curationTaxPercentage: 10000 # in parts per million
73-
minimumCurationDeposit: "1000000000000000000" # in wei
71+
minimumCurationDeposit: "1" # in wei
7472
calls:
7573
- fn: "syncAllContracts"
7674
DisputeManager:
@@ -84,11 +82,10 @@ contracts:
8482
qrySlashingPercentage: 25000 # in parts per million
8583
calls:
8684
- fn: "syncAllContracts"
87-
GNS:
85+
L2GNS:
8886
proxy: true
8987
init:
9088
controller: "${{Controller.address}}"
91-
bondingCurve: "${{BancorFormula.address}}"
9289
subgraphNFT: "${{SubgraphNFT.address}}"
9390
calls:
9491
- fn: "approveAll"
@@ -100,10 +97,10 @@ contracts:
10097
- fn: "setTokenDescriptor"
10198
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
10299
- fn: "setMinter"
103-
minter: "${{GNS.address}}"
100+
minter: "${{L2GNS.address}}"
104101
- fn: "transferOwnership"
105102
owner: *governor
106-
Staking:
103+
L2Staking:
107104
proxy: true
108105
init:
109106
controller: "${{Controller.address}}"
@@ -117,6 +114,7 @@ contracts:
117114
delegationRatio: 16 # delegated stake to indexer stake multiplier
118115
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
119116
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
117+
extensionImpl: "${{StakingExtension.address}}"
120118
calls:
121119
- fn: "setDelegationTaxPercentage"
122120
delegationTaxPercentage: 5000 # parts per million
@@ -140,7 +138,7 @@ contracts:
140138
AllocationExchange:
141139
init:
142140
graphToken: "${{L2GraphToken.address}}"
143-
staking: "${{Staking.address}}"
141+
staking: "${{L2Staking.address}}"
144142
governor: *allocationExchangeOwner
145143
authority: *authority
146144
calls:

config/graph.arbitrum-localhost.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ contracts:
1111
calls:
1212
- fn: "setContractProxy"
1313
id: "0xe6876326c1291dfcbbd3864a6816d698cd591defc7aa2153d7f9c4c04016c89f" # keccak256('Curation')
14-
contractAddress: "${{Curation.address}}"
14+
contractAddress: "${{L2Curation.address}}"
1515
- fn: "setContractProxy"
1616
id: "0x39605a6c26a173774ca666c67ef70cf491880e5d3d6d0ca66ec0a31034f15ea3" # keccak256('GNS')
17-
contractAddress: "${{GNS.address}}"
17+
contractAddress: "${{L2GNS.address}}"
1818
- fn: "setContractProxy"
1919
id: "0xf942813d07d17b56de9a9afc8de0ced6e8c053bbfdcc87b7badea4ddcf27c307" # keccak256('DisputeManager')
2020
contractAddress: "${{DisputeManager.address}}"
@@ -26,7 +26,7 @@ contracts:
2626
contractAddress: "${{RewardsManager.address}}"
2727
- fn: "setContractProxy"
2828
id: "0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034" # keccak256('Staking')
29-
contractAddress: "${{Staking.address}}"
29+
contractAddress: "${{L2Staking.address}}"
3030
- fn: "setContractProxy"
3131
id: "0x45fc200c7e4544e457d3c5709bfe0d520442c30bbcbdaede89e8d4a4bbc19247" # keccak256('GraphToken')
3232
contractAddress: "${{L2GraphToken.address}}"
@@ -62,15 +62,13 @@ contracts:
6262
- fn: "renounceMinter"
6363
- fn: "transferOwnership"
6464
owner: *governor
65-
Curation:
65+
L2Curation:
6666
proxy: true
6767
init:
6868
controller: "${{Controller.address}}"
69-
bondingCurve: "${{BancorFormula.address}}"
7069
curationTokenMaster: "${{GraphCurationToken.address}}"
71-
reserveRatio: 1000000 # in parts per million
7270
curationTaxPercentage: 10000 # in parts per million
73-
minimumCurationDeposit: "1000000000000000000" # in wei
71+
minimumCurationDeposit: "1" # in wei
7472
calls:
7573
- fn: "syncAllContracts"
7674
DisputeManager:
@@ -84,11 +82,10 @@ contracts:
8482
qrySlashingPercentage: 25000 # in parts per million
8583
calls:
8684
- fn: "syncAllContracts"
87-
GNS:
85+
L2GNS:
8886
proxy: true
8987
init:
9088
controller: "${{Controller.address}}"
91-
bondingCurve: "${{BancorFormula.address}}"
9289
subgraphNFT: "${{SubgraphNFT.address}}"
9390
calls:
9491
- fn: "approveAll"
@@ -100,10 +97,10 @@ contracts:
10097
- fn: "setTokenDescriptor"
10198
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
10299
- fn: "setMinter"
103-
minter: "${{GNS.address}}"
100+
minter: "${{L2GNS.address}}"
104101
- fn: "transferOwnership"
105102
owner: *governor
106-
Staking:
103+
L2Staking:
107104
proxy: true
108105
init:
109106
controller: "${{Controller.address}}"
@@ -117,6 +114,7 @@ contracts:
117114
delegationRatio: 16 # delegated stake to indexer stake multiplier
118115
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
119116
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
117+
extensionImpl: "${{StakingExtension.address}}"
120118
calls:
121119
- fn: "setDelegationTaxPercentage"
122120
delegationTaxPercentage: 5000 # parts per million
@@ -140,7 +138,7 @@ contracts:
140138
AllocationExchange:
141139
init:
142140
graphToken: "${{L2GraphToken.address}}"
143-
staking: "${{Staking.address}}"
141+
staking: "${{L2Staking.address}}"
144142
governor: *allocationExchangeOwner
145143
authority: *authority
146144
calls:

0 commit comments

Comments
 (0)