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

feat(asset-migration): implement unit-test #91

Open
wants to merge 4 commits into
base: feature/asset-migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
423 changes: 189 additions & 234 deletions logs/contract-code-sizes.log

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/mocks/MockCCIPPoolMultiLane.sol:MockCCIPPoolMultiLane:s_lockedTokensByChainSelector (storage_slot: 0) (offset: 0) (type: mapping(uint64 => uint256)) (numberOfBytes: 32)
2 changes: 1 addition & 1 deletion script/20240403-deploy-sepolia/deploy-sepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.19;
import { ISharedArgument } from "script/interfaces/ISharedArgument.sol";
import { LibSharedAddress } from "@fdk/libraries/LibSharedAddress.sol";
import { TokenStandard } from "@ronin/contracts/libraries/LibTokenInfo.sol";
import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol";
import { IMainchainGatewayV3 } from "script/interfaces/IMainchainGatewayV3.sol";
import { IPauseEnforcer } from "script/interfaces/IPauseEnforcer.sol";
import { Proposal } from "@ronin/contracts/libraries/Proposal.sol";
import { Ballot } from "@ronin/contracts/libraries/Ballot.sol";
Expand Down
14 changes: 11 additions & 3 deletions script/GeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ contract GeneralConfig is BaseGeneralConfig, Utils {
setNetworkInfo(Network.RoninDevnet.data());
}

