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

refactor and test: bridging contracts #118

Merged
merged 7 commits into from
Feb 29, 2024

Conversation

kupermind
Copy link
Collaborator

  • Addressing internal audit;
  • Adding tests

@kupermind kupermind requested review from 77ph and mariapiamo February 28, 2024 13:39
/// @author Aleksandr Kuperman - <[email protected]>
/// @author Andrey Lebedev - <[email protected]>
/// @author Mariapia Moscatiello - <[email protected]>
abstract contract BridgeMessenger is IBridgeErrors {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This just extracts the data processing that is the same everywhere.

/// @dev Interface to the CrossDomainMessenger (CDM) Contract Proxy.
interface ICrossDomainMessenger {
function xDomainMessageSender() external returns (address);
}

/// @dev Provided zero address.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extracted into its own IBridgeErrors.sol file.

}

// Unpack and process the data
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extracted into BridgeMessenger contract

@@ -1,85 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @dev Provided zero address.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extracted into IBridgeErrors.sol

@@ -154,54 +100,8 @@ contract WormholeMessenger {
}
mapDeliveryHashes[deliveryHash] = true;

// Check for the correct data length
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extracted into BridgeMessenger contract

/// @author Aleksandr Kuperman - <[email protected]>
/// @author Andrey Lebedev - <[email protected]>
/// @author Mariapia Moscatiello - <[email protected]>
contract MockL2Relayer {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mock contract to account for all messenger contracts testing.

Comment on lines -105 to +107
const sendPayloadSelector = "0x8fecdd02";
const sendPayloadSelector = "0x4b5ca6f4";
const timelockPayload = await wormholeRelayer.interface.encodeFunctionData(sendPayloadSelector, [targetChain,
wormholeMessengerAddress, data, 0, minGasLimit]);
wormholeMessengerAddress, data, 0, minGasLimit, targetChain, wormholeMessengerAddress]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function usage is better for wormhole as it allows to collect undelivered funds.

@@ -408,4 +409,27 @@ describe("buOLAS", function () {
).to.be.revertedWithCustomError(bu, "NonTransferable");
});
});

context("Time sensitive functions.", async function () {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wanted to fix that testing a long time ago - now it's merged into the main buOLAS.js testing file.

@@ -1,41 +0,0 @@
/*global describe, context, beforeEach, it*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This became obsolete now.

@kupermind kupermind merged commit e8f0cf0 into v1.1.10-internal-audit Feb 29, 2024
3 checks passed
@kupermind kupermind deleted the bridge_testing branch February 29, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants