Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust evm outbound tracker reporter to avoid submitting invalid hashes #2628

Merged
merged 15 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
* [2481](https://github.com/zeta-chain/node/pull/2481) - increase gas limit inbound and outbound vote message to 500k
* [2545](https://github.com/zeta-chain/node/pull/2545) - check solana minimum rent exempt to avoid outbound failure
* [2547](https://github.com/zeta-chain/node/pull/2547) - limit max txs in priority mempool
* [2628](https://github.com/zeta-chain/node/pull/2628) - avoid submitting invalid hashes to outbound tracker

### CI

Expand Down
6 changes: 6 additions & 0 deletions pkg/constant/constant.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package constant

import "time"

const (
// ZetaBlockTime is the block time of the ZetaChain network
// It's a rough estimate that can be used in non-critical path to estimate the time of a block
ZetaBlockTime = 6000 * time.Millisecond

// DonationMessage is the message for donation transactions
// Transaction sent to the TSS or ERC20 Custody address containing this message are considered as a donation
DonationMessage = "I am rich!"
Expand Down
11 changes: 6 additions & 5 deletions zetaclient/chains/base/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/chains/interfaces"
"github.com/zeta-chain/zetacore/zetaclient/db"
"github.com/zeta-chain/zetacore/zetaclient/logs"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
clienttypes "github.com/zeta-chain/zetacore/zetaclient/types"
"github.com/zeta-chain/zetacore/zetaclient/zetacore"
Expand Down Expand Up @@ -301,13 +302,13 @@ func (ob *Observer) Logger() *ObserverLogger {

// WithLogger attaches a new logger to the observer.
func (ob *Observer) WithLogger(logger Logger) *Observer {
chainLogger := logger.Std.With().Int64("chain", ob.chain.ChainId).Logger()
chainLogger := logger.Std.With().Int64(logs.FieldChain, ob.chain.ChainId).Logger()
ob.logger = ObserverLogger{
Chain: chainLogger,
Inbound: chainLogger.With().Str("module", "inbound").Logger(),
Outbound: chainLogger.With().Str("module", "outbound").Logger(),
GasPrice: chainLogger.With().Str("module", "gasprice").Logger(),
Headers: chainLogger.With().Str("module", "headers").Logger(),
Inbound: chainLogger.With().Str(logs.FieldModule, logs.ModNameInbound).Logger(),
Outbound: chainLogger.With().Str(logs.FieldModule, logs.ModNameOutbound).Logger(),
GasPrice: chainLogger.With().Str(logs.FieldModule, logs.ModNameGasPrice).Logger(),
Headers: chainLogger.With().Str(logs.FieldModule, logs.ModNameHeaders).Logger(),
Compliance: logger.Compliance,
}
return ob
Expand Down
6 changes: 5 additions & 1 deletion zetaclient/chains/base/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/zetaclient/chains/interfaces"
"github.com/zeta-chain/zetacore/zetaclient/logs"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
)

Expand Down Expand Up @@ -38,7 +39,10 @@ func NewSigner(chain chains.Chain, tss interfaces.TSSSigner, ts *metrics.Telemet
tss: tss,
ts: ts,
logger: Logger{
Std: logger.Std.With().Int64("chain", chain.ChainId).Str("module", "signer").Logger(),
Std: logger.Std.With().
Int64(logs.FieldChain, chain.ChainId).
Str(logs.FieldModule, "signer").
Logger(),
Compliance: logger.Compliance,
},
outboundBeingReported: make(map[string]bool),
Expand Down
7 changes: 4 additions & 3 deletions zetaclient/chains/evm/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package evm
import "time"

const (
// ZetaBlockTime is the block time of the Zeta network
ZetaBlockTime = 6500 * time.Millisecond

// OutboundInclusionTimeout is the timeout for waiting for an outbound to be included in a block
OutboundInclusionTimeout = 20 * time.Minute

// ReorgProtectBlockCount is confirmations count to protect against reorg
// Short 1~2 block reorgs could happen often on Ethereum due to network congestion or block production race conditions
ReorgProtectBlockCount = 2
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved

// OutboundTrackerReportTimeout is the timeout for waiting for an outbound tracker report
OutboundTrackerReportTimeout = 10 * time.Minute

Expand Down
19 changes: 0 additions & 19 deletions zetaclient/chains/evm/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ type Observer struct {
// evmJSONRPC is the EVM JSON RPC client for the observed chain
evmJSONRPC interfaces.EVMJSONRPCClient

// outboundPendingTransactions is the map to index pending transactions by hash
outboundPendingTransactions map[string]*ethtypes.Transaction

// outboundConfirmedReceipts is the map to index confirmed receipts by hash
outboundConfirmedReceipts map[string]*ethtypes.Receipt

Expand Down Expand Up @@ -92,7 +89,6 @@ func NewObserver(
Observer: *baseObserver,
evmClient: evmClient,
evmJSONRPC: ethrpc.NewEthRPC(evmCfg.Endpoint),
outboundPendingTransactions: make(map[string]*ethtypes.Transaction),
outboundConfirmedReceipts: make(map[string]*ethtypes.Receipt),
outboundConfirmedTransactions: make(map[string]*ethtypes.Transaction),
priorityFeeConfig: priorityFeeConfig{},
Expand Down Expand Up @@ -230,25 +226,10 @@ func (ob *Observer) WatchRPCStatus(ctx context.Context) error {
}
}

// SetPendingTx sets the pending transaction in memory
func (ob *Observer) SetPendingTx(nonce uint64, transaction *ethtypes.Transaction) {
ob.Mu().Lock()
defer ob.Mu().Unlock()
ob.outboundPendingTransactions[ob.OutboundID(nonce)] = transaction
}

// GetPendingTx gets the pending transaction from memory
func (ob *Observer) GetPendingTx(nonce uint64) *ethtypes.Transaction {
ob.Mu().Lock()
defer ob.Mu().Unlock()
return ob.outboundPendingTransactions[ob.OutboundID(nonce)]
}

// SetTxNReceipt sets the receipt and transaction in memory
func (ob *Observer) SetTxNReceipt(nonce uint64, receipt *ethtypes.Receipt, transaction *ethtypes.Transaction) {
ob.Mu().Lock()
defer ob.Mu().Unlock()
delete(ob.outboundPendingTransactions, ob.OutboundID(nonce)) // remove pending transaction, if any
ob.outboundConfirmedReceipts[ob.OutboundID(nonce)] = receipt
ob.outboundConfirmedTransactions[ob.OutboundID(nonce)] = transaction
}
Expand Down
Loading
Loading