Skip to content

fix(light): stop witness comparison after divergence checks (backport #5820) - #5826

Merged
mergify[bot] merged 3 commits into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5820
May 4, 2026
Merged

mergify[bot] merged 3 commits into
v0.38.xfrom
mergify/bp/v0.38.x/pr-5820

Conversation

@mergify

@mergify mergify Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Return immediately when a witness reports conflicting headers or proposer-priority divergence so the detector cannot treat a mismatch as a valid match. Add a detector test that keeps header hashes equal while diverging proposer priorities to verify ErrProposerPrioritiesDiverge is returned.


PR checklist

  • Tests written/updated
  • Changelog entry added in CHANGELOG.md
  • Updated relevant documentation (docs/ or spec/) and code comments

This is an automatic backport of pull request #5820 done by [Mergify](https://mergify.com).

Return immediately when a witness reports conflicting headers or
proposer-priority divergence so the detector cannot treat a mismatch as
a valid match. Add a detector test that keeps header hashes equal while
diverging proposer priorities to verify ErrProposerPrioritiesDiverge is
returned.

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `CHANGELOG.md`
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments

---------

Co-authored-by: Matt Acciai <[email protected]>
(cherry picked from commit 24e5aeb)

# Conflicts:
#	CHANGELOG.md
@mergify mergify Bot added the conflicts label May 4, 2026
@mergify

mergify Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 24e5aeb has failed:

On branch mergify/bp/v0.38.x/pr-5820
Your branch is up to date with 'origin/v0.38.x'.

You are currently cherry-picking commit 24e5aeb1.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   light/detector.go
	modified:   light/detector_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CHANGELOG.md

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@greptile-apps

greptile-apps Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

aljo242 and others added 2 commits May 4, 2026 14:02
Pin golangci-lint to the repository's stable version and remove flaky assumptions in TestProvider so CI no longer fails on unrelated lint drift or timing-sensitive heights.

Co-authored-by: Cursor <[email protected]>
@mattac21
mattac21 force-pushed the mergify/bp/v0.38.x/pr-5820 branch from 75d3323 to 8a29516 Compare May 4, 2026 19:19
@mattac21 mattac21 removed the conflicts label May 4, 2026
@mattac21
mattac21 enabled auto-merge May 4, 2026 19:19
@mergify
mergify Bot merged commit 20818d7 into v0.38.x May 4, 2026
24 of 25 checks passed
@mergify
mergify Bot deleted the mergify/bp/v0.38.x/pr-5820 branch May 4, 2026 19:28
JayT106 added a commit to crypto-org-chain/cometbft that referenced this pull request Oct 5, 2026
Backport of the test change in upstream cometbft#5826; fast runners pass height
1000 before the assertions run.
JayT106 added a commit to crypto-org-chain/cometbft that referenced this pull request Oct 7, 2026
* perf(indexer): paginate tx search results before loading txs

Sort and page matched txs by the height and index stored in event keys,
so only the requested page is read from the store. The local RPC client
now passes the caller's context to TxSearch and BlockSearch.

* chore: add changelog entry

* chore(ci): pin golangci-lint to v2.11.3

Matches upstream v0.38.x; @latest flags existing code with newer checks.

* test(light): make TestProvider independent of chain height

Backport of the test change in upstream cometbft#5826; fast runners pass height
1000 before the assertions run.

* perf(indexer): cut per-match allocations in tx search

Dedup matches by sorting instead of a set, keep the hash as a substring
of the map key, and parse the event sequence without splitting the key.
Peak heap for a 100k-match page-1 query drops from 96MB to 45MB.

* chore: single changelog entry, paginated tx search benchmark

* refactor(indexer): keep TxIndexer.Search, add optional PageSearcher

Search keeps its v0.38 signature. The kv indexer also implements
txindex.PageSearcher, which rpc/core uses when available and otherwise
falls back to loading, sorting and slicing every match.

* fix(indexer): guard page offset overflow in Paginate

page comes from the request and is validated only after the search, so a
huge page overflowed (page-1)*perPage and panicked when slicing. Also
assert that the kv indexer built from config is a PageSearcher.

* fixes and optimisation

* chore: keep changelog entry to the PR title

---------

Co-authored-by: Thomas Nguy <[email protected]>
JayT106 added a commit to crypto-org-chain/cometbft that referenced this pull request Nov 23, 2026
* perf(indexer): paginate tx search results before loading txs

Sort and page matched txs by the height and index stored in event keys,
so only the requested page is read from the store. The local RPC client
now passes the caller's context to TxSearch and BlockSearch.

* chore: add changelog entry

* chore(ci): pin golangci-lint to v2.11.3

Matches upstream v0.38.x; @latest flags existing code with newer checks.

* test(light): make TestProvider independent of chain height

Backport of the test change in upstream cometbft#5826; fast runners pass height
1000 before the assertions run.

* perf(indexer): cut per-match allocations in tx search

Dedup matches by sorting instead of a set, keep the hash as a substring
of the map key, and parse the event sequence without splitting the key.
Peak heap for a 100k-match page-1 query drops from 96MB to 45MB.

* chore: single changelog entry, paginated tx search benchmark

* refactor(indexer): keep TxIndexer.Search, add optional PageSearcher

Search keeps its v0.38 signature. The kv indexer also implements
txindex.PageSearcher, which rpc/core uses when available and otherwise
falls back to loading, sorting and slicing every match.

* fix(indexer): guard page offset overflow in Paginate

page comes from the request and is validated only after the search, so a
huge page overflowed (page-1)*perPage and panicked when slicing. Also
assert that the kv indexer built from config is a PageSearcher.

* fixes and optimisation

* chore: keep changelog entry to the PR title

---------

Co-authored-by: Thomas Nguy <[email protected]>
(cherry picked from commit 5cbc9c4)

Port to v0.38.26: the golangci-lint pin and TestProvider fix are already
upstream, so those hunks drop out; the changelog entry moves under a new
UNRELEASED section.
JayT106 added a commit to crypto-org-chain/cometbft that referenced this pull request Nov 30, 2026
* perf(indexer): paginate tx search results before loading txs

Sort and page matched txs by the height and index stored in event keys,
so only the requested page is read from the store. The local RPC client
now passes the caller's context to TxSearch and BlockSearch.

* chore: add changelog entry

* chore(ci): pin golangci-lint to v2.11.3

Matches upstream v0.38.x; @latest flags existing code with newer checks.

* test(light): make TestProvider independent of chain height

Backport of the test change in upstream cometbft#5826; fast runners pass height
1000 before the assertions run.

* perf(indexer): cut per-match allocations in tx search

Dedup matches by sorting instead of a set, keep the hash as a substring
of the map key, and parse the event sequence without splitting the key.
Peak heap for a 100k-match page-1 query drops from 96MB to 45MB.

* chore: single changelog entry, paginated tx search benchmark

* refactor(indexer): keep TxIndexer.Search, add optional PageSearcher

Search keeps its v0.38 signature. The kv indexer also implements
txindex.PageSearcher, which rpc/core uses when available and otherwise
falls back to loading, sorting and slicing every match.

* fix(indexer): guard page offset overflow in Paginate

page comes from the request and is validated only after the search, so a
huge page overflowed (page-1)*perPage and panicked when slicing. Also
assert that the kv indexer built from config is a PageSearcher.

* fixes and optimisation

* chore: keep changelog entry to the PR title

---------

Co-authored-by: Thomas Nguy <[email protected]>

(cherry picked from commit 5cbc9c4)

Port to v0.40.x: the golangci-lint pin and TestProvider fix are already
upstream, so those hunks drop out.
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.

3 participants