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(zetaclient): add zetaclient evm outbound tx index by nonce to supplement outtx tracker #2735

Merged
merged 21 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
064ec6a
zetaclient: cache outbound tx while scanning blocks
brewmaster012 Aug 16, 2024
e6091c4
PoC: no outbound tracker to validate the local indexing
brewmaster012 Aug 16, 2024
96353c7
Merge branch 'develop' into zetaclient-evm-index-by-nonce
ws4charlie Aug 19, 2024
1a88984
Update zetaclient/chains/evm/observer/inbound.go
brewmaster012 Aug 21, 2024
2469d77
Merge branch 'develop' into zetaclient-evm-index-by-nonce
brewmaster012 Aug 21, 2024
d6cba72
fixed rename
brewmaster012 Aug 23, 2024
9e08821
fixed rename
brewmaster012 Aug 23, 2024
f8264e1
revert the manual test in localnet e2e
brewmaster012 Aug 23, 2024
4af0d61
fix unit test
brewmaster012 Aug 23, 2024
8c8e675
Merge branch 'develop' into zetaclient-evm-index-by-nonce
brewmaster012 Aug 23, 2024
7c0c232
fix some logs/comments due to rename
brewmaster012 Aug 23, 2024
c140c4e
Update zetaclient/chains/evm/observer/inbound.go
brewmaster012 Aug 23, 2024
e787e70
check cache before calling RPC
brewmaster012 Aug 23, 2024
8664efc
Merge branch 'develop' of https://github.com/zeta-chain/node into zet…
ws4charlie Aug 30, 2024
1bed195
Merge branch 'develop' into zetaclient-evm-index-by-nonce
brewmaster012 Sep 5, 2024
0c73da6
Merge branch 'develop' into zetaclient-evm-index-by-nonce
brewmaster012 Sep 7, 2024
252311e
Merge branch 'develop' into zetaclient-evm-index-by-nonce
ws4charlie Sep 9, 2024
c0d19c9
use a separate function FilterTSSOutbound to scan TSS outbounds and s…
ws4charlie Sep 10, 2024
19699f3
replace manual evm rpc mock with mockery generated mock
ws4charlie Sep 11, 2024
243452b
Merge branch 'develop' of https://github.com/zeta-chain/node into zet…
ws4charlie Sep 11, 2024
cf8f943
Merge branch 'develop' into zetaclient-evm-index-by-nonce
ws4charlie Sep 11, 2024
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 @@ -29,6 +29,7 @@

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module
* [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one
* [2735](https://github.com/zeta-chain/node/pull/2735) - fix the outbound tracker blocking confirmation and outbound processing on EVM chains by locally index outbound txs in zetaclient

## v19.0.0

Expand Down
15 changes: 11 additions & 4 deletions zetaclient/chains/evm/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@
// query incoming gas asset
for bn := startBlock; bn <= toBlock; bn++ {
// observe TSS received gas token in block 'bn'
err := ob.ObserveTSSReceiveInBlock(ctx, bn)
err := ob.ObserveTSSReceiveInBlockAndOutbound(ctx, bn)

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

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L449

Added line #L449 was not covered by tests
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
ob.Logger().Inbound.Error().
Err(err).
Int64("tss.chain_id", chainID).
Uint64("tss.block_number", bn).
Msg("ObserverTSSReceive: unable to ObserveTSSReceiveInBlock")
Msg("ObserverTSSReceive: unable to ObserveTSSReceiveInBlockAndOutbound")

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

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L455

Added line #L455 was not covered by tests

// we have to re-scan from this block next time
return bn - 1, nil
Expand Down Expand Up @@ -770,8 +770,9 @@
)
}

// ObserveTSSReceiveInBlock queries the incoming gas asset to TSS address in a single block and posts votes
func (ob *Observer) ObserveTSSReceiveInBlock(ctx context.Context, blockNumber uint64) error {
// ObserveTSSReceiveInBlockAndOutbound queries the incoming gas asset to TSS address in a single block and posts votes.
// It also filters TSS outbounds indexed by nonce to supplement outtx tracker.
func (ob *Observer) ObserveTSSReceiveInBlockAndOutbound(ctx context.Context, blockNumber uint64) error {
block, err := ob.GetBlockByNumberCached(blockNumber)
if err != nil {
return errors.Wrapf(err, "error getting block %d for chain %d", blockNumber, ob.Chain().ChainId)
Expand All @@ -794,6 +795,12 @@
)
}
}
if ethcommon.HexToAddress(tx.From) == ob.TSS().EVMAddress() {
nonce := uint64(tx.Nonce)
brewmaster012 marked this conversation as resolved.
Show resolved Hide resolved
if receipt, txx, ok := ob.checkConfirmedTx(ctx, tx.Hash, nonce); ok {
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved
ob.SetTxNReceipt(nonce, receipt, txx)

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

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/inbound.go#L799-L801

Added lines #L799 - L801 were not covered by tests
ws4charlie marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/chains/evm/observer/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,19 @@ func Test_ObserveTSSReceiveInBlock(t *testing.T) {
// feed archived block and receipt
evmJSONRPC.WithBlock(block)
evmClient.WithReceipt(receipt)
err := ob.ObserveTSSReceiveInBlock(ctx, blockNumber)
err := ob.ObserveTSSReceiveInBlockAndOutbound(ctx, blockNumber)
require.NoError(t, err)
})
t.Run("should not observe on error getting block", func(t *testing.T) {
ob, _ := MockEVMObserver(t, chain, evmClient, evmJSONRPC, zetacoreClient, tss, lastBlock, chainParam)
err := ob.ObserveTSSReceiveInBlock(ctx, blockNumber)
err := ob.ObserveTSSReceiveInBlockAndOutbound(ctx, blockNumber)
// error getting block is expected because the mock JSONRPC contains no block
require.ErrorContains(t, err, "error getting block")
})
t.Run("should not observe on error getting receipt", func(t *testing.T) {
ob, _ := MockEVMObserver(t, chain, evmClient, evmJSONRPC, zetacoreClient, tss, lastBlock, chainParam)
evmJSONRPC.WithBlock(block)
err := ob.ObserveTSSReceiveInBlock(ctx, blockNumber)
err := ob.ObserveTSSReceiveInBlockAndOutbound(ctx, blockNumber)
// error getting block is expected because the mock evmClient contains no receipt
require.ErrorContains(t, err, "error getting receipt")
})
Expand Down
Loading