-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.5' into tamara-sup-9339-optimize-refund-mappings
- Loading branch information
Showing
31 changed files
with
1,962 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
script/forge-scripts/misc/Abstract.Configure.PreBeraLaunch.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity ^0.8.23; | ||
|
||
import "../EnvironmentUtils.s.sol"; | ||
import { ILayerZeroEndpointV2, IMessageLibManager } from "src/vendor/layerzero/v2/ILayerZeroEndpointV2.sol"; | ||
import { SetConfigParam } from "src/vendor/layerzero/v2/IMessageLibManager.sol"; | ||
|
||
interface ILayerzeroEndpointV2Delegates is ILayerZeroEndpointV2 { | ||
function delegates(address _impl) external view returns (address); | ||
} | ||
|
||
struct UpdateVars { | ||
uint64 chainId; | ||
uint64 dstChainId; | ||
uint256 srcTrueIndex; | ||
uint256 dstTrueIndex; | ||
address receiveLib; | ||
address dstLzImpl; | ||
address axl; | ||
address srcLzImpl; | ||
bytes config; | ||
SuperRegistry superRegistryC; | ||
AxelarImplementation axelarImpl; | ||
SuperformFactory superformFactory; | ||
SetConfigParam[] setConfigParams; | ||
address sendLib; | ||
} | ||
|
||
abstract contract AbstractPreBeraLaunch is EnvironmentUtils { | ||
function _configure( | ||
uint256 env, | ||
uint256 srcChainIndex, | ||
Cycle cycle, | ||
uint64[] memory finalDeployedChains | ||
) | ||
internal | ||
setEnvDeploy(cycle) | ||
{ | ||
assert(salt.length > 0); | ||
UpdateVars memory vars; | ||
|
||
vars.chainId = finalDeployedChains[srcChainIndex]; | ||
|
||
vars.axl = _readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "AxelarImplementation"); | ||
assert(vars.axl != address(0)); | ||
// Configure for the source chain | ||
vars.srcLzImpl = _readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "LayerzeroImplementation"); | ||
assert(vars.srcLzImpl != address(0)); | ||
|
||
vars.superRegistryC = | ||
SuperRegistry(_readContractsV1(env, chainNames[srcChainIndex], vars.chainId, "SuperRegistry")); | ||
assert(address(vars.superRegistryC) != address(0)); | ||
bytes memory txn; | ||
|
||
txn = abi.encodeWithSelector( | ||
vars.superRegistryC.setAddress.selector, rewardsAdminRole, REWARDS_ADMIN, vars.chainId | ||
); | ||
addToBatch(address(vars.superRegistryC), 0, txn); | ||
|
||
console.log("Setting config"); | ||
UlnConfig memory ulnConfig; | ||
|
||
ulnConfig.requiredDVNCount = 2; | ||
ulnConfig.optionalDVNCount = 0; | ||
|
||
address[] memory optionalDVNs = new address[](0); | ||
ulnConfig.optionalDVNs = optionalDVNs; | ||
|
||
address[] memory requiredDVNs = new address[](2); | ||
requiredDVNs[0] = SuperformDVNs[srcChainIndex]; | ||
requiredDVNs[1] = LzDVNs[srcChainIndex]; | ||
|
||
// Sort DVNs | ||
if (requiredDVNs[0] > requiredDVNs[1]) { | ||
(requiredDVNs[0], requiredDVNs[1]) = (requiredDVNs[1], requiredDVNs[0]); | ||
} | ||
|
||
ulnConfig.requiredDVNs = requiredDVNs; | ||
|
||
/// @dev default to 0 to use lz v2 defaults | ||
ulnConfig.confirmations = 0; | ||
|
||
address[] memory rescuerAddress = new address[](2); | ||
bytes32[] memory ids = new bytes32[](2); | ||
uint64[] memory targetChains = new uint64[](2); | ||
targetChains[0] = LINEA; | ||
targetChains[1] = BLAST; | ||
|
||
for (uint256 j; j < finalDeployedChains.length; j++) { | ||
if (finalDeployedChains[j] == vars.chainId) { | ||
continue; | ||
} | ||
vars.dstTrueIndex = _getTrueIndex(finalDeployedChains[j]); | ||
|
||
vars.setConfigParams = new SetConfigParam[](1); | ||
|
||
vars.config = abi.encode(ulnConfig); | ||
|
||
vars.setConfigParams[0] = SetConfigParam(uint32(lz_chainIds[vars.dstTrueIndex]), uint32(2), vars.config); | ||
|
||
// Set send config on source chain | ||
vars.sendLib = ILayerZeroEndpointV2(lzV2Endpoint).defaultSendLibrary(lz_chainIds[vars.dstTrueIndex]); | ||
txn = abi.encodeWithSelector( | ||
IMessageLibManager.setConfig.selector, vars.srcLzImpl, vars.sendLib, vars.setConfigParams | ||
); | ||
addToBatch(lzV2Endpoint, 0, txn); | ||
|
||
// Set receive config on source chain | ||
vars.receiveLib = ILayerZeroEndpointV2(lzV2Endpoint).defaultReceiveLibrary(lz_chainIds[vars.dstTrueIndex]); | ||
txn = abi.encodeWithSelector( | ||
IMessageLibManager.setConfig.selector, vars.srcLzImpl, vars.receiveLib, vars.setConfigParams | ||
); | ||
addToBatch(lzV2Endpoint, 0, txn); | ||
|
||
// disable Axelar's other chain info on LINEA and BLAST | ||
if (vars.chainId == LINEA || vars.chainId == BLAST) { | ||
/* | ||
if (finalDeployedChains[j] == LINEA || finalDeployedChains[j] == BLAST) { | ||
txn = abi.encodeWithSelector( | ||
AxelarImplementation.setChainId.selector, | ||
finalDeployedChains[j], | ||
axelar_chainIds[vars.dstTrueIndex] | ||
); | ||
addToBatch(vars.axl, 0, txn); | ||
} | ||
txn = abi.encodeWithSelector( | ||
AxelarImplementation.setReceiver.selector, axelar_chainIds[vars.dstTrueIndex], address(0xDEAD) | ||
); | ||
addToBatch(vars.axl, 0, txn); | ||
*/ | ||
} else { | ||
for (uint256 i; i < rescuerAddress.length; i++) { | ||
ids[i] = keccak256("CORE_STATE_REGISTRY_RESCUER_ROLE"); | ||
rescuerAddress[i] = CSR_RESCUER; | ||
} | ||
txn = abi.encodeWithSelector( | ||
vars.superRegistryC.batchSetAddress.selector, ids, rescuerAddress, targetChains | ||
); | ||
addToBatch(address(vars.superRegistryC), 0, txn); | ||
} | ||
} | ||
|
||
// Send the batch | ||
executeBatch(vars.chainId, PROTOCOL_ADMINS[srcChainIndex], manualNonces[srcChainIndex], true); | ||
} | ||
|
||
function _getTrueIndex(uint256 chainId) public view returns (uint256 index) { | ||
for (uint256 i; i < chainIds.length; i++) { | ||
if (chainId == chainIds[i]) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
script/forge-scripts/misc/Abstract.Update.PriceFeeds.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.23; | ||
|
||
import "../EnvironmentUtils.s.sol"; | ||
|
||
struct UpdateVars { | ||
uint64 chainId; | ||
uint64 dstChainId; | ||
uint256 dstTrueIndex; | ||
} | ||
|
||
abstract contract AbstractUpdatePriceFeeds is EnvironmentUtils { | ||
function _updatePriceFeeds( | ||
uint256 env, | ||
uint256 i, | ||
uint256 trueIndex, | ||
Cycle cycle, | ||
uint64[] memory s_superFormChainIds | ||
) | ||
internal | ||
setEnvDeploy(cycle) | ||
{ | ||
assert(salt.length > 0); | ||
UpdateVars memory vars; | ||
|
||
vars.chainId = s_superFormChainIds[i]; | ||
|
||
cycle == Cycle.Dev ? vm.startBroadcast(deployerPrivateKey) : vm.startBroadcast(); | ||
|
||
address superRegistry = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "SuperRegistry"); | ||
address expectedSr = | ||
env == 0 ? 0x17A332dC7B40aE701485023b219E9D6f493a2514 : 0xB2C097ac459aFAc892ae5b35f6bd6a9Dd3071F47; | ||
assert(superRegistry == expectedSr); | ||
|
||
address paymentHelper = _readContractsV1(env, chainNames[trueIndex], vars.chainId, "PaymentHelper"); | ||
address expectedPaymentHelper = | ||
env == 0 ? 0x69c531E5bdf2458FFb4f5E0dB3DE41745151b2Bd : 0xe14BCe82D4a72e4C95402a83fEF3C2299a61fD8C; | ||
assert(paymentHelper == expectedPaymentHelper); | ||
uint256 countFeeds; | ||
for (uint256 j = 0; j < s_superFormChainIds.length; j++) { | ||
vars.dstChainId = s_superFormChainIds[j]; | ||
|
||
for (uint256 k = 0; k < chainIds.length; k++) { | ||
if (vars.dstChainId == chainIds[k]) { | ||
vars.dstTrueIndex = k; | ||
|
||
break; | ||
} | ||
} | ||
if (PRICE_FEEDS[vars.chainId][vars.dstChainId] != address(0)) { | ||
IPaymentHelper(payable(paymentHelper)).updateRemoteChain( | ||
vars.dstChainId, 1, abi.encode(PRICE_FEEDS[vars.chainId][vars.dstChainId]) | ||
); | ||
countFeeds++; | ||
} | ||
} | ||
console.log("Updated %d feeds", countFeeds); | ||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "../EnvironmentUtils.s.sol"; | ||
import "src/vendor/layerzero/v2/ILayerZeroEndpointV2.sol"; | ||
|
||
contract DecodeULNConfig is EnvironmentUtils { | ||
function decodeULNConfig(uint64 chainid, uint64 dstChainId, bytes memory config) public { | ||
_setEnvironment(0, false); | ||
_preDeploymentSetup(); | ||
|
||
UlnConfig memory ulnConfig = abi.decode(config, (UlnConfig)); | ||
|
||
address[] memory requiredDVNsToAssert = new address[](2); | ||
requiredDVNsToAssert[0] = SuperformDVNs[_getTrueIndex(chainid)]; | ||
requiredDVNsToAssert[1] = LzDVNs[_getTrueIndex(chainid)]; | ||
|
||
if (requiredDVNsToAssert[0] > requiredDVNsToAssert[1]) { | ||
(requiredDVNsToAssert[0], requiredDVNsToAssert[1]) = (requiredDVNsToAssert[1], requiredDVNsToAssert[0]); | ||
} | ||
assert(ulnConfig.confirmations == 0); | ||
assert(requiredDVNsToAssert[0] == ulnConfig.requiredDVNs[0]); | ||
assert(requiredDVNsToAssert[1] == ulnConfig.requiredDVNs[1]); | ||
console.log("asserted, SRC, DST: ", chainid, dstChainId); | ||
} | ||
|
||
function _getTrueIndex(uint256 chainId) public view returns (uint256 index) { | ||
for (uint256 i; i < chainIds.length; i++) { | ||
if (chainId == chainIds[i]) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.23; | ||
|
||
import { AbstractPreBeraLaunch } from "./Abstract.Configure.PreBeraLaunch.s.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
contract MainnetConfigPreBeraDVN is AbstractPreBeraLaunch { | ||
function configure(uint256 env, uint256 selectedChainIndex, uint256 useNewSalt) external { | ||
_setEnvironment(env, useNewSalt == 1 ? true : false); | ||
_preDeploymentSetup(); | ||
|
||
uint256 trueIndex; | ||
for (uint256 i = 0; i < chainIds.length; i++) { | ||
if (TARGET_CHAINS[selectedChainIndex] == chainIds[i]) { | ||
trueIndex = i; | ||
break; | ||
} | ||
} | ||
|
||
_configure(env, trueIndex, Cycle.Prod, TARGET_CHAINS); | ||
} | ||
} |
Oops, something went wrong.