fix: prevent SQLite lock churn and validate EVM RPC capabilities - #107
Draft
quqi1599 wants to merge 1 commit into
Draft
fix: prevent SQLite lock churn and validate EVM RPC capabilities#107quqi1599 wants to merge 1 commit into
quqi1599 wants to merge 1 commit into
Conversation
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
This fixes two production failure modes that can silently reduce payment-recognition reliability in the default pure-Go SQLite deployment:
SQLITE_BUSY / database is lockederrors while cleaning transaction locks and updating EVM scan cursors;eth_getLogsoreth_subscribecapability is rate-limited or disabled.It also makes live EVM WebSocket subscriptions start at
latest. Without an explicitFromBlock, go-ethereum serializes the filter asfromBlock: 0x0, which some public providers reject as an oversized historical range.Root cause
The pure-Go SQLite driver uses modernc.org/sqlite. Its per-connection PRAGMA syntax is
_pragma=...; the previous_busy_timeout=5000DSN option was ignored. RunningPRAGMA busy_timeout=5000once after opening the database only configured one pooled connection, while the runtime database allowed multiple concurrent writers.RPC health checks only performed a TCP dial. That allowed endpoints returning HTTP 403/429 or WebSocket subscription quota errors to remain
okand be selected repeatedly by listeners and backfill scanners.Changes
synchronous=NORMAL, and a 5-second busy timeout to every pure-Go SQLite connection;eth_blockNumberplus the scanner's cursor-based historicaleth_getLogsfilter;latest;fromBlock: latest.Validation
go test ./...go vet ./...CGO_ENABLED=0 go build -trimpath .-raceruns for all newly added SQLite, retry, HTTP RPC, and WebSocket RPC testsIn a single-instance deployment, the change stopped new SQLite busy errors during the observation window, restored a continuously advancing BSC backfill cursor, and correctly classified quota-limited/unsupported RPC nodes as down.
No schema migration is introduced. A real on-chain payment was not executed as part of validation.