Skip to content
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

deploy(REP4): v0.7.0 testnet #303

Merged
merged 131 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
6a3c8b8
restructure
nxqbao May 25, 2023
1924b70
add profile contract
nxqbao May 25, 2023
fb546f1
add storage log
nxqbao May 25, 2023
18ead5d
fix staking test
nxqbao May 25, 2023
2debf1a
fix fixture
nxqbao May 25, 2023
b798920
Revert "fix fixture"
nxqbao May 29, 2023
bae94dd
fix hardhat deploy path
nxqbao May 29, 2023
b857c57
fix deploy script
nxqbao May 29, 2023
5c29690
rollback initializerV1
nxqbao May 29, 2023
a149649
restructure profile contract
nxqbao May 29, 2023
b3a654c
fix fixture
nxqbao May 29, 2023
7d0782f
fix dependent test
nxqbao May 29, 2023
b36bc50
fix dependent test
nxqbao May 29, 2023
36173a0
fix: profile execApply
nxqbao May 29, 2023
6e53384
fix hardhat deploy src path
nxqbao May 29, 2023
383a203
rollback NON_VALIDATOR slash type
nxqbao May 29, 2023
56ba919
follow new code convention
nxqbao Jun 7, 2023
c77b82e
feat: support change admin address
nxqbao Jun 7, 2023
9cbfaaa
fix: inheritance graph
nxqbao Jun 8, 2023
7d19da3
fix: fix test setup
nxqbao Jun 8, 2023
387748e
add dev comment
nxqbao Jun 9, 2023
b1a3c99
fix rebase issue
nxqbao Jun 13, 2023
16ae502
rename for convention
nxqbao Jun 13, 2023
622cbbe
add enum for custom error
nxqbao Jun 13, 2023
99fdaca
udvt TPoolId
nxqbao Jun 13, 2023
7b424ac
Revert "udvt TPoolId"
nxqbao Jun 13, 2023
df55f31
distinguish poolId vs consensus
nxqbao Jun 14, 2023
c5eb936
declare TPoolId type
nxqbao Jun 14, 2023
359c86c
remove mockup contract
nxqbao Jun 15, 2023
46e5a49
remove bridge operator change method
nxqbao Jun 15, 2023
6bdb1ce
rename interface param
nxqbao Jun 15, 2023
9a9530c
remove comment
nxqbao Jun 15, 2023
daed9f9
refactor
nxqbao Jun 15, 2023
7fd337b
revert casting in coinbase
nxqbao Jun 15, 2023
a763dd7
Remove TPoolId. Using TConsensus.
nxqbao Jun 16, 2023
ca2bae8
fix test
nxqbao Jun 16, 2023
be65d5c
remove public vars
nxqbao Jun 16, 2023
034516b
remove more public vars
nxqbao Jun 16, 2023
7fc8fb1
remove redundant code
nxqbao Jun 16, 2023
a309710
wrap all external method to TConsensus type
nxqbao Jun 18, 2023
48e35fb
fix config
nxqbao Jun 19, 2023
0382510
fix test init
nxqbao Jun 19, 2023
4086926
fix mock
nxqbao Jun 19, 2023
e8e6612
fix test
nxqbao Jun 20, 2023
648c40c
fix test
nxqbao Jun 20, 2023
dcad9f1
add comment
nxqbao Jun 20, 2023
75eef9c
fix helper
nxqbao Jun 21, 2023
5d118fe
restructure
nxqbao Jun 21, 2023
23eb77c
fix edge case
nxqbao Jun 21, 2023
e2496e7
fix conventions
nxqbao Jun 21, 2023
253c89b
add docs
nxqbao Jun 22, 2023
470e02e
fix: foundry config
nxqbao Jun 22, 2023
87d9b20
chore: fix conventions
nxqbao Jun 22, 2023
17bc08b
Merge branch 'dev' into feat/profile
nxqbao Jul 20, 2023
b46f849
fix: remove bridge voter
nxqbao Jul 20, 2023
6efa842
fix: change inheritance tree
nxqbao Jul 20, 2023
d40095a
Merge branch 'feat/fast-finality' into feat/profile
nxqbao Jul 21, 2023
d2e2bba
fix: fix test setup
nxqbao Jul 21, 2023
06b1036
Merge branch 'feat/bridge-admin-rebase' into feat/profile
nxqbao Jul 21, 2023
cd91cdf
fix test after merging
nxqbao Jul 21, 2023
dfb0913
chore: add TODO tag
nxqbao Jul 24, 2023
69bad65
tmp disable forge test
nxqbao Jul 24, 2023
e6c0ea1
Merge branch 'testnet' into feat/profile
nxqbao Sep 13, 2023
18e4704
fix fixture
nxqbao Sep 13, 2023
7a0799f
Merge branch 'testnet' into feat/profile
nxqbao Sep 13, 2023
68581db
update ci
nxqbao Sep 13, 2023
207ed04
Continue merge branch 'testnet' into feat/profile
nxqbao Sep 13, 2023
022ccd1
fix test setup
nxqbao Sep 13, 2023
69e2555
fix more test setup
nxqbao Sep 13, 2023
134c40a
fix test
nxqbao Sep 15, 2023
8502f66
fix test & improve conf test
nxqbao Sep 15, 2023
7ef092e
refactor initializer
nxqbao Sep 15, 2023
8bd8f49
apply initializer for test suites
nxqbao Sep 15, 2023
cf1b5cb
fix fast finality test
nxqbao Sep 15, 2023
a49cb6c
fix initializers
nxqbao Sep 15, 2023
84bfe67
Merge branch 'testnet' into feat/profile
nxqbao Sep 25, 2023
83c1646
Merge branch 'release/v0.7.0' into feat/profile
nxqbao Oct 31, 2023
9deed7d
chore: resolve conflict
nxqbao Oct 31, 2023
983b747
feat(Profile): remove unused method, fix execApplyCandidate
nxqbao Oct 31, 2023
5e7aa25
feat(Profile, Staking): require pubkey at apply candidate, fix init test
nxqbao Oct 31, 2023
87e582e
test(Profile): fix other dependent tests
nxqbao Oct 31, 2023
a4699ef
chore: fix test
nxqbao Nov 1, 2023
ef2be4c
feat(ValidatorSet): recover slot shifted
nxqbao Nov 1, 2023
584236c
fix(Profile): cherry-pick fix from 'test/feat/profile'
nxqbao Nov 2, 2023
c95a4a3
fix(SlashFastFinality): fix wrapper for consensus
nxqbao Nov 2, 2023
7c92992
chore: resolve low-level call warning
nxqbao Nov 2, 2023
f60e927
temp(*): rename to cid, pid, _shadowed**
nxqbao Nov 2, 2023
d7793fb
feat(ValidatorSet): cached admin
nxqbao Nov 2, 2023
2682fa2
feat(Profile, ValidatorSet): handle execChangeAdminAddress
nxqbao Nov 2, 2023
285d700
feat(Staking): rename admin to `__shadowPoolAdmin`
nxqbao Nov 2, 2023
1b9a39e
feat(Profile): handle change treasury, fix missing rename
nxqbao Nov 2, 2023
cd99aa7
chore(Validator): rename to *ById suffix
nxqbao Nov 3, 2023
f5ac24b
chore: rename `_convert*C2P`
nxqbao Nov 3, 2023
7445b93
chore(Validator): remove old version contract
nxqbao Nov 3, 2023
1cf578c
chore(docs): write natspecs doc for struct
nxqbao Nov 3, 2023
f4603e6
chore(*): remove `_` for consistent var names
nxqbao Nov 3, 2023
79e50f1
chore(docs): NatSpecs for __css2cid
nxqbao Nov 3, 2023
639c372
chore: remove compiler warning
nxqbao Nov 3, 2023
c2aa6db
feat(TrustedOrg): handle change consensus for Trusted Org
nxqbao Nov 3, 2023
38bcac4
feat(SlashIndicator): remove code related to bridge
nxqbao Nov 3, 2023
1bdedd9
chore: clean up PR, remove unrelated files
nxqbao Nov 3, 2023
f4d3017
fix(Staking): fix inaccurate shifted gap
nxqbao Nov 3, 2023
a056da1
chore(ValidatorSet): consist interface
nxqbao Nov 3, 2023
359ddb8
chore(ValidatorSet, Staking): move callbacks to separate files
nxqbao Nov 3, 2023
564c31e
chore(ValidatorSet): refactor callbacks
nxqbao Nov 3, 2023
69248be
chore: remove log
nxqbao Nov 3, 2023
4e6a0ce
fix(TrustedOrg): remove onlyAdmin in initV2, fix test
nxqbao Nov 6, 2023
3235fa1
test: fix test after restrict not allowing rejoin in Profile
nxqbao Nov 6, 2023
59dee15
test: fix more test
nxqbao Nov 6, 2023
1fb67e5
feat(RoninTO): fix bug when change consensus in RoninTO
nxqbao Nov 6, 2023
9ae8a44
chore: fix rebase issue
nxqbao Nov 6, 2023
9e9a879
fix(RoninTO): delete deprecated storage
nxqbao Nov 7, 2023
240605f
chore: rename consensus to cid
nxqbao Nov 7, 2023
b6ab17b
fix(GovernanceAdmin): fix emergency exit typehash
nxqbao Nov 7, 2023
140dfdb
test(*): fix deprecated voter for test setup
nxqbao Nov 7, 2023
fca0888
feat(RoninTO): return address(0) for bridge voter
nxqbao Nov 7, 2023
5772afb
chore: fix typo
nxqbao Nov 7, 2023
a4c56c5
chore: fix deprecatedVoter in test
nxqbao Nov 7, 2023
c057690
feat(RoninTO): rename for consistency
nxqbao Nov 7, 2023
dd0fd85
feat(Validator): better handling emergency exit revert
nxqbao Nov 7, 2023
43eda58
feat(EmergencyExit): revert to original typehash
nxqbao Nov 8, 2023
61e439d
fix(Profile); rename check to require
nxqbao Nov 8, 2023
88d9239
feat: migrate registry for renounced candidates
nxqbao Nov 9, 2023
1a9650b
feat(Profile): fix migration
nxqbao Nov 9, 2023
96656ae
add script
nxqbao Nov 9, 2023
466c08a
fix: fix initialV2 script of Profile
nxqbao Nov 9, 2023
b9c58e6
fix: gasAmount of init Profile
nxqbao Nov 9, 2023
f5a57c2
fix: pass proxy to initialize
nxqbao Nov 9, 2023
83215e6
deploy: add artifacts
nxqbao Nov 9, 2023
0ca2b5e
chore: fix command
nxqbao Nov 9, 2023
ecab4d8
Merge branch 'release/v0.7.0' into deploy/v0.7.0-testnet
nxqbao Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
349 changes: 237 additions & 112 deletions deployments/ronin-testnet/MaintenanceLogic.json

