Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Dec 4, 2024
1 parent ef6847e commit c00f964
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
3 changes: 1 addition & 2 deletions x/crosschain/types/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ func (m *Status) AbortRefunded() {
func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) {
m.UpdateStatus(newStatus, statusMsg)

if errorMsg != "" &&
(newStatus == CctxStatus_Aborted || newStatus == CctxStatus_Reverted || newStatus == CctxStatus_PendingRevert) {
if errorMsg != "" {
m.UpdateErrorMessage(errorMsg)
}
}
Expand Down
20 changes: 7 additions & 13 deletions zetaclient/chains/evm/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,13 @@ func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error {
ob.Logger().Inbound.Info().Msgf("checking tracker for inbound %s chain %d", tracker.TxHash, ob.Chain().ChainId)

// try processing the tracker for v2 inbound
gatewayAddr, gateway, err := ob.GetGatewayContract()
if err != nil {
ob.Logger().Inbound.Debug().Err(err).Msg("error getting gateway contract for processing inbound tracker")
}
if err == nil && tx != nil {
// filter error if event is not found, in this case we run v1 tracker process
if err := ob.ProcessInboundTrackerV2(ctx, gateway, gatewayAddr, tx, receipt); err != nil &&
!errors.Is(err, errEventNotFound) {
return err
} else if err == nil {
// continue with next tracker
continue
}
// filter error if event is not found, in this case we run v1 tracker process
if err := ob.ProcessInboundTrackerV2(ctx, tx, receipt); err != nil &&
!errors.Is(err, ErrEventNotFound) && !errors.Is(err, ErrGatewayNotSet) {
return err
} else if err == nil {
// continue with next tracker
continue

Check warning on line 155 in zetaclient/chains/evm/observer/inbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L148-L155

Added lines #L148 - L155 were not covered by tests
}

// try processing the tracker for v1 inbound
Expand Down
19 changes: 12 additions & 7 deletions zetaclient/chains/evm/observer/v2_inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@ package observer

import (
"context"
"errors"
"fmt"

ethcommon "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/onrik/ethrpc"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol"
"github.com/pkg/errors"

"github.com/zeta-chain/node/zetaclient/zetacore"
)

var errEventNotFound = errors.New("no gateway event found in inbound tracker")
var (
ErrEventNotFound = errors.New("event not found")
ErrGatewayNotSet = errors.New("gateway contract not set")
)

// ProcessInboundTrackerV2 processes inbound tracker events from the gateway
func (ob *Observer) ProcessInboundTrackerV2(
ctx context.Context,
gateway *gatewayevm.GatewayEVM,
gatewayAddr ethcommon.Address,
tx *ethrpc.Transaction,
receipt *ethtypes.Receipt,
) error {
gatewayAddr, gateway, err := ob.GetGatewayContract()
if err != nil {
ob.Logger().Inbound.Debug().Err(err).Msg("error getting gateway contract for processing inbound tracker")
return ErrGatewayNotSet
}

Check warning on line 29 in zetaclient/chains/evm/observer/v2_inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/v2_inbound_tracker.go#L25-L29

Added lines #L25 - L29 were not covered by tests

// check confirmations
if confirmed := ob.HasEnoughConfirmations(receipt, ob.LastBlock()); !confirmed {
return fmt.Errorf(
Expand All @@ -33,7 +38,7 @@ func (ob *Observer) ProcessInboundTrackerV2(
}

for _, log := range receipt.Logs {
if log == nil && log.Address != gatewayAddr {
if log == nil || log.Address != gatewayAddr {

Check warning on line 41 in zetaclient/chains/evm/observer/v2_inbound_tracker.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/v2_inbound_tracker.go#L41

Added line #L41 was not covered by tests
continue
}

Expand Down

0 comments on commit c00f964

Please sign in to comment.