ExocoreNetwork / exocore-contracts

5 stars 5 forks source link

[Layerzero][Optimize]: use the nonce of MessagingReceipt as request id instead of maintaining outBoundNonce #22

Closed adu-web3 closed 3 months ago

adu-web3 commented 5 months ago

Description

in ClientChainGateway.sol, we maintain outBoundNonce as the request id so that we could cache every request that is sent out: https://github.com/ExocoreNetwork/exocore-contracts/blob/8c0aef0498ae00a3c336e6f9bb49ad16753b0991/src/core/BaseRestakingController.sol#L77

But actually when we call ClientChainGateway._lzSend() in ClientChainGateway._sendMsgToExocore(), it returns an MessagingReceipt that has the outbound nonce included:

struct MessagingReceipt {
    bytes32 guid;
    uint64 nonce;
    MessagingFee fee;
}

we should use the nonce returned by layerzero endpoint as request id instead of maintaining it by ourselves