Large diffs are not rendered by default.

352 changes: 261 additions & 91 deletions deployments/ronin-testnet/ProfileLogic.json

Large diffs are not rendered by default.

483 changes: 349 additions & 134 deletions deployments/ronin-testnet/RoninTrustedOrganizationLogic.json

Large diffs are not rendered by default.

284 changes: 196 additions & 88 deletions deployments/ronin-testnet/RoninValidatorSetLogic.json

Large diffs are not rendered by default.

509 changes: 151 additions & 358 deletions deployments/ronin-testnet/SlashIndicatorLogic.json

Large diffs are not rendered by default.

567 changes: 371 additions & 196 deletions deployments/ronin-testnet/StakingLogic.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions src/upgrades/REP-004--testnet/20231109-proposal-on-roninchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { Instance, ProposalSegmentArguments, defaultSegment, explorerUrl, proxyInterface } from '../upgradeUtils';
import { VoteType } from '../../script/proposal';
import { roninchainNetworks, stakingVestingConfig } from '../../configs/config';
import { network } from 'hardhat';
import {
Maintenance__factory,
Profile__factory,
RoninTrustedOrganization__factory,
RoninValidatorSet__factory,
Staking__factory,
} from '../../types';
import { ProposalDetailStruct } from '../../types/GovernanceAdmin';
import { Address } from 'hardhat-deploy/dist/types';

