Skip to content

Commit be5cbd5

Browse files
authored
Merge pull request #52 from bgd-labs/feat/soneium-path-activation
feat: Soneium path activation payload
2 parents 6024aae + 5fea30b commit be5cbd5

File tree

7 files changed

+159
-3
lines changed

7 files changed

+159
-3
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ deploy-mantle-path-payload:
298298
deploy-ink-path-payload:
299299
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
300300

301+
deploy-soneium-path-payload:
302+
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)
303+
301304
update-owners-and-guardians:
302305
$(call deploy_fn,helpers/Update_Ownership,zksync)
303306

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+
"1868": {
7+
"from": "",
8+
"to": {
9+
"0xe66973c4571F733CafEb1BDE1fa58Ff35416d901": "0x5698e43Ef1be85C68Dec568B5925dD5DB7903e39"
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_Soneium_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 Soneium 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.soneiumAdapter,
29+
destinationChainBridgeAdapter: destinationAddresses.soneiumAdapter,
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
@@ -7,11 +7,26 @@ import {Ethereum_Activate_Lina_Bridge_Adapter_Payload} from './Ethereum_Activate
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';
99
import {Ethereum_Activate_Ink_Bridge_Adapter_Payload} from './Ethereum_Activate_Ink_Bridge_Adapter_Payload.s.sol';
10+
import {Ethereum_Activate_Soneium_Bridge_Adapter_Payload} from './Ethereum_Activate_Soneium_Bridge_Adapter_Payload.s.sol';
1011
import {Ethereum_Celo_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol';
1112
import {Ethereum_Sonic_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Sonic_Path_Payload.sol';
1213
import {SimpleAddForwarderAdapter} from '../../../../src/templates/SimpleAddForwarderAdapter.sol';
1314

14-
contract Ethereum is Ethereum_Activate_Ink_Bridge_Adapter_Payload {
15+
contract Ethereum is Ethereum_Activate_Soneium_Bridge_Adapter_Payload {
16+
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
17+
return ChainIds.ETHEREUM;
18+
}
19+
20+
function _getPayloadByteCode() internal pure override returns (bytes memory) {
21+
return type(SimpleAddForwarderAdapter).creationCode;
22+
}
23+
24+
function DESTINATION_CHAIN_ID() internal pure override returns (uint256) {
25+
return ChainIds.SONEIUM;
26+
}
27+
}
28+
29+
contract Ethereum_Ink is Ethereum_Activate_Ink_Bridge_Adapter_Payload {
1530
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
1631
return ChainIds.ETHEREUM;
1732
}

tests/adi/ADITestBase.sol

Lines changed: 4 additions & 1 deletion
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[](15);
633+
uint256[] memory chainIds = new uint256[](16);
634634
chainIds[0] = ChainIds.MAINNET;
635635
chainIds[1] = ChainIds.POLYGON;
636636
chainIds[2] = ChainIds.AVALANCHE;
@@ -646,6 +646,7 @@ contract ADITestBase is Test {
646646
chainIds[12] = ChainIds.SONIC;
647647
chainIds[13] = ChainIds.MANTLE;
648648
chainIds[14] = ChainIds.INK;
649+
chainIds[15] = ChainIds.SONEIUM;
649650

650651
return chainIds;
651652
} else if (chainId == ChainIds.POLYGON) {
@@ -731,6 +732,8 @@ contract ADITestBase is Test {
731732
return 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB;
732733
} else if (chainId == ChainIds.INK) {
733734
return 0x990B75fD1a2345D905a385dBC6e17BEe0Cb2f505;
735+
} else if (chainId == ChainIds.SONEIUM) {
736+
return 0xD92b37a5114b33F668D274Fb48f23b726a854d6E;
734737
}
735738
revert();
736739
}

tests/payloads/ethereum/AddInkPathTest.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} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
6+
import {Addresses, Ethereum_Ink as Ethereum} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
77
import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol';
88

99
abstract contract BaseAddInkPathPayloadTest is ADITestBase {
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 BaseAddSoneiumPathPayloadTest 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_soneium_path_to_adi', NETWORK),
39+
_crossChainController,
40+
address(_payload),
41+
false,
42+
vm
43+
);
44+
}
45+
46+
function test_samePayloadAddress() public {
47+
SimpleAddForwarderAdapter deployedPayload = SimpleAddForwarderAdapter(_getDeployedPayload());
48+
SimpleAddForwarderAdapter predictedPayload = SimpleAddForwarderAdapter(_getPayload());
49+
50+
assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID());
51+
assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER());
52+
assertEq(
53+
predictedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER(),
54+
deployedPayload.CURRENT_CHAIN_BRIDGE_ADAPTER()
55+
);
56+
assertEq(
57+
predictedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER(),
58+
deployedPayload.DESTINATION_CHAIN_BRIDGE_ADAPTER()
59+
);
60+
}
61+
}
62+
63+
contract EthereumAddSoneiumPathPayloadTest is
64+
Ethereum,
65+
BaseAddSoneiumPathPayloadTest('ethereum', 22424684)
66+
{
67+
function _getDeployedPayload() internal pure override returns (address) {
68+
return 0xD934A9034C95f9c31e1D6077DFed49B0F4d36FC3;
69+
}
70+
71+
function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) {
72+
return _getAddresses(TRANSACTION_NETWORK());
73+
}
74+
75+
function _getPayload() internal override returns (address) {
76+
Addresses memory currentAddresses = _getCurrentNetworkAddresses();
77+
Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID());
78+
79+
AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({
80+
crossChainController: currentAddresses.crossChainController,
81+
currentChainBridgeAdapter: currentAddresses.soneiumAdapter, // ethereum -> soneium bridge adapter
82+
destinationChainBridgeAdapter: destinationAddresses.soneiumAdapter, // soneium bridge adapter
83+
destinationChainId: DESTINATION_CHAIN_ID()
84+
});
85+
return _deployPayload(args);
86+
}
87+
}

0 commit comments

Comments
 (0)