-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add script and task for migration #208
Merged
Merged
Changes from 44 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
e420562
add script and task for migration
0xCardinalError 0339c93
add task and hre for ethers
0xCardinalError b95b2cd
update info on migration
0xCardinalError ede46cd
Merge branch 'master' of https://github.com/ethersphere/storage-incen…
0xCardinalError 89a4480
do it on main fork
0xCardinalError 0f679c2
add migration to root, add it to task, working copy of migration
0xCardinalError f9000a3
add tyep check
0xCardinalError 972f675
remove erc20 transfers
0xCardinalError a4e1a4d
remove tests for ERC20 as we will not be transfering it
0xCardinalError 4b4df09
Merge branch 'master' of https://github.com/ethersphere/storage-incen…
0xCardinalError b34717b
install tenderly hh plugin for verifications
0xCardinalError 17c43a5
add tenderly config and init data
0xCardinalError 362bdde
add tenderly configs
0xCardinalError 68ce454
final config for mainfork and tenderly
0xCardinalError 4ba73da
move migrations to folder
0xCardinalError 1452c6d
fix stamp scripts, remove tenderly as it breaks tests
0xCardinalError d8784a6
remove flat
0xCardinalError e2e5ec2
remove tenderly as it breaks tests
0xCardinalError 4c1abb0
add steps
0xCardinalError e650ddb
refine steps
0xCardinalError a1b1257
add current command
0xCardinalError b360ddb
change end
0xCardinalError c8f88fc
block info
0xCardinalError 872c670
add snapshot from current state
0xCardinalError 40e2923
add stamp var
0xCardinalError 821173d
Replace mainfork with tenderly as in that case verifications will work
0xCardinalError 6b1ef6f
disable verification
0xCardinalError 097f3fe
add batch script
0xCardinalError c3b446a
working bulk migration script
0xCardinalError d05f6f7
latest migration test
0xCardinalError 31cb676
add comments and info
0xCardinalError 504b34e
add some automations for tenderly fork deployments
0xCardinalError 982a218
refactor tenderly with mainnet
0xCardinalError e5ef1eb
modify tenderly parts for proper workflow
0xCardinalError 789ee96
make oracle unpaused by default
0xCardinalError 79bf910
tags
0xCardinalError 35b7f11
cleanup messages, try again with non signer to set roles
0xCardinalError 6d3f92b
remove simulation as it breaks deployment
0xCardinalError 16eddd1
cleanup tenderly
0xCardinalError 7f66d06
proper order for reset script
0xCardinalError 7f970e9
comment out tenderly as it breaks tests
0xCardinalError b5d868e
fix lint
0xCardinalError b80d42e
reset fix for TS
0xCardinalError 250f212
add pause so test doesnt fail
0xCardinalError e02b4c1
Merge branch 'master' of github.com:ethersphere/storage-incentives in…
0xCardinalError 540aebb
add all the changes per review
0xCardinalError 0397b16
fix type assertion
0xCardinalError f8ffa3a
cleanup more
0xCardinalError 172b45c
migration of goerlis stamps
0xCardinalError 930d1cc
add fail event for batch loop so we get info but continue looping
0xCardinalError 0c22ae4
change const
0xCardinalError aa47989
unionize migration scripts
0xCardinalError 68f3904
use id
0xCardinalError 63b9985
change event name
0xCardinalError 8a7305c
Set 70 as sweet spot, add buffer for gas limit
0xCardinalError e12092e
add buffer for single batch
0xCardinalError b003db8
change names
0xCardinalError 122a7a4
create admin role withs script
0xCardinalError ba980b4
add fetch and bump up newer ethers
0xCardinalError 1221324
use older ethers version
0xCardinalError 0dfd1df
add todos
0xCardinalError 000b851
remove fetch test
0xCardinalError 20abebe
add admin role check to bulk batch
0xCardinalError ce2e319
add new contracts deployment
0xCardinalError ff37a16
100 is mainnet swarm id
0xCardinalError 487cd78
it is 1 after all
0xCardinalError 4a776ec
latest batches and import
0xCardinalError File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ contractsInfo.json | |
|
||
# Gas reports | ||
gas-report.txt | ||
|
||
# Tenderly | ||
tenderly.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// BEFORE running the deployment reset the environment with this command/script | ||
// hh run scripts/tenderly_reset.ts --network tenderly | ||
|
||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, ethers, network }) { | ||
const { log, get } = deployments; | ||
let token = null; | ||
|
||
// We ONLY use already deployed token for MAINNET FORKS | ||
if (!(token = await get('Token'))) { | ||
// we have problem as there is not token, error out | ||
} else { | ||
log('Using already deployed Token at', token.address); | ||
} | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['token', 'preparation']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, log, get } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const token = await get('Token'); | ||
const argsStamp = [token.address, 16]; | ||
|
||
await deploy('PostageStamp', { | ||
from: deployer, | ||
args: argsStamp, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['postageStamp', 'contracts']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, get, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const args = [(await get('PostageStamp')).address]; | ||
await deploy('PriceOracle', { | ||
from: deployer, | ||
args: args, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['oracle', 'contracts']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network, ethers }) { | ||
const { deploy, log, get, read } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const swarmNetworkID = networkConfig[network.name]?.swarmNetworkId; | ||
const token = await get('Token'); | ||
let staking = null; | ||
|
||
if (!(staking = await get('StakeRegistry'))) { | ||
} else { | ||
log('Using already deployed Staking at', staking.address); | ||
} | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['staking', 'contracts']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, get, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const args = [ | ||
(await get('StakeRegistry')).address, | ||
(await get('PostageStamp')).address, | ||
(await get('PriceOracle')).address, | ||
]; | ||
|
||
await deploy('Redistribution', { | ||
from: deployer, | ||
args: args, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['redistribution', 'contracts']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting PostageStamps roles'); | ||
|
||
const priceOracleRole = await read('PostageStamp', 'PRICE_ORACLE_ROLE'); | ||
await execute('PostageStamp', { from: deployer }, 'grantRole', priceOracleRole, (await get('PriceOracle')).address); | ||
|
||
const redistributorRole = await read('PostageStamp', 'REDISTRIBUTOR_ROLE'); | ||
await execute( | ||
'PostageStamp', | ||
{ from: deployer }, | ||
'grantRole', | ||
redistributorRole, | ||
( | ||
await get('Redistribution') | ||
).address | ||
); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['postageStamp_roles', 'roles']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({}) { | ||
// Currently we dont need to set any roles on Redistribution contract, they are all set on Constructor | ||
// This is used just as placeholder for future possible settings | ||
}; | ||
|
||
export default func; | ||
func.tags = ['redistribution_roles', 'roles']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting Staking roles'); | ||
// As currently we are reusing staking, and there is multisig wallet as ADMIN | ||
// we either need to add deployer temporarly as ADMIN or do this manually over multisig | ||
|
||
const redisAddress = (await get('Redistribution')).address; | ||
const adminRole = await read('StakeRegistry', 'DEFAULT_ADMIN_ROLE'); | ||
|
||
if (await read('StakeRegistry', { from: deployer }, 'hasRole', adminRole, deployer)) { | ||
const redisRole = await read('StakeRegistry', 'REDISTRIBUTOR_ROLE'); | ||
await execute('StakeRegistry', { from: deployer }, 'grantRole', redisRole, redisAddress); | ||
} else { | ||
log( | ||
'DEPLOYER NEEDS TO HAVE ADMIN ROLE TO ASSIGN THE REDISTRIBUTION ROLE, PLEASE ASSIGN IT AND/OR GRANT ROLE MANUALLY' | ||
); | ||
} | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['staking_roles', 'roles']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting Oracles roles'); | ||
|
||
const redisAddress = (await get('Redistribution')).address; | ||
|
||
const updaterRole = await read('PriceOracle', 'PRICE_UPDATER_ROLE'); | ||
await execute('PriceOracle', { from: deployer }, 'grantRole', updaterRole, redisAddress); | ||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['staking_roles', 'roles']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
import * as fs from 'fs'; | ||
|
||
interface DeployedContract { | ||
abi: Array<unknown>; | ||
bytecode: string; | ||
address: string; | ||
block: number; | ||
url: string; | ||
} | ||
|
||
interface DeployedData { | ||
chainId: number; | ||
swarmNetworkId: number; | ||
contracts: { | ||
postageStamp: DeployedContract; | ||
redistribution: DeployedContract; | ||
staking: DeployedContract; | ||
priceOracle: DeployedContract; | ||
bzzToken: DeployedContract; | ||
}; | ||
} | ||
|
||
const func: DeployFunction = async function ({ deployments, network, config }) { | ||
const { get, log } = deployments; | ||
|
||
const deployedData = { | ||
chainId: network.config.chainId, | ||
swarmNetworkId: networkConfig[network.name]?.swarmNetworkId || 1, | ||
contracts: { | ||
bzzToken: {} as DeployedContract, | ||
staking: {} as DeployedContract, | ||
postageStamp: {} as DeployedContract, | ||
priceOracle: {} as DeployedContract, | ||
redistribution: {} as DeployedContract, | ||
}, | ||
} as DeployedData; | ||
|
||
async function writeResult(deployedData: DeployedData) { | ||
let fileName = ''; | ||
|
||
if (fileName.length == 0 || !fs.existsSync(fileName)) { | ||
fileName = network.name + '_deployed.json'; | ||
} | ||
|
||
fs.writeFileSync(fileName, JSON.stringify(deployedData, null, '\t') + '\n'); | ||
log('Data saved to ' + fileName); | ||
} | ||
|
||
const tokenContract = await get('Token'); | ||
const stampsContract = await get('PostageStamp'); | ||
const oracleContract = await get('PriceOracle'); | ||
const stakingContract = await get('StakeRegistry'); | ||
const redisContract = await get('Redistribution'); | ||
const browserURL = config.etherscan.customChains.find((chain) => chain.network === network.name)?.urls.browserURL; | ||
|
||
// Token data | ||
deployedData['contracts']['bzzToken']['abi'] = tokenContract.abi; | ||
deployedData['contracts']['bzzToken']['bytecode'] = tokenContract.bytecode ? tokenContract.bytecode : ''; | ||
deployedData['contracts']['bzzToken']['address'] = tokenContract.address; | ||
deployedData['contracts']['bzzToken']['block'] = | ||
tokenContract.receipt && tokenContract.receipt.blockNumber ? tokenContract.receipt.blockNumber : 16514506; | ||
deployedData['contracts']['bzzToken']['url'] = browserURL + tokenContract.address; | ||
|
||
// PostageStamp data | ||
deployedData['contracts']['postageStamp']['abi'] = stampsContract.abi; | ||
deployedData['contracts']['postageStamp']['bytecode'] = stampsContract.bytecode ? stampsContract.bytecode : ''; | ||
deployedData['contracts']['postageStamp']['address'] = stampsContract.address; | ||
deployedData['contracts']['postageStamp']['block'] = | ||
stampsContract.receipt && stampsContract.receipt.blockNumber ? stampsContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['postageStamp']['url'] = browserURL + stampsContract.address; | ||
|
||
// Redistribution data | ||
deployedData['contracts']['redistribution']['abi'] = redisContract.abi; | ||
deployedData['contracts']['redistribution']['bytecode'] = redisContract.bytecode ? redisContract.bytecode : ''; | ||
deployedData['contracts']['redistribution']['address'] = redisContract.address; | ||
deployedData['contracts']['redistribution']['block'] = | ||
redisContract.receipt && redisContract.receipt.blockNumber ? redisContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['redistribution']['url'] = browserURL + redisContract.address; | ||
|
||
// Staking data | ||
deployedData['contracts']['staking']['abi'] = stakingContract.abi; | ||
deployedData['contracts']['staking']['bytecode'] = stakingContract.bytecode ? stakingContract.bytecode : ''; | ||
deployedData['contracts']['staking']['address'] = stakingContract.address; | ||
deployedData['contracts']['staking']['block'] = | ||
stakingContract.receipt && stakingContract.receipt.blockNumber ? stakingContract.receipt.blockNumber : 25527075; | ||
deployedData['contracts']['staking']['url'] = browserURL + stakingContract.address; | ||
|
||
// Oracle data | ||
deployedData['contracts']['priceOracle']['abi'] = oracleContract.abi; | ||
deployedData['contracts']['priceOracle']['bytecode'] = oracleContract.bytecode ? oracleContract.bytecode : ''; | ||
deployedData['contracts']['priceOracle']['address'] = oracleContract.address; | ||
deployedData['contracts']['priceOracle']['block'] = | ||
oracleContract.receipt && oracleContract.receipt.blockNumber ? oracleContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['priceOracle']['url'] = browserURL + oracleContract.address; | ||
|
||
await writeResult(deployedData); | ||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['local']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, network }) { | ||
const { log } = deployments; | ||
|
||
// We verified all the contracts automtically with setup and Hardhat plugin, for any additional changes look here | ||
// https://docs.tenderly.co/monitoring/smart-contract-verification/verifying-contracts-using-the-tenderly-hardhat-plugin/automatic-contract-verification | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['verify']; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use some import from already existing deployment scripts that do the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. we should, not have gotten to that yet.