const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => {
if (!roninchainNetworks.includes(network.name!)) {
return;
}

const { execute } = deployments;
let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file
console.log('Governor:', governor);

const allDeployments: Instance = {
RoninGovernanceAdmin: await deployments.get('RoninGovernanceAdmin'),
RoninValidatorSetProxy: await deployments.get('RoninValidatorSetProxy'),
ProfileProxy: await deployments.get('ProfileProxy'),
StakingProxy: await deployments.get('StakingProxy'),
SlashIndicatorProxy: await deployments.get('SlashIndicatorProxy'),
MaintenanceProxy: await deployments.get('MaintenanceProxy'),
RoninTrustedOrganizationProxy: await deployments.get('RoninTrustedOrganizationProxy'),
StakingVestingProxy: await deployments.get('StakingVestingProxy'),
FastFinalityTrackingProxy: await deployments.get('FastFinalityTrackingProxy'),
RoninBridgeManager: await deployments.get('RoninBridgeManager'),

RoninValidatorSetLogic: await deployments.get('RoninValidatorSetLogic'),
ProfileLogic: await deployments.get('ProfileLogic'),
StakingLogic: await deployments.get('StakingLogic'),
SlashIndicatorLogic: await deployments.get('SlashIndicatorLogic'),
MaintenanceLogic: await deployments.get('MaintenanceLogic'),
RoninTrustedOrganizationLogic: await deployments.get('RoninTrustedOrganizationLogic'),
StakingVestingLogic: await deployments.get('StakingVestingLogic'),
FastFinalityTrackingLogic: await deployments.get('FastFinalityTrackingLogic'),
};

// Upgrade DPoS Contracts
// See `test/foundry/forking/REP-004/ChangeConsensusAddress.t.sol`
let proposalSegments = await upgradeDPoSContractSetProposalPart(allDeployments);

console.log(proposalSegments);

// return;

//////////////////////////////////////////
// Propose the proposal
//////////////////////////////////////////
const blockNumBefore = await ethers.provider.getBlockNumber();
const blockBefore = await ethers.provider.getBlock(blockNumBefore);
const timestampBefore = blockBefore.timestamp;
const proposalExpiryTimestamp = timestampBefore + 3600 * 24 * 10; // expired in 10 days

const tx = await execute(
'RoninGovernanceAdmin',
{ from: governor, log: true },
'proposeProposalForCurrentNetwork',
proposalExpiryTimestamp, // expiryTimestamp
[...proposalSegments.map((_) => _.target)], // targets
[...proposalSegments.map((_) => _.value)], // values
[...proposalSegments.map((_) => _.data)], // datas
[...proposalSegments.map((_) => _.gasAmount)], // gasAmounts
VoteType.For // ballot type
);
deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`);
};

async function upgradeDPoSContractSetProposalPart(instance: Instance): Promise<ProposalSegmentArguments[]> {
let segments: ProposalSegmentArguments[] = [];
// upgrade `Profile` and bump to V2
segments.push({
...defaultSegment,
gasAmount: 15_000_000,
target: instance.ProfileProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeToAndCall', [
instance.ProfileLogic!.address,
new Profile__factory().interface.encodeFunctionData('initializeV2', [
instance.StakingProxy!.address,
instance.RoninTrustedOrganizationProxy?.address,
]),
]),
});

// upgrade `Staking` and bump to V3
segments.push({
...defaultSegment,
target: instance.StakingProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeToAndCall', [
instance.StakingLogic!.address,
new Staking__factory().interface.encodeFunctionData('initializeV3', [instance.ProfileProxy!.address]),
]),
});

// upgrade `RoninValidatorSet` and bump to V4
segments.push({
...defaultSegment,
target: instance.RoninValidatorSetProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeToAndCall', [
instance.RoninValidatorSetLogic?.address,
new RoninValidatorSet__factory().interface.encodeFunctionData('initializeV4', [instance.ProfileProxy!.address]),
]),
});

// upgrade `Maintenance` and bump to V3
segments.push({
...defaultSegment,
target: instance.MaintenanceProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeToAndCall', [
instance.MaintenanceLogic!.address,
new Maintenance__factory().interface.encodeFunctionData('initializeV3', [instance.ProfileProxy!.address]),
]),
});

// upgrade `SlashIndicator` and bump to V3
segments.push({
...defaultSegment,
target: instance.SlashIndicatorProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeTo', [instance.SlashIndicatorLogic!.address]),
});

// upgrade `RoninTrustedOrganization` and bump to V2
segments.push({
...defaultSegment,
target: instance.RoninTrustedOrganizationProxy!.address,
data: proxyInterface.encodeFunctionData('upgradeToAndCall', [
instance.RoninTrustedOrganizationLogic!.address,
new RoninTrustedOrganization__factory().interface.encodeFunctionData('initializeV2', [
instance.ProfileProxy?.address,
]),
]),
});

return segments;
}

// yarn hardhat deploy --tags 230231109__ProposalOnRoninChain__V0_7_0 --network ronin-testnet
deploy.tags = ['230231109__ProposalOnRoninChain__V0_7_0'];

export default deploy;