Skip to content

Commit e30e4f7

Browse files
authored
GitFlow: back merge (#298)
2 parents fa65258 + f301e1a commit e30e4f7

File tree

145 files changed

+28176
-4426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+28176
-4426
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ remix-compiler.config.js
1616
.yarnrc.yml
1717
logs/storage_layout_table.log
1818
cache_foundry
19-
out
19+
out
20+
.DS_Store
21+
22+
dry-run/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
path = lib/prb-math
1010
url = https://github.com/PaulRBerg/prb-math
1111
branch = release-v4
12+
[submodule "lib/solady"]
13+
path = lib/solady
14+
url = https://github.com/vectorized/solady

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ This repo contains source code of contracts that will be either deployed on the
5656

5757
- On mainchains:
5858
- Governance contract: `MainchainGovernanceAdmin`
59-
- Bridge contract: `MainchainGatewayV2`
59+
- Bridge contract: `MainchainGatewayV3`
6060
- Trusted orgs contract: `RoninTrustedOrganization`
6161
- On Ronin chain:
6262
- Governance contract: `RoninGovernanceAdmin`
63-
- Bridge operation: `RoninGatewayV2`
63+
- Bridge operation: `RoninGatewayV3`
6464
- Trusted orgs contract: `RoninTrustedOrganization`
6565
- DPoS contracts
6666

contracts/extensions/GatewayV2.sol renamed to contracts/extensions/GatewayV3.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "@openzeppelin/contracts/security/Pausable.sol";
55
import "../interfaces/IQuorum.sol";
66
import "./collections/HasProxyAdmin.sol";
77

8-
abstract contract GatewayV2 is HasProxyAdmin, Pausable, IQuorum {
8+
abstract contract GatewayV3 is HasProxyAdmin, Pausable, IQuorum {
99
uint256 internal _num;
1010
uint256 internal _denom;
1111

contracts/extensions/WithdrawalLimitation.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import "./GatewayV2.sol";
4+
import "./GatewayV3.sol";
55

6-
abstract contract WithdrawalLimitation is GatewayV2 {
6+
abstract contract WithdrawalLimitation is GatewayV3 {
77
/// @dev Error of invalid percentage.
88
error ErrInvalidPercentage();
99

@@ -50,7 +50,7 @@ abstract contract WithdrawalLimitation is GatewayV2 {
5050
uint256[50] private ______gap;
5151

5252
/**
53-
* @dev Override `GatewayV2-setThreshold`.
53+
* @dev Override `GatewayV3-setThreshold`.
5454
*
5555
* Requirements:
5656
* - The high-tier vote weight threshold must equal to or larger than the normal threshold.

contracts/extensions/version-control/ConditionalImplementControl.sol

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4+
import { HasContracts } from "../collections/HasContracts.sol";
45
import { IConditionalImplementControl } from "../../interfaces/version-control/IConditionalImplementControl.sol";
56
import { ErrorHandler } from "../../libraries/ErrorHandler.sol";
67
import { AddressArrayUtils } from "../../libraries/AddressArrayUtils.sol";
@@ -10,7 +11,7 @@ import { ErrOnlySelfCall, IdentityGuard } from "../../utils/IdentityGuard.sol";
1011
* @title ConditionalImplementControl
1112
* @dev A contract that allows conditional version control of contract implementations.
1213
*/
13-
abstract contract ConditionalImplementControl is IConditionalImplementControl, IdentityGuard {
14+
abstract contract ConditionalImplementControl is IConditionalImplementControl, IdentityGuard, HasContracts {
1415
using ErrorHandler for bool;
1516
using AddressArrayUtils for address[];
1617

@@ -21,6 +22,9 @@ abstract contract ConditionalImplementControl is IConditionalImplementControl, I
2122
*/
2223
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
2324

25+
/// @dev value is equal to keccak256("@ronin.extensions.version-control.ConditionalImplementControl.calldatas.slot") - 1
26+
bytes32 internal constant CALLDATAS_SLOT = 0x330d87be17f5b23d41285647e0e9b0e7124a778feb3f952590ed6a023ae02633;
27+
2428
/**
2529
* @dev address of the proxy that delegates to this contract.
2630
* @notice immutable variables are directly stored in contract code.
@@ -99,11 +103,49 @@ abstract contract ConditionalImplementControl is IConditionalImplementControl, I
99103
_upgradeTo(NEW_IMPL);
100104
}
101105

106+
/**
107+
* @dev See {IConditionalImplementControl-setCallDatas}.
108+
*/
109+
function setCallDatas(bytes[] calldata args) external onlyAdmin onlyDelegateFromProxyStorage {
110+
bytes[] storage callDatas = _callDatas();
111+
uint256 length = args.length;
112+
for (uint256 i; i < length; ) {
113+
callDatas.push(args[i]);
114+
115+
unchecked {
116+
++i;
117+
}
118+
}
119+
}
120+
121+
/**
122+
* @dev Internal function to access the array of calldatas.
123+
* @return callDatas the storage array of calldatas.
124+
*/
125+
function _callDatas() internal pure returns (bytes[] storage callDatas) {
126+
assembly ("memory-safe") {
127+
callDatas.slot := CALLDATAS_SLOT
128+
}
129+
}
130+
102131
function _upgradeTo(address newImplementation) internal {
103132
assembly ("memory-safe") {
104133
sstore(_IMPLEMENTATION_SLOT, newImplementation)
105134
}
106135
emit Upgraded(newImplementation);
136+
137+
bytes[] storage callDatas = _callDatas();
138+
uint256 length = callDatas.length;
139+
bool success;
140+
bytes memory returnOrRevertData;
141+
for (uint256 i; i < length; ) {
142+
(success, returnOrRevertData) = newImplementation.delegatecall(callDatas[i]);
143+
success.handleRevert(bytes4(callDatas[i]), returnOrRevertData);
144+
145+
unchecked {
146+
++i;
147+
}
148+
}
107149
}
108150

109151
/**

contracts/interfaces/IMainchainGatewayV2.sol renamed to contracts/interfaces/IMainchainGatewayV3.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "./consumers/SignatureConsumer.sol";
66
import "./consumers/MappedTokenConsumer.sol";
77
import "../libraries/Transfer.sol";
88

9-
interface IMainchainGatewayV2 is SignatureConsumer, MappedTokenConsumer {
9+
interface IMainchainGatewayV3 is SignatureConsumer, MappedTokenConsumer {
1010
/**
1111
* @dev Error indicating that a query was made for an approved withdrawal.
1212
*/

contracts/interfaces/IRoninGatewayV2.sol renamed to contracts/interfaces/IRoninGatewayV3.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
44
import "../libraries/Transfer.sol";
55
import "./consumers/MappedTokenConsumer.sol";
66

7-
interface IRoninGatewayV2 is MappedTokenConsumer {
7+
interface IRoninGatewayV3 is MappedTokenConsumer {
88
/**
99
* @dev Error thrown when attempting to withdraw funds that have already been migrated.
1010
*/

contracts/interfaces/bridge/IBridgeSlash.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface IBridgeSlash is IBridgeSlashEvents {
1818
uint256 totalBallot,
1919
uint256 totalVote,
2020
uint256 period
21-
) external returns (bool slashed);
21+
) external;
2222

2323
/**
2424
* @dev Returns the penalize durations for the specified bridge operators.

contracts/interfaces/version-control/IConditionalImplementControl.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ interface IConditionalImplementControl {
1414
* @dev Executes the selfUpgrade function, upgrading to the new contract implementation.
1515
*/
1616
function selfUpgrade() external;
17+
18+
/**
19+
* @dev Set additional calldata to call when upgrading via `selfUpgrade`.
20+
*/
21+
function setCallDatas(bytes[] calldata args) external;
1722
}

0 commit comments

Comments
 (0)