Skip to content

fix(getLogs): guard merge boundaries and preserve complete log results - #428

Merged
wanliqun merged 15 commits into
mainfrom
codex/getlogs-consistency
Oct 27, 2026
Merged

wanliqun merged 15 commits into
mainfrom
codex/getlogs-consistency

Conversation

@wanliqun

@wanliqun wanliqun commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Hash-based getLogs could lose block identity after a reorg, mixed DB/fullnode reads could combine different forks, and indivisible DB queries stopped before returning all logs. This change preserves block identity, checks the merge boundary around the node log read, and returns complete single-unit results.

  • Core blockHashes go directly to the fullnode using the original filter. eSpace uses the DB only after its pivot metadata matches the requested hash; unknown or mismatched identities fall back using the original hash. DB failures and pruning keep their existing error handling.
  • Mixed DB/regular-fullnode reads compare the fullnode's identity at the DB boundary with the same DB hash both before and after querying node logs. A failed pre-check skips the log RPC; a failed post-check discards the entire attempt. Empty results are checked too. There is no independent head/checkpoint lookup, and reorgs above the boundary do not independently invalidate the merge. Core checks the boundary epoch's pivot identity.
  • DB reorg version changes and boundary conflicts retry the entire request with cancellable 10ms backoff and no retry-count cap. Multi-unit queries share one 3-second budget from entry; single-unit queries retain their first-read exemption and start a shared retry budget on the first conflict. Earlier caller deadlines win, ordinary DB/RPC errors return directly, and pooled clients are copied before binding request contexts.
  • Indivisible DB queries use 1,000-row keyset pages across storage routes and publish results only after the full read succeeds. Exemptions are based on the original RPC request, so a multi-unit request retains its limits even if its DB segment spans only one unit.
  • Core/eSpace response sizes use typed JSON estimators and shared array accounting across DB, archive and node logs, including optional fields, hex lengths and commas, without marshaling in the hot path. Size accounting excludes the JSON-RPC envelope.

requestControl.getLogs.checkMixedSourceConsistency defaults to true; deployments syncing finalized data on the same chain can disable the mixed-source checks. Archive-source merges remain outside this protection. Independent RPC checks cannot exclude ABA reorgs or guarantee completeness for a requested range above the fullnode head. Topics compatibility and scanLogs behavior are unchanged.

Validation on the final boundary-check implementation:

  • go test ./...
  • go test -race ./rpc/handler ./store/mysql
  • git diff --check

Permanent tests cover pre/post boundary mismatches and missing metadata, ordinary RPC errors, repeated/alternating conflicts, DB boundary refresh, cancellation, empty results, unchanged requested ranges, hash routing, complete 10,002-row reads and original-request limit classification. Existing Marshal comparisons and bounded fuzz tests cover JSON size calculations.


This change is Reviewable

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T02:15:29.857367Z 562979d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@wanliqun

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wanliqun wanliqun changed the title fix(getLogs): preserve block identity and complete mixed-source results fix(getLogs): guard merge boundaries and preserve complete log results Oct 26, 2026
@wanliqun

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 562979d5ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wanliqun
wanliqun merged commit 63c30b6 into main Oct 27, 2026
1 check passed
@wanliqun
wanliqun deleted the codex/getlogs-consistency branch October 27, 2026 02:25
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.

1 participant