Skip to content

fix(validator): avoid crash when policy rejection topic is disabled - #1694

Open
rohenaz wants to merge 1 commit into
bsv-blockchain:mainfrom
rohenaz:codex/optional-policy-producer
Open

fix(validator): avoid crash when policy rejection topic is disabled#1694
rohenaz wants to merge 1 commit into
bsv-blockchain:mainfrom
rohenaz:codex/optional-policy-producer

Conversation

@rohenaz

@rohenaz rohenaz commented Sep 5, 2026

Copy link
Copy Markdown

When TxPolicyRejectedConfig is unset, the validator service passes a typed nil producer into a KafkaAsyncProducerI interface. A low-fee transaction then reaches publishPolicyRejectedTx, passes its interface nil check, and panics in TryPublish instead of returning the policy rejection.

Keep the interface nil when the optional producer is absent, matching the existing local-validator construction path. Configured producers and fee policy are unchanged.

The regression starts the real local regtest daemon with SQLite, in-memory messaging and the optional topic explicitly disabled. It submits a signed transaction paying 1 sat, requires the low-fee error, and verifies that the transaction enters neither UTXO storage nor block assembly.

Validation on upstream 40faeb0f0bfcf94baf1eaa69517b5e5889af0d89:

  • Focused real-daemon regression passed, including -race.
  • Existing local-validator producer construction/cleanup tests passed.
  • git diff --check passed.

Reproduce the focused test without external services:

SETTINGS_CONTEXT=dev.system.test CGO_ENABLED=1 go test -v -race -count=1 -parallel=1 -timeout=120s -tags testtxmetacache -run '^TestValidatorRejectsLowFeeWithoutPolicyRejectedTopic$' ./test/e2e/daemon/ready/optional_policy_producer_test.go

The full node suite and production-scale testing were not run. This change adds no CPFP acceptance or fee-policy exception.

@rohenaz
rohenaz marked this pull request as ready for review September 5, 2026 00:48
Copilot AI lite review requested due to automatic review settings September 5, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fix correctly prevents the typed-nil interface panic for an optional producer and is backed by a targeted e2e regression test that asserts the intended behavior.

Pull request overview

This PR fixes a validator crash caused by passing a typed-nil *KafkaAsyncProducer into the kafka.KafkaAsyncProducerI interface when the optional TxPolicyRejectedConfig topic is disabled, and adds an end-to-end regression test to ensure low-fee transactions are rejected without panicking and without being persisted/assembled.

Changes:

  • Ensure the policy-rejected Kafka producer remains a true nil interface when the topic is not configured, preventing false-positive nil checks and panics in TryPublish.
  • Add an e2e daemon regression test that disables TxPolicyRejectedConfig, submits a low-fee tx, and asserts the expected policy error and no side effects (no UTXO insert, no block-assembly enqueue).
File summaries
File Description
daemon/daemon_services.go Normalizes the optional policy-rejected producer to a true nil interface before wiring it into validator.NewServer.
test/e2e/daemon/ready/optional_policy_producer_test.go Adds a real-daemon regression covering the “topic disabled + low-fee tx” panic path and verifies the tx is not stored or assembled.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants