relay: gate mismatched-nonce PoW rejection behind StrictPow - #10
Merged
Conversation
processEvent's Verify() call ran with no options, so any event carrying a
nonce tag whose declared difficulty didn't match the event ID's actual
leading-zero-bit count was hard-rejected unconditionally -- there was no
relay config to disable it. This is distinct from (and ran before) the
existing MinPowDifficulty/StrictPow floor check, which is opt-in and
correctly gated already.
Skip the base check the same way: pass nip01.WithoutPowCheck() unless
Limitation.StrictPow is on, matching this repo's own tests' stated intent
("min: 0 == accept all" by default) and the documented behavior consumers
like ncli's apply --strict-pow already assume the relay side follows.
Adds regression coverage in relay/pow_test.go for both the tolerant default
and the StrictPow=true rejection.
naliyi
marked this pull request as ready for review
September 3, 2026 11:51
1 task
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Session.processEventcalledEvent.Verify()with no options, so any event carrying anoncetag whose declared difficulty didn't match the event ID's actual leading-zero-bit count was hard-rejected unconditionally — no relay config could disable it.MinPowDifficulty/StrictPowfloor check, which is opt-in and was already correctly gated.nip01.WithoutPowCheck(), unlessLimitation.StrictPowis on — consistent with the existing floor check and with this repo's own tests' stated intent ("min: 0 == accept all" by default).Downstream symptom this fixes:
ncli apply stream/syncforwarding an event whose nonce tag overclaims its difficulty to any nmilat-backed relay got it silently dropped at the relay (invalid: pow check failed: ...), regardless ofstrictPow/--strict-powon the ncli side — because that setting only ever controlled ncli's own read-side verification, never the destination relay's independent ingest decision.Test plan
relay/pow_test.go: addedTestProcessEvent_MismatchedNonceToleratedByDefaultandTestProcessEvent_MismatchedNonceRejectedWhenStrict, covering the previously-untested "nonce tag overclaims its difficulty" case (existing tests only used honestly-mined events).go test ./...passes with no regressions.gofmt -lclean on changed files.