function getCompanionNetwork(TNetwork network) public view virtual returns (TNetwork companionNetwork) {
function getCompanionNetwork(
TNetwork network
) public view virtual returns (TNetwork companionNetwork) {
if (network == DefaultNetwork.RoninMainnet.key()) return Network.EthMainnet.key();
if (network == Network.EthMainnet.key()) return DefaultNetwork.RoninMainnet.key();
if (network == DefaultNetwork.RoninTestnet.key()) return Network.Sepolia.key();
Expand All @@ -34,7 +36,9 @@ contract GeneralConfig is BaseGeneralConfig, Utils {
return _localNetwork;
}

function setLocalNetwork(IGeneralConfigExtended.LocalNetwork network) public virtual {
function setLocalNetwork(
IGeneralConfigExtended.LocalNetwork network
) public virtual {
_localNetwork = network;
}

Expand Down Expand Up @@ -81,9 +85,13 @@ contract GeneralConfig is BaseGeneralConfig, Utils {

TNetwork currNetwork = getCurrentNetwork();
if (currNetwork == Network.Sepolia.key()) _contractNameMap[Contract.WBTC.key()] = "WBTC_Sepolia";
if (currNetwork == DefaultNetwork.LocalHost.key()) _contractNameMap[Contract.MainchainGatewayV3.key()] = "MainchainGatewayV3_initialize";
if (currNetwork == DefaultNetwork.LocalHost.key()) _contractNameMap[Contract.RoninGatewayV3.key()] = "RoninGatewayV3_initialize";
}

function _mapContractName(Contract contractEnum) internal {
function _mapContractName(
Contract contractEnum
) internal {
_contractNameMap[contractEnum.key()] = contractEnum.name();
}

Expand Down
13 changes: 9 additions & 4 deletions script/Migration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ contract Migration is BaseMigration, Utils, SignatureConsumer {
param.test.governorPKs = governorPKs;

// Mainchain Gateway Pause Enforcer
param.mainchainPauseEnforcer.admin = 0x968D0Cd7343f711216817E617d3f92a23dC91c07;
param.mainchainPauseEnforcer.admin = new address[](1);
param.mainchainPauseEnforcer.admin[0] = 0x968D0Cd7343f711216817E617d3f92a23dC91c07;
param.mainchainPauseEnforcer.sentries = wrapAddress(0x8Ed0c5B427688f2Bd945509199CAa4741C81aFFe); // Gnosis Sepolia

// Mainchain Gateway V3
Expand Down Expand Up @@ -161,7 +162,8 @@ contract Migration is BaseMigration, Utils, SignatureConsumer {
// Bridge Tracking

// Ronin Gateway Pause Enforcer
param.roninPauseEnforcer.admin = makeAddr("pause-enforcer-admin");
param.roninPauseEnforcer.admin = new address[](1);
param.roninPauseEnforcer.admin[0] = makeAddr("pause-enforcer-admin");
param.roninPauseEnforcer.sentries = wrapAddress(makeAddr("pause-enforcer-sentry"));

// Ronin Gateway V3
Expand All @@ -182,7 +184,8 @@ contract Migration is BaseMigration, Utils, SignatureConsumer {
param.roninBridgeManager.targets = targets;

// Mainchain Gateway Pause Enforcer
param.mainchainPauseEnforcer.admin = makeAddr("pause-enforcer-admin");
param.mainchainPauseEnforcer.admin = new address[](1);
param.mainchainPauseEnforcer.admin[0] = makeAddr("pause-enforcer-admin");
param.mainchainPauseEnforcer.sentries = wrapAddress(makeAddr("pause-enforcer-sentry"));

// Mainchain Gateway V3
Expand Down Expand Up @@ -313,7 +316,9 @@ contract Migration is BaseMigration, Utils, SignatureConsumer {
}
}

function _deployLogic(TContract contractType) internal virtual override returns (address payable logic) {
function _deployLogic(
TContract contractType
) internal virtual override returns (address payable logic) {
logic = _deployLogic(contractType, EMPTY_ARGS);
}

Expand Down
2 changes: 1 addition & 1 deletion script/contracts/MainchainGatewayV3Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol";
import { IMainchainGatewayV3 } from "script/interfaces/IMainchainGatewayV3.sol";
import { Contract } from "../utils/Contract.sol";
import { ISharedArgument } from "../interfaces/ISharedArgument.sol";
import { Migration } from "../Migration.s.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/contracts/MainchainPauseEnforcerDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { Migration } from "../Migration.s.sol";

contract MainchainPauseEnforcerDeploy is Migration {
function run() public virtual returns (IPauseEnforcer) {
return IPauseEnforcer(_deployProxy(Contract.MainchainPauseEnforcer.key(), EMPTY_ARGS));
return IPauseEnforcer(_deployImmutable(Contract.MainchainPauseEnforcer.key()));
}
}
2 changes: 1 addition & 1 deletion script/contracts/RoninGatewayV3Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { IRoninGatewayV3 } from "@ronin/contracts/interfaces/IRoninGatewayV3.sol";
import { IRoninGatewayV3 } from "script/interfaces/IRoninGatewayV3.sol";
import { IWETH } from "src/interfaces/IWETH.sol";
import { Contract } from "../utils/Contract.sol";
import { ISharedArgument } from "../interfaces/ISharedArgument.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/contracts/RoninPauseEnforcerDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { Migration } from "../Migration.s.sol";

contract RoninPauseEnforcerDeploy is Migration {
function run() public virtual returns (IPauseEnforcer) {
return IPauseEnforcer(_deployProxy(Contract.RoninPauseEnforcer.key(), EMPTY_ARGS));
return IPauseEnforcer(_deployImmutable(Contract.RoninPauseEnforcer.key()));
}
}
180 changes: 180 additions & 0 deletions script/interfaces/IMainchainGatewayV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;

import { TokenOwner } from "src/libraries/LibTokenOwner.sol";
import { TokenInfo, TokenStandard, Transfer } from "src/libraries/Transfer.sol";
import { MappedTokenConsumer } from "src/interfaces/consumers/MappedTokenConsumer.sol";
import { VoteStatusConsumer } from "src/interfaces/consumers/VoteStatusConsumer.sol";
import { ContractType } from "src/utils/ContractType.sol";
import { RoleAccess } from "src/utils/RoleAccess.sol";
import { SignatureConsumer } from "src/interfaces/consumers/SignatureConsumer.sol";

interface IMainchainGatewayV3 {
error ErrContractTypeNotFound(ContractType contractType);
error ErrERC1155MintingFailed();
error ErrERC20MintingFailed();
error ErrERC721MintingFailed();
error ErrEmptyArray();
error ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);
error ErrInvalidInfo();
error ErrInvalidOrder(bytes4 msgSig);
error ErrInvalidPercentage();
error ErrInvalidReceipt();
error ErrInvalidReceiptKind();
error ErrInvalidRequest();
error ErrInvalidSigner(address signer, uint256 weight, SignatureConsumer.Signature sig);
error ErrInvalidThreshold(bytes4 msgSig);
error ErrInvalidTokenStandard();
error ErrLengthMismatch(bytes4 msgSig);
error ErrNotWhitelistedToken(address token);
error ErrNullHighTierVoteWeightProvided(bytes4 msgSig);
error ErrNullMinVoteWeightProvided(bytes4 msgSig);
error ErrNullTotalWeightProvided(bytes4 msgSig);
error ErrQueryForApprovedWithdrawal();
error ErrQueryForInsufficientVoteWeight();
error ErrQueryForProcessedWithdrawal();
error ErrReachedDailyWithdrawalLimit();
error ErrRestricted(bytes4 fnSig, TokenStandard standard);
error ErrTokenCouldNotTransfer(TokenInfo tokenInfo, address to, address token);
error ErrTokenCouldNotTransferFrom(TokenInfo tokenInfo, address from, address to, address token);
error ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);
error ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);
error ErrUnsupportedStandard();
error ErrUnsupportedToken();
error ErrWhitelistWrappedTokenInstead();
error ErrZeroCodeContract(address addr);

event ContractUpdated(ContractType indexed contractType, address indexed addr);
event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);
event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);
event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);
event HighTierVoteWeightThresholdUpdated(
uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator
);
event Initialized(uint8 version);
event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);
event Paused(address account);
event Restricted(address indexed by, bytes4 indexed fnSig, uint8 enumBitmap);
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
event ThresholdUpdated(uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator);
event TokenMapped(address[] mainchainTokens, address[] roninTokens, TokenStandard[] standards);
event UnRestricted(address indexed by, bytes4 indexed fnSig);
event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);
event Unpaused(address account);
event WhitelistUpdated(address indexed by, address[] tokens, address[] recipients, uint64[] remoteChainSelectors);
event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);
event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);
event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);
event WrappedNativeTokenContractUpdated(address weth);

