Skip to content

Commit c406510

Browse files
samt1803jtakalai
andauthored
Eth 138 migrate streams to ocr (#190)
* added bulk add stream function and test to migrate streams from core-api * added first draft of script, parsing tsv file with all streams, checking validity of ids * further into migration script, nonce is issue * migrate script is working with manual nonces * adding an array of permissions per stream into registry ([][] not supported by thegraph, need to remove the method from abi) * migrate script does not spam mempool and saves progress to disk * added stream data clean script * refactores migration script to use new cleanded up data * little linting * detect stuck transactions, resend them with higher gasPrice working * renaming of permission attributes cherrypicked from master * reset progress file * fixed possible timing async issue * created new package with migration, that can connect to the sqldb and uses the contracts sources from the other package to talk to the chain * added graphql client * graphql query not working completely yet * refactoring migration logic * further writing logic for migration * continue implementation and refactor of migration script * refactor migration algorithm * seems to work as intended * code cleanup, adding better log outputs * resolve dependency cycle, some renaming * small fix; gasprice streategy; permissions are migrated in chunks of 20 * fix pagination * add correct metadata from the database * script is writing back migrated_at timestamps to the DB * looping migration * some cleanup * some cleanup, loop-running without self-referencing setTimeouts * remove setup of migrator role * production endpoint settings * moved configs to .env file/env variables * replacement logic for transactions, where they are replaced with higher gas ones * debug code cleanup * increase timeout on stuck transaction to 30 seconds * remove one debug output * add one debug output * change of gas increase, some improvements in error handling, env variables, log outputs * fixed bug with number addition not working in classes in typescript * better error handling * fix: bugfix with permissions, where all their streams are filtered out in the graphQL query * fix linting * fix: fact that migrationscript has no tests should not throw error * cleanup * fix: lint * doc: add comments * refactor: mostly renaming and adding comments while reviewing the PR * fix: rpc URL * build: remove IDE file * Revert "refactor: mostly renaming and adding comments" This reverts commit fc0475c. Co-authored-by: Juuso Takalainen <[email protected]>
1 parent 436ff25 commit c406510

21 files changed

+37335
-52
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/packages/smartcontracts/artifacts/
66
/packages/smartcontracts/typechain/
77
/packages/smartcontracts/.openzeppelin/
8+
/packages/brubeck-migration-script/artifacts
9+
/packages/brubeck-migration-script/typechain
810
/bin/
911
.DS_Store
1012
.idea

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
},
4747
"cwd": "${workspaceFolder}/packages/smartcontracts"
4848
},
49+
{
50+
"command": "npm run migration-run",
51+
"name": "Run migration",
52+
"request": "launch",
53+
"type": "node-terminal",
54+
"env": {
55+
"DEBUG": "*,-mocha:*"
56+
},
57+
"cwd": "${workspaceFolder}"
58+
},
4959
{
5060
"type": "node",
5161
"request": "launch",

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"graph2_copyInfo": "./scripts/copyAbis.sh && ./scripts/generateYaml.sh",
1717
"graph3_build": "npm run doAll --workspace=streamregistry-thegraph-subgraph",
1818
"graph": "npm run graph1_build && npm run graph2_copyInfo && npm run graph3_build",
19-
"e2etest": "npm run e2etest --workspace=smartcontracts"
19+
"e2etest": "npm run e2etest --workspace=smartcontracts",
20+
"migration-build": "npm run build -w=brubeck-migration-script",
21+
"migration-run": "npm run migration -w=brubeck-migration-script"
2022
},
2123
"devDependencies": {
2224
"@types/chai": "4.3.0",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DB_HOST="localhost"
2+
DB_USER="root"
3+
DB_PASSWORD="password"
4+
DB_NAME="core_test"
5+
6+
PAUSE_BETWEEN_MIGRATIONS_MS="5000"
7+
THE_GRAPH_URL="http://10.200.10.1:8000/subgraphs/name/streamr-dev/network-contracts"
8+
CHAIN_NODE_URL="http://localhost:8546"
9+
ADMIN_PRIVATEKEY="0x5e98cce00cff5dea6b454889f359a4ec06b9fa6b88e9d69b86de8e1c81887da0"
10+
MIGRATOR_PRIVATEKEY="0x000000000000000000000000000000000000000000000000000000000000000c"
11+
STREAMREGISTRY_ADDRESS="0x6cCdd5d866ea766f6DF5965aA98DeCCD629ff222"
12+
13+
GASPRICE_INCREASE_PERCENT="10"
14+
GASPRICE_INCREASE_TIMEOUT_MS="40000"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DB_HOST="localhost"
2+
DB_USER="root"
3+
DB_PASSWORD=""
4+
DB_NAME="streamr_prod"
5+
6+
PAUSE_BETWEEN_MIGRATIONS_MS="30000"
7+
THE_GRAPH_URL="https://api.thegraph.com/subgraphs/name/streamr-dev/streams"
8+
CHAIN_NODE_URL="https://polygon-rpc.com/"
9+
STREAMREGISTRY_ADDRESS="0x0D483E10612F327FC11965Fc82E90dC19b141641"
10+
11+
GASPRICE_INCREASE_PERCENT="10"
12+
GASPRICE_INCREASE_TIMEOUT_MS="40000"

packages/brubeck-migration-script/contracts/emptyFolderPlaceholder

Whitespace-only changes.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// import { task } from 'hardhat/config'
2+
// import '@nomiclabs/hardhat-waffle'
3+
import 'hardhat-typechain'
4+
// import { HardhatUserConfig } from 'hardhat/types'
5+
// import 'hardhat-deploy'
6+
import 'hardhat-deploy-ethers'
7+
require('@openzeppelin/hardhat-upgrades')
8+
9+
// require('solidity-coverage')
10+
require('hardhat-dependency-compiler')
11+
12+
// This is a sample Hardhat task. To learn how to create your own go to
13+
// https://hardhat.org/guides/create-task.html
14+
// task('accounts', 'Prints the list of accounts', async (args, hre) => {
15+
// const accounts = await hre.ethers.getSigners()
16+
// // eslint-disable-next-line no-restricted-syntax
17+
// for (const account of accounts) {
18+
// // eslint-disable-next-line no-console
19+
// console.log(account.address)
20+
// }
21+
// })
22+
23+
// TODO: add this to the hardhat-dependency-compiler repo as a pull request or whatever
24+
// declare module 'hardhat/types/config' {
25+
// interface HardhatUserConfig {
26+
// dependencyCompiler?: any;
27+
// }
28+
// }
29+
30+
// You need to export an object to set up your config
31+
// Go to https://hardhat.org/config/ to learn more
32+
33+
module.exports = {
34+
35+
defaultNetwork: 'hardhat',
36+
networks: {
37+
hardhat: {
38+
gas: 12000000,
39+
blockGasLimit: 0x1fffffffffffff,
40+
allowUnlimitedContractSize: true
41+
},
42+
localsidechain: {
43+
chainId: 8997,
44+
url: 'http://10.200.10.1:8546',
45+
accounts: ['0x5e98cce00cff5dea6b454889f359a4ec06b9fa6b88e9d69b86de8e1c81887da0']
46+
},
47+
polygonTestMumbai1: {
48+
chainId: 80001,
49+
url: 'https://rpc-mumbai.maticvigil.com',
50+
// accounts: ['0x4059de411f15511a85ce332e7a428f36492ab4e87c7830099dadbf130f1896ae']
51+
},
52+
polygonTestMumbai2: {
53+
chainId: 80001,
54+
url: 'https://matic-mumbai.chainstacklabs.com/',
55+
// accounts: ['0x4059de411f15511a85ce332e7a428f36492ab4e87c7830099dadbf130f1896ae']
56+
},
57+
polygonMainnet: {
58+
chainId: 137,
59+
// url: 'https://polygon-rpc.com',
60+
url: 'https://wild-dark-thunder.matic.quiknode.pro/08b0fa6254499defc975c381ee21777cb197fac5/',
61+
}
62+
},
63+
dependencyCompiler: {
64+
paths: [
65+
'smartcontracts/contracts/StreamRegistry/StreamRegistryV3.sol'
66+
],
67+
},
68+
solidity: {
69+
compilers: [
70+
{
71+
version: '0.8.9',
72+
settings: {
73+
optimizer: {
74+
enabled: true,
75+
runs: 100,
76+
},
77+
},
78+
}],
79+
},
80+
typechain: {
81+
outDir: './typechain',
82+
target: 'ethers-v5',
83+
}
84+
}

0 commit comments

Comments
 (0)