Skip to content

Commit

Permalink
fix: adjust evm outbound tracker reporter to avoid submitting invalid…
Browse files Browse the repository at this point in the history
… hashes (#2628)

* refactor and fix evm outbound tracker reporter to avoid invalid hashes; print log when outbound tracker is full of invalid hashes

* add changelog entry

* used predefined log fields

* remove repeated fields information from log message; Devops team would configure Datadog to show the fields

* remove redundant fields in log message; unified logs

* remove pending transaction map from observer; the outbound tracker reporter will no longer report pending hash

* use bg.Work() to launch outbound tracker reporter goroutines

* bring the checking EnsureNoTrackers() back

* add more rationale to EVM outbound tracker submission

* sync observer and signers without wait on startup

* try fixing tss migration E2E failure by increase timeout
  • Loading branch information
ws4charlie authored and gartnera committed Aug 15, 2024
1 parent 76caa0a commit 8701bd2
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 362 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [2568](https://github.com/zeta-chain/node/pull/2568) - improve AppContext by converging chains, chainParams, enabledChains, and additionalChains into a single zctx.Chain
* [2597](https://github.com/zeta-chain/node/pull/2597) - Add generic rpc metrics to zetaclient
* [2634](https://github.com/zeta-chain/node/pull/2634) - add support for EIP-1559 gas fees
* [2628](https://github.com/zeta-chain/node/pull/2628) - avoid submitting invalid hashes to outbound tracker


## v19.0.1
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/zetacore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
AdminPolicyName = "admin"
OperationalPolicyName = "operational"

DefaultCctxTimeout = 4 * time.Minute
DefaultCctxTimeout = 6 * time.Minute
)

// WaitCctxMinedByInboundHash waits until cctx is mined; returns the cctxIndex (the last one)
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 @@ -295,13 +296,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

// 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

0 comments on commit 8701bd2

Please sign in to comment.