Skip to content

Commit fdad86c

Browse files
committed
Merge branch 'v2.5.0-fixes' into fix/FLY-2216
2 parents 2362710 + a0177da commit fdad86c

File tree

80 files changed

+2294
-1989
lines changed

Some content is hidden

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

80 files changed

+2294
-1989
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on: [push, pull_request, workflow_dispatch]
77

88
permissions:
99
contents: read
10+
packages: read
1011

1112
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1213
jobs:

.github/workflows/fuzz.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Fuzz test smart contracts
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- QA-Test
8+
- Stable-Test
9+
- master
10+
- "v*.*.*"
11+
pull_request:
12+
branches:
13+
- QA-Test
14+
- Stable-Test
15+
- master
16+
- "v*.*.*"
17+
18+
permissions:
19+
contents: read
20+
packages: read
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
28+
- name: Use Node.js 20.15.1
29+
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
30+
with:
31+
node-version: "20.15.1"
32+
33+
- name: NPM Login
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: npm config set //npm.pkg.github.com/:_authToken $GITHUB_TOKEN
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: "Install Foundry"
42+
uses: "foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e" # v1.5.0
43+
with:
44+
version: stable
45+
46+
- name: Lint contracts
47+
run: npm run lint:sol
48+
49+
- name: Compile contracts
50+
run: npm run compile
51+
52+
- name: Fuzz test smart contracts
53+
run: npm run test:fuzz

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ PegIn Quotes consist of:
4848
uint callTime; // the time (in seconds) that the LP has to perform the call on behalf of the user after the deposit achieves the number of confirmations
4949
uint depositConfirmations; // the number of confirmations that the LP requires before making the call
5050
bool callOnRegister: // a boolean value indicating whether the callForUser can be called on registerPegIn.
51-
uint256 productFeeAmount; // the fee payed to the network DAO
5251
uint256 gasFee; // the fee payed to the LP to cover the gas of the RSK transaction
5352
}
5453

@@ -72,7 +71,6 @@ PegOut Quotes consist of:
7271
uint transferTime; // the time (in seconds) that the LP has to transfer on behalf of the user after the deposit achieves the number of confirmations
7372
uint expireDate; // the timestamp to consider the quote expired
7473
uint expireBlock; // the block number to consider the quote expired
75-
uint256 productFeeAmount; // the fee payed to the network DAO
7674
uint256 gasFee; // the fee payed to the LP to cover the fee of the BTC transaction
7775
}
7876

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"compile": "npm run lint:sol && forge build",
88
"test": "npm run compile && make test-unit",
9+
"test:fuzz": "npm run compile && make test-fuzz",
910
"coverage": "forge coverage",
1011
"lint:ts": "npx prettier --check . && npx eslint .",
1112
"lint:sol": "solhint 'src/**/*.sol'",

script/ComputeStorageSlot.s.sol

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.25;
3+
4+
import "forge-std/Script.sol";
5+
6+
contract ComputeStorageSlot is Script {
7+
function run() external view {
8+
bytes32 slotPauseRegistry = bytes32(
9+
uint256(
10+
keccak256(
11+
abi.encode(
12+
uint256(keccak256("rsk.flyover.PauseRegistry")) - 1
13+
)
14+
)
15+
) & ~uint256(0xff)
16+
);
17+
bytes32 slotEmergencyPause = bytes32(
18+
uint256(
19+
keccak256(
20+
abi.encode(
21+
uint256(keccak256("rsk.flyover.EmergencyPause")) - 1
22+
)
23+
)
24+
) & ~uint256(0xff)
25+
);
26+
console.logBytes32(slotPauseRegistry);
27+
console.logBytes32(slotEmergencyPause);
28+
}
29+
}

script/HelperConfig.s.sol

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import {Script} from "lib/forge-std/src/Script.sol";
55
import {BridgeMock} from "../src/test-contracts/BridgeMock.sol";
66

