Skip to content

Commit e68ebf9

Browse files
committed
Fixes and tests for L2 token
1 parent 577559b commit e68ebf9

File tree

12 files changed

+593
-376
lines changed

12 files changed

+593
-376
lines changed

arbitrum-graph.config.yml

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -30,89 +30,90 @@ contracts:
3030
- fn: "setContractProxy"
3131
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
3232
contractAddress: "${{L2GraphTokenGateway.address}}"
33-
ServiceRegistry:
34-
proxy: true
35-
init:
36-
controller: "${{Controller.address}}"
37-
EpochManager:
38-
proxy: true
39-
init:
40-
controller: "${{Controller.address}}"
41-
lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
33+
# ServiceRegistry:
34+
# proxy: true
35+
# init:
36+
# controller: "${{Controller.address}}"
37+
# EpochManager:
38+
# proxy: true
39+
# init:
40+
# controller: "${{Controller.address}}"
41+
# lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
4242
L2GraphToken:
4343
proxy: true
4444
init:
45+
owner: *governor
4546
initialSupply: "0"
46-
Curation:
47-
proxy: true
48-
init:
49-
controller: "${{Controller.address}}"
50-
bondingCurve: "${{BancorFormula.address}}"
51-
curationTokenMaster: "${{GraphCurationToken.address}}"
52-
reserveRatio: 500000 # 50% (parts per million)
53-
curationTaxPercentage: 10000 # 1% (parts per million)
54-
minimumCurationDeposit: "1000000000000000000" # 1 GRT
55-
DisputeManager:
56-
proxy: true
57-
init:
58-
controller: "${{Controller.address}}"
59-
arbitrator: *arbitrator
60-
minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
61-
fishermanRewardPercentage: 500000 # 50% (parts per million)
62-
idxSlashingPercentage: 25000 # 2.5% (parts per million)
63-
qrySlashingPercentage: 5000 # 0.5% (parts per million)
64-
GNS:
65-
proxy: true
66-
init:
67-
controller: "${{Controller.address}}"
68-
bondingCurve: "${{BancorFormula.address}}"
69-
subgraphNFT: "${{SubgraphNFT.address}}"
70-
calls:
71-
- fn: "approveAll"
72-
SubgraphNFT:
73-
init:
74-
governor: "${{Env.deployer}}"
75-
calls:
76-
- fn: "setTokenDescriptor"
77-
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
78-
- fn: "setMinter"
79-
minter: "${{GNS.address}}"
80-
Staking:
81-
proxy: true
82-
init:
83-
controller: "${{Controller.address}}"
84-
minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
85-
thawingPeriod: 6646 # 10 days (in blocks)
86-
protocolPercentage: 10000 # 1% (parts per million)
87-
curationPercentage: 100000 # 10% (parts per million)
88-
channelDisputeEpochs: 2 # (in epochs)
89-
maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
90-
delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
91-
delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
92-
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
93-
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
94-
calls:
95-
- fn: "setDelegationTaxPercentage"
96-
delegationTaxPercentage: 5000 # 0.5% (parts per million)
97-
- fn: "setSlasher"
98-
slasher: "${{DisputeManager.address}}"
99-
allowed: true
100-
- fn: "setAssetHolder"
101-
assetHolder: "${{AllocationExchange.address}}"
102-
allowed: true
103-
RewardsManager:
104-
proxy: true
105-
init:
106-
controller: "${{Controller.address}}"
107-
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
108-
AllocationExchange:
109-
init:
110-
graphToken: "${{L2GraphToken.address}}"
111-
staking: "${{Staking.address}}"
112-
governor: *governor
113-
authority: *authority
114-
calls:
115-
- fn: "approveAll"
47+
# Curation:
48+
# proxy: true
49+
# init:
50+
# controller: "${{Controller.address}}"
51+
# bondingCurve: "${{BancorFormula.address}}"
52+
# curationTokenMaster: "${{GraphCurationToken.address}}"
53+
# reserveRatio: 500000 # 50% (parts per million)
54+
# curationTaxPercentage: 10000 # 1% (parts per million)
55+
# minimumCurationDeposit: "1000000000000000000" # 1 GRT
56+
# DisputeManager:
57+
# proxy: true
58+
# init:
59+
# controller: "${{Controller.address}}"
60+
# arbitrator: *arbitrator
61+
# minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
62+
# fishermanRewardPercentage: 500000 # 50% (parts per million)
63+
# idxSlashingPercentage: 25000 # 2.5% (parts per million)
64+
# qrySlashingPercentage: 5000 # 0.5% (parts per million)
65+
# GNS:
66+
# proxy: true
67+
# init:
68+
# controller: "${{Controller.address}}"
69+
# bondingCurve: "${{BancorFormula.address}}"
70+
# subgraphNFT: "${{SubgraphNFT.address}}"
71+
# calls:
72+
# - fn: "approveAll"
73+
# SubgraphNFT:
74+
# init:
75+
# governor: "${{Env.deployer}}"
76+
# calls:
77+
# - fn: "setTokenDescriptor"
78+
# tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
79+
# - fn: "setMinter"
80+
# minter: "${{GNS.address}}"
81+
# Staking:
82+
# proxy: true
83+
# init:
84+
# controller: "${{Controller.address}}"
85+
# minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
86+
# thawingPeriod: 6646 # 10 days (in blocks)
87+
# protocolPercentage: 10000 # 1% (parts per million)
88+
# curationPercentage: 100000 # 10% (parts per million)
89+
# channelDisputeEpochs: 2 # (in epochs)
90+
# maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
91+
# delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
92+
# delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
93+
# rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
94+
# rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
95+
# calls:
96+
# - fn: "setDelegationTaxPercentage"
97+
# delegationTaxPercentage: 5000 # 0.5% (parts per million)
98+
# - fn: "setSlasher"
99+
# slasher: "${{DisputeManager.address}}"
100+
# allowed: true
101+
# - fn: "setAssetHolder"
102+
# assetHolder: "${{AllocationExchange.address}}"
103+
# allowed: true
104+
# RewardsManager:
105+
# proxy: true
106+
# init:
107+
# controller: "${{Controller.address}}"
108+
# issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
109+
# AllocationExchange:
110+
# init:
111+
# graphToken: "${{L2GraphToken.address}}"
112+
# staking: "${{Staking.address}}"
113+
# governor: *governor
114+
# authority: *authority
115+
# calls:
116+
# - fn: "approveAll"
116117
L2GraphTokenGateway:
117118
proxy: true
118119
init:

