Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions zetaclient/chains/bitcoin/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ func (ob *Observer) ObserveInbound(ctx context.Context) error {
return err
}

// Bitcoin's only inbound mechanism is direct transfers to the TSS address.
// When DisableTssBlockScan is true, skip all inbound scanning so new deposits
// are not observed (outbound/withdrawal processing is unaffected).
if ob.ChainParams().DisableTssBlockScan {
ob.Logger().Sampled.Info().Msg("skip inbound observation: DisableTssBlockScan is true")
return nil
}

// get fee rate multiplier
feeRateMultiplier, err := ob.ChainParams().GasPriceMultiplier.Float64()
if err != nil {
Expand Down
37 changes: 37 additions & 0 deletions zetaclient/chains/bitcoin/observer/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,43 @@ func TestAvgFeeRateBlock828440Errors(t *testing.T) {
})
}

func Test_ObserveInbound_DisableTssBlockScan(t *testing.T) {
chain := chains.BitcoinMainnet
ob := newTestSuite(t, chain)

// flip the chain param to disable inbound scanning
chainParams := ob.ChainParams()
chainParams.DisableTssBlockScan = true
ob.SetChainParams(chainParams)

// ObserveInbound should return early without scanning any block.
// We intentionally do NOT mock GetBlockHash/GetBlockVerbose — if scanning
// were attempted, the mock client would fail the test on unexpected calls.
err := ob.ObserveInbound(ob.ctx)
require.NoError(t, err)
}
Comment thread
skosito marked this conversation as resolved.

func Test_ObserveInboundTrackers_DisableTssBlockScan(t *testing.T) {
chain := chains.BitcoinMainnet
ob := newTestSuite(t, chain)

chainParams := ob.ChainParams()
chainParams.DisableTssBlockScan = true
ob.SetChainParams(chainParams)

// Even with trackers present, observeInboundTrackers should return early.
// We intentionally do NOT mock GetRawTransactionVerbose/GetBlockVerbose —
// if processing were attempted, the mock client would fail on unexpected calls.
trackers := []crosschaintypes.InboundTracker{
{ChainId: chain.ChainId, TxHash: "abc"},
}
err := ob.observeInboundTrackers(ob.ctx, trackers, false)
require.NoError(t, err)

err = ob.observeInboundTrackers(ob.ctx, trackers, true)
require.NoError(t, err)
}

func Test_GetInboundVoteFromBtcEvent(t *testing.T) {
r := sample.Rand()

Expand Down
12 changes: 12 additions & 0 deletions zetaclient/chains/bitcoin/observer/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func (ob *Observer) observeInboundTrackers(
trackers []types.InboundTracker,
isInternal bool,
) error {
// Bitcoin's only inbound mechanism is direct transfers to the TSS address.
// When DisableTssBlockScan is true, skip inbound tracker processing so new
// deposits referenced by external or internal trackers are not voted on
// (outbound/withdrawal processing is unaffected).
if ob.ChainParams().DisableTssBlockScan {
ob.Logger().Sampled.Info().
Bool("is_internal", isInternal).
Int("tracker_count", len(trackers)).
Msg("skip inbound tracker processing: DisableTssBlockScan is true")
return nil
}

// take at most MaxInternalTrackersPerScan for each scan
if len(trackers) > config.MaxInboundTrackersPerScan {
trackers = trackers[:config.MaxInboundTrackersPerScan]
Expand Down
Loading