From b497cbc5e1868dcfa6780c2a7c3a2a3246242560 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 6 Jun 2024 21:22:53 +0200 Subject: [PATCH] e2e test fix --- x/crosschain/keeper/cctx_gateway_zevm.go | 9 +++++++-- x/crosschain/keeper/cctx_orchestrator.go | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 08af8f9a74..5b61990215 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -20,7 +20,7 @@ func NewCCTXGatewayZEVM(crosschainKeeper Keeper) CCTXGatewayZEVM { // InitiateOutbound handles evm deposit and immediately validates pending outbound func (c CCTXGatewayZEVM) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChainTx) (newCCTXStatus types.CctxStatus) { - tmpCtx, _ := ctx.CacheContext() + tmpCtx, commit := ctx.CacheContext() isContractReverted, err := c.crosschainKeeper.HandleEVMDeposit(tmpCtx, cctx) if err != nil && !isContractReverted { @@ -30,5 +30,10 @@ func (c CCTXGatewayZEVM) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChai } cctx.SetPendingOutbound("") - return c.crosschainKeeper.ValidateOutboundZEVM(ctx, cctx, err, isContractReverted) + newCCTXStatus = c.crosschainKeeper.ValidateOutboundZEVM(ctx, cctx, err, isContractReverted) + if newCCTXStatus == types.CctxStatus_OutboundMined { + commit() + } + + return newCCTXStatus } diff --git a/x/crosschain/keeper/cctx_orchestrator.go b/x/crosschain/keeper/cctx_orchestrator.go index e263251cb0..bf207cb6a5 100644 --- a/x/crosschain/keeper/cctx_orchestrator.go +++ b/x/crosschain/keeper/cctx_orchestrator.go @@ -41,7 +41,6 @@ func (k Keeper) ValidateOutboundZEVM( depositErr error, isContractReverted bool, ) (newCCTXStatus types.CctxStatus) { - tmpCtx, commit := ctx.CacheContext() if depositErr != nil && isContractReverted { tmpCtxRevert, commitRevert := ctx.CacheContext() // contract call reverted; should refund via a revert tx @@ -60,8 +59,7 @@ func (k Keeper) ValidateOutboundZEVM( commitRevert() return types.CctxStatus_PendingRevert } - k.validateSuccessfulOutbound(tmpCtx, cctx, "", false) - commit() + k.validateSuccessfulOutbound(ctx, cctx, "", false) return types.CctxStatus_OutboundMined }