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

fix: compatibility with zkSync #51

Merged
merged 45 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c5e9615
commit tests that still need to be fixed
Apr 15, 2024
45d66d9
Merge pull request #1 from Moonsong-Labs/comment-out-failing-tests-fo…
HermanObst Apr 15, 2024
82647e2
assume on tests failing due to low addresses
Apr 16, 2024
e26b726
Merge pull request #2 from Moonsong-Labs/assume-safe-addresses
HermanObst Apr 16, 2024
582fb7d
fix(CrossChainReceiverTest): non reserved addrs
Karrq Apr 19, 2024
30354a2
fix(test:zk): 65536 offset
Karrq Apr 19, 2024
0650a62
Merge pull request #3 from Moonsong-Labs/fix/zksync-ccrt
Karrq Apr 22, 2024
d53f1b3
chore(zk:test): uncomment newly passing tests
Karrq Apr 22, 2024
fd35bc8
Merge pull request #4 from Moonsong-Labs/fix/zksync-ccrt
HermanObst Apr 22, 2024
52c29a0
uncomment CCIP adapter tests
Apr 23, 2024
6ab2092
uncomment tests failing due to mocks
Apr 23, 2024
4d6b2dc
fix foundry config
HermanObst Apr 23, 2024
6d1f1fa
Merge pull request #8 from Moonsong-Labs/herman/fix-foundry-config
Jrigada Apr 23, 2024
dc83950
correct addresss ranges
nbaztec Apr 24, 2024
a431bc8
Merge pull request #9 from Moonsong-Labs/nish-fix-test-1
nbaztec Apr 24, 2024
5e4dbbe
Merge pull request #5 from Moonsong-Labs/uncomment-CCIP-adapter-tests
Karrq Apr 24, 2024
7d50c67
uncomment arb adapter tests
Apr 24, 2024
2122285
Merge pull request #6 from Moonsong-Labs/uncomment-mock-failing-tests
Karrq Apr 24, 2024
e693193
fix test selectors
nbaztec Apr 24, 2024
c23939d
feat: uncomment CrossChainController* tests
Karrq Apr 24, 2024
0492780
Merge remote-tracking branch 'origin/nish-fix-test-2' into testing
Karrq Apr 24, 2024
ac30252
Merge remote-tracking branch 'origin/uncomment-arbadapter-tests' into…
Karrq Apr 24, 2024
d5213ce
Merge remote-tracking branch 'origin/fix/reserved_addrs' into testing
Karrq Apr 24, 2024
fc508d4
wip: uncomment ForwarderTest and PayloadScripts
Karrq Apr 24, 2024
7a1f42d
wip: uncomment CrossChainCommunicationSettings
Karrq Apr 24, 2024
670e982
fix: MetisAdapter::testForwardMessage
Karrq Apr 24, 2024
a0d3a70
fix test
nbaztec Apr 24, 2024
57caa06
Merge pull request #11 from Moonsong-Labs/nish-fix-test-2
Karrq Apr 24, 2024
0f991cc
fix(Forwarder): add forwardMessage mock in tests
Karrq Apr 25, 2024
822bc4b
Merge pull request #10 from Moonsong-Labs/uncomment-arbadapter-tests
Jrigada Apr 25, 2024
285575a
remove assume preventing usage of zkSync forbidden addresses in fuzz …
HermanObst Apr 26, 2024
6529127
re-include assume removed by error
HermanObst Apr 26, 2024
8d0bfb1
Merge pull request #13 from Moonsong-Labs/fix/forwarder-test
Karrq Apr 27, 2024
9cd3d64
enable CrossChainCommunicationSettingsTest
nbaztec Apr 28, 2024
bb3c20e
fix(test): use `_mockAdaptersForwardMessage`
Karrq Apr 30, 2024
9679a47
Merge pull request #16 from Moonsong-Labs/fix/forwarder-test
Karrq May 1, 2024
80d10a3
fix: assume called address != tx.origin
Karrq May 1, 2024
b26ea8d
Merge pull request #14 from Moonsong-Labs/nish-enable-test-2
Karrq May 1, 2024
9ed4977
Merge pull request #17 from Moonsong-Labs/fix/adapters-test
HermanObst May 1, 2024
0b2345a
Merge branch 'feat/zksync' into latest
Karrq May 1, 2024
93e8f80
fix: recomment PayloadScripts
Karrq May 1, 2024
8cb83d5
fix: 65566 -> 65536
Karrq May 1, 2024
8acd42d
fix: comment one failing test
Karrq May 1, 2024
4d7047b
Merge pull request #18 from Moonsong-Labs/chore/cleanup
HermanObst May 1, 2024
93733c0
enable testSolveEmergencyWhenUnreachableConfirmations
nbaztec May 2, 2024
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
4 changes: 4 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ celo={key="${ETHERSCAN_API_KEY_CELO}", chain=42220, utl='https://api.celoscan.io
celo-testnet={key="${ETHERSCAN_API_KEY_CELO}", chain=44787, url='https://api-alfajores.celoscan.io/api'}

# See more config options https://github.com/gakonst/foundry/tree/master/config
[fuzz]
no_zksync_reserved_addresses = true
[invariant]
no_zksync_reserved_addresses = true
14 changes: 7 additions & 7 deletions tests/BaseCrossChainController.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {Errors} from '../src/contracts/libs/Errors.sol';
import {IBaseAdapter} from '../src/contracts/adapters/IBaseAdapter.sol';

abstract contract BaseCrossChainControllerTest is Test {
address public constant OWNER = address(123);
address public constant GUARDIAN = address(1234);
address public constant BRIDGE_ADAPTER = address(123456);
address public constant OWNER = address(65536 + 123);
address public constant GUARDIAN = address(65536 + 1234);
address public constant BRIDGE_ADAPTER = address(65536 + 123456);

uint8 public constant CONFIRMATIONS = 1;

Expand Down Expand Up @@ -76,21 +76,21 @@ abstract contract BaseCrossChainControllerTest is Test {

// forwarder configs
address[] memory sendersToApprove = new address[](1);
sendersToApprove[0] = address(102);
sendersToApprove[0] = address(65536 + 102);
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]
memory forwarderBridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](
1
);
forwarderBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
currentChainBridgeAdapter: address(103),
destinationBridgeAdapter: address(110),
currentChainBridgeAdapter: address(65536 + 103),
destinationBridgeAdapter: address(65536 + 110),
destinationChainId: ChainIds.POLYGON
});

