Skip to content

Commit

Permalink
Merge 9bbee55 into 3cfb932
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 25, 2024
2 parents 3cfb932 + 9bbee55 commit 37aa3df
Show file tree
Hide file tree
Showing 43 changed files with 921 additions and 137 deletions.
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ a88906eaf3e08acc1f5517ddcbfaa26af7b8559b
04cca08e8242d2eff83fd895c4b56b456a52b37c
# style(automated): post-commit forge fmt (*.sol)
138b0b7fb7ebf761275fe9917243c89201f226c4
# style(automated): post-commit forge fmt (*.sol)
d8895a30b9b984a530b1a9060757d954db2e65f8
# style(automated): post-commit forge fmt (*.sol)
43e64bf94c48a2f6442eb0a6616573da3851dc72
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ deployments/**/exported_address
config/config.json
config/config.yaml
dependencies
deployments/ronin-mainnet-shadow
deployments/*-shadow
bin/ronin-random-beacon
broadcast/**/6063/*
broadcast/**/31337/*
12 changes: 6 additions & 6 deletions .husky/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ HAS_PENDING_CHANGES=false
# If there are any changes in the working directory, stash them
if [[ $(git status -s) ]]; then
HAS_PENDING_CHANGES=true
echo "\033[33m[post-commit] Stashing pending changes\033[0m"
echo -e "\033[33m[post-commit] Stashing pending changes\033[0m"
git stash push -m "post-commit: Stash changes"
fi

GIT_BLAME_IGNORE_REVS_FILE=".git-blame-ignore-revs"

# If `.git-blame-ignore-revs` does not exist, create it
if [ ! -f $GIT_BLAME_IGNORE_REVS_FILE ]; then
echo "\033[33m[post-commit] Creating $GIT_BLAME_IGNORE_REVS_FILE\033[0m"
echo -e "\033[33m[post-commit] Creating $GIT_BLAME_IGNORE_REVS_FILE\033[0m"

touch $GIT_BLAME_IGNORE_REVS_FILE
git add $GIT_BLAME_IGNORE_REVS_FILE
HUSKY=0 git commit -m "chore(automated): create .git-blame-ignore-revs" -n

echo "\033[33m[post-commit] Configuring git blame to ignore $GIT_BLAME_IGNORE_REVS_FILE\033[0m"
echo -e "\033[33m[post-commit] Configuring git blame to ignore $GIT_BLAME_IGNORE_REVS_FILE\033[0m"
# Config to ignore the changes in `.git-blame-ignore-revs`
git config blame.ignoreRevsFile $GIT_BLAME_IGNORE_REVS_FILE
fi
Expand All @@ -28,7 +28,7 @@ forge fmt

# Check if there are any changes after forge fmt
if [[ $(git status -s) ]]; then
echo "\033[33m[post-commit] Forge fmt changes detected\033[0m"
echo -e "\033[33m[post-commit] Forge fmt changes detected\033[0m"
git add src
git add script
git add test/foundry
Expand All @@ -40,13 +40,13 @@ forge build

# Check if `GIT_BLAME_IGNORE_REVS_FILE` has any changes
if [[ $(git status -s $GIT_BLAME_IGNORE_REVS_FILE) ]]; then
echo "\033[33m[post-commit] .git-blame-ignore-revs changes detected\033[0m"
echo -e "\033[33m[post-commit] .git-blame-ignore-revs changes detected\033[0m"
git add $GIT_BLAME_IGNORE_REVS_FILE
HUSKY=0 git commit -m "chore(automated): post-commit update .git-blame-ignore-revs" -n
fi

# If there were any pending changes, unstash them
if [ "$HAS_PENDING_CHANGES" = true ]; then
echo "\033[33m[post-commit] Unstashing pending changes\033[0m"
echo -e "\033[33m[post-commit] Unstashing pending changes\033[0m"
git stash pop
fi
1 change: 1 addition & 0 deletions generate-artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source dependencies/fdk-0.3.5-beta/generate-artifact.sh
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ forge-std/=dependencies/fdk-0.3.5-beta/dependencies/forge-std-1.9.3/src/
@solady/=dependencies/fdk-0.3.5-beta/dependencies/solady-0.0.228/src/
@fdk/=dependencies/fdk-0.3.5-beta/script/
@chainlink/contracts/=dependencies/chainlink-1.6.0/contracts/
@safe/contracts/=dependencies/safe-1.4.1/contracts/
@safe/contracts/=dependencies/safe-1.4.1/contracts/
3 changes: 2 additions & 1 deletion script/GeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ contract GeneralConfig is BaseGeneralConfig {
setNetworkInfo(Network.Goerli.data());
setNetworkInfo(Network.EthMainnet.data());
setNetworkInfo(Network.RoninDevnet.data());
setNetworkInfo(Network.ShadowForkMainnet.data());
setNetworkInfo(Network.RoninMainnetShadow.data());
setNetworkInfo(Network.RoninTestnetShadow.data());
}

function _setUpContracts() internal virtual override {
Expand Down
25 changes: 24 additions & 1 deletion script/PostChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PostChecker_Staking } from "./post-check/PostChecker_Staking.sol";
import { Contract } from "./utils/Contract.sol";
import { BaseMigration } from "@fdk/BaseMigration.s.sol";
import { ScriptExtended } from "@fdk/extensions/ScriptExtended.s.sol";
import { IHasContracts } from "src/interfaces/collections/IHasContracts.sol";

import { ProxyInterface } from "@fdk/libraries/LibDeploy.sol";
import { LibErrorHandler } from "@fdk/libraries/LibErrorHandler.sol";
Expand Down Expand Up @@ -187,6 +188,7 @@ contract PostChecker is

console.log("Submitting block reward at next block number after REP10 activated...".yellow());
VmSafe.Log[] memory logs = _randomlySubmitBlockReward({ validatorSet: validatorSet, txFee: 0.2 ether });
_randomlySubmitL2BlockReward({ validatorSet: validatorSet, txFee: 0.3 ether });
console.log("FF Percentage after REP-10".yellow(), stakingVesting.fastFinalityRewardPercentage());

bool emitted;
Expand Down Expand Up @@ -215,16 +217,37 @@ contract PostChecker is
assertEq(stakingVesting.fastFinalityRewardPercentage(), newPercentage, "REP10 percentage not match");

_randomlySubmitBlockReward({ validatorSet: validatorSet, txFee: 0.3 ether });
_randomlySubmitL2BlockReward({ validatorSet: validatorSet, txFee: 0.4 ether });
}

console.log(StdStyle.green("Cheat fast forward to 1 epoch ...\n"));
LibWrapUpEpoch.wrapUpEpoch();
}

function _randomlySubmitL2BlockReward(
IRoninValidatorSet validatorSet,
uint256 txFee
) internal returns (VmSafe.Log[] memory logs) {
console.log(
"Submitting L2 block reward at: - Period:", validatorSet.currentPeriod(), " - Block:", vm.getBlockNumber() + 1
);
address feePlaza = IHasContracts(address(validatorSet)).getContract(ContractType.ZK_FEE_PLAZA);
uint256 currUnixTimestamp = vm.unixTime();
address[] memory allCids = validatorSet.getValidatorCandidateIds();
address randomCid = allCids[currUnixTimestamp % allCids.length];

vm.deal(feePlaza, txFee);
vme.rollUpTo(vm.getBlockNumber() + 1);
vm.prank(feePlaza);
vm.recordLogs();
validatorSet.onL2BlockRewardSubmitted{ value: txFee }(randomCid);
logs = vm.getRecordedLogs();
}

function _randomlySubmitBlockReward(
IRoninValidatorSet validatorSet,
uint256 txFee
) private returns (VmSafe.Log[] memory logs) {
) internal returns (VmSafe.Log[] memory logs) {
console.log(
"Submitting block reward at: - Period:", validatorSet.currentPeriod(), " - Block:", vm.getBlockNumber() + 1
);
Expand Down
16 changes: 13 additions & 3 deletions script/RoninMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ contract RoninMigration is BaseMigration {

if (
network() == DefaultNetwork.LocalHost.key() || network() == DefaultNetwork.RoninTestnet.key()
|| network() == Network.RoninDevnet.key() || network() == Network.ShadowForkMainnet.key()
|| network() == Network.RoninDevnet.key() || network() == Network.RoninMainnetShadow.key()
|| network() == Network.RoninTestnetShadow.key()
) {
param.initialOwner = makeAddr("initial-owner");
_setProfileParam(param.profile);
_setStakingParam(param.staking);
_setMaintenanceParam(param.maintenance);
_setStakingVestingParam(param.stakingVesting);
Expand All @@ -73,6 +75,13 @@ contract RoninMigration is BaseMigration {
rawCallData = abi.encode(param);
}

function _setProfileParam(
ISharedArgument.ProfileParam memory param
) internal {
param.cooldown = vm.envOr("COOLDOWN", uint256(0 days));
param.rollupManager = makeAddr("rollup-manager");
}

function _setRoninValidatorSetREP10Migrator(
ISharedArgument.RoninValidatorSetREP10MigratorParam memory param
) internal view {
Expand Down Expand Up @@ -191,14 +200,15 @@ contract RoninMigration is BaseMigration {

function _setRoninValidatorSetParam(
ISharedArgument.RoninValidatorSetParam memory param
) internal view {
) internal {
param.maxValidatorNumber = vm.envOr("MAX_VALIDATOR_NUMBER", uint256(15));
param.maxPrioritizedValidatorNumber = vm.envOr("MAX_PRIORITIZED_VALIDATOR_NUMBER", uint256(4));
param.numberOfBlocksInEpoch = vm.envOr("NUMBER_OF_BLOCKS_IN_EPOCH", uint256(200));
param.maxValidatorCandidate = vm.envOr("MAX_VALIDATOR_CANDIDATE", uint256(100));
param.minEffectiveDaysOnwards = vm.envOr("MIN_EFFECTIVE_DAYS_ONWARDS", uint256(7));
param.emergencyExitLockedAmount = vm.envOr("EMERGENCY_EXIT_LOCKED_AMOUNT", uint256(500));
param.emergencyExpiryDuration = vm.envOr("EMERGENCY_EXPIRY_DURATION", uint256(14 days));
param.zkFeePlaza = makeAddr("zk-fee-plaza");
}

function _setGovernanceAdminParam(
Expand Down Expand Up @@ -296,7 +306,7 @@ contract RoninMigration is BaseMigration {
if (
currentNetwork == DefaultNetwork.RoninTestnet.key() || currentNetwork == DefaultNetwork.RoninMainnet.key()
|| currentNetwork == Network.RoninDevnet.key() || currentNetwork == DefaultNetwork.LocalHost.key()
|| currentNetwork == Network.ShadowForkMainnet.key()
|| currentNetwork == Network.RoninMainnetShadow.key() || currentNetwork == Network.RoninTestnetShadow.key()
) {
// handle for ronin network
console.log(StdStyle.yellow("Voting on RoninGovernanceAdmin for upgrading..."));
Expand Down
9 changes: 7 additions & 2 deletions script/deploy-dpos/DeployDPoS.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract DeployDPoS is RoninMigration {
_initStaking(param.staking);
_initTrustedOrg(param.roninTrustedOrganization);
_initValidatorSet(param.roninValidatorSet);
_initProfile();
_initProfile(param.profile);
_initMaintenance(param.maintenance);
_initSlashIndicator(param.slashIndicator);
_initStakingVesting(param.stakingVesting);
Expand Down Expand Up @@ -223,10 +223,14 @@ contract DeployDPoS is RoninMigration {
}
}

function _initProfile() internal logFn("_initProfile") {
function _initProfile(
ISharedArgument.ProfileParam memory param
) internal logFn("_initProfile") {
vm.startBroadcast(sender());
profile.initialize(address(validatorSet));
profile.initializeV2(address(staking), address(trustedOrg));
profile.initializeV3(param.cooldown);
profile.initializeV4(param.rollupManager);
vm.stopBroadcast();
}

Expand Down Expand Up @@ -321,6 +325,7 @@ contract DeployDPoS is RoninMigration {
// validatorSet.initializeV2();
validatorSet.initializeV3(address(fastFinalityTracking));
validatorSet.initializeV4(address(profile));
validatorSet.initializeV5(param.zkFeePlaza);
vm.stopBroadcast();

UpgradeInfo({
Expand Down
2 changes: 2 additions & 0 deletions script/interfaces/ISharedArgument.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ interface ISharedArgument is IGeneralConfig {
uint256 minEffectiveDaysOnwards;
uint256 emergencyExitLockedAmount;
uint256 emergencyExpiryDuration;
address zkFeePlaza;
}

struct RoninGovernanceAdminParam {
Expand All @@ -90,6 +91,7 @@ interface ISharedArgument is IGeneralConfig {

struct ProfileParam {
uint256 cooldown;
address rollupManager;
}

struct RoninRandomBeaconParam {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract Migration__01_Upgrade_ShadowForkMainnet_Release_V0_8_0 is RoninMigratio
IRoninGovernanceAdmin private roninGovernanceAdmin;
IRoninTrustedOrganization private roninTrustedOrganization;

function run() public onlyOn(Network.ShadowForkMainnet.key()) {
function run() public onlyOn(Network.RoninMainnetShadow.key()) {
staking = IStaking(loadContract(Contract.Staking.key()));
slashIndicator = ISlashIndicator(loadContract(Contract.SlashIndicator.key()));
roninValidatorSet = IRoninValidatorSet(loadContract(Contract.RoninValidatorSet.key()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract Migration_02_SetupVRFKeyHash_ShadowFork_Mainnet is RoninMigration {
IRoninTrustedOrganization private trustedOrg;
LibVRFProof.VRFKey[] private keys;

function run() public onlyOn(Network.ShadowForkMainnet.key()) {
function run() public onlyOn(Network.RoninMainnetShadow.key()) {
profile = IProfile(loadContract(Contract.Profile.key()));
trustedOrg = IRoninTrustedOrganization(loadContract(Contract.RoninTrustedOrganization.key()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract Migration__02_ProposeAndExecuteNewProposal_ShadowMainnet_Release_V0_8_1

Proposal.ProposalDetail internal _proposal;

function run() public virtual override onlyOn(Network.ShadowForkMainnet.key()) {
function run() public virtual override onlyOn(Network.RoninMainnetShadow.key()) {
super.run();
vm.chainId(2020);
address payable[] memory allContracts = config.getAllAddresses(network());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract Migration_03_SetupVRFKeyHash_ShadowFork_Mainnet is RoninMigration {
IRoninTrustedOrganization private trustedOrg;
LibVRFProof.VRFKey[] private keys;

function run() public onlyOn(Network.ShadowForkMainnet.key()) {
function run() public onlyOn(Network.RoninMainnetShadow.key()) {
profile = IProfile(loadContract(Contract.Profile.key()));
trustedOrg = IRoninTrustedOrganization(loadContract(Contract.RoninTrustedOrganization.key()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract Migration__04_ProposeAndExecuteProposalPatch_ShadowMainnet_Release_V0_8

Proposal.ProposalDetail internal _proposal;

function run() public virtual override onlyOn(Network.ShadowForkMainnet.key()) {
function run() public virtual override onlyOn(Network.RoninMainnetShadow.key()) {
super.run();
roninRandomBeacon = IRandomBeacon(loadContract(Contract.RoninRandomBeacon.key()));
vm.chainId(2020);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract Migration__05_Propose_HotFix_ShadowMainnet_Release_V0_8_1C is REP10_Con

Proposal.ProposalDetail internal _proposal;

function run() public virtual override onlyOn(Network.ShadowForkMainnet.key()) {
function run() public virtual override onlyOn(Network.RoninMainnetShadow.key()) {
vm.chainId(2020);

super.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ abstract contract REP10_Config_Mainnet_Base is RoninMigration {
IRoninGovernanceAdmin internal roninGovernanceAdmin;
IRoninTrustedOrganization internal roninTrustedOrganization;

function run() public virtual onlyOn(Network.ShadowForkMainnet.key()) {
function run() public virtual onlyOn(Network.RoninMainnetShadow.key()) {
staking = IStaking(loadContract(Contract.Staking.key()));
stakingVesting = IStakingVesting(loadContract(Contract.StakingVesting.key()));
slashIndicator = ISlashIndicator(loadContract(Contract.SlashIndicator.key()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { TransparentUpgradeableProxy } from
"@openzeppelin-v4/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { DefaultNetwork } from "@fdk/utils/DefaultNetwork.sol";

import { IProfile } from "src/interfaces/IProfile.sol";
import { IRoninGovernanceAdmin } from "src/interfaces/IRoninGovernanceAdmin.sol";
import { IRoninTrustedOrganization } from "src/interfaces/IRoninTrustedOrganization.sol";

import { Proposal } from "src/libraries/Proposal.sol";
import { RoninValidatorSetConstructor } from "src/ronin/validator/RoninValidatorSetConstructor.sol";

import { RoninMigration } from "script/RoninMigration.s.sol";

import { ISharedArgument } from "script/interfaces/ISharedArgument.sol";
import { LibProposal } from "script/shared/libraries/LibProposal.sol";

import { Contract } from "script/utils/Contract.sol";
import { Network } from "script/utils/Network.sol";

contract Migration_01_Upgrade_TestnetShadow_Release_v0_8_2 is RoninMigration {
uint256 internal constant DEFAULT_EXPIRY = 1 hours;

function run() public virtual onlyOn(Network.RoninTestnetShadow.key()) {
address zkFeePlaza = 0x3aB093b72EbD8B3B5222641b300Bd09EcBC6A6a6;
address zkRollupManager = 0x3F087034ca3bA5792591cbB93CB1CCFb650Abf85;

// Set the chain ID to the Ronin Testnet chain ID
vm.chainId(vme.getNetworkData(DefaultNetwork.RoninTestnet.key()).chainId);

address profileLogic = _deployLogic(Contract.Profile.key());
address validatorSetInitializer = vm.deployCode("RoninValidatorSetConstructor.sol");
address validatorSetLogic = _deployLogic(Contract.RoninValidatorSet.key());

address[] memory targets = new address[](3);
targets[0] = loadContract(Contract.Profile.key());
targets[1] = loadContract(Contract.RoninValidatorSet.key());
targets[2] = targets[1];

uint256[] memory values = new uint256[](3);
values[0] = 0;
values[1] = 0;
values[2] = 0;

bytes[] memory callDatas = new bytes[](3);
callDatas[0] = abi.encodeCall(
TransparentUpgradeableProxy.upgradeToAndCall,
(profileLogic, abi.encodeCall(IProfile.initializeV4, (zkRollupManager)))
);
callDatas[1] = abi.encodeCall(
TransparentUpgradeableProxy.upgradeToAndCall,
(validatorSetInitializer, abi.encodeCall(RoninValidatorSetConstructor.initializeV5, (zkFeePlaza)))
);
callDatas[2] = abi.encodeCall(TransparentUpgradeableProxy.upgradeTo, (validatorSetLogic));

address gov = loadContract(Contract.RoninGovernanceAdmin.key());
address trustedOrg = loadContract(Contract.RoninTrustedOrganization.key());

Proposal.ProposalDetail memory proposal = LibProposal.buildProposal(
IRoninGovernanceAdmin(gov), block.timestamp + DEFAULT_EXPIRY, targets, values, callDatas
);

LibProposal.executeProposal(IRoninGovernanceAdmin(gov), IRoninTrustedOrganization(trustedOrg), proposal);
}

function _afterRunningScript() internal virtual override {
// Do nothing
}
}
4 changes: 4 additions & 0 deletions script/shared/libraries/LibProposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ library LibProposal {
Ballot.VoteType support
) internal {
IRoninTrustedOrganization.TrustedOrganization[] memory allTrustedOrgs = roninTrustedOrg.getAllTrustedOrganizations();
for (uint256 i; i < allTrustedOrgs.length; ++i) {
console.log("Governor[%s]: %s", i, vm.toString(allTrustedOrgs[i].governor));
}

bool shouldPrankOnly = config.isPostChecking();

Expand All @@ -82,6 +85,7 @@ library LibProposal {
break;
}

console.log("%s is voting for the proposal", vm.toString(iTrustedOrg));
if (shouldPrankOnly) {
vm.prank(iTrustedOrg);
} else {
Expand Down
Loading

0 comments on commit 37aa3df

Please sign in to comment.