Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 12, 2024
1 parent d36876d commit 4bdf50f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 36 deletions.
6 changes: 0 additions & 6 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,3 @@ You can also run an alias of `zetae2e run` like so:
```shell
`./e2e/scripts/run.sh bitcoin_withdraw_restricted 0.001`
```

To setup BTC suite, run

```shell
zetae2e setup-bitcoin cmd/zetae2e/config/local.yml
```
26 changes: 13 additions & 13 deletions zetaclient/chains/bitcoin/observer/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ func (ob *Observer) IsOutboundProcessed(
cctx *crosschaintypes.CrossChainTx,
logger zerolog.Logger,
) (bool, bool, error) {
const (

Check warning on line 130 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L129-L130

Added lines #L129 - L130 were not covered by tests
// not used with Bitcoin
outboundGasUsed = 0
outboundGasPrice = 0
outboundGasLimit = 0

Check warning on line 134 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L132-L134

Added lines #L132 - L134 were not covered by tests

gasLimit = zetacore.PostVoteOutboundGasLimit
gasRetryLimit = 0
)

Check warning on line 138 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L136-L138

Added lines #L136 - L138 were not covered by tests

params := *cctx.GetCurrentOutboundParam()
nonce := cctx.GetCurrentOutboundParam().TssNonce

Expand Down Expand Up @@ -191,16 +201,6 @@ func (ob *Observer) IsOutboundProcessed(

signer := ob.ZetacoreClient().GetKeys().GetOperatorAddress()

Check warning on line 202 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L202

Added line #L202 was not covered by tests

const (
// not used with Bitcoin
outboundGasUsed = 0
outboundGasPrice = 0
outboundGasLimit = 0

gasLimit = zetacore.PostVoteOutboundGasLimit
gasRetryLimit = 0
)

msg := crosschaintypes.NewMsgVoteOutbound(
signer.String(),
cctx.Index,

Check warning on line 206 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L204-L206

Added lines #L204 - L206 were not covered by tests
Expand All @@ -223,17 +223,17 @@ func (ob *Observer) IsOutboundProcessed(

zetaHash, ballot, err := ob.ZetacoreClient().PostVoteOutbound(ctx, gasLimit, gasRetryLimit, msg)

Check warning on line 224 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L224

Added line #L224 was not covered by tests

lf := map[string]any{
logFields := map[string]any{
"outbound.external_tx_hash": res.TxID,
"outbound.nonce": nonce,
"outbound.zeta_tx_hash": zetaHash,
"outbound.ballot": ballot,

Check warning on line 230 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L226-L230

Added lines #L226 - L230 were not covered by tests
}

if err != nil {
logger.Error().Err(err).Fields(lf).Msg("IsOutboundProcessed: error confirming bitcoin outbound")
logger.Error().Err(err).Fields(logFields).Msg("IsOutboundProcessed: error confirming bitcoin outbound")

Check warning on line 234 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L234

Added line #L234 was not covered by tests
} else if zetaHash != "" {
logger.Info().Fields(lf).Msgf("IsOutboundProcessed: confirmed Bitcoin outbound")
logger.Info().Fields(logFields).Msgf("IsOutboundProcessed: confirmed Bitcoin outbound")

Check warning on line 236 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L236

Added line #L236 was not covered by tests
}

return true, true, nil
Expand Down
10 changes: 5 additions & 5 deletions zetaclient/chains/evm/observer/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (ob *Observer) PostVoteOutbound(
logger zerolog.Logger,
) {
chainID := ob.Chain().ChainId
lf := map[string]any{
logFields := map[string]any{
"outbound.chain_id": chainID,
"outbound.external_tx_hash": receipt.TxHash.String(),
"outbound.nonce": nonce,
Expand Down Expand Up @@ -149,18 +149,18 @@ func (ob *Observer) PostVoteOutbound(

zetaTxHash, ballot, err := ob.ZetacoreClient().PostVoteOutbound(ctx, gasLimit, retryGasLimit, msg)
if err != nil {
logger.Error().Err(err).Fields(lf).Msgf("PostVoteOutbound: error posting vote for chain %d", chainID)
logger.Error().Err(err).Fields(logFields).Msgf("PostVoteOutbound: error posting vote for chain %d", chainID)
return

Check warning on line 153 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L152-L153

Added lines #L152 - L153 were not covered by tests
}

if zetaTxHash == "" {
return
}

lf["outbound.zeta_tx_hash"] = zetaTxHash
lf["outbound.ballot"] = ballot
logFields["outbound.zeta_tx_hash"] = zetaTxHash
logFields["outbound.ballot"] = ballot

Check warning on line 161 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L160-L161

Added lines #L160 - L161 were not covered by tests

logger.Info().Fields(lf).Msgf("PostVoteOutbound: posted vote for chain %d", chainID)
logger.Info().Fields(logFields).Msgf("PostVoteOutbound: posted vote for chain %d", chainID)

Check warning on line 163 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L163

Added line #L163 was not covered by tests
}

// IsOutboundProcessed checks outbound status and returns (isIncluded, isConfirmed, error)
Expand Down
24 changes: 12 additions & 12 deletions zetaclient/zetacore/client_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *Client) monitorVoteOutboundResult(
return errors.Wrap(err, "failed to query tx result")

Check warning on line 58 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L58

Added line #L58 was not covered by tests
}

lf := map[string]any{
logFields := map[string]any{
"outbound.hash": zetaTxHash,
"outbound.raw_log": txResult.RawLog,
}
Expand All @@ -67,21 +67,21 @@ func (c *Client) monitorVoteOutboundResult(
case strings.Contains(txResult.RawLog, "failed to execute message"):

Check warning on line 67 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L67

Added line #L67 was not covered by tests
// the inbound vote tx shouldn't fail to execute
// this shouldn't happen
c.logger.Error().Fields(lf).Msg("monitorVoteOutboundResult: failed to execute vote")
c.logger.Error().Fields(logFields).Msg("monitorVoteOutboundResult: failed to execute vote")
case strings.Contains(txResult.RawLog, "out of gas"):

Check warning on line 71 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L70-L71

Added lines #L70 - L71 were not covered by tests
// if the tx fails with an out of gas error, resend the tx with more gas if retryGasLimit > 0
c.logger.Debug().Fields(lf).Msg("monitorVoteOutboundResult: out of gas")
c.logger.Debug().Fields(logFields).Msg("monitorVoteOutboundResult: out of gas")

Check warning on line 73 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L73

Added line #L73 was not covered by tests

if retryGasLimit > 0 {

Check warning on line 75 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L75

Added line #L75 was not covered by tests
// new retryGasLimit set to 0 to prevent reentering this function
if _, _, err := c.PostVoteOutbound(ctx, retryGasLimit, 0, msg); err != nil {
c.logger.Error().Err(err).Fields(lf).Msg("monitorVoteOutboundResult: failed to resend tx")
c.logger.Error().Err(err).Fields(logFields).Msg("monitorVoteOutboundResult: failed to resend tx")
} else {
c.logger.Info().Fields(lf).Msg("monitorVoteOutboundResult: successfully resent tx")
c.logger.Info().Fields(logFields).Msg("monitorVoteOutboundResult: successfully resent tx")

Check warning on line 80 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L77-L80

Added lines #L77 - L80 were not covered by tests
}
}
default:
c.logger.Debug().Fields(lf).Msg("monitorVoteOutboundResult: successful")
c.logger.Debug().Fields(logFields).Msg("monitorVoteOutboundResult: successful")
}

return nil
Expand Down Expand Up @@ -133,7 +133,7 @@ func (c *Client) monitorVoteInboundResult(
return errors.Wrap(err, "failed to query tx result")

Check warning on line 133 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L133

Added line #L133 was not covered by tests
}

lf := map[string]any{
logFields := map[string]any{
"inbound.hash": zetaTxHash,
"inbound.raw_log": txResult.RawLog,
}
Expand All @@ -142,23 +142,23 @@ func (c *Client) monitorVoteInboundResult(
case strings.Contains(txResult.RawLog, "failed to execute message"):

Check warning on line 142 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L142

Added line #L142 was not covered by tests
// the inbound vote tx shouldn't fail to execute
// this shouldn't happen
c.logger.Error().Fields(lf).Msg("monitorVoteInboundResult: failed to execute vote")
c.logger.Error().Fields(logFields).Msg("monitorVoteInboundResult: failed to execute vote")

Check warning on line 145 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L145

Added line #L145 was not covered by tests

case strings.Contains(txResult.RawLog, "out of gas"):

Check warning on line 147 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L147

Added line #L147 was not covered by tests
// if the tx fails with an out of gas error, resend the tx with more gas if retryGasLimit > 0
c.logger.Debug().Fields(lf).Msg("monitorVoteInboundResult: out of gas")
c.logger.Debug().Fields(logFields).Msg("monitorVoteInboundResult: out of gas")

Check warning on line 149 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L149

Added line #L149 was not covered by tests

if retryGasLimit > 0 {

Check warning on line 151 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L151

Added line #L151 was not covered by tests
// new retryGasLimit set to 0 to prevent reentering this function
if _, _, err := c.PostVoteInbound(ctx, retryGasLimit, 0, msg); err != nil {
c.logger.Error().Err(err).Fields(lf).Msg("monitorVoteInboundResult: failed to resend tx")
c.logger.Error().Err(err).Fields(logFields).Msg("monitorVoteInboundResult: failed to resend tx")
} else {
c.logger.Info().Fields(lf).Msg("monitorVoteInboundResult: successfully resent tx")
c.logger.Info().Fields(logFields).Msg("monitorVoteInboundResult: successfully resent tx")

Check warning on line 156 in zetaclient/zetacore/client_monitor.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_monitor.go#L153-L156

Added lines #L153 - L156 were not covered by tests
}
}

default:
c.logger.Debug().Fields(lf).Msgf("monitorVoteInboundResult: successful")
c.logger.Debug().Fields(logFields).Msgf("monitorVoteInboundResult: successful")
}

return nil
Expand Down

0 comments on commit 4bdf50f

Please sign in to comment.