Skip to content

Commit

Permalink
chore: add ways for caller to specify successful senders
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsomraaj committed Oct 5, 2023
1 parent c18dc67 commit 6cedaa5
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 41 deletions.
37 changes: 29 additions & 8 deletions src/MultiBridgeMessageSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract MultiBridgeMessageSender {
uint256 expiration;
address refundAddress;
uint256[] fees;
uint256 successThreshold;
address[] excludedAdapters;
}

Expand Down Expand Up @@ -149,18 +150,28 @@ contract MultiBridgeMessageSender {
/// @param _expiration refers to the number of seconds that a message remains valid before it is considered stale and can no longer be executed.
/// @param _refundAddress refers to the refund address for any extra native tokens paid
/// @param _fees refers to the fees to pay to each adapter
/// @param _successThreshold refers to minimum number of bridges required to relay the message
function remoteCall(
uint256 _dstChainId,
address _target,
bytes calldata _callData,
bytes memory _callData,
uint256 _nativeValue,
uint256 _expiration,
address _refundAddress,
uint256[] calldata _fees
uint256[] memory _fees,
uint256 _successThreshold
) external payable onlyCaller validateExpiration(_expiration) {
_remoteCall(
RemoteCallArgs(
_dstChainId, _target, _callData, _nativeValue, _expiration, _refundAddress, _fees, new address[](0)
_dstChainId,
_target,
_callData,
_nativeValue,
_expiration,
_refundAddress,
_fees,
_successThreshold,
new address[](0)
)
);
}
Expand All @@ -173,20 +184,30 @@ contract MultiBridgeMessageSender {
/// @param _refundAddress refers to the refund address for any extra native tokens paid
/// @param _fees refers to the fees to pay to each sender adapter that is not in the exclusion list specified by _excludedAdapters.
/// The fees are in the same order as the sender adapters in the senderAdapters list, after the exclusion list is applied.
/// @param _successThreshold refers to minimum number of bridges required to relay the message
/// @param _excludedAdapters are the sender adapters to be excluded from relaying the message, in ascending order by address
function remoteCall(
uint256 _dstChainId,
address _target,
bytes calldata _callData,
bytes memory _callData,
uint256 _nativeValue,
uint256 _expiration,
address _refundAddress,
uint256[] calldata _fees,
address[] calldata _excludedAdapters
uint256[] memory _fees,
uint256 _successThreshold,
address[] memory _excludedAdapters
) external payable onlyCaller validateExpiration(_expiration) {
_remoteCall(
RemoteCallArgs(
_dstChainId, _target, _callData, _nativeValue, _expiration, _refundAddress, _fees, _excludedAdapters
_dstChainId,
_target,
_callData,
_nativeValue,
_expiration,
_refundAddress,
_fees,
_successThreshold,
_excludedAdapters
)
);
}
Expand Down Expand Up @@ -284,7 +305,7 @@ contract MultiBridgeMessageSender {
(bool[] memory adapterSuccess, uint256 successCount) =
_dispatchMessages(adapters, mmaReceiver, _args.dstChainId, message, _args.fees);

if (successCount == 0) {
if (successCount < _args.successThreshold) {
revert Error.MULTI_MESSAGE_SEND_FAILED();
}

Expand Down
1 change: 1 addition & 0 deletions test/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ abstract contract Setup is Test {
address constant owner = address(420);
address constant refundAddress = address(420420);
uint256 constant EXPIRATION_CONSTANT = 5 days;
uint256 constant DEFAULT_SUCCESS_THRESHOLD = 2;

/// @dev constants for axelar
address constant ETH_GATEWAY = 0x4F4495243837681061C4743b74B3eEdf548D56A5;
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/GracePeriodExpiry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ contract GracePeriodExpiryTest is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/MultiMessageAggregation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ contract MultiBridgeMessageAggregationTest is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/RemoteAdapterAdd.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ contract RemoteAdapterAdd is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/RemoteAdapterRemove.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ contract RemoteAdapterRemove is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/RemoteSetQuorum.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ contract RemoteQuorumUpdate is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/RemoteTimelockUpdate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ contract RemoteTimelockUpdate is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
3 changes: 2 additions & 1 deletion test/integration-tests/TimelockCheck.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ contract TimelockCheckTest is Setup {
0,
EXPIRATION_CONSTANT,
refundAddress,
fees
fees,
DEFAULT_SUCCESS_THRESHOLD
);

Vm.Log[] memory logs = vm.getRecordedLogs();
Expand Down
Loading

0 comments on commit 6cedaa5

Please sign in to comment.