Skip to content

Commit 34b85a9

Browse files
authored
Merge pull request #44 from bgd-labs/feat/mantle-path-activation
feat: Mantle a.DI activation path
2 parents ec0298e + c98028b commit 34b85a9

File tree

8 files changed

+173
-12
lines changed

8 files changed

+173
-12
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BASE_KEY = --private-key ${PRIVATE_KEY}
1717

1818

1919

20-
custom_ethereum := --with-gas-price 3000000000 # 53 gwei
20+
custom_ethereum := --with-gas-price 1000000000 # 53 gwei
2121
#custom_polygon := --with-gas-price 190000000000 # 560 gwei
2222
#custom_avalanche := --with-gas-price 27000000000 # 27 gwei
2323
#custom_metis-testnet := --legacy --verifier-url https://goerli.explorer.metisdevops.link/api/
@@ -286,8 +286,11 @@ deploy-zksync-path-payload:
286286
deploy-sonic-path-payload:
287287
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
288288

289+
deploy-mantle-path-payload:
290+
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
291+
289292
update-owners-and-guardians:
290293
$(call deploy_fn,helpers/Update_Ownership,zksync)
291294

292-
update-sonic-permissions:
293-
$(call deploy_fn,helpers/UpdateCCCPermissions,sonic)
295+
update-ccc-permissions:
296+
$(call deploy_fn,helpers/UpdateCCCPermissions,mantle)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Raw diff
2+
3+
```json
4+
{
5+
"forwarderAdaptersByChain": {
6+
"5000": {
7+
"from": "",
8+
"to": {
9+
"0xb66FA987fa7975Cac3d12B629c9c44e459e50990": "0x4E740ac02b866b429738a9e225e92A15F4452521"
10+
}
11+
}
12+
}
13+
}
14+
```

scripts/helpers/UpdateCCCPermissions.s.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ abstract contract UpdateCCCPermissions {
3939

4040

4141

42-
contract UpdateCCCPermissionsSonic is UpdateCCCPermissions {
42+
contract UpdateCCCPermissionsMantle is UpdateCCCPermissions {
4343
function targetOwner() public pure override returns (address) {
44-
return 0x7b62461a3570c6AC8a9f8330421576e417B71EE7; // executor
44+
return 0x70884634D0098782592111A2A6B8d223be31CB7b; // executor
4545
}
4646

4747
function targetADIGuardian() public pure override returns (address) {
48-
return 0x10078c1D8E46dd1ed5D8df2C42d5ABb969b11566; // Granular Guardian
48+
return 0xb26670d2800DBB9cfCe2f2660FfDcA48C799c86d; // Granular Guardian
4949
}
5050

5151

5252
function aDIContractsToUpdate() public pure override returns (address[] memory) {
5353
address[] memory contracts = new address[](1);
54-
contracts[0] = 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c; // CCC
54+
contracts[0] = 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB; // CCC
5555
return contracts;
5656
}
5757
}
5858

59-
contract Sonic is Script, UpdateCCCPermissionsSonic {
59+
contract Mantle is Script, UpdateCCCPermissionsMantle {
6060
function run() external {
6161
vm.startBroadcast();
6262

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import '../../../BaseDeployerScript.sol';
5+
import '../../../../src/templates/SimpleAddForwarderAdapter.sol';
6+
7+
abstract contract Ethereum_Activate_Mantle_Bridge_Adapter_Payload is BaseDeployerScript {
8+
function _getPayloadByteCode() internal virtual returns (bytes memory);
9+
10+
function PAYLOAD_SALT() internal pure virtual returns (string memory) {
11+
return 'Add Mantle path to a.DI';
12+
}
13+
14+
function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256);
15+
16+
function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) {
17+
bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args));
18+
19+
return _deployByteCode(payloadCode, PAYLOAD_SALT());
20+
}
21+
22+
function _execute(Addresses memory addresses) internal virtual override {
23+
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID());
24+
25+
_deployPayload(
26+
AddForwarderAdapterArgs({
27+
crossChainController: addresses.crossChainController,
28+
currentChainBridgeAdapter: addresses.mantleAdapter,
29+
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter,
30+
destinationChainId: DESTINATION_CHAIN_ID()
31+
})
32+
);
33+
}
34+
}

