Skip to content

Commit 0877142

Browse files
authored
refactor: updates to facilitate local network testing (#517)
* build: support local network deployment (network id 1337) * fix: various bug fixes to protocol get/set, gns, and gns modules. * test: add timeout to avoid test to fail in certain cases
1 parent e5583e1 commit 0877142

File tree

13 files changed

+231
-16
lines changed

13 files changed

+231
-16
lines changed

Diff for: addresses.json

+176-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@
548548
},
549549
"GraphGovernance": {
550550
"address": "0x47241861A3918eaa9097c0345bb5A91660D7AEE1",
551-
"initArgs": ["0x1679a1d1caf1252ba43fb8fc17ebf914a0c725ae"],
551+
"initArgs": [
552+
"0x1679a1d1caf1252ba43fb8fc17ebf914a0c725ae"
553+
],
552554
"creationCodeHash": "0xa02709eb59b9cca8bee1271845b42db037dc1d042dad93410ba532d378a7c79f",
553555
"runtimeCodeHash": "0xdb307489fd9a4a438b5b48909e12020b209280ad777561c0a7451655db097e75",
554556
"txHash": "0x5101e33eb13504780b225a2557a7062bef93cada0838937e02e879fb3d5c2c01",
@@ -584,5 +586,178 @@
584586
"runtimeCodeHash": "0xec837eb756268aa8a18c5d3182a5c2bf89bd0369f1de07ffa33b1ec5d3bef41a",
585587
"txHash": "0x359cf3945b2584f45633c6f6f37ce5a46129b462232107bb29c456d7fdcb66d0"
586588
}
589+
},
590+
"1337": {
591+
"GraphProxyAdmin": {
592+
"address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
593+
"creationCodeHash": "0x3c6fbf43e7ba578059c1a167eb04a39fa6195e100ad4ebe0411db87b90e82dc9",
594+
"runtimeCodeHash": "0xee84b27af27551b9674c5c479c5f7bcc5036da7ee73c3636e65cd29ee7c9be5d",
595+
"txHash": "0xf704259e9724c551e5540f1758c8c8f2e1fc916abd4f23c5e10b667d6655a0c3"
596+
},
597+
"BancorFormula": {
598+
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
599+
"creationCodeHash": "0x0ed95869cfb576e5147fd72932c26be5ecf2591248d3796ce0b6510bd6f5a922",
600+
"runtimeCodeHash": "0x34ddeaa6e34c7b878dd36f594b8f66de155b20f591652611ae903471e92de247",
601+
"txHash": "0x5487cdaa1b5ecb4cbec70136988c24a1bff6a9471f5e5c8ba2d71a0ec9921e7d"
602+
},
603+
"Controller": {
604+
"address": "0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
605+
"creationCodeHash": "0xf8fcbcf368cb07268fd3866007a7f43dddec6305e4c4f9dfb0116f3ccb34fdd7",
606+
"runtimeCodeHash": "0x427aefc26cdddd97c8688a18b474d71383b15bdb166479f148a51693b9405b5b",
607+
"txHash": "0xd035a342f18fc932e4ee2f53f28e0453bcfe1e8e0674da1598c0a7d50c2ac732"
608+
},
609+
"EpochManager": {
610+
"address": "0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb",
611+
"initArgs": [
612+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
613+
"2"
614+
],
615+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
616+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
617+
"txHash": "0xfdec3dd6f716ec8de4afbe1b7e9417887cd313153b26fa3a26c35fbb347da938",
618+
"proxy": true,
619+
"implementation": {
620+
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
621+
"creationCodeHash": "0xfe6b91aed6bd59ebb74dff26991aa7a3e1ffd07d94db2244c0c5ba80be5605a5",
622+
"runtimeCodeHash": "0x5ebfefd2aa0638ac3322319b469ef243e4729aec99fbb7818bff0bc3035f3afd",
623+
"txHash": "0xce692dc814262817b9558304cdf9261ebc2c02127b7bffb1805aa78ce174527a"
624+
}
625+
},
626+
"GraphToken": {
627+
"address": "0xe982E462b094850F12AF94d21D470e21bE9D0E9C",
628+
"constructorArgs": [
629+
"10000000000000000000000000000"
630+
],
631+
"creationCodeHash": "0x1606aba0ece48fd1e75bbf040871a409426157d8a16596e9b1dac5b59f3c0262",
632+
"runtimeCodeHash": "0x89710d3723e04f40d3f143407d707b2af9dd5e5b39186aa1c915bbd62bc9fb3c",
633+
"txHash": "0x0c12fd6d0aed0841149a968241f27202b597fb6ca00c943322e42099796520ba"
634+
},
635+
"ServiceRegistry": {
636+
"address": "0x0290FB167208Af455bB137780163b7B7a9a10C16",
637+
"initArgs": [
638+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B"
639+
],
640+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
641+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
642+
"txHash": "0x455ae5fd6e0817d33b184441f814a3fa0ba02bf2e3ef0809c75367165b5c5194",
643+
"proxy": true,
644+
"implementation": {
645+
"address": "0x59d3631c86BbE35EF041872d502F218A39FBa150",
646+
"creationCodeHash": "0x3e646e8eb89e8ef70ae48363b8020228128ee5628124d92ce63b1606f38f11b6",
647+
"runtimeCodeHash": "0x10a60a0ee4953cb52d054755429f663fd164dd3bbe6b807a93bb41feaa0a87b6",
648+
"txHash": "0x90bb5de2d65e693a35d9c6661d24655fc806fc8f259c4b29b40e9396d56c334f"
649+
}
650+
},
651+
"Curation": {
652+
"address": "0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66",
653+
"initArgs": [
654+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
655+
"0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
656+
"500000",
657+
"25000",
658+
"1000000000000000000"
659+
],
660+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
661+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
662+
"txHash": "0xba76d8cf6a2c6fa885619ad4454e8c048bf46ab5cfb4b85d9b7e4f6ad595ea04",
663+
"proxy": true,
664+
"implementation": {
665+
"address": "0x67B5656d60a809915323Bf2C40A8bEF15A152e3e",
666+
"creationCodeHash": "0xc6442531c219774af565fdd95cd7424859c556a2de5010940844013af3dce3d8",
667+
"runtimeCodeHash": "0x7554a69de3598150957311412b12a3c7e076594365c48bc12ed07edbccd383f2",
668+
"txHash": "0x8fc6a237137f3a60b536087b01a304bd143d9519a4d9193a6d6f92cb506fd0a9"
669+
}
670+
},
671+
"GNS": {
672+
"address": "0x630589690929E9cdEFDeF0734717a9eF3Ec7Fcfe",
673+
"initArgs": [
674+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
675+
"0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
676+
"0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab"
677+
],
678+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
679+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
680+
"txHash": "0x703c82d0d2519bb610c41f3b53cc20f442b9ed5c282dba08c454ded49492d7e9",
681+
"proxy": true,
682+
"implementation": {
683+
"address": "0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec",
684+
"creationCodeHash": "0x65e50db40f3b4359e8a6223784c261b550418729def825328c9ebcab4c5a7b85",
685+
"runtimeCodeHash": "0xd157cae30265f93522cbb81b414a22b2476f8a05b2ca44c3d2a0817d3ab1ad98",
686+
"txHash": "0x8be904e5d538a0cd200b69117037a73c54a12423569c6d1a2900b67ea42a6bae"
687+
}
688+
},
689+
"Staking": {
690+
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
691+
"initArgs": [
692+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
693+
"100000000000000000000000",
694+
"6646",
695+
"10000",
696+
"100000",
697+
"2",
698+
"6",
699+
"6",
700+
"16",
701+
"77",
702+
"100"
703+
],
704+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
705+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
706+
"txHash": "0x1b209109a23a075aec4d592545899ee782ada125b85514462f34803fcec1a72a",
707+
"proxy": true,
708+
"implementation": {
709+
"address": "0xA94B7f0465E98609391C623d0560C5720a3f2D33",
710+
"creationCodeHash": "0x1baf52ad3511c485d527d78ffae9d6c175442f48ad20a4e234a65eba7e35ef5b",
711+
"runtimeCodeHash": "0x409f4c44ee78e030c22313ecd67d3508ae23708d97219c763f1dad2cd9a9e08d",
712+
"txHash": "0x29ad28e27505872344ef579e964086d90c2a63c940ff7d55a16af67aa4b9d634",
713+
"libraries": {
714+
"LibCobbDouglas": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15"
715+
}
716+
}
717+
},
718+
"RewardsManager": {
719+
"address": "0x5f8e26fAcC23FA4cbd87b8d9Dbbd33D5047abDE1",
720+
"initArgs": [
721+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
722+
"1000000012184945188"
723+
],
724+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
725+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
726+
"txHash": "0x09a50136af6c055edf601537b0ad8ac23b226ead3e36ebfa3fa383ecd75c5642",
727+
"proxy": true,
728+
"implementation": {
729+
"address": "0xFC628dd79137395F3C9744e33b1c5DE554D94882",
730+
"creationCodeHash": "0x9351b711b69176491b7610ae19c0e98b2f1958542b708240d3225e68308e5215",
731+
"runtimeCodeHash": "0x2c6b4881b6d13447ec64e5390646eb02415417bf02debb89508ba09c0ef603ce",
732+
"txHash": "0x504a050740554b6eba28b85a97927228e99da6f4ab6528203b479733cb3e7330"
733+
}
734+
},
735+
"DisputeManager": {
736+
"address": "0x4bf749ec68270027C5910220CEAB30Cc284c7BA2",
737+
"initArgs": [
738+
"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B",
739+
"0xE1FDD398329C6b74C14cf19100316f0826a492d3",
740+
"10000000000000000000000",
741+
"500000",
742+
"25000",
743+
"5000"
744+
],
745+
"creationCodeHash": "0x12bbdb6d1b1e703fbc45b202bb9aee69866520f80fab9361a4616b647a63ba1c",
746+
"runtimeCodeHash": "0x5901b97cd4a87bf10d7f0090368c12bc8c5e812260a74d733661c36f9fb407cd",
747+
"txHash": "0x4e219090dd93b2dade0b1c181db555c4eea225e737f71ba711b8828f6b98e005",
748+
"proxy": true,
749+
"implementation": {
750+
"address": "0xD86C8F0327494034F60e25074420BcCF560D5610",
751+
"creationCodeHash": "0xd44cf1eeca41b8639024fbbb548838682b21df9998042c8dafb82092e56a0c9c",
752+
"runtimeCodeHash": "0xc3920a53e0e021982936ed1b87c700751b617dd47860c62ab4b057405b42b45c",
753+
"txHash": "0x587fb69e30a382a2712660e637691afe4f35285cc74a4e9e9cc237ef09d33308"
754+
}
755+
},
756+
"EthereumDIDRegistry": {
757+
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
758+
"creationCodeHash": "0xeb3fe93a765b9287be8bc39838171c548fbb2d58dbf761f104abec8414eec9f8",
759+
"runtimeCodeHash": "0x2414a6ea1dc9b8e941ebccf45d00a42a3b07084847ceb959d3aa726b47d0481e",
760+
"txHash": "0x056e53876ba50f7c956a9e4df880cca7a2844b64c0b00ac261343fdc7cafd94f"
761+
}
587762
}
588763
}

