Skip to content

Commit

Permalink
Merge branch 'v1.5' into tamara-sup-9339-optimize-refund-mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaraRingas authored Nov 25, 2024
2 parents 9fbeb91 + 1abc86d commit 9596c9c
Show file tree
Hide file tree
Showing 31 changed files with 1,962 additions and 251 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"


- name: "Show the Foundry version"
run: "forge --version"


- name: "Show the Foundry config"
run: "forge config"

Expand Down Expand Up @@ -171,7 +176,7 @@ jobs:
run: "make coverage"

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v4"
uses: "codecov/codecov-action@v5"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ build-sizes: ## Builds the project and shows sizes

.PHONY: test-vvv
test-vvv: ## Runs tests with verbose output
forge test --match-test test_rebalanceMultiPositions_tokenRefunds_interimDust_allowanceNot0 --evm-version cancun -vvvvv
forge test --match-test test_lzConfig --evm-version cancun -vvv

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

2 changes: 1 addition & 1 deletion lib/pigeon
214 changes: 164 additions & 50 deletions script/forge-scripts/Abstract.Deploy.Single.s.sol

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions script/forge-scripts/EnvironmentUtils.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
function _setEnvironment(uint256 env, bool useNewSalt) internal {
/// Production
if (env == 0) {
DEPLOY_AXELAR = true;
DEPLOY_7540 = false;
TARGET_CHAINS.push(ETH);
TARGET_CHAINS.push(BSC);
TARGET_CHAINS.push(AVAX);
Expand Down Expand Up @@ -65,6 +67,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {
WORMHOLE_VAA_RELAYER = 0x1A86b5c1467331A3A52572663FDBf037A9e29719;
// Staging
} else if (env == 1) {
DEPLOY_AXELAR = true;
DEPLOY_7540 = true;

TARGET_CHAINS.push(BSC);
TARGET_CHAINS.push(ARBI);
TARGET_CHAINS.push(OP);
Expand Down Expand Up @@ -97,6 +102,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {

// Tenderly
} else if (env == 2) {
DEPLOY_AXELAR = true;
DEPLOY_7540 = true;

TARGET_CHAINS.push(ETH);
TARGET_CHAINS.push(OP);
TARGET_CHAINS.push(ARBI);
Expand All @@ -123,6 +131,9 @@ abstract contract EnvironmentUtils is AbstractDeploySingle {

salt = "Tenderly";
} else if (env == 3) {
DEPLOY_AXELAR = false;
DEPLOY_7540 = false;

salt = "Testnet";

PAYMENT_ADMIN = 0xD911673eAF0D3e15fe662D58De15511c5509bAbB;
Expand Down
13 changes: 0 additions & 13 deletions script/forge-scripts/misc/Abstract.Configure.NewDVN.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ abstract contract AbstractConfigureNewDVN is EnvironmentUtils {
0xabC9b1819cc4D9846550F928B985993cF6240439
];

address[] public LzDVNs = [
0x589dEDbD617e0CBcB916A9223F4d1300c294236b,
0xfD6865c841c2d64565562fCc7e05e619A30615f0,
0x962F502A63F5FBeB44DC9ab932122648E8352959,
0x23DE2FE932d9043291f870324B74F820e11dc81A,
0x2f55C492897526677C5B68fb199ea31E2c126416,
0x6A02D83e8d433304bba74EF1c427913958187142,
0x9e059a54699a285714207b43B055483E78FAac25,
0xE60A3959Ca23a92BF5aAf992EF837cA7F828628a,
0x129Ee430Cb2Ff2708CCADDBDb408a88Fe4FFd480,
0xc097ab8CD7b053326DFe9fB3E3a31a0CCe3B526f
];

function _configureSendAndReceiveDVN(
uint256 env,
uint256 i,
Expand Down
158 changes: 158 additions & 0 deletions script/forge-scripts/misc/Abstract.Configure.PreBeraLaunch.s.sol
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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,7 @@ abstract contract AbstractConfigure5115FormAndDisableAMB is EnvironmentUtils {
);
addToBatch(address(vars.lzV1Impl), 0, txn);
/// @dev set receivers to 0xDEAD
txn = abi.encodeWithSelector(
AxelarImplementation.setReceiver.selector, axelar_chainIds[vars.dstTrueIndex], address(0xDEAD)
);

addToBatch(address(vars.axelarImpl), 0, txn);


/// @dev old layerzero, hyperlane and wormhole are only deployed on the previous networks
if (
Expand Down
60 changes: 60 additions & 0 deletions script/forge-scripts/misc/Abstract.Update.PriceFeeds.s.sol
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();
}
}
35 changes: 35 additions & 0 deletions script/forge-scripts/misc/DecodeULNConfig.sol
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;
}
}
}
}
22 changes: 22 additions & 0 deletions script/forge-scripts/misc/Mainnet.Configure.PreBera.s.sol
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);
}
}
Loading

0 comments on commit 9596c9c

Please sign in to comment.