Skip to content

Commit

Permalink
feat: migrate registry for renounced candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
nxqbao committed Nov 9, 2023
1 parent 61e439d commit 88d9239
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 9 deletions.
13 changes: 8 additions & 5 deletions contracts/ronin/profile/Profile.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ contract Profile is IProfile, ProfileXComponents, Initializable {
_setContract(ContractType.VALIDATOR, validatorContract);
}

function initializeV2(address stakingContract) external reinitializer(2) {
function initializeV2(address stakingContract, address trustedOrgContract) external reinitializer(2) {
_setContract(ContractType.STAKING, stakingContract);
}

function initializeV3(address trustedOrgContract) external reinitializer(3) {
_setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, trustedOrgContract);

// TODO(bao): handle renounced validators
address[] memory validatorCandidates = IRoninValidatorSet(getContract(ContractType.VALIDATOR))
.getValidatorCandidates();
TConsensus[] memory consensuses;
Expand All @@ -38,8 +34,15 @@ contract Profile is IProfile, ProfileXComponents, Initializable {
for (uint256 i; i < validatorCandidates.length; ++i) {
_consensus2Id[consensuses[i]] = validatorCandidates[i];
}

__migrationRenouncedCandidates();
}

/**
* @dev Add addresses of renounced candidates into registry. Only called during {initializeV2}F.
*/
function __migrationRenouncedCandidates() internal virtual {}

/**
* @inheritdoc IProfile
*/
Expand Down
55 changes: 55 additions & 0 deletions contracts/ronin/profile/Profile_Mainnet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: MIT

import "./Profile.sol";

pragma solidity ^0.8.9;

contract Profile_Mainnet is Profile {
function __migrationRenouncedCandidates() internal override onlyInitializing {
if (block.chainid != 2020) return;

uint length;
CandidateProfile storage _profile;

address[4] memory lConsensus = __consensuses();
address[4] memory lAdmin = __admins();
address[4] memory lTreasury = __treasuries();

for (uint i; i < length; ++i) {
address id = lConsensus[i];

_profile = _id2Profile[id];
_profile.id = id;
_setConsensus(_profile, TConsensus.wrap(id));
_setAdmin(_profile, lAdmin[i]);
_setTreasury(_profile, payable(lTreasury[i]));
}
}

function __admins() private pure returns (address[4] memory list) {
return [
0xdb3b1F69259f88Ce9d58f3738e15e3CC1B5A8563,
0x335fE9EF827a9F27CBAb819b31e5eE182c2081d7,
0xbCcB3FDa2B9e3Ab5b824AA9D5c1C4A62A98Da937,
0x9bc1946f1Aa6DA4667a6Ee966e66b9ec60637E10
];
}

function __consensuses() private pure returns (address[4] memory list) {
return [
0x07d28F88D677C4056EA6722aa35d92903b2a63da,
0x262B9fcfe8CFA900aF4D1f5c20396E969B9655DD,
0x20238eB5643d4D7b7Ab3C30f3bf7B8E2B85cA1e7,
0x03A7B98C226225e330d11D1B9177891391Fa4f80
];
}

function __treasuries() private pure returns (address[4] memory list) {
return [
0xdb3b1F69259f88Ce9d58f3738e15e3CC1B5A8563,
0x335fE9EF827a9F27CBAb819b31e5eE182c2081d7,
0xbCcB3FDa2B9e3Ab5b824AA9D5c1C4A62A98Da937,
0x9bc1946f1Aa6DA4667a6Ee966e66b9ec60637E10
];
}
}
265 changes: 265 additions & 0 deletions contracts/ronin/profile/Profile_Testnet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
// SPDX-License-Identifier: MIT

import "./Profile.sol";

pragma solidity ^0.8.9;

contract Profile_Testnet is Profile {
function __migrationRenouncedCandidates() internal override onlyInitializing {
if (block.chainid != 2021) return;

uint length;
CandidateProfile storage _profile;

address[74] memory lConsensus = __consensuses();
address[74] memory lAdmin = __admins();
address[74] memory lTreasury = __treasuries();

for (uint i; i < length; ++i) {
address id = lConsensus[i];

_profile = _id2Profile[id];
_profile.id = id;
_setConsensus(_profile, TConsensus.wrap(id));
_setAdmin(_profile, lAdmin[i]);
_setTreasury(_profile, payable(lTreasury[i]));
}
}

function __admins() private pure returns (address[74] memory list) {
return [
0xD682DC6D64710D6191512133dE957e146e9AA58f,
0xEFeaFf1d9f1E4EDB00c6084aE4016143B29Ed924,
0xC2caE7311FC0fe400A838d2dDe06A89E1d3e9Da7,
0xf90a912Fdb7Fd37572cD83325392d729e60Ef682,
0xAfB9554299491a34d303f2C5A91bebB162f6B2Cf,
0x8dA9d88F90141a03292d5e554691B1F6e7c6212c,
0xA87F9A2F0C7082FA2f1E3de1090D36047C7cD017,
0x6693dc258BDAAc5052ab678BA5de2440CA1cdAbe,
0x0B67dF5847aF7476B2EB46da328638E0fB2C6B29,
0xe91d1DCd0232BDa301379dE27bd0edE47Db3F750,
0xDc3de716C4430d598AC504c4685d69D0DcE1412F,
0x795CF28E5b71f1A50cC9E01077891C18D6587e53,
0xa3B3c71371331fD1901e316B67df2d16bF5535a0,
0x32Be208dE8A1595cC0ccf8E984CAB8759Ea1e5b2,
0x8136c74e94b08300d71Fa6C22087b821F73568c5,
0xda6c7342E90B77c5C77A8F7292765360099e30Ed,
0x95fC818CD7709fb6aD8920d0d14925010504876F,
0xe8E66b241414a40a3Db539eC7d864cD61938f817,
0xfD575770A68D5Af983b2A374981f604DdAD9D684,
0x9A54EDCb1D9a44e9f4235ea05c75B45b26679680,
0x6108570A29f500D6950fEbffC99ECB66a264A048,
0xdA071F710b0f82443866616E8a96069012A73ccf,
0x8A4ac64764238C71Ddf82F870BE6526e297Dc4Cd,
0x33f1727CaA54AE24CAdB2949881C3725eB61a100,
0x34DB532F09Ee1285DFEf26eD696c4eA25dcFce72,
0x302d51189FD89D7e72bcb26a65D16941d043F089,
0xFeb247F76E6F6C1Ec3455d04e6E3B694a577D57C,
0x05955d9e99f57E5574A1a9b73361DD14aEc8D641,
0xcf9F44dDB18a5538Efe2a2A28eF20300333f5a71,
0x779dCE1ddc28941Ec85bf2aE0dAC9F0f12836281,
0x0Bb270e5268a9E9a0742DdB027Fab7405Af56Fa7,
0x5b92Ea265597a7cf20C8dA56E6beb8485c1BA993,
0x0E3341Ae4Ed9dA65Fc30a7Fa6357e8B5Ac40b0A3,
0xf6fd5FcA4Bd769BA495B29B98dba5F2eCF4CEED3,
0x8d0a639BDD3b81dF264c4dB46476658858231510,
0xBB046932fEFCDD3Be4368444a1014F25DfEE83f2,
0x54e09bF04810f387347dA6D9687D6a37EC2aadC7,
0xDE5e1554e2bF5d0E54BafC74C932b8F2aD4e273F,
0xc68d0255e1b9C549C43c7181BD29684DC477edfc,
0x37920733DB9A5b45fC9CD5e3C80825bEfFC1a014,
0x7e9107480Bf92dd56c97118E20CdB3c1Ae9dD866,
0xC4F83A7b369070E32CEd4Bd6Fd647D19AEf828AC,
0x412D4d69122839FcCAd0180e9358d157C3876f3C,
0x355503B8E64205FDE9dBBAD269110991cf736a50,
0x306f23c32fdfC07850Bf242E8Ff59C5E79BFf812,
0x467c5425042C9D9f025265b72C93D73E0F2978C5,
0xEE992B0F5E9746fdb8e584Efa01AF79f6B1C0940,
0xBD6342c0009f55131b7a51f627CE8Cc87879DD66,
0x57018e929Eb6fe50355bF1BF9D1d39cA466b7Fa0,
0xAd4e3D2F85b4C095742B500751CEE5c4B8f65A5b,
0x89A6A074dB8BcD3Fd60626107eA2aE576693F7c5,
0xCB742186fA056444766fA7cc52a0479E8F6DEDEA,
0x60C8117901Ab35738fcFd7157D393207eFCe8055,
0xAD70AD152E27E0923C4f11C63490FCFD904A4C36,
0xd8b47b81648d9e81e50b8cA21EA81F2E1B6929BB,
0xeCB1374172970a613A1970370B3ddeAD8F844733,
0x0472dCa02318B532Fcb0B056661EE7fD2Adc8a20,
0xdd00ACc07F3F7AFa90B5a22cFd56c0808b6444dd,
0x4d3302c69fac489E2F7373bCB2f101d3B378c4Ce,
0xe7685E437F34De2D36eA2e9AB13E5Ab871711A2C,
0xAfB9554299491a34d303f2C5A91bebB162f6B2Cf,
0x3F9Df0717099BAaA95A14B3CAA285DAdDAFb0609,
0x23Dffc4a93c374A91Fbc1c33075af012b68663F7,
0x79eC4d83D40c1Bd1419D8f561BE851FDa1EA32a6,
0x2D3f28780bFb7Ed6FB5547c309E1a6837e5bD12B,
0xa164e8B5F90ce42B0F531E3882cdE3F698e1121f,
0x4a4bc674A97737376cFE990aE2fE0d2B6E738393,
0xF61806B65278fFDbF8b04f832C59b65076798Fb6,
0x836eeEdd931575CCE4285c74C15DBdA9Edc3Dc4F,
0xbd95B0581585E4151793b183ee75d509fDE528B6,
0xA75B1Ce2f8C447caB6c13F313dfd806287aA47e2,
0x4D546475321b4cA2a91B101f26750092C05350cF,
0xFC2d29Da710F45168DE11e5C051CaA558088D52a,
0x1C70B8160E92D56E550caf02e1f2e5EC0Fdb551A
];
}

function __consensuses() private pure returns (address[74] memory list) {
return [
0xD682dc6D64710D6191512133De957e146e9Aa58e,
0xEFeaFf1d9f1e4eDB00C6084ae4016143B29eD925,
0x57b572A9de68Bd29074e1C51c790Fc45C592ba39,
0xC0C2A56F9606bA109d37A0d18AF8E5bAA1e1C0aD,
0xaFB9554299491a34d303F2C5A91bebb162f6b2C1,
0x533f61B360e81f58919faB5C653724F71faf12ab,
0xa87F9A2F0C7082FA2f1E3De1090d36047c7cD018,
0x6693Dc258bDAaC5052aB678Ba5de2440ca1cDAb2,
0x96f78323481fc9abdb8Cc4D8aa50C1500AC93b92,
0xe91D1DcD0232BDa301379de27BD0edE47Db3f751,
0x981676e5E5164524e70f79AC45b52099EbDA8781,
0x795cf28e5B71f1A50cc9E01077891C18D6587E54,
0xa3b3C71371331fD1901e316B67DF2d16Bf5535A1,
0x32be208de8A1595cC0CcF8E984Cab8759Ea1e5b9,
0x2dc14d542B5478f206B296AcbCBfBCCEE6E8D248,
0xDA6C7342E90B77c5c77a8F7292765360099E30EE,
0x9D7EA2223e89A55a4ef69Ca993eae6FDE6E63371,
0xe8e66b241414a40a3db539EC7d864cD61938f818,
0x8fFF45d4a6A27F8256dF19D0DaDF7787CfbE56AA,
0x9a54EdCb1D9a44e9F4235EA05C75B45B26679681,
0x6108570A29F500D6950FEbFFc99eCB66a264a049,
0xDA071f710B0f82443866616E8a96069012A73cCE,
0x5f7f2AE316ec5C092d201744fe8337353ADB2BB3,
0x771DEc03db66a566a1DfE3fd635B3f8D404b9291,
0x71f9154ADc0bef39Bbe8dB1D060E6F239D2E10AE,
0x95908d03bA55c2a44688330b59E746Fdb2f17E3E,
0x3DB3abc65F203788836C8D50F6923C56f3f0FF7c,
0x05955D9e99f57E5574a1A9B73361Dd14aEC8D642,
0x283b4Baa1d0415603C81edc1C68FadD3C790837C,
0x2A5EB3f9CD4D6Ef49dc2a30041e4421af3303929,
0x3B9F2587d55E96276B09b258ac909D809961F6C2,
0x2576e6BC92A493F4DA6335C5E69BC0c272381C3A,
0x0E3341Ae4Ed9dA65Fc30a7Fa6357e8B5Ac40b0A3,
0xf6fd5FcA4Bd769BA495B29B98dba5F2eCF4CEED3,
0xd9299FA321407a5d10c73d71C57Ca687A2A38Af6,
0x877eFEfFE7A23E42C39e2C99b977e4AA4BEC7517,
0x071b510C415d3f84C6F4C6291C49887cC56cac41,
0xDE5e1554e2bF5d0e54bAFC74c932b8f2Ad4E2730,
0xc68d0255E1b9C549C43C7181bd29684DC477eDf0,
0xC3fB7b95b874bfcBD1E722A2061f3adf217121d3,
0x36Fd0d4A075507a4E742631aA37DAD46a1F4c0da,
0x661549d7717C20ffa62AD359B7667Bbf5c82053B,
0x412d4d69122839fcCAd0180e9358D157C3876F3D,
0x355503B8E64205FDE9dBbAd269110991CF736a51,
0x12Cf444bf83Ed5B610d0089927EcD3baBC81Ff88,
0x467C5425042c9d9f025265b72c93D73e0f2978C6,
0xB6bc5bc0410773A3F86B1537ce7495C52e38f88B,
0xBd6342C0009f55131b7A51F627ce8Cc87879dD67,
0x35C78DefBd03E96b4E3eE6a73e9CD4C49d2b885a,
0xAD4e3d2f85b4C095742B500751CeE5C4b8F65A5C,
0x42c535deCcc071D9039b177Cb3AbF30411531b05,
0xb212F24D850a0Ed90F2889dee31870E7FF3fED6c,
0x60C8117901AB35738FcfD7157D393207Efce8056,
0x30b0215a442Ea3D3088Acd83cD5Fe2aA2bcd775A,
0xD21BeCe2D8206A3fFdBAeDb827f4D4bD0FF79e3d,
0x4EfA5C5Bbe7a257743335F200E86cD44eEa4dcD9,
0x0472dcA02318B532fcB0B056661ee7Fd2aDc8A21,
0xDD00ACc07f3f7Afa90B5A22CFd56c0808b6444Df,
0x4d3302c69fAc489E2f7373bCB2f101d3b378C4cF,
0x8c29604e1caE4af683c4fBdAD951F3F855890EA0,
0xAfB9554299491a34d303f2C5A91bebB162f6B2Cf,
0xF48C06c56D78F5106b8c5Fa234fCeB1d1c50096B,
0x626ECe2ad62F59700D2734A523FC6177005aC8b0,
0xc6C15480855add4eeBE365c89a9bb6f278E18254,
0xF6071F7905D4e4B6eBd27b819aAF8923d542FDDF,
0x8872fe6335267aDB4C40b9f8667095667B55dCD9,
0x4a4bc674A97737376cFE990aE2fE0d2B6E738393,
0x27550f4B37f0309C56ea67578Eb924B4c19eEEB7,
0x181A053fd961DC1377B84BE4E551ce277053e4C0,
0xf44C500a8515a5ACc900C921bC888b5b62DA6556,
0xF20293d569f0Ee7ECcdEF266D86EE382F8932866,
0xb1D4782962A407343Aa3765a599637932d241305,
0x7F53d703836abCaF1ca3D5607d80dd7d96e50d02,
0x78fD38faa30ea66702cc39383D2E84f9a4A56fA6
];
}

function __treasuries() private pure returns (address[74] memory list) {
return [
0xD682DC6D64710D6191512133dE957e146e9AA58f,
0xEFeaFf1d9f1E4EDB00c6084aE4016143B29Ed924,
0xC2caE7311FC0fe400A838d2dDe06A89E1d3e9Da7,
0xf90a912Fdb7Fd37572cD83325392d729e60Ef682,
0xAfB9554299491a34d303f2C5A91bebB162f6B2Cf,
0x8dA9d88F90141a03292d5e554691B1F6e7c6212c,
0xA87F9A2F0C7082FA2f1E3de1090D36047C7cD017,
0x6693dc258BDAAc5052ab678BA5de2440CA1cdAbe,
0x0B67dF5847aF7476B2EB46da328638E0fB2C6B29,
0xe91d1DCd0232BDa301379dE27bd0edE47Db3F750,
0xDc3de716C4430d598AC504c4685d69D0DcE1412F,
0x795CF28E5b71f1A50cC9E01077891C18D6587e53,
0xa3B3c71371331fD1901e316B67df2d16bF5535a0,
0x32Be208dE8A1595cC0ccf8E984CAB8759Ea1e5b2,
0x8136c74e94b08300d71Fa6C22087b821F73568c5,
0xda6c7342E90B77c5C77A8F7292765360099e30Ed,
0x95fC818CD7709fb6aD8920d0d14925010504876F,
0xe8E66b241414a40a3Db539eC7d864cD61938f817,
0xfD575770A68D5Af983b2A374981f604DdAD9D684,
0x9A54EDCb1D9a44e9f4235ea05c75B45b26679680,
0x6108570A29f500D6950fEbffC99ECB66a264A048,
0xdA071F710b0f82443866616E8a96069012A73ccf,
0x8A4ac64764238C71Ddf82F870BE6526e297Dc4Cd,
0x33f1727CaA54AE24CAdB2949881C3725eB61a100,
0x34DB532F09Ee1285DFEf26eD696c4eA25dcFce72,
0x302d51189FD89D7e72bcb26a65D16941d043F089,
0xFeb247F76E6F6C1Ec3455d04e6E3B694a577D57C,
0x05955d9e99f57E5574A1a9b73361DD14aEc8D641,
0xcf9F44dDB18a5538Efe2a2A28eF20300333f5a71,
0x779dCE1ddc28941Ec85bf2aE0dAC9F0f12836281,
0x0Bb270e5268a9E9a0742DdB027Fab7405Af56Fa7,
0x5b92Ea265597a7cf20C8dA56E6beb8485c1BA993,
0x0E3341Ae4Ed9dA65Fc30a7Fa6357e8B5Ac40b0A3,
0xf6fd5FcA4Bd769BA495B29B98dba5F2eCF4CEED3,
0x8d0a639BDD3b81dF264c4dB46476658858231510,
0xBB046932fEFCDD3Be4368444a1014F25DfEE83f2,
0x54e09bF04810f387347dA6D9687D6a37EC2aadC7,
0xDE5e1554e2bF5d0E54BafC74C932b8F2aD4e273F,
0xc68d0255e1b9C549C43c7181BD29684DC477edfc,
0x37920733DB9A5b45fC9CD5e3C80825bEfFC1a014,
0x7e9107480Bf92dd56c97118E20CdB3c1Ae9dD866,
0xC4F83A7b369070E32CEd4Bd6Fd647D19AEf828AC,
0x412D4d69122839FcCAd0180e9358d157C3876f3C,
0x355503B8E64205FDE9dBBAD269110991cf736a50,
0x306f23c32fdfC07850Bf242E8Ff59C5E79BFf812,
0x467c5425042C9D9f025265b72C93D73E0F2978C5,
0xEE992B0F5E9746fdb8e584Efa01AF79f6B1C0940,
0xBD6342c0009f55131b7a51f627CE8Cc87879DD66,
0x57018e929Eb6fe50355bF1BF9D1d39cA466b7Fa0,
0xAd4e3D2F85b4C095742B500751CEE5c4B8f65A5b,
0x89A6A074dB8BcD3Fd60626107eA2aE576693F7c5,
0xCB742186fA056444766fA7cc52a0479E8F6DEDEA,
0x60C8117901Ab35738fcFd7157D393207eFCe8055,
0xAD70AD152E27E0923C4f11C63490FCFD904A4C36,
0xd8b47b81648d9e81e50b8cA21EA81F2E1B6929BB,
0xeCB1374172970a613A1970370B3ddeAD8F844733,
0x0472dCa02318B532Fcb0B056661EE7fD2Adc8a20,
0xdd00ACc07F3F7AFa90B5a22cFd56c0808b6444dd,
0x4d3302c69fac489E2F7373bCB2f101d3B378c4Ce,
0xe7685E437F34De2D36eA2e9AB13E5Ab871711A2C,
0xAfB9554299491a34d303f2C5A91bebB162f6B2Cf,
0x3F9Df0717099BAaA95A14B3CAA285DAdDAFb0609,
0x23Dffc4a93c374A91Fbc1c33075af012b68663F7,
0x79eC4d83D40c1Bd1419D8f561BE851FDa1EA32a6,
0x2D3f28780bFb7Ed6FB5547c309E1a6837e5bD12B,
0xa164e8B5F90ce42B0F531E3882cdE3F698e1121f,
0x4a4bc674A97737376cFE990aE2fE0d2B6E738393,
0xF61806B65278fFDbF8b04f832C59b65076798Fb6,
0x836eeEdd931575CCE4285c74C15DBdA9Edc3Dc4F,
0xbd95B0581585E4151793b183ee75d509fDE528B6,
0xA75B1Ce2f8C447caB6c13F313dfd806287aA47e2,
0x4D546475321b4cA2a91B101f26750092C05350cF,
0xFC2d29Da710F45168DE11e5C051CaA558088D52a,
0x1C70B8160E92D56E550caf02e1f2e5EC0Fdb551A
];
}
}
13 changes: 12 additions & 1 deletion src/deploy/logic/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { network } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

import { roninchainNetworks } from '../../configs/config';
import { Network } from '../../utils';

const deploy = async ({ getNamedAccounts, deployments }: HardhatRuntimeEnvironment) => {
if (!roninchainNetworks.includes(network.name!)) {
Expand All @@ -11,8 +12,18 @@ const deploy = async ({ getNamedAccounts, deployments }: HardhatRuntimeEnvironme
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

let contractToDeploy;
switch (network.name!) {
case Network.Testnet:
contractToDeploy = 'Profile_Testnet';
case Network.Mainnet:
contractToDeploy = 'Profile_Mainnet';
default:
contractToDeploy = 'Profile';
}

await deploy('ProfileLogic', {
contract: 'Profile',
contract: contractToDeploy,
from: deployer,
log: true,
});
Expand Down
Loading

0 comments on commit 88d9239

Please sign in to comment.