Diff for: cli/cli.ts

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import { cliOpts } from './defaults'
1515
dotenv.config()
1616

1717
yargs
18+
.parserConfiguration({
19+
'short-option-groups': true,
20+
'camel-case-expansion': true,
21+
'dot-notation': true,
22+
'parse-numbers': false,
23+
'parse-positional-numbers': false,
24+
'boolean-negation': true,
25+
})
1826
.env(true)
1927
.option('a', cliOpts.addressBook)
2028
.option('m', cliOpts.mnemonic)

Diff for: cli/commands/contracts/gns.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const mintNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promis
9393
const gns = cli.contracts.GNS
9494

9595
logger.info(`Minting nSignal for ${graphAccount}-${subgraphNumber}...`)
96-
await sendTransaction(cli.wallet, gns, 'mintNSignal', [graphAccount, subgraphNumber, tokens])
96+
await sendTransaction(cli.wallet, gns, 'mintNSignal', [graphAccount, subgraphNumber, tokens, 0])
9797
}
9898

9999
export const burnNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {

Diff for: cli/commands/contracts/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yargs, { Argv, command } from 'yargs'
1+
import yargs, { Argv } from 'yargs'
22

33
import { curationCommand } from './curation'
44
import { serviceRegistryCommand } from './serviceRegistry'

Diff for: cli/commands/migrate.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { EtherSymbol } = constants
1616
const { formatEther } = utils
1717

1818
// Contracts are deployed in the order defined in this list
19-
const allContracts = [
19+
let allContracts = [
2020
'GraphProxyAdmin',
2121
'BancorFormula',
2222
'Controller',
@@ -34,6 +34,11 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
3434
const graphConfigPath = cliArgs.graphConfig
3535
const force = cliArgs.force
3636
const contractName = cliArgs.contract
37+
const chainId = cli.chainId
38+
39+
if (chainId == 1337) {
40+
allContracts = ['EthereumDIDRegistry', ...allContracts]
41+
}
3742

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

Diff for: cli/commands/protocol/get.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ export const gettersList = {
3030
'disputes-arbitrator': { contract: 'DisputeManager', name: 'arbitrator' },
3131
'disputes-minimum-deposit': { contract: 'DisputeManager', name: 'minimumDeposit' },
3232
'disputes-reward-percentage': { contract: 'DisputeManager', name: 'fishermanRewardPercentage' },
33-
'disputes-slashing-percentage': { contract: 'DisputeManager', name: 'slashingPercentage' },
3433
// Epochs
3534
'epochs-length': { contract: 'EpochManager', name: 'epochLength' },
3635
'epochs-current': { contract: 'EpochManager', name: 'currentEpoch' },
3736
// Rewards
3837
'rewards-issuance-rate': { contract: 'RewardsManager', name: 'issuanceRate' },
38+
'subgraph-availability-oracle': {
39+
contract: 'RewardsManager',
40+
name: 'subgraphAvailabilityOracle',
41+
},
3942
// GNS
4043
'gns-bonding-curve': { contract: 'GNS', name: 'bondingCurve' },
4144
'gns-owner-tax-percentage': { contract: 'GNS', name: 'ownerTaxPercentage' },

Diff for: cli/commands/protocol/set.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getContractAt, sendTransaction } from '../../network'
55
import { loadEnv, CLIArgs, CLIEnvironment } from '../../env'
66

77
import { ProtocolFunction } from './index'
8+
import { BigNumber } from 'ethers'
89

910
export const settersList = {
1011
// Staking
@@ -39,6 +40,10 @@ export const settersList = {
3940
'epochs-length': { contract: 'EpochManager', name: 'setEpochLength' },
4041
// Rewards
4142
'rewards-issuance-rate': { contract: 'RewardsManager', name: 'setIssuanceRate' },
43+
'subgraph-availability-oracle': {
44+
contract: 'RewardsManager',
45+
name: 'setSubgraphAvailabilityOracle',
46+
},
4247
// GNS
4348
'gns-owner-tax-percentage': { contract: 'GNS', name: 'setOwnerTaxPercentage' },
4449
// Token
@@ -77,10 +82,20 @@ export const setProtocolParam = async (cli: CLIEnvironment, cliArgs: CLIArgs): P
7782

7883
// Parse params
7984
const params = cliArgs.params.toString().split(',')
85+
let parsedParams = []
86+
for (const param of params) {
87+
try {
88+
const parsedParam = BigNumber.from(param)
89+
parsedParams.push(parsedParam.toNumber())
90+
} catch {
91+
parsedParams.push(param)
92+
}
93+
}
94+
logger.info(`params: ${parsedParams}`)
8095

8196
// Send tx
8297
const contract = getContractAt(fn.contract, addressEntry.address).connect(cli.wallet)
83-
await sendTransaction(cli.wallet, contract, fn.name, params)
98+
await sendTransaction(cli.wallet, contract, fn.name, parsedParams)
8499
}
85100

86101
export const setCommand = {

Diff for: cli/defaults.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Options } from 'yargs'
2-
import { Overrides, utils } from 'ethers'
2+
import { Overrides } from 'ethers'
33

44
export const local = {
55
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',

Diff for: cli/helpers.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ export const pinMetadataToIPFS = async (
5252
if (type == 'subgraph') {
5353
metadata = jsonToSubgraphMetadata(JSON.parse(fs.readFileSync(__dirname + path).toString()))
5454
logger.info('Meta data:')
55-
logger.info(' Subgraph Description: ', metadata.description)
56-
logger.info(' Subgraph Display Name: ', metadata.displayName)
57-
logger.info(' Subgraph Image: ', metadata.image)
58-
logger.info(' Subgraph Code Repository: ', metadata.codeRepository)
59-
logger.info(' Subgraph Website: ', metadata.website)
55+
logger.info(` Subgraph Description: ${metadata.description}`)
56+
logger.info(`Subgraph Display Name: ${metadata.displayName}`)
57+
logger.info(` Subgraph Image: ${metadata.image}`)
58+
logger.info(` Subgraph Code Repository: ${metadata.codeRepository}`)
59+
logger.info(` Subgraph Website: ${metadata.website}`)
6060
} else if (type == 'version') {
6161
metadata = jsonToVersionMetadata(JSON.parse(fs.readFileSync(__dirname + path).toString()))
6262
logger.info('Meta data:')
63-
logger.info(' Version Description: ', metadata.description)
64-
logger.info(' Version Label: ', metadata.label)
63+
logger.info(` Version Description: ${metadata.description}`)
64+
logger.info(` Version Label: ${metadata.label}`)
6565
}
6666
}
6767

Diff for: graph.config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ contracts:
6262
init:
6363
controller: "${{Controller.address}}"
6464
bondingCurve: "${{BancorFormula.address}}"
65-
didRegistry: "0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"
65+
didRegistry: "${{EthereumDIDRegistry.address}}"
6666
calls:
6767
- fn: "approveAll"
6868
Staking:
@@ -89,4 +89,4 @@ contracts:
8989
proxy: true
9090
init:
9191
controller: "${{Controller.address}}"
92-
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
92+
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)

Diff for: hardhat.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,16 @@ const config: HardhatUserConfig = {
119119
loggingEnabled: false,
120120
gas: 12000000,
121121
gasPrice: 'auto',
122+
initialBaseFeePerGas: 0,
122123
blockGasLimit: 12000000,
123124
accounts: {
124125
mnemonic: DEFAULT_TEST_MNEMONIC,
125126
},
127+
mining: {
128+
auto: true,
129+
interval: 30000,
130+
},
131+
hardfork: 'london',
126132
},
127133
ganache: {
128134
chainId: 1337,

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"deploy": "scripts/predeploy && hardhat migrate",
9494
"deploy-ganache": "yarn deploy -- --force",
9595
"deploy-ganache-manual": "yarn deploy -- --network ganache --force",
96+
"deploy-hardhat": "yarn deploy -- --network hardhat --force",
9697
"deploy-rinkeby": "yarn deploy -- --force --network rinkeby",
9798
"predeploy": "scripts/predeploy",
9899
"test": "scripts/test",

Diff for: test/staking/delegation.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ describe('Staking::Delegation', () => {
447447
})
448448

449449
it('should undelegate properly when multiple delegations', async function () {
450+
this.timeout(60000) // increase timeout for test runner
451+
450452
// Use long enough epochs to avoid jumping to the next epoch involuntarily on our test
451453
await epochManager.setEpochLength(toBN((60 * 60) / 15))
452454

0 commit comments

Comments
 (0)