scripts/payloads/adapters/ethereum/Network_Deployments.s.sol

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@ import '../../../BaseDeployerScript.sol';
55
import {Ethereum_Activate_Celo_Bridge_Adapter_Payload} from './Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol';
66
import {Ethereum_Activate_Lina_Bridge_Adapter_Payload} from './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol';
77
import {Ethereum_Activate_Sonic_Bridge_Adapter_Payload} from './Ethereum_Activate_Sonic_Bridge_Adapter_Payload.s.sol';
8+
import {Ethereum_Activate_Mantle_Bridge_Adapter_Payload} from './Ethereum_Activate_Mantle_Bridge_Adapter_Payload.s.sol';
89
import {Ethereum_Celo_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol';
910
import {Ethereum_Sonic_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';
1011
import {SimpleAddForwarderAdapter} from '../../../../src/templates/SimpleAddForwarderAdapter.sol';
1112

12-
contract Ethereum is Ethereum_Activate_Sonic_Bridge_Adapter_Payload {
13+
contract Ethereum is Ethereum_Activate_Mantle_Bridge_Adapter_Payload {
14+
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
15+
return ChainIds.ETHEREUM;
16+
}
17+
18+
function _getPayloadByteCode() internal pure override returns (bytes memory) {
19+
return type(SimpleAddForwarderAdapter).creationCode;
20+
}
21+
22+
function DESTINATION_CHAIN_ID() internal pure override returns (uint256) {
23+
return ChainIds.MANTLE;
24+
}
25+
}
26+
27+
contract Ethereum_Sonic is Ethereum_Activate_Sonic_Bridge_Adapter_Payload {
1328
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
1429
return ChainIds.ETHEREUM;
1530
}

tests/adi/ADITestBase.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ contract ADITestBase is Test {
630630
uint256 chainId
631631
) internal pure returns (uint256[] memory) {
632632
if (chainId == ChainIds.MAINNET) {
633-
uint256[] memory chainIds = new uint256[](13);
633+
uint256[] memory chainIds = new uint256[](14);
634634
chainIds[0] = ChainIds.MAINNET;
635635
chainIds[1] = ChainIds.POLYGON;
636636
chainIds[2] = ChainIds.AVALANCHE;
@@ -644,7 +644,8 @@ contract ADITestBase is Test {
644644
chainIds[10] = ChainIds.LINEA;
645645
chainIds[11] = ChainIds.CELO;
646646
chainIds[12] = ChainIds.SONIC;
647-
647+
chainIds[13] = ChainIds.MANTLE;
648+
648649
return chainIds;
649650
} else if (chainId == ChainIds.POLYGON) {
650651
uint256[] memory chainIds = new uint256[](1);
@@ -725,6 +726,8 @@ contract ADITestBase is Test {
725726
return 0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd;
726727
} else if (chainId == ChainIds.SONIC) {
727728
return 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c;
729+
} else if (chainId == ChainIds.MANTLE) {
730+
return 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB;
728731
}
729732
revert();
730733
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import 'forge-std/console.sol';
5+
import {ADITestBase} from '../../adi/ADITestBase.sol';
6+
import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
7+
import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol';
8+
9+
abstract contract BaseAddMantlePathPayloadTest is ADITestBase {
10+
address internal _payload;
11+
address internal _crossChainController;
12+
13+
string internal NETWORK;
14+
uint256 internal immutable BLOCK_NUMBER;
15+
16+
constructor(string memory network, uint256 blockNumber) {
17+
NETWORK = network;
18+
BLOCK_NUMBER = blockNumber;
19+
}
20+
21+
function _getDeployedPayload() internal virtual returns (address);
22+
23+
function _getPayload() internal virtual returns (address);
24+
25+
function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory);
26+
27+
function setUp() public {
28+
vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER);
29+
30+
Addresses memory addresses = _getCurrentNetworkAddresses();
31+
_crossChainController = addresses.crossChainController;
32+
33+
_payload = _getPayload();
34+
}
35+
36+
function test_defaultTest() public {
37+
defaultTest(
38+
string.concat('add_mantle_path_to_adi', NETWORK),
39+
_crossChainController,
40+
address(_payload),
41+
false,
42+
vm
43+
);
44+
}
45+
46+
function test_samePayloadAddress(
47+
address currentChainAdapter,
48+
address destinationChainAdapter,
49+
address crossChainController,
50+
uint256 destinationChainId
51+
) public {
52+
SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload());
53+
SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload());
54+
55+
assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID());
56+
assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER());
57+
assertEq(
58+
predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(),
59+
deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER()
60+
);
61+
assertEq(
62+
predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(),
63+
deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER()
64+
);
65+
}
66+
}
67+
68+
contract EthereumAddMantlePathPayloadTest is
69+
PayloadEthereumScript,
70+
BaseAddMantlePathPayloadTest('ethereum', 21830243)
71+
{
72+
function _getDeployedPayload() internal pure override returns (address) {
73+
return 0x184CA99Cd89313c00a69b9A8E1649D84FBD8D86D;
74+
}
75+
76+
function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) {
77+
return _getAddresses(TRANSACTION_NETWORK());
78+
}
79+
80+
function _getPayload() internal override returns (address) {
81+
Addresses memory currentAddresses = _getCurrentNetworkAddresses();
82+
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID());
83+
84+
AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({
85+
crossChainController: currentAddresses.crossChainController,
86+
currentChainBridgeAdapter: currentAddresses.mantleAdapter, // ethereum -> mantle bridge adapter
87+
destinationChainBridgeAdapter: destinationAddresses.mantleAdapter, // mantle bridge adapter
88+
destinationChainId: DESTINATION_CHAIN_ID()
89+
});
90+
return _deployPayload(args);
91+
}
92+
}

tests/payloads/ethereum/AddSonicPathTest.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
33

44
import 'forge-std/console.sol';
55
import {ADITestBase} from '../../adi/ADITestBase.sol';
6-
import { Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
6+
import { Addresses, Ethereum_Sonic as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
77
import {Ethereum_Sonic_Path_Payload, AddForwarderAdapterArgs} from '../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';
88

99
abstract contract BaseAddSonicPathPayloadTest is ADITestBase {

0 commit comments

Comments
 (0)