77
contract HelperConfig is Script {
8-
error InvalidDaoFeeConfiguration(
9-
uint256 feePercentage,
10-
address feeCollector
11-
);
12-
138
struct NetworkConfig {
149
address bridge;
1510
uint256 minimumCollateral;
@@ -33,8 +28,6 @@ contract HelperConfig is Script {
3328
uint256 dustThreshold;
3429
uint256 btcBlockTime;
3530
bool mainnet;
36-
uint256 daoFeePercentage;
37-
address payable daoFeeCollector;
3831
uint48 adminDelay;
3932
}
4033

@@ -193,23 +186,9 @@ contract HelperConfig is Script {
193186
cachedFlyoverConfig = getFlyoverLocalConfig();
194187
}
195188

196-
// Validate DAO fee configuration
197-
_validateDaoFeeConfig(cachedFlyoverConfig);
198-
199189
return cachedFlyoverConfig;
200190
}
201191

202-
/// @notice Validate that DAO fee configuration is consistent
203-
/// @dev If feePercentage > 0, feeCollector must not be address(0)
204-
function _validateDaoFeeConfig(FlyoverConfig memory cfg) internal pure {
205-
if (cfg.daoFeePercentage > 0 && cfg.daoFeeCollector == address(0)) {
206-
revert InvalidDaoFeeConfiguration(
207-
cfg.daoFeePercentage,
208-
cfg.daoFeeCollector
209-
);
210-
}
211-
}
212-
213192
/// @notice Build Flyover config for a specific network suffix
214193
/// @param suffix The network suffix (e.g., "MAINNET", "TESTNET")
215194
/// @param isMainnet Whether this is mainnet
@@ -250,16 +229,6 @@ contract HelperConfig is Script {
250229
uint256(600)
251230
),
252231
mainnet: isMainnet,
253-
daoFeePercentage: vm.envOr(
254-
string.concat("DAO_FEE_PERCENTAGE_", suffix),
255-
uint256(0)
256-
),
257-
daoFeeCollector: payable(
258-
vm.envOr(
259-
string.concat("DAO_FEE_COLLECTOR_", suffix),
260-
address(0)
261-
)
262-
),
263232
adminDelay: uint48(
264233
vm.envOr(string.concat("ADMIN_DELAY_", suffix), uint256(0))
265234
)
@@ -286,13 +255,6 @@ contract HelperConfig is Script {
286255
),
287256
btcBlockTime: vm.envOr("BTC_BLOCK_TIME_LOCAL", uint256(600)),
288257
mainnet: false,
289-
daoFeePercentage: vm.envOr(
290-
"DAO_FEE_PERCENTAGE_LOCAL",
291-
uint256(0)
292-
),
293-
daoFeeCollector: payable(
294-
vm.envOr("DAO_FEE_COLLECTOR_LOCAL", address(0))
295-
),
296258
adminDelay: uint48(vm.envOr("ADMIN_DELAY_LOCAL", uint256(0)))
297259
});
298260
}

script/deployment/DeployCollateralManagement.s.sol

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ pragma solidity 0.8.25;
44
import {Script, console} from "lib/forge-std/src/Script.sol";
55
import {HelperConfig} from "../HelperConfig.s.sol";
66
import {CollateralManagementContract} from "../../src/CollateralManagement.sol";
7+
import {PauseRegistry} from "../../src/PauseRegistry.sol";
78
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
89
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
910