crossChainControllerImpl = _deployControllerImplementation();

vm.mockCall(
address(103),
address(65536 + 103),
abi.encodeWithSelector(IBaseAdapter.setupPayments.selector),
abi.encode()
);
Expand Down
48 changes: 24 additions & 24 deletions tests/CrossChainControllerWithEmergencyMode.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ICLEmergencyOracle} from '../src/contracts/emergency/interfaces/ICLEmerg
import {CrossChainControllerWithEmergencyMode, ICrossChainControllerWithEmergencyMode} from '../src/contracts/CrossChainControllerWithEmergencyMode.sol';

contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTest {
address public constant CL_EMERGENCY_ORACLE = address(12345);
address public constant CL_EMERGENCY_ORACLE = address(65536 + 12345);
event CLEmergencyOracleUpdated(address indexed newChainlinkEmergencyOracle);

function _deployControllerImplementation() internal override returns (address) {
Expand Down Expand Up @@ -55,14 +55,14 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe

// forwarder configs
address[] memory sendersToApprove = new address[](1);
sendersToApprove[0] = address(102);
sendersToApprove[0] = address(65536 + 102);
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]
memory forwarderBridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](
1
);
forwarderBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
currentChainBridgeAdapter: address(103),
destinationBridgeAdapter: address(110),
currentChainBridgeAdapter: address(65536 + 103),
destinationBridgeAdapter: address(65536 + 110),
destinationChainId: ChainIds.POLYGON
});

Expand Down Expand Up @@ -101,7 +101,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
1
);
receiverBridgeAdaptersToAllow[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: address(201),
bridgeAdapter: address(65536 + 201),
chainIds: originChainIds
});
uint8 newConfirmation = 1;
Expand Down Expand Up @@ -131,16 +131,16 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe

// forwarder config
address[] memory sendersToApprove = new address[](1);
sendersToApprove[0] = address(202);
sendersToApprove[0] = address(65536 + 202);
address[] memory sendersToRemove = new address[](1);
sendersToRemove[0] = address(102);
sendersToRemove[0] = address(65536 + 102);
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]
memory forwarderBridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](
1
);
forwarderBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
currentChainBridgeAdapter: address(203),
destinationBridgeAdapter: address(210),
currentChainBridgeAdapter: address(65536 + 203),
destinationBridgeAdapter: address(65536 + 210),
destinationChainId: ChainIds.POLYGON
});
ICrossChainForwarder.BridgeAdapterToDisable[]
Expand All @@ -150,7 +150,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
uint256[] memory chainIds = new uint256[](1);
chainIds[0] = ChainIds.POLYGON;
forwarderBridgeAdaptersToDisable[0] = ICrossChainForwarder.BridgeAdapterToDisable({
bridgeAdapter: address(103),
bridgeAdapter: address(65536 + 103),
chainIds: chainIds
});

Expand All @@ -163,7 +163,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
abi.encode(uint80(0), int256(1), 0, 0, uint80(0))
);
vm.mockCall(
address(203),
address(65536 + 203),
abi.encodeWithSelector(IBaseAdapter.setupPayments.selector),
abi.encode()
);
Expand All @@ -183,22 +183,22 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
assertEq(receiverConfig.requiredConfirmation, newConfirmation);
assertEq(receiverConfig.validityTimestamp, newValidityTimestamp);
assertEq(
crossChainController.isReceiverBridgeAdapterAllowed(address(201), ChainIds.ETHEREUM),
crossChainController.isReceiverBridgeAdapterAllowed(address(65536 + 201), ChainIds.ETHEREUM),
true
);
assertEq(
crossChainController.isReceiverBridgeAdapterAllowed(BRIDGE_ADAPTER, ChainIds.ETHEREUM),
false
);
assertEq(crossChainController.isSenderApproved(address(202)), true);
assertEq(crossChainController.isSenderApproved(address(102)), false);
assertEq(crossChainController.isSenderApproved(address(65536 + 202)), true);
assertEq(crossChainController.isSenderApproved(address(65536 + 102)), false);

ICrossChainForwarder.ChainIdBridgeConfig[] memory forwarderBridgeAdapters = crossChainController
.getForwarderBridgeAdaptersByChain(ChainIds.POLYGON);

assertEq(forwarderBridgeAdapters.length, 1);
assertEq(forwarderBridgeAdapters[0].destinationBridgeAdapter, address(210));
assertEq(forwarderBridgeAdapters[0].currentChainBridgeAdapter, address(203));
assertEq(forwarderBridgeAdapters[0].destinationBridgeAdapter, address(65536 + 210));
assertEq(forwarderBridgeAdapters[0].currentChainBridgeAdapter, address(65536 + 203));
}

function testSolveEmergencyWhenUnreachableConfirmations() public {
Expand All @@ -210,7 +210,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
1
);
receiverBridgeAdaptersToAllow[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: address(201),
bridgeAdapter: address(65536 + 201),
chainIds: originChainIds
});
uint8 newConfirmation = 3;
Expand Down Expand Up @@ -240,16 +240,16 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe

// forwarder config
address[] memory sendersToApprove = new address[](1);
sendersToApprove[0] = address(202);
sendersToApprove[0] = address(65536 + 202);
address[] memory sendersToRemove = new address[](1);
sendersToRemove[0] = address(102);
sendersToRemove[0] = address(65536 + 102);
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]
memory forwarderBridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](
1
);
forwarderBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
currentChainBridgeAdapter: address(203),
destinationBridgeAdapter: address(210),
currentChainBridgeAdapter: address(65536 + 203),
destinationBridgeAdapter: address(65536 + 210),
destinationChainId: ChainIds.POLYGON
});
ICrossChainForwarder.BridgeAdapterToDisable[]
Expand All @@ -259,7 +259,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
uint256[] memory chainIds = new uint256[](1);
chainIds[0] = ChainIds.POLYGON;
forwarderBridgeAdaptersToDisable[0] = ICrossChainForwarder.BridgeAdapterToDisable({
bridgeAdapter: address(103),
bridgeAdapter: address(65536 + 103),
chainIds: chainIds
});

Expand Down Expand Up @@ -323,7 +323,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
}

function testUpdateCLEmergencyOracle() public {
address newChainlinkEmergencyOracle = address(101);
address newChainlinkEmergencyOracle = address(65536 + 101);

hoax(OWNER);
vm.expectEmit(true, false, false, true);
Expand All @@ -340,7 +340,7 @@ contract CrossChainControllerWithEmergencyModeTest is BaseCrossChainControllerTe
}

