Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
uses: bgd-labs/github-workflows/.github/workflows/foundry-lint-prettier.yml@main
test:
uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main
with:
compareLcov: false
secrets:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
# only when the repo has zksync code
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ deploy-sonic-path-payload:
deploy-mantle-path-payload:
$(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum)

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Raw diff

```json
{
"forwarderAdaptersByChain": {
"57073": {
"from": "",
"to": {
"0x98E78C2cD3013BF13a658E210e27C3732c8Dc48A": "0xC2cD4F76B7a77AEaE3C04A9B6B105EC1Ad28e984"
}
}
}
}
```
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_Ink_Bridge_Adapter_Payload is BaseDeployerScript {
function _getPayloadByteCode() internal virtual returns (bytes memory);

function PAYLOAD_SALT() internal pure virtual returns (string memory) {
return 'Add Ink 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.inkAdapter,
destinationChainBridgeAdapter: destinationAddresses.inkAdapter,
destinationChainId: DESTINATION_CHAIN_ID()
})
);
}
}
16 changes: 15 additions & 1 deletion scripts/payloads/adapters/ethereum/Network_Deployments.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@ import {Ethereum_Activate_Celo_Bridge_Adapter_Payload} from './Ethereum_Activate
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_Activate_Ink_Bridge_Adapter_Payload} from './Ethereum_Activate_Ink_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_Ink_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.INK;
}
}

contract Ethereum_Mantle is Ethereum_Activate_Mantle_Bridge_Adapter_Payload {
function TRANSACTION_NETWORK() internal pure override returns (uint256) {
return ChainIds.ETHEREUM;
Expand Down Expand Up @@ -65,4 +80,3 @@ contract Ethereum_Linea is Ethereum_Activate_Lina_Bridge_Adapter_Payload {
return ChainIds.LINEA;
}
}

9 changes: 5 additions & 4 deletions tests/adi/ADITestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ contract ADITestBase is Test {
);
}



function createConfigurationSnapshot(
SnapshotParams memory snapshotParams
) public returns (CCCConfig memory) {
Expand Down Expand Up @@ -630,7 +628,7 @@ contract ADITestBase is Test {
uint256 chainId
) internal pure returns (uint256[] memory) {
if (chainId == ChainIds.MAINNET) {
uint256[] memory chainIds = new uint256[](14);
uint256[] memory chainIds = new uint256[](15);
chainIds[0] = ChainIds.MAINNET;
chainIds[1] = ChainIds.POLYGON;
chainIds[2] = ChainIds.AVALANCHE;
Expand All @@ -645,7 +643,8 @@ contract ADITestBase is Test {
chainIds[11] = ChainIds.CELO;
chainIds[12] = ChainIds.SONIC;
chainIds[13] = ChainIds.MANTLE;

chainIds[14] = ChainIds.INK;

return chainIds;
} else if (chainId == ChainIds.POLYGON) {
uint256[] memory chainIds = new uint256[](1);
Expand Down Expand Up @@ -728,6 +727,8 @@ contract ADITestBase is Test {
return 0x58e003a3C6f2Aeed6a2a6Bc77B504566523cb15c;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's replace with addresses from address-book

} else if (chainId == ChainIds.MANTLE) {
return 0x1283C5015B1Fb5616FA3aCb0C18e6879a02869cB;
} else if (chainId == ChainIds.INK) {
return 0x990B75fD1a2345D905a385dBC6e17BEe0Cb2f505;
}
revert();
}
Expand Down
92 changes: 92 additions & 0 deletions tests/payloads/ethereum/AddInkPathTest.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} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol';
import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol';

abstract contract BaseAddInkPathPayloadTest 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_ink_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 EthereumAddInkPathPayloadTest is
Ethereum,
BaseAddInkPathPayloadTest('ethereum', 22123500)
{
function _getDeployedPayload() internal pure override returns (address) {
return 0x9cdA84ae11d829079EDcCaEd49e473f6fb841b75;
}

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.inkAdapter, // ethereum -> ink bridge adapter
destinationChainBridgeAdapter: destinationAddresses.inkAdapter, // ink bridge adapter
destinationChainId: DESTINATION_CHAIN_ID()
});
return _deployPayload(args);
}
}
Loading