From 0ffb0d52ad413d868db4db758942c95751d5dc16 Mon Sep 17 00:00:00 2001 From: huyhuynh3103 Date: Fri, 2 Feb 2024 11:21:28 +0700 Subject: [PATCH] feat+test: remove local chains and fix tryBulkDepositFor on RoninGatewayV3 --- script/Migration.s.sol | 14 +- src/ronin/gateway/RoninGatewayV3.sol | 127 +++++++++--------- test/bridge/integration/BaseIntegration.t.sol | 80 +++++++---- ...oteBridgeOperator.RoninBridgeManager.t.sol | 8 +- .../setConfig.MainchainManager.t.sol | 2 +- .../setConfig.RoninBridgeManager.t.sol | 2 +- ...IsApprovedInLastEpoch.BridgeTracking.t.sol | 10 +- ...otApprovedInLastEpoch.BridgeTracking.t.sol | 6 +- .../submitWithdrawal.MainchainGatewayV3.t.sol | 6 +- .../accessControl.PauseEnforcer.t.sol | 2 +- .../emergencyAction.PauseEnforcer.t.sol | 18 +-- .../set-config/normalPause.GatewayV3.t.sol | 2 +- .../set-config/setConfig.PauseEnforcer.t.sol | 2 +- .../depositVote.RoninGatewayV3.t.sol | 10 +- .../ronin-gateway/updateOperator.t.sol | 80 +++++++---- test/helpers/MainchainBridgeAdminUtils.t.sol | 6 +- test/helpers/ProposalUtils.t.sol | 10 +- test/helpers/RoninBridgeAdminUtils.t.sol | 6 +- 18 files changed, 211 insertions(+), 180 deletions(-) diff --git a/script/Migration.s.sol b/script/Migration.s.sol index 6fd4ff139..a5cc4c273 100644 --- a/script/Migration.s.sol +++ b/script/Migration.s.sol @@ -26,13 +26,15 @@ contract Migration is BaseMigrationV2, Utils { // Undefined } else if (network() == DefaultNetwork.RoninTestnet.key()) { // Undefined - } else if (network() == Network.RoninLocal.key() || network() == Network.EthLocal.key()) { + } else if ( + network() == Network.RoninLocal.key() || network() == Network.EthLocal.key() + || network() == DefaultNetwork.Local.key() + ) { // test param.test.numberOfBlocksInEpoch = 200; param.test.proxyAdmin = makeAddr("proxy-admin"); param.test.dposGA = makeAddr("governance-admin"); param.test.mainchainChainId = Network.EthLocal.chainId(); - param.test.roninChainId = Network.RoninLocal.chainId(); // tokens param.weth.name = "Wrapped WETH"; @@ -95,7 +97,7 @@ contract Migration is BaseMigrationV2, Utils { param.roninBridgeManager.num = 2; param.roninBridgeManager.denom = 4; param.roninBridgeManager.roninChainId = 0; - param.roninBridgeManager.roninChainId = param.test.roninChainId; + param.roninBridgeManager.roninChainId = block.chainid; param.roninBridgeManager.expiryDuration = 60 * 60 * 24 * 14; // 14 days param.roninBridgeManager.bridgeOperators = operatorAddrs; param.roninBridgeManager.governors = governorAddrs; @@ -108,7 +110,7 @@ contract Migration is BaseMigrationV2, Utils { param.mainchainPauseEnforcer.sentries = wrapAddress(makeAddr("pause-enforcer-sentry")); // Mainchain Gateway V3 - param.mainchainGatewayV3.roninChainId = param.test.roninChainId; + param.mainchainGatewayV3.roninChainId = block.chainid; param.mainchainGatewayV3.numerator = 1; param.mainchainGatewayV3.highTierVWNumerator = 10; param.mainchainGatewayV3.denominator = 10; @@ -117,14 +119,12 @@ contract Migration is BaseMigrationV2, Utils { param.mainchainBridgeManager.num = 2; param.mainchainBridgeManager.denom = 4; param.mainchainBridgeManager.roninChainId = 0; - param.mainchainBridgeManager.roninChainId = param.test.roninChainId; + param.mainchainBridgeManager.roninChainId = block.chainid; param.mainchainBridgeManager.bridgeOperators = operatorAddrs; param.mainchainBridgeManager.governors = governorAddrs; param.mainchainBridgeManager.voteWeights = voteWeights; param.mainchainBridgeManager.targetOptions = options; param.mainchainBridgeManager.targets = targets; - } else if (network() == DefaultNetwork.Local.key()) { - // Undefined } else { revert("Migration: Network Unknown Shared Parameters Unimplemented!"); } diff --git a/src/ronin/gateway/RoninGatewayV3.sol b/src/ronin/gateway/RoninGatewayV3.sol index 6a11782c8..4335f659f 100644 --- a/src/ronin/gateway/RoninGatewayV3.sol +++ b/src/ronin/gateway/RoninGatewayV3.sol @@ -75,8 +75,9 @@ contract RoninGatewayV3 is * @dev Reverts if the method caller is not bridge operator. */ function _requireBridgeOperator() internal view { - if (!IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).isBridgeOperator(msg.sender)) + if (!IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).isBridgeOperator(msg.sender)) { revert ErrUnauthorized(msg.sig, RoleAccess.__DEPRECATED_BRIDGE_OPERATOR); + } } /** @@ -88,7 +89,7 @@ contract RoninGatewayV3 is uint256 _denominator, uint256 _trustedNumerator, uint256 _trustedDenominator, - address[] calldata /* _withdrawalMigrators */, + address[] calldata, /* _withdrawalMigrators */ // _packedAddresses[0]: roninTokens // _packedAddresses[1]: mainchainTokens address[][2] calldata _packedAddresses, @@ -122,12 +123,13 @@ contract RoninGatewayV3 is /** * @inheritdoc IRoninGatewayV3 */ - function getWithdrawalSignatures( - uint256 withdrawalId, - address[] calldata operators - ) external view returns (bytes[] memory _signatures) { + function getWithdrawalSignatures(uint256 withdrawalId, address[] calldata operators) + external + view + returns (bytes[] memory _signatures) + { _signatures = new bytes[](operators.length); - for (uint256 _i = 0; _i < operators.length; ) { + for (uint256 _i = 0; _i < operators.length;) { _signatures[_i] = _withdrawalSig[withdrawalId][operators[_i]]; unchecked { @@ -143,25 +145,25 @@ contract RoninGatewayV3 is address _sender = msg.sender; _depositFor(_receipt, _sender, minimumVoteWeight()); IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)).recordVote( - IBridgeTracking.VoteKind.Deposit, - _receipt.id, - _sender + IBridgeTracking.VoteKind.Deposit, _receipt.id, _sender ); } /** * @inheritdoc IRoninGatewayV3 */ - function tryBulkAcknowledgeMainchainWithdrew( - uint256[] calldata _withdrawalIds - ) external onlyBridgeOperator returns (bool[] memory _executedReceipts) { + function tryBulkAcknowledgeMainchainWithdrew(uint256[] calldata _withdrawalIds) + external + onlyBridgeOperator + returns (bool[] memory _executedReceipts) + { address _governor = msg.sender; uint256 _minVoteWeight = minimumVoteWeight(); uint256 _withdrawalId; _executedReceipts = new bool[](_withdrawalIds.length); IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)); - for (uint256 _i; _i < _withdrawalIds.length; ) { + for (uint256 _i; _i < _withdrawalIds.length;) { _withdrawalId = _withdrawalIds[_i]; _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.MainchainWithdrawal, _withdrawalId, _governor); if (mainchainWithdrew(_withdrawalId)) { @@ -187,23 +189,26 @@ contract RoninGatewayV3 is /** * @inheritdoc IRoninGatewayV3 */ - function tryBulkDepositFor( - Transfer.Receipt[] calldata _receipts - ) external whenNotPaused onlyBridgeOperator returns (bool[] memory _executedReceipts) { + function tryBulkDepositFor(Transfer.Receipt[] calldata _receipts) + external + whenNotPaused + onlyBridgeOperator + returns (bool[] memory _executedReceipts) + { address _sender = msg.sender; Transfer.Receipt memory _receipt; _executedReceipts = new bool[](_receipts.length); uint256 _minVoteWeight = minimumVoteWeight(); IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)); - for (uint256 _i; _i < _receipts.length; ) { + for (uint256 _i; _i < _receipts.length;) { _receipt = _receipts[_i]; - _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.Deposit, _receipt.id, _sender); if (depositVote[_receipt.mainchain.chainId][_receipt.id].status == VoteStatus.Executed) { _executedReceipts[_i] = true; } else { _depositFor(_receipt, _sender, _minVoteWeight); } + _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.Deposit, _receipt.id, _sender); unchecked { ++_i; @@ -224,7 +229,7 @@ contract RoninGatewayV3 is function bulkRequestWithdrawalFor(Transfer.Request[] calldata _requests, uint256 _chainId) external whenNotPaused { if (_requests.length == 0) revert ErrEmptyArray(); - for (uint256 _i; _i < _requests.length; ) { + for (uint256 _i; _i < _requests.length;) { _requestWithdrawalFor(_requests[_i], msg.sender, _chainId); unchecked { ++_i; @@ -249,10 +254,11 @@ contract RoninGatewayV3 is /** * @inheritdoc IRoninGatewayV3 */ - function bulkSubmitWithdrawalSignatures( - uint256[] calldata withdrawals, - bytes[] calldata signatures - ) external whenNotPaused onlyBridgeOperator { + function bulkSubmitWithdrawalSignatures(uint256[] calldata withdrawals, bytes[] calldata signatures) + external + whenNotPaused + onlyBridgeOperator + { address operator = msg.sender; if (!(withdrawals.length > 0 && withdrawals.length == signatures.length)) { @@ -263,7 +269,7 @@ contract RoninGatewayV3 is uint256 id; IBridgeTracking _bridgeTrackingContract = IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)); - for (uint256 _i; _i < withdrawals.length; ) { + for (uint256 _i; _i < withdrawals.length;) { id = withdrawals[_i]; _withdrawalSig[id][operator] = signatures[_i]; _bridgeTrackingContract.recordVote(IBridgeTracking.VoteKind.Withdrawal, id, operator); @@ -338,10 +344,11 @@ contract RoninGatewayV3 is uint256[] calldata _chainIds, Token.Standard[] calldata _standards ) internal { - if (!(_roninTokens.length == _mainchainTokens.length && _roninTokens.length == _chainIds.length)) + if (!(_roninTokens.length == _mainchainTokens.length && _roninTokens.length == _chainIds.length)) { revert ErrLengthMismatch(msg.sig); + } - for (uint256 _i; _i < _roninTokens.length; ) { + for (uint256 _i; _i < _roninTokens.length;) { _mainchainToken[_roninTokens[_i]][_chainIds[_i]].tokenAddr = _mainchainTokens[_i]; _mainchainToken[_roninTokens[_i]][_chainIds[_i]].erc = _standards[_i]; @@ -368,8 +375,9 @@ contract RoninGatewayV3 is MappedToken memory _token = getMainchainToken(receipt.ronin.tokenAddr, receipt.mainchain.chainId); - if (!(_token.erc == receipt.info.erc && _token.tokenAddr == receipt.mainchain.tokenAddr)) + if (!(_token.erc == receipt.info.erc && _token.tokenAddr == receipt.mainchain.tokenAddr)) { revert ErrInvalidReceipt(); + } IsolatedGovernance.Vote storage _proposal = depositVote[receipt.mainchain.chainId][id]; bytes32 _receiptHash = receipt.hash(); @@ -379,8 +387,7 @@ contract RoninGatewayV3 is _proposal.status = VoteStatus.Executed; receipt.info.handleAssetTransfer(payable(receipt.ronin.addr), receipt.ronin.tokenAddr, IWETH(address(0))); IBridgeTracking(getContract(ContractType.BRIDGE_TRACKING)).handleVoteApproved( - IBridgeTracking.VoteKind.Deposit, - receipt.id + IBridgeTracking.VoteKind.Deposit, receipt.id ); emit Deposited(_receiptHash, receipt); } @@ -418,12 +425,8 @@ contract RoninGatewayV3 is address _mainchainTokenAddr ) internal returns (uint256 _withdrawalId) { _withdrawalId = withdrawalCount++; - Transfer.Receipt memory _receipt = _request.into_withdrawal_receipt( - _requester, - _withdrawalId, - _mainchainTokenAddr, - _chainId - ); + Transfer.Receipt memory _receipt = + _request.into_withdrawal_receipt(_requester, _withdrawalId, _mainchainTokenAddr, _chainId); withdrawal[_withdrawalId] = _receipt; emit WithdrawalRequested(_receipt.hash(), _receipt); } @@ -450,12 +453,11 @@ contract RoninGatewayV3 is * - The voter has not voted for the round. * */ - function _castIsolatedVote( - IsolatedGovernance.Vote storage _v, - address _voter, - uint256 _minVoteWeight, - bytes32 _hash - ) internal virtual returns (VoteStatus _status) { + function _castIsolatedVote(IsolatedGovernance.Vote storage _v, address _voter, uint256 _minVoteWeight, bytes32 _hash) + internal + virtual + returns (VoteStatus _status) + { _v.castVote(_voter, _hash); uint256 _totalWeight = _getVoteWeight(_v, _hash); return _v.syncVoteStatus(_minVoteWeight, _totalWeight, _hash); @@ -464,16 +466,16 @@ contract RoninGatewayV3 is /** * @dev Returns the vote weight for a specified hash. */ - function _getVoteWeight( - IsolatedGovernance.Vote storage _v, - bytes32 _hash - ) internal view returns (uint256 _totalWeight) { - (, address[] memory bridgeOperators, uint96[] memory weights) = IBridgeManager( - getContract(ContractType.BRIDGE_MANAGER) - ).getFullBridgeOperatorInfos(); + function _getVoteWeight(IsolatedGovernance.Vote storage _v, bytes32 _hash) + internal + view + returns (uint256 _totalWeight) + { + (, address[] memory bridgeOperators, uint96[] memory weights) = + IBridgeManager(getContract(ContractType.BRIDGE_MANAGER)).getFullBridgeOperatorInfos(); uint256 length = bridgeOperators.length; unchecked { - for (uint _i; _i < length; ++_i) { + for (uint256 _i; _i < length; ++_i) { if (_v.voteHashOf[bridgeOperators[_i]] == _hash) { _totalWeight += weights[_i]; } @@ -481,10 +483,12 @@ contract RoninGatewayV3 is } } - function setTrustedThreshold( - uint256 _trustedNumerator, - uint256 _trustedDenominator - ) external virtual onlyAdmin returns (uint256, uint256) { + function setTrustedThreshold(uint256 _trustedNumerator, uint256 _trustedDenominator) + external + virtual + onlyAdmin + returns (uint256, uint256) + { return _setTrustedThreshold(_trustedNumerator, _trustedDenominator); } @@ -501,10 +505,11 @@ contract RoninGatewayV3 is * Emits the `TrustedThresholdUpdated` event. * */ - function _setTrustedThreshold( - uint256 _trustedNumerator, - uint256 _trustedDenominator - ) internal virtual returns (uint256 _previousTrustedNum, uint256 _previousTrustedDenom) { + function _setTrustedThreshold(uint256 _trustedNumerator, uint256 _trustedDenominator) + internal + virtual + returns (uint256 _previousTrustedNum, uint256 _previousTrustedDenom) + { if (_trustedNumerator > _trustedDenominator) revert ErrInvalidTrustedThreshold(); _previousTrustedNum = _num; @@ -513,11 +518,7 @@ contract RoninGatewayV3 is _trustedDenom = _trustedDenominator; unchecked { emit TrustedThresholdUpdated( - nonce++, - _trustedNumerator, - _trustedDenominator, - _previousTrustedNum, - _previousTrustedDenom + nonce++, _trustedNumerator, _trustedDenominator, _previousTrustedNum, _previousTrustedDenom ); } } diff --git a/test/bridge/integration/BaseIntegration.t.sol b/test/bridge/integration/BaseIntegration.t.sol index 0e6f875e5..b86f58554 100644 --- a/test/bridge/integration/BaseIntegration.t.sol +++ b/test/bridge/integration/BaseIntegration.t.sol @@ -105,8 +105,8 @@ contract BaseIntegration_Test is Base_Test { } function _deployContractsOnRonin() internal { - _config.createFork(Network.RoninLocal.key()); - _config.switchTo(Network.RoninLocal.key()); + // _config.createFork(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); _roninGatewayV3 = new RoninGatewayV3Deploy().run(); _bridgeTracking = new BridgeTrackingDeploy().run(); @@ -122,15 +122,14 @@ contract BaseIntegration_Test is Base_Test { _roninUsdc = new USDCDeploy().run(); _param = ISharedArgument(LibSharedAddress.CONFIG).sharedArguments(); - _roninProposalUtils = new RoninBridgeAdminUtils( - _param.test.roninChainId, _param.test.governorPKs, _roninBridgeManager, _param.roninBridgeManager.governors[0] - ); + _roninProposalUtils = + new RoninBridgeAdminUtils(_param.test.governorPKs, _roninBridgeManager, _param.roninBridgeManager.governors[0]); _validatorSet = new MockValidatorContract_OnlyTiming_ForHardhatTest(_param.test.numberOfBlocksInEpoch); } function _deployContractsOnMainchain() internal { - _config.createFork(Network.EthLocal.key()); - _config.switchTo(Network.EthLocal.key()); + // _config.createFork(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); _mainchainPauseEnforcer = new MainchainPauseEnforcerDeploy().run(); _mainchainGatewayV3 = new MainchainGatewayV3Deploy().run(); @@ -144,28 +143,25 @@ contract BaseIntegration_Test is Base_Test { _param = ISharedArgument(LibSharedAddress.CONFIG).sharedArguments(); _mainchainProposalUtils = new MainchainBridgeAdminUtils( - _param.test.roninChainId, - _param.test.governorPKs, - _mainchainBridgeManager, - _param.mainchainBridgeManager.governors[0] + _param.test.governorPKs, _mainchainBridgeManager, _param.mainchainBridgeManager.governors[0] ); } function _initializeRonin() internal { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); - _validatorSet.setCurrentPeriod(block.timestamp / _validatorSet.PERIOD_DURATION() - 2); + _endDayAndWrapUpEpoch(1); - _bridgeRewardInitialize(); - _bridgeTrackingInitialize(); _bridgeSlashInitialize(); + _bridgeTrackingInitialize(); + _bridgeRewardInitialize(); _roninPauseEnforcerInitialize(); _roninGatewayV3Initialize(); _constructForRoninBridgeManager(); } function _initializeMainchain() internal { - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); _mainchainPauseEnforcerInitialize(); _constructForMainchainBridgeManager(); @@ -228,6 +224,9 @@ contract BaseIntegration_Test is Base_Test { _bridgeTracking.initializeV3( address(_roninBridgeManager), address(_bridgeSlash), address(_bridgeReward), _param.test.dposGA ); + + _endDayAndWrapUpEpoch(1); + vm.prank(_param.test.dposGA); _bridgeTracking.initializeREP2(); } @@ -264,7 +263,7 @@ contract BaseIntegration_Test is Base_Test { Token.Standard[] memory standards = new Token.Standard[](tokenNum); for (uint256 i; i < tokenNum; i++) { minimumThreshold[i] = 0; - chainIds[i] = _param.test.mainchainChainId; + chainIds[i] = block.chainid; standards[i] = Token.Standard.ERC20; } @@ -506,7 +505,7 @@ contract BaseIntegration_Test is Base_Test { } function _changeAdminOnRonin() internal { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.startPrank(_param.test.proxyAdmin); TransparentUpgradeableProxyV2(payable(address(_roninGatewayV3))).changeAdmin(address(_roninBridgeManager)); @@ -517,7 +516,7 @@ contract BaseIntegration_Test is Base_Test { } function _changeAdminOnMainchain() internal { - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); vm.startPrank(_param.test.proxyAdmin); TransparentUpgradeableProxyV2(payable(address(_mainchainGatewayV3))).changeAdmin(address(_mainchainBridgeManager)); @@ -525,27 +524,27 @@ contract BaseIntegration_Test is Base_Test { } function _configEmergencyPauserForRoninGateway() internal { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); bytes memory calldata_ = abi.encodeCall(GatewayV3.setEmergencyPauser, (address(_roninPauseEnforcer))); _roninProposalUtils.functionDelegateCall(address(_roninGatewayV3), calldata_); + + _roninBridgeManager.round(2024); } function _configEmergencyPauserForMainchainGateway() internal { - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); bytes memory calldata_ = abi.encodeCall(GatewayV3.setEmergencyPauser, (address(_mainchainPauseEnforcer))); _mainchainProposalUtils.functionDelegateCall(address(_mainchainGatewayV3), calldata_); } function _configBridgeTrackingForRoninGateway() internal { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); bytes memory calldata_ = abi.encodeCall(IHasContracts.setContract, (ContractType.BRIDGE_TRACKING, address(_bridgeTracking))); _roninProposalUtils.functionDelegateCall(address(_roninGatewayV3), calldata_); - - _config.switchTo(Network.EthLocal.key()); } function _deployGeneralConfig() internal { @@ -561,15 +560,38 @@ contract BaseIntegration_Test is Base_Test { vm.roll(block.number + 1); } - function _wrapUpEpoch() internal { - uint256 multiplier = _validatorSet.numberOfBlocksInEpoch(); - vm.roll((block.number / multiplier + 1) * multiplier - 1); + function _endDayAndWrapUpEpoch(uint256 times) internal { + for (uint256 i; i < times; ++i) { + _fastForwardToNextDay(); + _wrapUpEpoch(); + } + } + function _wrapUpEpoch() internal { + console.log("=============== WrapUp Epoch ==========="); + console.log("> period before wrapped up: ", _validatorSet.currentPeriod()); vm.prank(block.coinbase); _validatorSet.wrapUpEpoch(); + console.log("> wrapping up ..."); + console.log("> period after wrap up: ", _validatorSet.currentPeriod()); + console.log("> current epoch: ", _validatorSet.epochOf(block.number)); } - function _setTimestampToPeriodEnding() internal { - vm.warp(((block.timestamp / 1 days) + 1) * 1 days); + function _fastForwardToNextDay() internal { + vm.warp(block.timestamp + 3 seconds); + vm.roll(block.number + 1); + + uint256 numberOfBlocksInEpoch = _validatorSet.numberOfBlocksInEpoch(); + + uint256 epochEndingBlockNumber = block.number + (numberOfBlocksInEpoch - 1) - (block.number % numberOfBlocksInEpoch); + uint256 nextDayTimestamp = block.timestamp + 1 days; + + // fast forward to next day + vm.warp(nextDayTimestamp); + vm.roll(epochEndingBlockNumber); + + console.log("Next day:"); + console.log(">> time:", block.timestamp); + console.log(">> block:", epochEndingBlockNumber); } } diff --git a/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol b/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol index 0b831b4c1..b0df8f932 100644 --- a/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol +++ b/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol @@ -55,7 +55,7 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { } function test_voteAddBridgeOperatorsProposal() public { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); _globalProposal = _roninProposalUtils.createGlobalProposal({ expiryTimestamp: block.timestamp + _proposalExpiryDuration, @@ -88,7 +88,7 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { function test_relayAddBridgeOperator() public { test_voteAddBridgeOperatorsProposal(); - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); // before relay assertEq(_mainchainBridgeManager.globalProposalRelayed(_globalProposal.nonce), false); @@ -117,7 +117,7 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { uint256 numAddingOperators = seed % 10 + 10; _generateAddingOperators(numAddingOperators); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); _globalProposal = _roninProposalUtils.createGlobalProposal({ expiryTimestamp: block.timestamp + _proposalExpiryDuration, @@ -150,7 +150,7 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { function test_relayExpiredProposal() public { test_voteAddBridgeOperatorsProposal(); - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); vm.warp(block.timestamp + _proposalExpiryDuration + 1); // before relay diff --git a/test/bridge/integration/bridge-manager/set-config/setConfig.MainchainManager.t.sol b/test/bridge/integration/bridge-manager/set-config/setConfig.MainchainManager.t.sol index 311aefff8..021f08260 100644 --- a/test/bridge/integration/bridge-manager/set-config/setConfig.MainchainManager.t.sol +++ b/test/bridge/integration/bridge-manager/set-config/setConfig.MainchainManager.t.sol @@ -8,7 +8,7 @@ import "../../BaseIntegration.t.sol"; contract SetConfig_MainchainManager_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); } function test_configBridgeContractCorrectly() external { diff --git a/test/bridge/integration/bridge-manager/set-config/setConfig.RoninBridgeManager.t.sol b/test/bridge/integration/bridge-manager/set-config/setConfig.RoninBridgeManager.t.sol index 887ca08d0..f13c12302 100644 --- a/test/bridge/integration/bridge-manager/set-config/setConfig.RoninBridgeManager.t.sol +++ b/test/bridge/integration/bridge-manager/set-config/setConfig.RoninBridgeManager.t.sol @@ -8,7 +8,7 @@ import "../../BaseIntegration.t.sol"; contract SetConfig_RoninBridgeManager_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); } function test_configBridgeContractCorrectly() external { diff --git a/test/bridge/integration/bridge-tracking/EpochE1_VoteIsApprovedInLastEpoch.BridgeTracking.t.sol b/test/bridge/integration/bridge-tracking/EpochE1_VoteIsApprovedInLastEpoch.BridgeTracking.t.sol index 3cdb172f2..a4f36dff8 100644 --- a/test/bridge/integration/bridge-tracking/EpochE1_VoteIsApprovedInLastEpoch.BridgeTracking.t.sol +++ b/test/bridge/integration/bridge-tracking/EpochE1_VoteIsApprovedInLastEpoch.BridgeTracking.t.sol @@ -16,7 +16,7 @@ contract EpochE1_VoteIsApprovedInLastEpoch_BridgeTracking_Test is BaseIntegratio function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.coinbase(makeAddr("coin-base-addr")); _operators.push(_param.roninBridgeManager.bridgeOperators[0]); @@ -33,7 +33,7 @@ contract EpochE1_VoteIsApprovedInLastEpoch_BridgeTracking_Test is BaseIntegratio vm.deal(address(_bridgeReward), 10 ether); - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); _period = _validatorSet.currentPeriod(); @@ -79,7 +79,7 @@ contract EpochE1_VoteIsApprovedInLastEpoch_BridgeTracking_Test is BaseIntegratio test_epochE1_notRecordVoteAndBallot_voteInLastEpoch(); uint256 lastPeriod = _period; - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); uint256 newPeriod = _validatorSet.currentPeriod(); @@ -144,7 +144,7 @@ contract EpochE1_VoteIsApprovedInLastEpoch_BridgeTracking_Test is BaseIntegratio assertEq(_bridgeTracking.totalBallotOf(_period, _param.roninBridgeManager.bridgeOperators[3]), expectedTotalVotes); assertEq(_bridgeTracking.totalBallotOf(_period, _param.roninBridgeManager.bridgeOperators[4]), expectedTotalVotes); - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); assertEq(_bridgeTracking.totalVote(_period), expectedTotalVotes); @@ -177,7 +177,7 @@ contract EpochE1_VoteIsApprovedInLastEpoch_BridgeTracking_Test is BaseIntegratio function test_epoch3E_metricOfNewPeriodGetReset() public { test_epoch3E_notRecordNewBallot_periodMetricIsFinalizedAsInEpoch2E_1(); - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); uint256 lastPeriod = _period; diff --git a/test/bridge/integration/bridge-tracking/EpochE2_VoteIsNotApprovedInLastEpoch.BridgeTracking.t.sol b/test/bridge/integration/bridge-tracking/EpochE2_VoteIsNotApprovedInLastEpoch.BridgeTracking.t.sol index 1f3f2c03a..6e198eced 100644 --- a/test/bridge/integration/bridge-tracking/EpochE2_VoteIsNotApprovedInLastEpoch.BridgeTracking.t.sol +++ b/test/bridge/integration/bridge-tracking/EpochE2_VoteIsNotApprovedInLastEpoch.BridgeTracking.t.sol @@ -16,7 +16,7 @@ contract EpochE2_VoteIsNotApprovedInLastEpoch_BridgeTracking_Test is BaseIntegra function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.coinbase(makeAddr("coin-base-addr")); // upgrade ronin gateway v3 @@ -28,7 +28,7 @@ contract EpochE2_VoteIsNotApprovedInLastEpoch_BridgeTracking_Test is BaseIntegra vm.deal(address(_bridgeReward), 10 ether); - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); _period = _validatorSet.currentPeriod(); @@ -92,7 +92,7 @@ contract EpochE2_VoteIsNotApprovedInLastEpoch_BridgeTracking_Test is BaseIntegra function test_epochE_continueVotingForVoteInE2_notRecordInNextPeriod() public { test_epochE1_recordForWhoVoteLately_onceRequestIsApproved(); - _setTimestampToPeriodEnding(); + _fastForwardToNextDay(); _wrapUpEpochAndMine(); uint256 lastPeriod = _period; diff --git a/test/bridge/integration/mainchain-gateway/submit-withdrawal/submitWithdrawal.MainchainGatewayV3.t.sol b/test/bridge/integration/mainchain-gateway/submit-withdrawal/submitWithdrawal.MainchainGatewayV3.t.sol index ea51c8b99..c7d310120 100644 --- a/test/bridge/integration/mainchain-gateway/submit-withdrawal/submitWithdrawal.MainchainGatewayV3.t.sol +++ b/test/bridge/integration/mainchain-gateway/submit-withdrawal/submitWithdrawal.MainchainGatewayV3.t.sol @@ -16,7 +16,7 @@ contract SubmitWithdrawal_MainchainGatewayV3_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.EthLocal.key()); + // _config.switchTo(Network.EthLocal.key()); _domainSeparator = _mainchainGatewayV3.DOMAIN_SEPARATOR(); @@ -24,10 +24,10 @@ contract SubmitWithdrawal_MainchainGatewayV3_Test is BaseIntegration_Test { _withdrawalReceipt.kind = Transfer.Kind.Withdrawal; _withdrawalReceipt.ronin.addr = makeAddr("requester"); _withdrawalReceipt.ronin.tokenAddr = address(_roninWeth); - _withdrawalReceipt.ronin.chainId = _param.test.roninChainId; + _withdrawalReceipt.ronin.chainId = block.chainid; _withdrawalReceipt.mainchain.addr = makeAddr("recipient"); _withdrawalReceipt.mainchain.tokenAddr = address(_mainchainWeth); - _withdrawalReceipt.mainchain.chainId = _param.test.mainchainChainId; + _withdrawalReceipt.mainchain.chainId = block.chainid; _withdrawalReceipt.info.erc = Token.Standard.ERC20; _withdrawalReceipt.info.id = 0; _withdrawalReceipt.info.quantity = 0; diff --git a/test/bridge/integration/pause-enforcer/set-config/accessControl.PauseEnforcer.t.sol b/test/bridge/integration/pause-enforcer/set-config/accessControl.PauseEnforcer.t.sol index 250529ba4..194ea5629 100644 --- a/test/bridge/integration/pause-enforcer/set-config/accessControl.PauseEnforcer.t.sol +++ b/test/bridge/integration/pause-enforcer/set-config/accessControl.PauseEnforcer.t.sol @@ -6,7 +6,7 @@ import "../../BaseIntegration.t.sol"; contract AccessControl_PauseEnforcer_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); } function test_changeAdmin_OfPauseEnforcer() public { diff --git a/test/bridge/integration/pause-enforcer/set-config/emergencyAction.PauseEnforcer.t.sol b/test/bridge/integration/pause-enforcer/set-config/emergencyAction.PauseEnforcer.t.sol index 04126e766..dc86034b8 100644 --- a/test/bridge/integration/pause-enforcer/set-config/emergencyAction.PauseEnforcer.t.sol +++ b/test/bridge/integration/pause-enforcer/set-config/emergencyAction.PauseEnforcer.t.sol @@ -14,7 +14,7 @@ contract EmergencyAction_PauseEnforcer_Test is BaseIntegration_Test { // Should be able to emergency pause function test_EmergencyPause_RoninGatewayV3() public { - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.prank(_param.roninPauseEnforcer.sentries[0]); _roninPauseEnforcer.triggerPause(); @@ -28,12 +28,8 @@ contract EmergencyAction_PauseEnforcer_Test is BaseIntegration_Test { Transfer.Receipt memory receipt = Transfer.Receipt({ id: 0, kind: Transfer.Kind.Deposit, - ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: _param.test.roninChainId }), - mainchain: Token.Owner({ - addr: makeAddr("requester"), - tokenAddr: address(_mainchainWeth), - chainId: _param.test.mainchainChainId - }), + ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: block.chainid }), + mainchain: Token.Owner({ addr: makeAddr("requester"), tokenAddr: address(_mainchainWeth), chainId: block.chainid }), info: Token.Info({ erc: Token.Standard.ERC20, id: 0, quantity: 100 }) }); @@ -69,12 +65,8 @@ contract EmergencyAction_PauseEnforcer_Test is BaseIntegration_Test { Transfer.Receipt memory receipt = Transfer.Receipt({ id: 0, kind: Transfer.Kind.Deposit, - ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: _param.test.roninChainId }), - mainchain: Token.Owner({ - addr: makeAddr("requester"), - tokenAddr: address(_mainchainWeth), - chainId: _param.test.mainchainChainId - }), + ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: block.chainid }), + mainchain: Token.Owner({ addr: makeAddr("requester"), tokenAddr: address(_mainchainWeth), chainId: block.chainid }), info: Token.Info({ erc: Token.Standard.ERC20, id: 0, quantity: 100 }) }); diff --git a/test/bridge/integration/pause-enforcer/set-config/normalPause.GatewayV3.t.sol b/test/bridge/integration/pause-enforcer/set-config/normalPause.GatewayV3.t.sol index 77a3cb9ad..320ebce8a 100644 --- a/test/bridge/integration/pause-enforcer/set-config/normalPause.GatewayV3.t.sol +++ b/test/bridge/integration/pause-enforcer/set-config/normalPause.GatewayV3.t.sol @@ -11,7 +11,7 @@ contract NormalPause_GatewayV3_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); } // Should gateway admin can pause the gateway through voting diff --git a/test/bridge/integration/pause-enforcer/set-config/setConfig.PauseEnforcer.t.sol b/test/bridge/integration/pause-enforcer/set-config/setConfig.PauseEnforcer.t.sol index e9bde2189..d23bd5567 100644 --- a/test/bridge/integration/pause-enforcer/set-config/setConfig.PauseEnforcer.t.sol +++ b/test/bridge/integration/pause-enforcer/set-config/setConfig.PauseEnforcer.t.sol @@ -8,7 +8,7 @@ import "../../BaseIntegration.t.sol"; contract SetConfig_PauseEnforcer_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); } function test_configPauseEnforcerContract() public { diff --git a/test/bridge/integration/ronin-gateway/depositVote.RoninGatewayV3.t.sol b/test/bridge/integration/ronin-gateway/depositVote.RoninGatewayV3.t.sol index f0e13164e..c51a3e98e 100644 --- a/test/bridge/integration/ronin-gateway/depositVote.RoninGatewayV3.t.sol +++ b/test/bridge/integration/ronin-gateway/depositVote.RoninGatewayV3.t.sol @@ -18,19 +18,15 @@ contract DepositVote_RoninGatewayV3_Test is BaseIntegration_Test { function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.etch(address(_roninGatewayV3), address(new MockRoninGatewayV3Extended()).code); Transfer.Receipt memory receipt = Transfer.Receipt({ id: 0, kind: Transfer.Kind.Deposit, - ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: _param.test.roninChainId }), - mainchain: Token.Owner({ - addr: makeAddr("requester"), - tokenAddr: address(_mainchainWeth), - chainId: _param.test.mainchainChainId - }), + ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: block.chainid }), + mainchain: Token.Owner({ addr: makeAddr("requester"), tokenAddr: address(_mainchainWeth), chainId: block.chainid }), info: Token.Info({ erc: Token.Standard.ERC20, id: 0, quantity: 100 }) }); diff --git a/test/bridge/integration/ronin-gateway/updateOperator.t.sol b/test/bridge/integration/ronin-gateway/updateOperator.t.sol index deb9b947a..b6c60555c 100644 --- a/test/bridge/integration/ronin-gateway/updateOperator.t.sol +++ b/test/bridge/integration/ronin-gateway/updateOperator.t.sol @@ -17,26 +17,22 @@ contract UpdateOperator_RoninGatewayV3_Test is BaseIntegration_Test { uint256 _numOperatorsForVoteExecuted; Transfer.Receipt[] first50Receipts; Transfer.Receipt[] second50Receipts; + uint256 id = 0; function setUp() public virtual override { super.setUp(); - _config.switchTo(Network.RoninLocal.key()); + // _config.switchTo(Network.RoninLocal.key()); vm.deal(address(_bridgeReward), 10 ether); _newBridgeOperator = makeAddr("new-bridge-operator"); Transfer.Receipt memory sampleReceipt = Transfer.Receipt({ id: 0, kind: Transfer.Kind.Deposit, - ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: _param.test.roninChainId }), - mainchain: Token.Owner({ - addr: makeAddr("requester"), - tokenAddr: address(_mainchainWeth), - chainId: _param.test.mainchainChainId - }), + ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: block.chainid }), + mainchain: Token.Owner({ addr: makeAddr("requester"), tokenAddr: address(_mainchainWeth), chainId: block.chainid }), info: Token.Info({ erc: Token.Standard.ERC20, id: 0, quantity: 100 }) }); - uint256 id = 1; for (uint256 i; i < 50; i++) { first50Receipts.push(sampleReceipt); second50Receipts.push(sampleReceipt); @@ -51,38 +47,68 @@ contract UpdateOperator_RoninGatewayV3_Test is BaseIntegration_Test { } function test_bulkDeposit_100Txs() public { - _setTimestampToPeriodEnding(); - _wrapUpEpochAndMine(); - uint256 periodAfter = _validatorSet.currentPeriod(); + console.log("=============== Test Update Operator ==========="); - for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { - vm.prank(_param.roninBridgeManager.bridgeOperators[i]); - _roninGatewayV3.tryBulkDepositFor(first50Receipts); - } + _depositFor(); + + _endDayAndWrapUpEpoch(1); + + _depositFor(); + + _endDayAndWrapUpEpoch(1); + console.log( + "totalVote of period", + _validatorSet.currentPeriod() - 1, + _bridgeTracking.totalVote(_validatorSet.currentPeriod() - 1) + ); + + console.log("=============== First 50 Receipts ==========="); + _bulkDepositFor(first50Receipts); + + console.log("=============== Update bridge operator ==========="); vm.prank(_param.roninBridgeManager.governors[0]); _roninBridgeManager.updateBridgeOperator(_newBridgeOperator); - _param.roninBridgeManager.bridgeOperators[0] = _newBridgeOperator; - for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { - vm.prank(_param.roninBridgeManager.bridgeOperators[i]); - _roninGatewayV3.tryBulkDepositFor(second50Receipts); - } + console.log("=============== Second 50 Receipts ==========="); + _bulkDepositFor(second50Receipts); - uint256[] memory totalBallots2 = - _bridgeTracking.getManyTotalBallots(periodAfter, _param.roninBridgeManager.bridgeOperators); + _endDayAndWrapUpEpoch(1); - _setTimestampToPeriodEnding(); - _wrapUpEpochAndMine(); - _wrapUpEpochAndMine(); + console.log( + "totalVote of period", + _validatorSet.currentPeriod() - 1, + _bridgeTracking.totalVote(_validatorSet.currentPeriod() - 1) + ); + console.log( + "totalVote of period", _validatorSet.currentPeriod(), _bridgeTracking.totalVote(_validatorSet.currentPeriod()) + ); - Transfer.Receipt memory sampleReceipt = first50Receipts[0]; - sampleReceipt.id = 101; + console.log("=============== Check slash and reward behavior ==========="); + _depositFor(); + + _endDayAndWrapUpEpoch(1); + + _depositFor(); + } + function _depositFor() internal { + Transfer.Receipt memory sampleReceipt = first50Receipts[0]; + sampleReceipt.id = ++id + 50; for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { + console.log("Operator vote: ", i); vm.prank(_param.roninBridgeManager.bridgeOperators[i]); _roninGatewayV3.depositFor(sampleReceipt); } } + + function _bulkDepositFor(Transfer.Receipt[] memory receipts) internal { + for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { + console.log("Operator vote: ", i); + + vm.prank(_param.roninBridgeManager.bridgeOperators[i]); + _roninGatewayV3.tryBulkDepositFor(receipts); + } + } } diff --git a/test/helpers/MainchainBridgeAdminUtils.t.sol b/test/helpers/MainchainBridgeAdminUtils.t.sol index 1d02105a8..55c534d05 100644 --- a/test/helpers/MainchainBridgeAdminUtils.t.sol +++ b/test/helpers/MainchainBridgeAdminUtils.t.sol @@ -8,9 +8,7 @@ contract MainchainBridgeAdminUtils is ProposalUtils { MainchainBridgeManager _contract; address _sender; - constructor(uint256 roninChainId, uint256[] memory signerPKs, MainchainBridgeManager contract_, address sender) - ProposalUtils(roninChainId, signerPKs) - { + constructor(uint256[] memory signerPKs, MainchainBridgeManager contract_, address sender) ProposalUtils(signerPKs) { _contract = contract_; _sender = sender; } @@ -26,7 +24,7 @@ contract MainchainBridgeAdminUtils is ProposalUtils { value: 0, calldata_: abi.encodeWithSignature("functionDelegateCall(bytes)", data), gasAmount: 2_000_000, - nonce: _contract.round(_roninChainId) + 1 + nonce: _contract.round(block.chainid) + 1 }); SignatureConsumer.Signature[] memory signatures = this.generateSignatures(proposal); diff --git a/test/helpers/ProposalUtils.t.sol b/test/helpers/ProposalUtils.t.sol index ef504c8be..4e06b0b53 100644 --- a/test/helpers/ProposalUtils.t.sol +++ b/test/helpers/ProposalUtils.t.sol @@ -15,13 +15,11 @@ contract ProposalUtils is Utils, Test { using GlobalProposal for GlobalProposal.GlobalProposalDetail; using Proposal for Proposal.ProposalDetail; - uint256 _roninChainId; uint256[] _signerPKs; bytes32 _domain; - constructor(uint256 roninChainId, uint256[] memory signerPKs) { - _roninChainId = roninChainId; - _domain = getBridgeManagerDomain(roninChainId); + constructor(uint256[] memory signerPKs) { + _domain = getBridgeManagerDomain(); for (uint256 i; i < signerPKs.length; i++) { _signerPKs.push(signerPKs[i]); @@ -118,13 +116,13 @@ contract ProposalUtils is Utils, Test { return generateSignaturesGlobal(proposal, _signerPKs, Ballot.VoteType.For); } - function getBridgeManagerDomain(uint256 roninChainId) public pure returns (bytes32) { + function getBridgeManagerDomain() public view returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,bytes32 salt)"), keccak256("BridgeAdmin"), // name hash keccak256("2"), // version hash - keccak256(abi.encode("BRIDGE_ADMIN", roninChainId)) // salt + keccak256(abi.encode("BRIDGE_ADMIN", block.chainid)) // salt ) ); } diff --git a/test/helpers/RoninBridgeAdminUtils.t.sol b/test/helpers/RoninBridgeAdminUtils.t.sol index 180d88fe4..1b65257de 100644 --- a/test/helpers/RoninBridgeAdminUtils.t.sol +++ b/test/helpers/RoninBridgeAdminUtils.t.sol @@ -8,9 +8,7 @@ contract RoninBridgeAdminUtils is ProposalUtils { RoninBridgeManager _contract; address _sender; - constructor(uint256 roninChainId, uint256[] memory signerPKs, RoninBridgeManager contract_, address sender) - ProposalUtils(roninChainId, signerPKs) - { + constructor(uint256[] memory signerPKs, RoninBridgeManager contract_, address sender) ProposalUtils(signerPKs) { _contract = contract_; _sender = sender; } @@ -26,7 +24,7 @@ contract RoninBridgeAdminUtils is ProposalUtils { value: 0, calldata_: abi.encodeWithSignature("functionDelegateCall(bytes)", data), gasAmount: 2_000_000, - nonce: _contract.round(_roninChainId) + 1 + nonce: _contract.round(block.chainid) + 1 }); SignatureConsumer.Signature[] memory signatures = this.generateSignatures(proposal);