function testUpdateCLEmergencyOracleWhenNotOwner() public {
address newChainlinkEmergencyOracle = address(101);
address newChainlinkEmergencyOracle = address(65536 + 101);

vm.expectRevert(bytes('Ownable: caller is not the owner'));
ICrossChainControllerWithEmergencyMode(address(crossChainController)).updateCLEmergencyOracle(
Expand Down
16 changes: 8 additions & 8 deletions tests/CrossChainForwarder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {Transaction, EncodedTransaction, Envelope} from '../src/contracts/libs/E
import {BaseTest} from './BaseTest.sol';

contract CrossChainForwarderTest is BaseTest {
address public constant OWNER = address(123);
address public constant GUARDIAN = address(12);
address public constant OWNER = address(65536 + 123);
address public constant GUARDIAN = address(65536 + 12);
// mock addresses
address public constant DESTINATION_BRIDGE_ADAPTER = address(12345);
address public constant DESTINATION_BRIDGE_ADAPTER = address(65536 + 12345);
address public constant SENDER = address(123456);

uint256 public constant ORIGIN_LZ_CHAIN_ID = ChainIds.ETHEREUM;
Expand Down Expand Up @@ -186,9 +186,9 @@ contract CrossChainForwarderTest is BaseTest {
3
);

address NEW_BRIDGE_ADAPTER_1 = address(201);
address NEW_BRIDGE_ADAPTER_2 = address(202);
address NEW_DESTINATION_BRIDGE_ADAPTER_A = address(203);
address NEW_BRIDGE_ADAPTER_1 = address(65536 + 201);
address NEW_BRIDGE_ADAPTER_2 = address(65536 + 202);
address NEW_DESTINATION_BRIDGE_ADAPTER_A = address(65536 + 203);

// this one overwrites
newBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
Expand Down Expand Up @@ -327,8 +327,8 @@ contract CrossChainForwarderTest is BaseTest {
2
);

address NEW_BRIDGE_ADAPTER_1 = address(201);
address NEW_DESTINATION_BRIDGE_ADAPTER_A = address(203);
address NEW_BRIDGE_ADAPTER_1 = address(65536 + 201);
address NEW_DESTINATION_BRIDGE_ADAPTER_A = address(65536 + 203);

// new one on same network
newBridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({
Expand Down
14 changes: 7 additions & 7 deletions tests/CrossChainReceiver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {BaseTest} from './BaseTest.sol';
import {Transaction, Envelope} from '../src/contracts/libs/EncodingUtils.sol';

contract CrossChainReceiverTest is BaseTest {
address public constant GUARDIAN = address(12);
address public constant OWNER = address(123);
address public constant BRIDGE_ADAPTER = address(1234);
address public constant BRIDGE_ADAPTER_2 = address(1234567);
address public constant GUARDIAN = address(65536 + 12);
address public constant OWNER = address(65536 + 123);
address public constant BRIDGE_ADAPTER = address(65536 + 1234);
address public constant BRIDGE_ADAPTER_2 = address(65536 + 1234567);

address public constant GOVERNANCE_CORE = address(12345);
address public constant VOTING_MACHINE = address(123456);
address public constant GOVERNANCE_CORE = address(65536 + 12345);
address public constant VOTING_MACHINE = address(65536 + 123456);
uint256 public constant DEFAULT_ORIGIN_CHAIN_ID = 1;

ICrossChainReceiver public crossChainReceiver;
Expand Down Expand Up @@ -370,7 +370,7 @@ contract CrossChainReceiverTest is BaseTest {
assertEq(crossChainReceiver.isReceiverBridgeAdapterAllowed(BRIDGE_ADAPTER, 137), true);
}

// // TEST RECEIVE MESSAGES
// TEST RECEIVE MESSAGES
function testReceiveCrossChainMessage(uint256 txNonce, uint256 envelopeNonce) public {
ExtendedTransaction memory txExtended = _generateExtendedTransaction(
TestParams({
Expand Down
1 change: 1 addition & 0 deletions tests/Forwarder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ contract ForwarderTest is BaseCCForwarderTest {
validateTransactionNonceIncrement
validateTransactionRegistry(extendedTx)
{
_mockAdaptersForwardMessage(extendedTx.envelope.destinationChainId);
UsedAdapter[] memory usedAdapters = _currentlyUsedAdaptersByChain[
extendedTx.envelope.destinationChainId
];
Expand Down
Loading
Loading