Skip to content

Commit f56472b

Browse files
committed
feat: Ink path activation payload
1 parent 736c404 commit f56472b

File tree

6 files changed

+163
-5
lines changed

6 files changed

+163
-5
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ deploy-sonic-path-payload:
292292
deploy-mantle-path-payload:
293293
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
294294

295+
deploy-ink-path-payload:
296+
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
297+
295298
update-owners-and-guardians:
296299
$(call deploy_fn,helpers/Update_Ownership,zksync)
297300

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+
"57073": {
7+
"from": "",
8+
"to": {
9+
"0x98E78C2cD3013BF13a658E210e27C3732c8Dc48A": "0xC2cD4F76B7a77AEaE3C04A9B6B105EC1Ad28e984"
10+
}
11+
}
12+
}
13+
}
14+
```
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_Ink_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 Ink 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.inkAdapter,
29+
destinationChainBridgeAdapter: destinationAddresses.inkAdapter,
30+
destinationChainId: DESTINATION_CHAIN_ID()
31+
})
32+
);
33+
}
34+
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@ import {Ethereum_Activate_Celo_Bridge_Adapter_Payload} from './Ethereum_Activate
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';
88
import {Ethereum_Activate_Mantle_Bridge_Adapter_Payload} from './Ethereum_Activate_Mantle_Bridge_Adapter_Payload.s.sol';
9+
import {Ethereum_Activate_Ink_Bridge_Adapter_Payload} from './Ethereum_Activate_Ink_Bridge_Adapter_Payload.s.sol';
910
import {Ethereum_Celo_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol';
1011
import {Ethereum_Sonic_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';
1112
import {SimpleAddForwarderAdapter} from '../../../../src/templates/SimpleAddForwarderAdapter.sol';
1213

14+
contract Ethereum is Ethereum_Activate_Ink_Bridge_Adapter_Payload {
15+
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
16+
return ChainIds.ETHEREUM;
17+
}
18+
19+
function _getPayloadByteCode() internal pure override returns (bytes memory) {
20+
return type(SimpleAddForwarderAdapter).creationCode;
21+
}
22+
23+
function DESTINATION_CHAIN_ID() internal pure override returns (uint256) {
24+
return ChainIds.INK;
25+
}
26+
}
27+
1328
contract Ethereum_Mantle is Ethereum_Activate_Mantle_Bridge_Adapter_Payload {
1429
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
1530
return ChainIds.ETHEREUM;
@@ -65,4 +80,3 @@ contract Ethereum_Linea is Ethereum_Activate_Lina_Bridge_Adapter_Payload {
6580
return ChainIds.LINEA;
6681
}
6782
}
68-

tests/adi/ADITestBase.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,6 @@ contract ADITestBase is Test {
415415
);
416416
}
417417

418-
419-
420418
function createConfigurationSnapshot(
421419
SnapshotParams memory snapshotParams
422420
) public returns (CCCConfig memory) {
@@ -630,7 +628,7 @@ contract ADITestBase is Test {
630628
uint256 chainId
631629
) internal pure returns (uint256[] memory) {
632630
if (chainId == ChainIds.MAINNET) {
633-
uint256[] memory chainIds = new uint256[](14);
631+
uint256[] memory chainIds = new uint256[](15);
634632
chainIds[0] = ChainIds.MAINNET;
635633
chainIds[1] = ChainIds.POLYGON;
636634
chainIds[2] = ChainIds.AVALANCHE;
@@ -645,7 +643,8 @@ contract ADITestBase is Test {
645643
chainIds[11] = ChainIds.CELO;
646644
chainIds[12] = ChainIds.SONIC;
647645
chainIds[13] = ChainIds.MANTLE;
648-
646+
chainIds[14] = ChainIds.INK;
647+
649648
return chainIds;
650649
} else if (chainId == ChainIds.POLYGON) {
651650
uint256[] memory chainIds = new uint256[](1);
@@ -728,6 +727,8 @@ contract ADITestBase is Test {
728727
return 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c;
729728
} else if (chainId == ChainIds.MANTLE) {
730729
return 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB;
730+
} else if (chainId == ChainIds.INK) {
731+
return 0x990B75fD1a2345D905a385dBC6e17BEe0Cb2f505;
731732
}
732733
revert();
733734
}
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} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
7+
import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol';
8+
9+
abstract contract BaseAddInkPathPayloadTest 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_ink_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 EthereumAddInkPathPayloadTest is
69+
Ethereum,
70+
BaseAddInkPathPayloadTest('ethereum', 22123500)
71+
{
72+
function _getDeployedPayload() internal pure override returns (address) {
73+
return 0x9cdA84ae11d829079EDcCaEd49e473f6fb841b75;
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.inkAdapter, // ethereum -> ink bridge adapter
87+
destinationChainBridgeAdapter: destinationAddresses.inkAdapter, // ink bridge adapter
88+
destinationChainId: DESTINATION_CHAIN_ID()
89+
});
90+
return _deployPayload(args);
91+
}
92+
}

0 commit comments

Comments
 (0)