-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add upgrade scripts for chain state contract for withdrawal finalization #402
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
Open
PraneshASP
wants to merge
10
commits into
main
Choose a base branch
from
praneshasp/400-update-withdrawal-time
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b5e7e07
deploy: add devent upgrade script for chainstate contract
PraneshASP 8deb07b
deploy: add testnet upgrade script for chainstate contract
PraneshASP 57313d0
chore: fmt
PraneshASP eec78a5
chore: remove upgradeProxy() for devnet
PraneshASP 7ca0ae0
chore: minor cleanup and logging
PraneshASP 3191ce7
deploy: upload devnet artifacts
PraneshASP 5468c95
build: fix pnpm audit error in CI (#403)
DefiCake fcf68b6
deploy: upload testnet artifacts
PraneshASP 40eebaf
chore: changeset
PraneshASP c6c00c8
Merge branch 'praneshasp/400-update-withdrawal-time' of https://githu…
PraneshASP 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
53 changes: 53 additions & 0 deletions
53
packages/solidity-contracts/deploy/devnet/019.chain_state_time_finalize_upgrade.ts
This file contains hidden or 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,53 @@ | ||
import type { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import type { DeployFunction } from 'hardhat-deploy/dist/types'; | ||
|
||
import { FuelChainState__factory as FuelChainState } from '../../typechain'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { | ||
ethers, | ||
upgrades: { upgradeProxy, erc1967 }, | ||
deployments: { get, save }, | ||
} = hre; | ||
const [deployer] = await ethers.getSigners(); | ||
|
||
const fuelChainState = await get('FuelChainState'); | ||
|
||
const BLOCKS_PER_COMMIT_INTERVAL = 10800; | ||
const TIME_TO_FINALIZE = 3600 * 24; | ||
const COMMIT_COOLDOWN = TIME_TO_FINALIZE; | ||
|
||
const constructorArgs = [ | ||
TIME_TO_FINALIZE, | ||
BLOCKS_PER_COMMIT_INTERVAL, | ||
COMMIT_COOLDOWN, | ||
]; | ||
const contract = await upgradeProxy( | ||
fuelChainState.address, | ||
new FuelChainState(deployer), | ||
{ | ||
unsafeAllow: ['constructor'], | ||
constructorArgs, | ||
} | ||
); | ||
const address = await contract.getAddress(); | ||
|
||
const implementation = await erc1967.getImplementationAddress(address); | ||
|
||
console.log('Upgraded FuelChainState at', address); | ||
await save('FuelChainState', { | ||
address, | ||
abi: [...FuelChainState.abi], | ||
implementation, | ||
linkedData: { | ||
constructorArgs, | ||
factory: 'FuelChainState', | ||
}, | ||
}); | ||
|
||
return true; | ||
}; | ||
|
||
func.tags = ['chain_state_time_finalize_upgrade']; | ||
func.id = 'chain_state_time_finalize_upgrade'; | ||
export default func; |
59 changes: 59 additions & 0 deletions
59
packages/solidity-contracts/deploy/testnet/020.chain_state_time_finalize_upgrade.ts
This file contains hidden or 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,59 @@ | ||
import type { TransactionResponse } from 'ethers'; | ||
import type { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import type { DeployFunction } from 'hardhat-deploy/dist/types'; | ||
|
||
import { FuelChainState__factory as FuelChainState } from '../../typechain'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { | ||
upgrades: { prepareUpgrade }, | ||
deployments: { save }, | ||
} = hre; | ||
|
||
const contractDeployment = await hre.deployments.get('FuelChainState'); | ||
|
||
const BLOCKS_PER_COMMIT_INTERVAL = 10800; | ||
const TIME_TO_FINALIZE = 3600 * 24; | ||
const COMMIT_COOLDOWN = TIME_TO_FINALIZE; | ||
|
||
const constructorArgs = [ | ||
TIME_TO_FINALIZE, | ||
BLOCKS_PER_COMMIT_INTERVAL, | ||
COMMIT_COOLDOWN, | ||
]; | ||
|
||
const factory = await hre.ethers.getContractFactory('FuelChainState'); | ||
|
||
const response = (await prepareUpgrade(contractDeployment.address, factory, { | ||
kind: 'uups', | ||
constructorArgs, | ||
getTxResponse: true, | ||
redeployImplementation: 'always', | ||
})) as TransactionResponse; | ||
|
||
const receipt = await hre.ethers.provider.getTransactionReceipt( | ||
response.hash | ||
); | ||
|
||
const implementation = receipt?.contractAddress ?? ''; | ||
|
||
if (implementation === '') | ||
throw new Error( | ||
`Upgrade proposal failed for FuelChainState proxy (${contractDeployment.address})` | ||
); | ||
|
||
await save('FuelChainState', { | ||
address: contractDeployment.address, | ||
abi: [...FuelChainState.abi], | ||
implementation, | ||
transactionHash: response.hash, | ||
linkedData: { | ||
constructorArgs, | ||
factory: 'FuelChainState', | ||
}, | ||
}); | ||
}; | ||
|
||
func.tags = ['prepareUpgrade_chain_state_time_finalize']; | ||
func.id = 'prepareUpgrade_chain_state_time_finalize'; | ||
export default func; |
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.
Uh oh!
There was an error while loading. Please reload this page.