Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add linea activation path payload #31

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BASE_KEY = --private-key ${PRIVATE_KEY}



custom_ethereum := --with-gas-price 30000000000 # 53 gwei
custom_ethereum := --with-gas-price 20000000000 # 53 gwei
#custom_polygon := --with-gas-price 190000000000 # 560 gwei
#custom_avalanche := --with-gas-price 27000000000 # 27 gwei
#custom_metis-testnet := --legacy --verifier-url https://goerli.explorer.metisdevops.link/api/
Expand Down Expand Up @@ -280,5 +280,8 @@ deploy-ccc-shuffle-payload:
deploy-zksync-path-payload:
$(call deploy_fn,payloads/adapters/zksync/Network_Deployments,ethereum)

deploy-linea-path-payload:
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)

update-owners-and-guardians:
$(call deploy_fn,helpers/Update_Ownership,zksync)
2 changes: 1 addition & 1 deletion deployments/linea.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"crossChainControllerImpl": "0xcb5C27e1EF28949b354904ee8D3088330D806a6f",
"emergencyRegistry": "0x0000000000000000000000000000000000000000",
"gnosisAdapter": "0x0000000000000000000000000000000000000000",
"granularCCCGuardian": "0x8CAdaAE6cd278c7C8FBaD5d6F55Ca6129A627E10",
"granularCCCGuardian": "0xc1cd6faF6e9138b4e6C21d438f9ebF2bd6F6cA16",
"guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6",
"hlAdapter": "0x0000000000000000000000000000000000000000",
"lineaAdapter": "0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Raw diff

```json
{
"forwarderAdaptersByChain": {
"59144": {
"from": "",
"to": {
"0x8097555ffDa4176C93FEf92dF473b9763e467686": "0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6"
}
}
}
}
```
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ metadata="none"
solc = "0.8.20"
ffi = true

#evm_version = 'london'

[profile.zksync.zksync]
fallback_oz = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ contract Linea is DeployGranularGuardian {
}

function SOLVE_EMERGENCY_GUARDIAN() internal pure override returns (address) {
return 0x0BF186764D8333a938f35e5dD124a7b9b9dccDF9; // dao guardian
return 0x056E4C4E80D1D14a637ccbD0412CDAAEc5B51F4E; // dao governance guardian
}

function TRANSACTION_NETWORK() internal pure override returns (uint256) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '../../../BaseDeployerScript.sol';
import '../../../../src/templates/SimpleAddForwarderAdapter.sol';

abstract contract Ethereum_Activate_Lina_Bridge_Adapter_Payload is BaseDeployerScript {
function _getPayloadByteCode() internal virtual returns (bytes memory);

function PAYLOAD_SALT() internal pure virtual returns (string memory) {
return 'Add Linea path to a.DI';
}

function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256);

function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) {
bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args));

return _deployByteCode(payloadCode, PAYLOAD_SALT());
}

function _execute(Addresses memory addresses) internal virtual override {
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID());

_deployPayload(
AddForwarderAdapterArgs({
crossChainController: addresses.crossChainController,
currentChainBridgeAdapter: addresses.lineaAdapter,
destinationChainBridgeAdapter: destinationAddresses.lineaAdapter,
destinationChainId: DESTINATION_CHAIN_ID()
})
);
}
}
18 changes: 18 additions & 0 deletions scripts/payloads/adapters/ethereum/Network_Deployments.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol';

contract Ethereum is Ethereum_Activate_Lina_Bridge_Adapter_Payload {
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
return ChainIds.ETHEREUM;
}

function _getPayloadByteCode() internal pure override returns (bytes memory) {
return type(SimpleAddForwarderAdapter).creationCode;
}

function DESTINATION_CHAIN_ID() internal pure override returns (uint256) {
return ChainIds.LINEA;
}
}
2 changes: 1 addition & 1 deletion tests/access_control/GranularGuardianDeployTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ contract CBaseGGTest is Base, BaseGGTest('base', 15896446) {
}
}

