Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed May 29, 2024
1 parent 1b347f2 commit 365c2d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions x/crosschain/keeper/cctx_gateway_observers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ func NewCCTXGatewayObservers(crosschainKeeper Keeper) CCTXGatewayObservers {
}
}

/*
InitiateOutbound updates the store so observers can use the PendingCCTX query:
- If the crosschain message passing is successful, the CCTX status is changed to PendingOutbound.
- If the crosschain message passing returns an error, the CCTX status is changed to Aborted.
We do not return an error from this function, as all changes need to be persisted to the state.
Instead, we use a temporary context to make changes and then commit the context on for the happy path, i.e cctx is set to PendingOutbound.
*/
func (c CCTXGatewayObservers) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChainTx) error {
tmpCtx, commit := ctx.CacheContext()
outboundReceiverChainID := cctx.GetCurrentOutboundParam().ReceiverChainId
Expand Down
12 changes: 12 additions & 0 deletions x/crosschain/keeper/cctx_gateway_zevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ func NewCCTXGatewayZEVM(crosschainKeeper Keeper) CCTXGatewayZEVM {
}
}

/*
InitiateOutbound handles evm deposit and then ValidateOutbound is called.
TODO: move this comment to ValidateOutbound once it's added
- If the deposit is successful, the CCTX status is changed to OutboundMined.
- If the deposit returns an internal error i.e if HandleEVMDeposit() returns an error, but isContractReverted is false, the CCTX status is changed to Aborted.
- If the deposit is reverted, the function tries to create a revert cctx with status PendingRevert.
- If the creation of revert tx also fails it changes the status to Aborted.
Note : Aborted CCTXs are not refunded in this function. The refund is done using a separate refunding mechanism.
We do not return an error from this function , as all changes need to be persisted to the state.
Instead we use a temporary context to make changes and then commit the context on for the happy path ,i.e cctx is set to OutboundMined.
*/
func (c CCTXGatewayZEVM) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChainTx) error {
tmpCtx, commit := ctx.CacheContext()
isContractReverted, err := c.crosschainKeeper.HandleEVMDeposit(tmpCtx, cctx)
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/initiate_inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// InitiateOutbound processes the inbound CCTX.
// It does a conditional dispatch to observer or zevm CCTX gateway based on the receiver chain
// It does a conditional dispatch to correct CCTX gateway based on the receiver chain
// which handle the state changes and error handling.
func (k Keeper) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChainTx) error {
chainInfo := chains.GetChainFromChainID(cctx.GetCurrentOutboundParam().ReceiverChainId)
Expand Down

0 comments on commit 365c2d4

Please sign in to comment.