Skip to content

Commit

Permalink
refactor: use receipt's nonce instead of outboundNonce (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
adu-web3 authored Aug 2, 2024
1 parent eac5558 commit a11311d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/core/BaseRestakingController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,16 @@ abstract contract BaseRestakingController is
/// @param actionArgs The encodePacked arguments for the action.
/// @param encodedRequest The encoded request.
function _processRequest(Action action, bytes memory actionArgs, bytes memory encodedRequest) internal {
outboundNonce++;
_registeredRequests[outboundNonce] = encodedRequest;
_registeredRequestActions[outboundNonce] = action;
uint64 requestNonce = _sendMsgToExocore(action, actionArgs);

_sendMsgToExocore(action, actionArgs);
_registeredRequests[requestNonce] = encodedRequest;
_registeredRequestActions[requestNonce] = action;
}

/// @dev Sends a message to Exocore.
/// @param action The action to be performed.
/// @param actionArgs The encodePacked arguments for the action.
function _sendMsgToExocore(Action action, bytes memory actionArgs) internal {
function _sendMsgToExocore(Action action, bytes memory actionArgs) internal returns (uint64) {
bytes memory payload = abi.encodePacked(action, actionArgs);
bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(
DESTINATION_GAS_LIMIT, DESTINATION_MSG_VALUE
Expand All @@ -105,6 +104,8 @@ abstract contract BaseRestakingController is
MessagingReceipt memory receipt =
_lzSend(EXOCORE_CHAIN_ID, payload, options, MessagingFee(fee.nativeFee, 0), msg.sender, false);
emit MessageSent(action, receipt.guid, receipt.nonce, receipt.fee.nativeFee);

return receipt.nonce;
}

}
3 changes: 0 additions & 3 deletions src/storage/ClientChainGatewayStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import {IBeacon} from "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
/// ClientChainGateway contract. Shared items should be kept in BootstrapStorage.
contract ClientChainGatewayStorage is BootstrapStorage {

/// @notice The nonce for outbound messages.
uint64 public outboundNonce;

/// @notice Mapping of owner addresses to their corresponding ExoCapsule contracts.
mapping(address => IExoCapsule) public ownerToCapsule;

Expand Down

0 comments on commit a11311d

Please sign in to comment.