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: Mantle a.DI activation path #44

Merged
merged 2 commits into from
Feb 12, 2025
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
9 changes: 6 additions & 3 deletions 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 3000000000 # 53 gwei
custom_ethereum := --with-gas-price 1000000000 # 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 @@ -286,8 +286,11 @@ deploy-zksync-path-payload:
deploy-sonic-path-payload:
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)

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

update-owners-and-guardians:
$(call deploy_fn,helpers/Update_Ownership,zksync)

update-sonic-permissions:
$(call deploy_fn,helpers/UpdateCCCPermissions,sonic)
update-ccc-permissions:
$(call deploy_fn,helpers/UpdateCCCPermissions,mantle)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Raw diff

```json
{
"forwarderAdaptersByChain": {
"5000": {
"from": "",
"to": {
"0xb66FA987fa7975Cac3d12B629c9c44e459e50990": "0x4E740ac02b866b429738a9e225e92A15F4452521"
}
}
}
}
```
10 changes: 5 additions & 5 deletions scripts/helpers/UpdateCCCPermissions.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ abstract contract UpdateCCCPermissions {



contract UpdateCCCPermissionsSonic is UpdateCCCPermissions {
contract UpdateCCCPermissionsMantle is UpdateCCCPermissions {
function targetOwner() public pure override returns (address) {
return 0x7b62461a3570c6AC8a9f8330421576e417B71EE7; // executor
return 0x70884634D0098782592111A2A6B8d223be31CB7b; // executor
}

function targetADIGuardian() public pure override returns (address) {
return 0x10078c1D8E46dd1ed5D8df2C42d5ABb969b11566; // Granular Guardian
return 0xb26670d2800DBB9cfCe2f2660FfDcA48C799c86d; // Granular Guardian
}


function aDIContractsToUpdate() public pure override returns (address[] memory) {
address[] memory contracts = new address[](1);
contracts[0] = 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c; // CCC
contracts[0] = 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB; // CCC
return contracts;
}
}

contract Sonic is Script, UpdateCCCPermissionsSonic {
contract Mantle is Script, UpdateCCCPermissionsMantle {
function run() external {
vm.startBroadcast();

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_Mantle_Bridge_Adapter_Payload is BaseDeployerScript {
function _getPayloadByteCode() internal virtual returns (bytes memory);

function PAYLOAD_SALT() internal pure virtual returns (string memory) {
return 'Add Mantle 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.mantleAdapter,
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter,
destinationChainId: DESTINATION_CHAIN_ID()
})
);
}
}
17 changes: 16 additions & 1 deletion scripts/payloads/adapters/ethereum/Network_Deployments.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@ import '../../../BaseDeployerScript.sol';
import {Ethereum_Activate_Celo_Bridge_Adapter_Payload} from './Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol';
import {Ethereum_Activate_Lina_Bridge_Adapter_Payload} from './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol';
import {Ethereum_Activate_Sonic_Bridge_Adapter_Payload} from './Ethereum_Activate_Sonic_Bridge_Adapter_Payload.s.sol';
import {Ethereum_Activate_Mantle_Bridge_Adapter_Payload} from './Ethereum_Activate_Mantle_Bridge_Adapter_Payload.s.sol';
import {Ethereum_Celo_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol';
import {Ethereum_Sonic_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';
import {SimpleAddForwarderAdapter} from '../../../../src/templates/SimpleAddForwarderAdapter.sol';

contract Ethereum is Ethereum_Activate_Sonic_Bridge_Adapter_Payload {
contract Ethereum is Ethereum_Activate_Mantle_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.MANTLE;
}
}

contract Ethereum_Sonic is Ethereum_Activate_Sonic_Bridge_Adapter_Payload {
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
return ChainIds.ETHEREUM;
}
Expand Down
7 changes: 5 additions & 2 deletions tests/adi/ADITestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ contract ADITestBase is Test {
uint256 chainId
) internal pure returns (uint256[] memory) {
if (chainId == ChainIds.MAINNET) {
uint256[] memory chainIds = new uint256[](13);
uint256[] memory chainIds = new uint256[](14);
chainIds[0] = ChainIds.MAINNET;
chainIds[1] = ChainIds.POLYGON;
chainIds[2] = ChainIds.AVALANCHE;
Expand All @@ -644,7 +644,8 @@ contract ADITestBase is Test {
chainIds[10] = ChainIds.LINEA;
chainIds[11] = ChainIds.CELO;
chainIds[12] = ChainIds.SONIC;

chainIds[13] = ChainIds.MANTLE;

return chainIds;
} else if (chainId == ChainIds.POLYGON) {
uint256[] memory chainIds = new uint256[](1);
Expand Down Expand Up @@ -725,6 +726,8 @@ contract ADITestBase is Test {
return 0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd;
} else if (chainId == ChainIds.SONIC) {
return 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c;
} else if (chainId == ChainIds.MANTLE) {
return 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB;
}
revert();
}
Expand Down
92 changes: 92 additions & 0 deletions tests/payloads/ethereum/AddMantlePathTest.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 {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol';

abstract contract BaseAddMantlePathPayloadTest 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_mantle_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 EthereumAddMantlePathPayloadTest is
PayloadEthereumScript,
BaseAddMantlePathPayloadTest('ethereum', 21830243)
{
function _getDeployedPayload() internal pure override returns (address) {
return 0x184CA99Cd89313c00a69b9A8E1649D84FBD8D86D;
}

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: currentAddresses.mantleAdapter, // ethereum -> mantle bridge adapter
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter, // mantle bridge adapter
destinationChainId: DESTINATION_CHAIN_ID()
});
return _deployPayload(args);
}
}
2 changes: 1 addition & 1 deletion tests/payloads/ethereum/AddSonicPathTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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 { Addresses, Ethereum_Sonic as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
import {Ethereum_Sonic_Path_Payload, AddForwarderAdapterArgs} from '../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';

abstract contract BaseAddSonicPathPayloadTest is ADITestBase {
Expand Down
Loading