contract LineaGGTest is Linea, BaseGGTest('linea', 13215719) {
contract LineaGGTest is Linea, BaseGGTest('linea', 13223742) {
function CROSS_CHAIN_CONTROLLER() internal view override returns (address) {
return _getAddresses(TRANSACTION_NETWORK()).crossChainController;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/adi/ADITestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol';
import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol';
import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol';
import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol';
//import {GovernanceV3Linea} from 'aave-address-book/GovernanceV3Linea.sol';
import {IBaseAdapter} from 'aave-address-book/common/IBaseAdapter.sol';

contract ADITestBase is Test {
Expand Down Expand Up @@ -586,7 +587,7 @@ contract ADITestBase is Test {
uint256 chainId
) internal pure returns (uint256[] memory) {
if (chainId == ChainIds.MAINNET) {
uint256[] memory chainIds = new uint256[](10);
uint256[] memory chainIds = new uint256[](11);
chainIds[0] = ChainIds.MAINNET;
chainIds[1] = ChainIds.POLYGON;
chainIds[2] = ChainIds.AVALANCHE;
Expand All @@ -597,6 +598,7 @@ contract ADITestBase is Test {
chainIds[7] = ChainIds.METIS;
chainIds[8] = ChainIds.BASE;
chainIds[9] = ChainIds.SCROLL;
chainIds[10] = ChainIds.LINEA;

return chainIds;
} else if (chainId == ChainIds.POLYGON) {
Expand Down Expand Up @@ -672,6 +674,8 @@ contract ADITestBase is Test {
return GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER;
} else if (chainId == ChainIds.SCROLL) {
return GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER;
} else if (chainId == ChainIds.LINEA) {
return 0x0D3f821e9741C8a8Bcac231162320251Db0cdf52;
}
revert();
}
Expand Down
92 changes: 92 additions & 0 deletions tests/payloads/ethereum/AddLineaPathTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import 'forge-std/console.sol';
import {ADITestBase} from '../../adi/ADITestBase.sol';
import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
import '../../../src/templates/SimpleAddForwarderAdapter.sol';

abstract contract BaseAddLineaPathPayloadTest is ADITestBase {
address internal _payload;
address internal _crossChainController;

string internal NETWORK;
uint256 internal immutable BLOCK_NUMBER;

constructor(string memory network, uint256 blockNumber) {
NETWORK = network;
BLOCK_NUMBER = blockNumber;
}

function _getDeployedPayload() internal virtual returns (address);

function _getPayload() internal virtual returns (address);

function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory);

function setUp() public {
vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER);

Addresses memory addresses = _getCurrentNetworkAddresses();
_crossChainController = addresses.crossChainController;

_payload = _getPayload();
}

function test_defaultTest() public {
defaultTest(
string.concat('add_linea_path_to_adi', NETWORK),
_crossChainController,
address(_payload),
false,
vm
);
}

function test_samePayloadAddress(
address currentChainAdapter,
address destinationChainAdapter,
address crossChainController,
uint256 destinationChainId
) public {
SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload());
SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload());

assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID());
assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER());
assertEq(
predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(),
deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER()
);
assertEq(
predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(),
deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER()
);
}
}

contract EthereumAddLineaPathPayloadTest is
PayloadEthereumScript,
BaseAddLineaPathPayloadTest('ethereum', 21386891)
{
function _getDeployedPayload() internal pure override returns (address) {
return 0x3C2A076cD5ECbed55D8Fc0A341c14Fc808bA7fF7;
}

function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) {
return _getAddresses(TRANSACTION_NETWORK());
}

function _getPayload() internal override returns (address) {
Addresses memory currentAddresses = _getCurrentNetworkAddresses();
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID());

AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({
crossChainController: currentAddresses.crossChainController,
currentChainBridgeAdapter: 0x8097555ffDa4176C93FEf92dF473b9763e467686, // ethereum -> linea bridge adapter
Cycxyz marked this conversation as resolved.
Show resolved Hide resolved
destinationChainBridgeAdapter: 0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6, // linea bridge adapter
destinationChainId: DESTINATION_CHAIN_ID()
});
return _deployPayload(args);
}
}
Loading