Skip to content

Commit fa60dbf

Browse files
committed
fix: add gns and staking counter part addresses when configuring bridge
1 parent d921301 commit fa60dbf

File tree

5 files changed

+132
-3
lines changed

5 files changed

+132
-3
lines changed

packages/contracts/cli/commands/protocol/configure-bridge.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ export const configureL1Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
1515
const l2AddressBook = getAddressBook(cliArgs.addressBook, l2ChainId)
1616
const arbAddressBook = getAddressBook(cliArgs.arbAddressBook, cli.chainId.toString())
1717

18+
// Gateway
1819
const gateway = cli.contracts['L1GraphTokenGateway']
1920

2021
const l2GRT = l2AddressBook.getEntry('L2GraphToken')
2122
logger.info('L2 GRT address: ' + l2GRT.address)
2223
await sendTransaction(cli.wallet, gateway, 'setL2TokenAddress', [l2GRT.address])
2324

24-
const l2Counterpart = l2AddressBook.getEntry('L2GraphTokenGateway')
25-
logger.info('L2 Gateway address: ' + l2Counterpart.address)
26-
await sendTransaction(cli.wallet, gateway, 'setL2CounterpartAddress', [l2Counterpart.address])
25+
const l2GatewayCounterpart = l2AddressBook.getEntry('L2GraphTokenGateway')
26+
logger.info('L2 Gateway address: ' + l2GatewayCounterpart.address)
27+
await sendTransaction(cli.wallet, gateway, 'setL2CounterpartAddress', [
28+
l2GatewayCounterpart.address,
29+
])
2730

31+
// Escrow
2832
const bridgeEscrow = cli.contracts.BridgeEscrow
2933
logger.info('Escrow address: ' + bridgeEscrow.address)
3034
await sendTransaction(cli.wallet, gateway, 'setEscrowAddress', [bridgeEscrow.address])
@@ -39,6 +43,20 @@ export const configureL1Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
3943
l1Inbox.address,
4044
l1Router.address,
4145
])
46+
47+
// GNS
48+
const gns = cli.contracts.L1GNS
49+
const l2GNSCounterpart = l2AddressBook.getEntry('L2GNS')
50+
logger.info('L2 GNS address: ' + l2GNSCounterpart.address)
51+
await sendTransaction(cli.wallet, gns, 'setCounterpartGNSAddress', [l2GNSCounterpart.address])
52+
53+
// Staking
54+
const staking = cli.contracts.L1Staking
55+
const l2StakingCounterpart = l2AddressBook.getEntry('L2Staking')
56+
logger.info('L2 Staking address: ' + l2StakingCounterpart.address)
57+
await sendTransaction(cli.wallet, staking, 'setCounterpartStakingAddress', [
58+
l2StakingCounterpart.address,
59+
])
4260
}
4361

4462
export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
@@ -52,6 +70,7 @@ export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
5270
const l1AddressBook = getAddressBook(cliArgs.addressBook, l1ChainId)
5371
const arbAddressBook = getAddressBook(cliArgs.arbAddressBook, cli.chainId.toString())
5472

73+
// Gateway
5574
const gateway = cli.contracts['L2GraphTokenGateway']
5675
const token = cli.contracts['L2GraphToken']
5776

@@ -70,6 +89,20 @@ export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
7089

7190
logger.info('L2 Gateway address: ' + gateway.address)
7291
await sendTransaction(cli.wallet, token, 'setGateway', [gateway.address])
92+
93+
// GNS
94+
const gns = cli.contracts.L2GNS
95+
const l1GNSCounterpart = l1AddressBook.getEntry('L1GNS')
96+
logger.info('L1 GNS address: ' + l1GNSCounterpart.address)
97+
await sendTransaction(cli.wallet, gns, 'setCounterpartGNSAddress', [l1GNSCounterpart.address])
98+
99+
// Staking
100+
const staking = cli.contracts.L2Staking
101+
const l1StakingCounterpart = l1AddressBook.getEntry('L1Staking')
102+
logger.info('L1 Staking address: ' + l1StakingCounterpart.address)
103+
await sendTransaction(cli.wallet, staking, 'setCounterpartStakingAddress', [
104+
l1StakingCounterpart.address,
105+
])
73106
}
74107

75108
export const configureL1BridgeCommand = {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L1] GNS', () => {
7+
const graph = hre.graph()
8+
const { L1GNS } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L1GNS', () => {
18+
it('counterpartGNSAddress should match the L2GNS address', async () => {
19+
const l2GNS = await L1GNS.counterpartGNSAddress()
20+
expect(l2GNS).eq(graph.l2.contracts.L2GNS.address)
21+
})
22+
})
23+
})
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L1] Staking', () => {
7+
const graph = hre.graph()
8+
const { L1Staking } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L1Staking', () => {
18+
it('counterpartStakingAddress should match the L2Staking address', async () => {
19+
// counterpartStakingAddress is internal so we access the storage directly
20+
const l2StakingData = await hre.ethers.provider.getStorageAt(L1Staking.address, 24)
21+
const l2Staking = hre.ethers.utils.defaultAbiCoder.decode(['address'], l2StakingData)[0]
22+
expect(l2Staking).eq(graph.l2.contracts.L2Staking.address)
23+
})
24+
})
25+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L2] GNS', () => {
7+
const graph = hre.graph()
8+
const { L2GNS } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L2GNS', () => {
18+
it('counterpartGNSAddress should match the L1GNS address', async () => {
19+
const l1GNS = await L2GNS.counterpartGNSAddress()
20+
expect(l1GNS).eq(graph.l1.contracts.L1GNS.address)
21+
})
22+
})
23+
})
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L2] Staking', () => {
7+
const graph = hre.graph()
8+
const { L2Staking } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L2Staking', () => {
18+
it('counterpartStakingAddress should match the L1Staking address', async () => {
19+
// counterpartStakingAddress is internal so we access the storage directly
20+
const l1StakingData = await hre.ethers.provider.getStorageAt(L2Staking.address, 24)
21+
const l1Staking = hre.ethers.utils.defaultAbiCoder.decode(['address'], l1StakingData)[0]
22+
expect(l1Staking).eq(graph.l1.contracts.L1Staking.address)
23+
})
24+
})
25+
})

0 commit comments

Comments
 (0)