Skip to content

Commit aa794c7

Browse files
authored
feat: V1.5 pre bera fix SUP-9039 (#646)
1 parent 616c993 commit aa794c7

27 files changed

+2094
-247
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ jobs:
5656
- name: "Install Foundry"
5757
uses: "foundry-rs/foundry-toolchain@v1"
5858

59+
60+
- name: "Show the Foundry version"
61+
run: "forge --version"
62+
63+
5964
- name: "Show the Foundry config"
6065
run: "forge config"
6166

@@ -171,7 +176,7 @@ jobs:
171176
run: "make coverage"
172177

173178
- name: "Upload coverage report to Codecov"
174-
uses: "codecov/codecov-action@v4"
179+
uses: "codecov/codecov-action@v5"
175180
env:
176181
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
177182
with:

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ build-sizes: ## Builds the project and shows sizes
121121

122122
.PHONY: test-vvv
123123
test-vvv: ## Runs tests with verbose output
124-
forge test --match-test test_rebalanceMultiPositions_tokenRefunds_interimDust_allowanceNot0 --evm-version cancun -vvvvv
124+
forge test --match-test test_printConfirmations --evm-version cancun -vvv
125125

126126
.PHONY: ftest
127127
ftest: ## Runs tests with cancun evm version
@@ -177,3 +177,4 @@ help: ## Prints this help
177177
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
178178
| sort \
179179
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
180+

script/forge-scripts/Abstract.Deploy.Single.s.sol

Lines changed: 163 additions & 50 deletions
Large diffs are not rendered by default.

script/forge-scripts/EnvironmentUtils.s.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
2828
function _setEnvironment(uint256 env, bool useNewSalt) internal {
2929
/// Production
3030
if (env == 0) {
31+
DEPLOY_AXELAR = true;
32+
DEPLOY_7540 = false;
3133
TARGET_CHAINS.push(ETH);
3234
TARGET_CHAINS.push(BSC);
3335
TARGET_CHAINS.push(AVAX);
@@ -65,6 +67,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
6567
WORMHOLE_VAA_RELAYER = 0x1A86b5c1467331A3A52572663FDBf037A9e29719;
6668
// Staging
6769
} else if (env == 1) {
70+
DEPLOY_AXELAR = true;
71+
DEPLOY_7540 = true;
72+
6873
TARGET_CHAINS.push(BSC);
6974
TARGET_CHAINS.push(ARBI);
7075
TARGET_CHAINS.push(OP);
@@ -97,6 +102,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
97102

98103
// Tenderly
99104
} else if (env == 2) {
105+
DEPLOY_AXELAR = true;
106+
DEPLOY_7540 = true;
107+
100108
TARGET_CHAINS.push(ETH);
101109
TARGET_CHAINS.push(OP);
102110
TARGET_CHAINS.push(ARBI);
@@ -123,6 +131,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
123131

124132
salt = "Tenderly";
125133
} else if (env == 3) {
134+
DEPLOY_AXELAR = false;
135+
DEPLOY_7540 = false;
136+
126137
salt = "Testnet";
127138

128139
PAYMENT_ADMIN = 0xD911673eAF0D3e15fe662D58De15511c5509bAbB;

script/forge-scripts/misc/Abstract.Configure.NewDVN.s.sol

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ abstract contract AbstractConfigureNewDVN is EnvironmentUtils {
4848
0xabC9b1819cc4D9846550F928B985993cF6240439
4949
];
5050

51-
address[] public LzDVNs = [
52-
0x589dEDbD617e0CBcB916A9223F4d1300c294236b,
53-
0xfD6865c841c2d64565562fCc7e05e619A30615f0,
54-
0x962F502A63F5FBeB44DC9ab932122648E8352959,
55-
0x23DE2FE932d9043291f870324B74F820e11dc81A,
56-
0x2f55C492897526677C5B68fb199ea31E2c126416,
57-
0x6A02D83e8d433304bba74EF1c427913958187142,
58-
0x9e059a54699a285714207b43B055483E78FAac25,
59-
0xE60A3959Ca23a92BF5aAf992EF837cA7F828628a,
60-
0x129Ee430Cb2Ff2708CCADDBDb408a88Fe4FFd480,
61-
0xc097ab8CD7b053326DFe9fB3E3a31a0CCe3B526f
62-
];
63-
6451
function _configureSendAndReceiveDVN(
6552
uint256 env,
6653
uint256 i,
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/// SPDX-License-Identifier: BUSL-1.1
2+
3+
pragma solidity ^0.8.23;
4+
5+
import "../EnvironmentUtils.s.sol";
6+
import { ILayerZeroEndpointV2, IMessageLibManager } from "src/vendor/layerzero/v2/ILayerZeroEndpointV2.sol";
7+
import { SetConfigParam } from "src/vendor/layerzero/v2/IMessageLibManager.sol";
8+
9+
interface ILayerzeroEndpointV2Delegates is ILayerZeroEndpointV2 {
10+
function delegates(address _impl) external view returns (address);
11+
}
12+
13+
struct UpdateVars {
14+
uint64 chainId;
15+
uint64 dstChainId;
16+
uint256 srcTrueIndex;
17+
uint256 dstTrueIndex;
18+
address receiveLib;
19+
address dstLzImpl;
20+
address axl;
21+
address srcLzImpl;
22+
bytes config;
23+
SuperRegistry superRegistryC;
24+
AxelarImplementation axelarImpl;
25+
SuperformFactory superformFactory;
26+
SetConfigParam[] setConfigParams;
27+
address sendLib;
28+
}
29+
30+
abstract contract AbstractPreBeraLaunch is EnvironmentUtils {
31+
function _configure(
32+
uint256 env,
33+
uint256 srcChainIndex,
34+
Cycle cycle,
35+
uint64[] memory finalDeployedChains
36+
)
37+
internal
38+
setEnvDeploy(cycle)
39+
{
40+
assert(salt.length > 0);
41+
UpdateVars memory vars;
42+
43+
vars.chainId = finalDeployedChains[srcChainIndex];
44+
45+
vars.axl = _readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "AxelarImplementation");
46+
assert(vars.axl != address(0));
47+
// Configure for the source chain
48+
vars.srcLzImpl = _readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "LayerzeroImplementation");
49+
assert(vars.srcLzImpl != address(0));
50+
51+
vars.superRegistryC =
52+
SuperRegistry(_readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "SuperRegistry"));
53+
assert(address(vars.superRegistryC) != address(0));
54+
bytes memory txn;
55+
56+
txn = abi.encodeWithSelector(
57+
vars.superRegistryC.setAddress.selector, rewardsAdminRole, REWARDS_ADMIN, vars.chainId
58+
);
59+
addToBatch(address(vars.superRegistryC), 0, txn);
60+
61+
console.log("Setting config");
62+
UlnConfig memory ulnConfig;
63+
64+
ulnConfig.requiredDVNCount = 2;
65+
ulnConfig.optionalDVNCount = 0;
66+
67+
address[] memory optionalDVNs = new address[](0);
68+
ulnConfig.optionalDVNs = optionalDVNs;
69+
70+
address[] memory requiredDVNs = new address[](2);
71+
requiredDVNs[0] = SuperformDVNs[srcChainIndex];
72+
requiredDVNs[1] = LzDVNs[srcChainIndex];
73+
74+
// Sort DVNs
75+
if (requiredDVNs[0] > requiredDVNs[1]) {
76+
(requiredDVNs[0], requiredDVNs[1]) = (requiredDVNs[1], requiredDVNs[0]);
77+
}
78+
79+
ulnConfig.requiredDVNs = requiredDVNs;
80+
81+
/// @dev default to 0 to use lz v2 defaults
82+
ulnConfig.confirmations = 0;
83+
84+
address[] memory rescuerAddress = new address[](2);
85+
bytes32[] memory ids = new bytes32[](2);
86+
uint64[] memory targetChains = new uint64[](2);
87+
targetChains[0] = LINEA;
88+
targetChains[1] = BLAST;
89+
90+
for (uint256 j; j < finalDeployedChains.length; j++) {
91+
if (finalDeployedChains[j] == vars.chainId) {
92+
continue;
93+
}
94+
vars.dstTrueIndex = _getTrueIndex(finalDeployedChains[j]);
95+
96+
vars.setConfigParams = new SetConfigParam[](1);
97+
98+
vars.config = abi.encode(ulnConfig);
99+
100+
vars.setConfigParams[0] = SetConfigParam(uint32(lz_chainIds[vars.dstTrueIndex]), uint32(2), vars.config);
101+
102+
// Set send config on source chain
103+
vars.sendLib = ILayerZeroEndpointV2(lzV2Endpoint).defaultSendLibrary(lz_chainIds[vars.dstTrueIndex]);
104+
txn = abi.encodeWithSelector(
105+
IMessageLibManager.setConfig.selector, vars.srcLzImpl, vars.sendLib, vars.setConfigParams
106+
);
107+
addToBatch(lzV2Endpoint, 0, txn);
108+
109+
// Set receive config on source chain
110+
vars.receiveLib = ILayerZeroEndpointV2(lzV2Endpoint).defaultReceiveLibrary(lz_chainIds[vars.dstTrueIndex]);
111+
txn = abi.encodeWithSelector(
112+
IMessageLibManager.setConfig.selector, vars.srcLzImpl, vars.receiveLib, vars.setConfigParams
113+
);
114+
addToBatch(lzV2Endpoint, 0, txn);
115+
116+
// disable Axelar's other chain info on LINEA and BLAST
117+
if (vars.chainId == LINEA || vars.chainId == BLAST) {
118+
/*
119+
if (finalDeployedChains[j] == LINEA || finalDeployedChains[j] == BLAST) {
120+
txn = abi.encodeWithSelector(
121+
AxelarImplementation.setChainId.selector,
122+
finalDeployedChains[j],
123+
axelar_chainIds[vars.dstTrueIndex]
124+
);
125+
126+
addToBatch(vars.axl, 0, txn);
127+
}
128+
txn = abi.encodeWithSelector(
129+
AxelarImplementation.setReceiver.selector, axelar_chainIds[vars.dstTrueIndex], address(0xDEAD)
130+
);
131+
132+
addToBatch(vars.axl, 0, txn);
133+
*/
134+
} else {
135+
for (uint256 i; i < rescuerAddress.length; i++) {
136+
ids[i] = keccak256("CORE_STATE_REGISTRY_RESCUER_ROLE");
137+
rescuerAddress[i] = CSR_RESCUER;
138+
}
139+
txn = abi.encodeWithSelector(
140+
vars.superRegistryC.batchSetAddress.selector, ids, rescuerAddress, targetChains
141+
);
142+
addToBatch(address(vars.superRegistryC), 0, txn);
143+
}
144+
}
145+
146+
// Send the batch
147+
executeBatch(vars.chainId, PROTOCOL_ADMINS[srcChainIndex], manualNonces[srcChainIndex], true);
148+
}
149+
150+
function _getTrueIndex(uint256 chainId) public view returns (uint256 index) {
151+
for (uint256 i; i < chainIds.length; i++) {
152+
if (chainId == chainIds[i]) {
153+
index = i;
154+
break;
155+
}
156+
}
157+
}
158+
}

script/forge-scripts/misc/Abstract.ConfigureERC5115AndDisableAMBs.s.sol

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,7 @@ abstract contract AbstractConfigure5115FormAndDisableAMB is EnvironmentUtils {
430430
);
431431
addToBatch(address(vars.lzV1Impl), 0, txn);
432432
/// @dev set receivers to 0xDEAD
433-
txn = abi.encodeWithSelector(
434-
AxelarImplementation.setReceiver.selector, axelar_chainIds[vars.dstTrueIndex], address(0xDEAD)
435-
);
436-
437-
addToBatch(address(vars.axelarImpl), 0, txn);
433+
438434

439435
/// @dev old layerzero, hyperlane and wormhole are only deployed on the previous networks
440436
if (
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.23;
3+
4+
import "../EnvironmentUtils.s.sol";
5+
6+
struct UpdateVars {
7+
uint64 chainId;
8+
uint64 dstChainId;
9+
uint256 dstTrueIndex;
10+
}
11+
12+
abstract contract AbstractUpdatePriceFeeds is EnvironmentUtils {
13+
function _updatePriceFeeds(
14+
uint256 env,
15+
uint256 i,
16+
uint256 trueIndex,
17+
Cycle cycle,
18+
uint64[] memory s_superFormChainIds
19+
)
20+
internal
21+
setEnvDeploy(cycle)
22+
{
23+
assert(salt.length > 0);
24+
UpdateVars memory vars;
25+
26+
vars.chainId = s_superFormChainIds[i];
27+
28+
cycle == Cycle.Dev ? vm.startBroadcast(deployerPrivateKey) : vm.startBroadcast();
29+
30+
address superRegistry = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperRegistry");
31+
address expectedSr =
32+
env == 0 ? 0x17A332dC7B40aE701485023b219E9D6f493a2514 : 0xB2C097ac459aFAc892ae5b35f6bd6a9Dd3071F47;
33+
assert(superRegistry == expectedSr);
34+
35+
address paymentHelper = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "PaymentHelper");
36+
address expectedPaymentHelper =
37+
env == 0 ? 0x69c531E5bdf2458FFb4f5E0dB3DE41745151b2Bd : 0xe14BCe82D4a72e4C95402a83fEF3C2299a61fD8C;
38+
assert(paymentHelper == expectedPaymentHelper);
39+
uint256 countFeeds;
40+
for (uint256 j = 0; j < s_superFormChainIds.length; j++) {
41+
vars.dstChainId = s_superFormChainIds[j];
42+
43+
for (uint256 k = 0; k < chainIds.length; k++) {
44+
if (vars.dstChainId == chainIds[k]) {
45+
vars.dstTrueIndex = k;
46+
47+
break;
48+
}
49+
}
50+
if (PRICE_FEEDS[vars.chainId][vars.dstChainId] != address(0)) {
51+
IPaymentHelper(payable(paymentHelper)).updateRemoteChain(
52+
vars.dstChainId, 1, abi.encode(PRICE_FEEDS[vars.chainId][vars.dstChainId])
53+
);
54+
countFeeds++;
55+
}
56+
}
57+
console.log("Updated %d feeds", countFeeds);
58+
vm.stopBroadcast();
59+
}
60+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.23;
3+
4+
import "../EnvironmentUtils.s.sol";
5+
import "src/vendor/layerzero/v2/ILayerZeroEndpointV2.sol";
6+
7+
contract DecodeULNConfig is EnvironmentUtils {
8+
function decodeULNConfig(uint64 chainid, uint64 dstChainId, bytes memory config) public {
9+
_setEnvironment(0, false);
10+
_preDeploymentSetup();
11+
12+
UlnConfig memory ulnConfig = abi.decode(config, (UlnConfig));
13+
14+
address[] memory requiredDVNsToAssert = new address[](2);
15+
requiredDVNsToAssert[0] = SuperformDVNs[_getTrueIndex(chainid)];
16+
requiredDVNsToAssert[1] = LzDVNs[_getTrueIndex(chainid)];
17+
18+
if (requiredDVNsToAssert[0] > requiredDVNsToAssert[1]) {
19+
(requiredDVNsToAssert[0], requiredDVNsToAssert[1]) = (requiredDVNsToAssert[1], requiredDVNsToAssert[0]);
20+
}
21+
assert(ulnConfig.confirmations == 0);
22+
assert(requiredDVNsToAssert[0] == ulnConfig.requiredDVNs[0]);
23+
assert(requiredDVNsToAssert[1] == ulnConfig.requiredDVNs[1]);
24+
console.log("asserted, SRC, DST: ", chainid, dstChainId);
25+
}
26+
27+
function _getTrueIndex(uint256 chainId) public view returns (uint256 index) {
28+
for (uint256 i; i < chainIds.length; i++) {
29+
if (chainId == chainIds[i]) {
30+
index = i;
31+
break;
32+
}
33+
}
34+
}
35+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.23;
3+
4+
import { AbstractPreBeraLaunch } from "./Abstract.Configure.PreBeraLaunch.s.sol";
5+
import "forge-std/console.sol";
6+
7+
contract MainnetConfigPreBeraDVN is AbstractPreBeraLaunch {
8+
function configure(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external {
9+
_setEnvironment(env, useNewSalt == 1 ? true : false);
10+
_preDeploymentSetup();
11+
12+
uint256 trueIndex;
13+
for (uint256 i = 0; i < chainIds.length; i++) {
14+
if (TARGET_CHAINS[selectedChainIndex] == chainIds[i]) {
15+
trueIndex = i;
16+
break;
17+
}
18+
}
19+
20+
_configure(env, trueIndex, Cycle.Prod, TARGET_CHAINS);
21+
}
22+
}

0 commit comments

Comments
 (0)