Skip to content
This repository was archived by the owner on Jun 9, 2026. It is now read-only.

feat: immediate receipt issuance#169

Merged
ARR4N merged 19 commits into
mainfrom
arr4n/receiptcache
Feb 24, 2026
Merged

feat: immediate receipt issuance#169
ARR4N merged 19 commits into
mainfrom
arr4n/receiptcache

Conversation

@ARR4N

@ARR4N ARR4N commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

The geth APIs fetch individual transaction results by loading the entire block's receipts, which forces all senders to wait until the whole block has finished execution. This PR introduces a cache of recent receipts, and intercepts the GetTransactionReceipt() RPC method, serving from the cache if it holds the data. This allows for receipt issuance immediately after transaction execution, not after block execution. The cache is cleared at the same time as the respective block is ejected from VM memory.

To further reduce polling of GetTransactionReceipt(), the caching mechanism is aware of pending (accepted but not executed) transactions and will block until they are executed or context cancellation occurs. The test case in which a pending transaction returns nil, nil for receipt requests is therefore removed.

The saexec.syncMap type is a thread-safe key-value store that aims to reduce lock contention by spreading reads and writes over independent buckets. Without this, every enqueued block (execution thread) and every cache clearance (GC) would block receipt storage / retrieval. Both scenarios only hold 1/256 locks at any time to avoid starving the RPCs.

Although existing receipt tests hit the current path, an explicit unit test demonstrates that blocking of a transaction doesn't block earlier receipt availability.

Closes ava-labs/avalanchego#5252

@ARR4N ARR4N force-pushed the arr4n/receiptcache branch from e1e6189 to 23dc7ee Compare February 17, 2026 16:29
Base automatically changed from arr4n/recovery to main February 17, 2026 19:54
@ARR4N ARR4N force-pushed the arr4n/receiptcache branch from 23dc7ee to 133d00f Compare February 18, 2026 11:09
@ARR4N ARR4N marked this pull request as ready for review February 23, 2026 13:37
Comment thread cache/cache.go Outdated
Comment thread cache/cache.go Outdated
Comment thread cache/cache.go Outdated
Comment thread cache/cache.go Outdated
Comment thread saexec/execution.go Outdated
Comment thread sae/consensus.go Outdated
Comment thread sae/vm.go Outdated
@ARR4N

ARR4N commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator Author

Sorry for the crap code the last few days. I'm well now and thinking more clearly so have completely refactored this.

Comment thread saexec/receipts.go
Comment thread saexec/receipts.go Outdated
Comment thread saexec/receipts.go
Comment thread sae/rpc_receipts_test.go Outdated
ARR4N and others added 4 commits February 24, 2026 16:42
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
@ARR4N ARR4N merged commit 3e5cc3d into main Feb 24, 2026
19 checks passed
@ARR4N ARR4N deleted the arr4n/receiptcache branch February 24, 2026 19:52
powerslider pushed a commit that referenced this pull request Feb 25, 2026
The `geth` APIs fetch individual transaction results by loading the
entire block's receipts, which forces all senders to wait until the
whole block has finished execution. This PR introduces a cache of recent
receipts, and intercepts the `GetTransactionReceipt()` RPC method,
serving from the cache if it holds the data. This allows for receipt
issuance immediately after _transaction_ execution, not after _block_
execution. The cache is cleared at the same time as the respective block
is ejected from `VM` memory.

To further reduce polling of `GetTransactionReceipt()`, the caching
mechanism is aware of pending (accepted but not executed) transactions
and will block until they are executed or context cancellation occurs.
The test case in which a pending transaction returns `nil, nil` for
receipt requests is therefore removed.

The `saexec.syncMap` type is a thread-safe key-value store that aims to
reduce lock contention by spreading reads and writes over independent
buckets. Without this, every enqueued block (execution thread) and every
cache clearance (GC) would block receipt storage / retrieval. Both
scenarios only hold 1/256 locks at any time to avoid starving the RPCs.

Although existing receipt tests hit the current path, an explicit unit
test demonstrates that blocking of a transaction doesn't block earlier
receipt availability.

Closes #208

---------

Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Receipt cache for RPC access

3 participants