1011
/// @title DeployCollateralManagement
1112
/// @notice Deploys the CollateralManagement contract with proxy pattern
13+
/// @dev Requires PAUSE_REGISTRY_PROXY env var
1214
contract DeployCollateralManagement is Script {
1315
struct DeploymentResult {
1416
address implementation;
@@ -22,16 +24,23 @@ contract DeployCollateralManagement is Script {
2224
uint256 deployerKey = helper.getDeployerPrivateKey();
2325
address deployer = vm.rememberKey(deployerKey);
2426

27+
address pauseRegistryProxy = vm.envAddress("PAUSE_REGISTRY_PROXY");
28+
require(
29+
pauseRegistryProxy != address(0),
30+
"PAUSE_REGISTRY_PROXY required"
31+
);
32+
2533
vm.startBroadcast(deployerKey);
26-
result = _deploy(deployer, cfg);
34+
result = _deploy(deployer, cfg, pauseRegistryProxy);
2735
vm.stopBroadcast();
2836

2937
_log(result);
3038
}
3139

3240
function _deploy(
3341
address defaultAdmin,
34-
HelperConfig.FlyoverConfig memory cfg
42+
HelperConfig.FlyoverConfig memory cfg,
43+
address pauseRegistryProxy
3544
) private returns (DeploymentResult memory result) {
3645
result.implementation = address(new CollateralManagementContract());
3746
result.admin = address(new ProxyAdmin(defaultAdmin));
@@ -46,7 +55,8 @@ contract DeployCollateralManagement is Script {
4655
cfg.adminDelay,
4756
cfg.minimumCollateral,
4857
cfg.resignDelayBlocks,
49-
cfg.rewardPercentage
58+
cfg.rewardPercentage,
59+
PauseRegistry(pauseRegistryProxy)
5060
)
5161
)
5262
)

script/deployment/DeployFlyover.s.sol

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {HelperConfig} from "../HelperConfig.s.sol";
77

88
import {CollateralManagementContract} from "../../src/CollateralManagement.sol";
99
import {FlyoverDiscovery} from "../../src/FlyoverDiscovery.sol";
10+
import {PauseRegistry} from "../../src/PauseRegistry.sol";
1011
import {PegInContract} from "../../src/PegInContract.sol";
1112
import {PegOutContract} from "../../src/PegOutContract.sol";
1213

@@ -18,6 +19,7 @@ import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.s
1819
/// @dev Gas optimized: single ProxyAdmin, inlined deployment logic, linked libraries
1920
contract DeployFlyover is Script {
2021
struct FlyoverDeployment {
22+
address pauseRegistryProxy;
2123
address collateralManagementImpl;
2224
address collateralManagementProxy;
2325
address flyoverDiscoveryImpl;
@@ -54,6 +56,16 @@ contract DeployFlyover is Script {
5456
// Single ProxyAdmin for all contracts
5557
d.proxyAdmin = address(new ProxyAdmin(defaultAdmin));
5658

59+
// 0) PauseRegistry (shared by all)
60+
PauseRegistry prImpl = new PauseRegistry();
61+
d.pauseRegistryProxy = address(
62+
new TransparentUpgradeableProxy(
63+
address(prImpl),
64+
d.proxyAdmin,
65+
abi.encodeCall(prImpl.initialize, (0, defaultAdmin))
66+
)
67+
);
68+
5769
// 1) CollateralManagement
5870
d.collateralManagementImpl = address(
5971
new CollateralManagementContract()
@@ -69,7 +81,8 @@ contract DeployFlyover is Script {
6981
cfg.adminDelay,
7082
cfg.minimumCollateral,
7183
cfg.resignDelayBlocks,
72-
cfg.rewardPercentage
84+
cfg.rewardPercentage,
85+
PauseRegistry(d.pauseRegistryProxy)
7386
)
7487
)
7588
)
@@ -83,7 +96,12 @@ contract DeployFlyover is Script {
8396
d.proxyAdmin,
8497
abi.encodeCall(
8598
FlyoverDiscovery.initialize,
86-
(defaultAdmin, cfg.adminDelay, d.collateralManagementProxy)
99+
(
100+
defaultAdmin,
101+
cfg.adminDelay,
102+
d.collateralManagementProxy,
103+
PauseRegistry(d.pauseRegistryProxy)
104+
)
87105
)
88106
)
89107
);
@@ -103,8 +121,7 @@ contract DeployFlyover is Script {
103121
cfg.minimumPegIn,
104122
d.collateralManagementProxy,
105123
cfg.mainnet,
106-
cfg.daoFeePercentage,
107-
cfg.daoFeeCollector
124+
PauseRegistry(d.pauseRegistryProxy)
108125
)
109126
)
110127
)
@@ -125,8 +142,7 @@ contract DeployFlyover is Script {
125142
d.collateralManagementProxy,
126143
cfg.mainnet,
127144
cfg.btcBlockTime,
128-
cfg.daoFeePercentage,
129-
cfg.daoFeeCollector
145+
PauseRegistry(d.pauseRegistryProxy)
130146
)
131147
)
132148
)
@@ -148,6 +164,7 @@ contract DeployFlyover is Script {
148164
function _log(FlyoverDeployment memory d) private pure {
149165
console.log("=== FLYOVER DEPLOYMENT ===");
150166
console.log("ProxyAdmin:", d.proxyAdmin);
167+
console.log("PauseRegistry proxy:", d.pauseRegistryProxy);
151168
console.log("CollateralManagement impl:", d.collateralManagementImpl);
152169
console.log("CollateralManagement proxy:", d.collateralManagementProxy);
153170
console.log("FlyoverDiscovery impl:", d.flyoverDiscoveryImpl);

script/deployment/DeployFlyoverDiscovery.s.sol

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ pragma solidity 0.8.25;
44
import {Script, console} from "lib/forge-std/src/Script.sol";
55
import {HelperConfig} from "../HelperConfig.s.sol";
66
import {FlyoverDiscovery} from "../../src/FlyoverDiscovery.sol";
7+
import {PauseRegistry} from "../../src/PauseRegistry.sol";
78
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
89
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
910

1011
/// @title DeployFlyoverDiscovery
1112
/// @notice Deploys the FlyoverDiscovery contract with proxy pattern
12-
/// @dev Requires COLLATERAL_MANAGEMENT_PROXY env var
13+
/// @dev Requires COLLATERAL_MANAGEMENT_PROXY and PAUSE_REGISTRY_PROXY env vars
1314
contract DeployFlyoverDiscovery is Script {
1415
struct DeploymentResult {
1516
address implementation;
@@ -26,13 +27,23 @@ contract DeployFlyoverDiscovery is Script {
2627
address collateralManagementProxy = vm.envAddress(
2728
"COLLATERAL_MANAGEMENT_PROXY"
2829
);
30+
address pauseRegistryProxy = vm.envAddress("PAUSE_REGISTRY_PROXY");
2931
require(
3032
collateralManagementProxy != address(0),
3133
"COLLATERAL_MANAGEMENT_PROXY required"
3234
);
35+
require(
36+
pauseRegistryProxy != address(0),
37+
"PAUSE_REGISTRY_PROXY required"
38+
);
3339

3440
vm.startBroadcast(deployerKey);
35-
result = _deploy(deployer, cfg, collateralManagementProxy);
41+
result = _deploy(
42+
deployer,
43+
cfg,
44+
collateralManagementProxy,
45+
pauseRegistryProxy
46+
);
3647
vm.stopBroadcast();
3748

3849
_log(result);
@@ -41,7 +52,8 @@ contract DeployFlyoverDiscovery is Script {
4152
function _deploy(
4253
address defaultAdmin,
4354
HelperConfig.FlyoverConfig memory cfg,
44-
address collateralManagementProxy
55+
address collateralManagementProxy,
56+
address pauseRegistryProxy
4557
) private returns (DeploymentResult memory result) {
4658
result.implementation = address(new FlyoverDiscovery());
4759
result.admin = address(new ProxyAdmin(defaultAdmin));
@@ -51,7 +63,12 @@ contract DeployFlyoverDiscovery is Script {
5163
result.admin,
5264
abi.encodeCall(
5365
FlyoverDiscovery.initialize,
54-
(defaultAdmin, cfg.adminDelay, collateralManagementProxy)
66+
(
67+
defaultAdmin,
68+
cfg.adminDelay,
69+
collateralManagementProxy,
70+
PauseRegistry(pauseRegistryProxy)
71+
)
5572
)
5673
)
5774
);

0 commit comments

Comments
 (0)