contracts/l2/gateway/L2GraphTokenGateway.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger {
5959
);
6060
_;
6161
}
62+
/**
63+
* @dev Initialize this contract.
64+
*/
65+
function initialize(address _controller) external onlyImpl {
66+
Managed._initialize(_controller);
67+
__ReentrancyGuard_init();
68+
_paused = true;
69+
}
6270

6371
function setL2Router(address _l2Router) external onlyGovernor {
6472
l2Router = _l2Router;

contracts/l2/token/L2GraphToken.sol

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Upgradeable,
6767
* @dev Graph Token Contract initializer.
6868
* @param _initialSupply Initial supply of GRT
6969
*/
70-
function _initialize(uint256 _initialSupply) internal {
70+
function _initialize(address owner, uint256 _initialSupply) internal {
7171
__ERC20_init("Graph Token", "GRT");
72-
Governed._initialize(msg.sender);
72+
Governed._initialize(owner);
7373

7474
// The Governor has the initial supply of tokens
75-
_mint(msg.sender, _initialSupply);
75+
_mint(owner, _initialSupply);
7676

7777
// The Governor is the default minter
78-
_addMinter(msg.sender);
78+
_addMinter(owner);
7979

8080
// EIP-712 domain separator
8181
DOMAIN_SEPARATOR = keccak256(
@@ -207,7 +207,7 @@ contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Upgradeable,
207207
contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
208208
using SafeMath for uint256;
209209
address public gateway;
210-
address public l1GRT;
210+
address public override l1Address;
211211

212212
event BridgeMinted(address indexed account, uint256 amount);
213213
event BridgeBurned(address indexed account, uint256 amount);
@@ -222,8 +222,8 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
222222
* @dev L2 Graph Token Contract Constructor.
223223
* @param _initialSupply Initial supply of GRT
224224
*/
225-
function initialize(uint256 _initialSupply) external onlyImpl {
226-
GraphTokenUpgradeable._initialize(_initialSupply);
225+
function initialize(address owner, uint256 _initialSupply) external onlyImpl {
226+
GraphTokenUpgradeable._initialize(owner, _initialSupply);
227227
}
228228

229229
function setGateway(address gw) external onlyGovernor {
@@ -232,8 +232,8 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
232232
}
233233

234234
function setL1Address(address addr) external onlyGovernor {
235-
l1GRT = addr;
236-
emit L1AddressSet(l1GRT);
235+
l1Address = addr;
236+
emit L1AddressSet(addr);
237237
}
238238

239239
/**
@@ -255,12 +255,4 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
255255
burnFrom(account, amount);
256256
emit BridgeBurned(account, amount);
257257
}
258-
259-
/**
260-
* @dev Get the address of the L1 counterpart of this token
261-
* @return address of layer 1 token
262-
*/
263-
function l1Address() external override view returns (address) {
264-
return l1GRT;
265-
}
266258
}

test/epochs.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getAccounts,
1313
toBN,
1414
Account,
15+
initNetwork,
1516
} from './lib/testHelpers'
1617

1718
describe('EpochManager', () => {
@@ -23,6 +24,7 @@ describe('EpochManager', () => {
2324
const epochLength: BigNumber = toBN('3')
2425

2526
before(async function () {
27+
initNetwork()
2628
;[me, governor] = await getAccounts()
2729
})
2830

0 commit comments

Comments
 (0)