receive() external payable;

function DEFAULT_ADMIN_ROLE() external view returns (bytes32);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function WITHDRAWAL_UNLOCKER_ROLE() external view returns (bytes32);
function _MAX_PERCENTAGE() external view returns (uint256);
function checkHighTierVoteWeightThreshold(
uint256 _voteWeight
) external view returns (bool);
function checkThreshold(
uint256 _voteWeight
) external view returns (bool);
function dailyWithdrawalLimit(
address
) external view returns (uint256);
function depositCount() external view returns (uint256);
function emergencyPauser() external view returns (address);
function getContract(
ContractType contractType
) external view returns (address contract_);
function getHighTierVoteWeightThreshold() external view returns (uint256, uint256);
function getRoleAdmin(
bytes32 role
) external view returns (bytes32);
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
function getRoleMemberCount(
bytes32 role
) external view returns (uint256);
function getRoninToken(
address mainchainToken
) external view returns (MappedTokenConsumer.MappedToken memory token);
function getThreshold() external view returns (uint256 num_, uint256 denom_);
function getWhitelistedAddresses(
address[] memory tokens
) external view returns (address[] memory whitelisteds);
function grantRole(bytes32 role, address account) external;
function hasRole(bytes32 role, address account) external view returns (bool);
function highTierThreshold(
address
) external view returns (uint256);
function initializeV5(address migrator, address newEmergencyPauser) external;
function lastDateSynced(
address
) external view returns (uint256);
function lastSyncedWithdrawal(
address
) external view returns (uint256);
function lockedThreshold(
address
) external view returns (uint256);
function mapTokens(address[] memory _mainchainTokens, address[] memory _roninTokens, TokenStandard[] memory _standards) external;
function mapTokensAndThresholds(
address[] memory _mainchainTokens,
address[] memory _roninTokens,
TokenStandard[] memory _standards,
uint256[][4] memory _thresholds
) external;
function migrateERC20(address[] memory tokens, uint256[] memory amounts) external;
function migrateERC721(address[] memory tokens, uint256[] memory ids) external;
function minimumVoteWeight() external view returns (uint256);
function nonce() external view returns (uint256);
function onBridgeOperatorsAdded(address[] memory operators, uint96[] memory weights, bool[] memory addeds) external returns (bytes4);
function onBridgeOperatorsRemoved(address[] memory operators, bool[] memory removeds) external returns (bytes4);
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) external returns (bytes4);
function onERC1155Received(address, address, uint256, uint256, bytes memory) external returns (bytes4);
function pause() external;
function paused() external view returns (bool);
function reachedWithdrawalLimit(address _token, uint256 _quantity) external view returns (bool);
function renounceRole(bytes32 role, address account) external;
function requestDepositFor(
Transfer.Request memory _request
) external payable;
function restrict(bytes4 fnSig, uint8 enumBitmap) external;
function restricted(bytes4 fnSig, TokenStandard standard) external view returns (bool yes);
function revokeRole(bytes32 role, address account) external;
function roninChainId() external view returns (uint256);
function setContract(ContractType contractType, address addr) external;
function setDailyWithdrawalLimits(address[] memory _tokens, uint256[] memory _limits) external;
function setEmergencyPauser(
address _addr
) external;
function setHighTierThresholds(address[] memory _tokens, uint256[] memory _thresholds) external;
function setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator) external returns (uint256 _previousNum, uint256 _previousDenom);
function setLockedThresholds(address[] memory _tokens, uint256[] memory _thresholds) external;
function setThreshold(uint256 num, uint256 denom) external;
function setUnlockFeePercentages(address[] memory _tokens, uint256[] memory _percentages) external;
function setWrappedNativeTokenContract(
address _wrappedToken
) external;
function submitWithdrawal(Transfer.Receipt memory _receipt, SignatureConsumer.Signature[] memory _signatures) external returns (bool _locked);
function supportsInterface(
bytes4 interfaceId
) external view returns (bool);
function unlockFeePercentages(
address
) external view returns (uint256);
function unlockWithdrawal(
Transfer.Receipt memory receipt
) external;
function unpause() external;
function whitelist(address[] memory tokens, address[] memory recipients, uint64[] memory remoteChainSelectors) external;
function withdrawalHash(
uint256
) external view returns (bytes32);
function withdrawalLocked(
uint256
) external view returns (bool);
function wrappedNativeToken() external view returns (address);
}
25 changes: 19 additions & 6 deletions script/interfaces/IPauseEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,33 @@ interface IPauseEnforcer {

function DEFAULT_ADMIN_ROLE() external view returns (bytes32);
function SENTRY_ROLE() external view returns (bytes32);
function changeTarget(address _target) external;
function changeTarget(
address _target
) external;
function emergency() external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function getRoleAdmin(
bytes32 role
) external view returns (bytes32);
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
function getRoleMemberCount(bytes32 role) external view returns (uint256);
function getRoleMemberCount(
bytes32 role
) external view returns (uint256);
function grantRole(bytes32 role, address account) external;
function grantSentry(address _sentry) external;
function grantSentry(
address _sentry
) external;
function hasRole(bytes32 role, address account) external view returns (bool);
function initialize(address _target, address _admin, address[] memory _sentries) external;
function renounceRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function revokeSentry(address _sentry) external;
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function revokeSentry(
address _sentry
) external;
function supportsInterface(
bytes4 interfaceId
) external view returns (bool);
function target() external view returns (address);
function triggerPause() external;
function triggerUnpause() external;
function triggerRestrict(bytes4 fnSig, uint8 enumBitmap) external;
}
Loading
Loading