Skip to content

feat(rpc): add neutral trace cache primitives - #4065

Open
danielntmd wants to merge 6 commits into
mainfrom
danielntmd/trace-cache-primitives
Open

danielntmd wants to merge 6 commits into
mainfrom
danielntmd/trace-cache-primitives

Conversation

@danielntmd

@danielntmd danielntmd commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

User description

User description

User description

This PR introduces the foundation for sharing immutable, read-only block traces across RPC versions.

Retained Behavior:

  • Completed traces remain cached with bounded capacity, and each RPC version retains its own response format.

Cache Behavior:

  • One writer owns work for a block at a time and produces a new result outside the cache mutex, without mutating the published trace.
  • Requests needing in-progress work wait for the writer. Requests already satisfied by a cached trace can continue using it.
  • Active ownership survives cache eviction. Aborting a writer preserves any existing cached result, and canceling a waiting request does not interrupt shared work.

@danielntmd
danielntmd added this pull request to stack #4068 September 14, 2026 07:49
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.40%. Comparing base (e85a15e) to head (df96cef).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4065      +/-   ##
==========================================
+ Coverage   79.19%   79.40%   +0.21%     
==========================================
  Files         464      469       +5     
  Lines       35741    36147     +406     
==========================================
+ Hits        28305    28703     +398     
- Misses       7427     7435       +8     
  Partials        9        9              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Review in progress

  • Gather context (PR diff, changed files)
  • Read repo CLAUDE.md for conventions
  • Review rpc/tracecache/cache.go
  • Review rpc/tracecache/result.go
  • Review rpc/tracecache/trace.go
  • Review tests for coverage/races
  • Post inline comments for findings
  • Post final summary

View job run

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
⚠️ Risk level: Low
📂 Priority files

  • rpc/tracecache/cache.go
🏅 Score: 85
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Leak On Missing Release

A Lease obtained from Acquire (cacheLoad path) must have Publish or Abort called on it
eventually, or the entry in flights is never removed. If a caller's code path panics or
returns early before deferring Abort/Publish (e.g. between receiving the lease and the
defer statement, or in code that doesn't defer at all), every subsequent Acquire for that
key blocks forever unless the caller's context gets cancelled. Since this is a shared,
version-neutral cache intended to be used from multiple RPC handlers, a single buggy caller
that forgets the defer (or panics before it) can permanently stall trace requests for a given
block.

func (c *Cache[K, V]) Acquire(
	ctx context.Context,
	key *K,
	accepts func(V) bool,
) (V, *Lease[K, V], error) {
	for {
		lookup := c.lookupOrStart(key, accepts)
		switch lookup.kind {
		case cacheHit:
			return lookup.value, nil, nil
		case cacheLoad:
			return lookup.value, lookup.work, nil
		case cacheWait:
			select {
			case <-ctx.Done():
				var zero V
				return zero, nil, ctx.Err()
			case <-lookup.done:
			}
		}
	}
}

@rodrodros
rodrodros self-requested a review September 15, 2026 09:22

@rodrodros rodrodros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good, some nitpicks here and there.

I will need to read the follow up PR to see the cache in action and give a proper review to this one.

Comment thread rpc/tracecache/result.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache_test.go Outdated
Comment thread rpc/tracecache/result_test.go
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go

// Cache stores immutable values with one active owner per key.
type Cache[K comparable, V any] struct {
mu sync.Mutex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the mutex seems to lock everyone independently if they are readers or writers. I see that Lease only wants to read, so there is a maybe a benefit for it.

Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go
Comment on lines +99 to +120
// Publish stores read-only data and releases ownership. Released leases are ignored.
func (w *Lease[K, V]) Publish(value V) {
cache := w.cache
cache.mu.Lock()
defer cache.mu.Unlock()
if cache.flights[w.key] != w.flight {
return
}
cache.records.Add(w.key, value)
cache.finishLocked(&w.key, w.flight)
}

// Abort releases ownership without changing the value. Repeated calls are safe.
func (w *Lease[K, V]) Abort() {
cache := w.cache
cache.mu.Lock()
defer cache.mu.Unlock()
if cache.flights[w.key] != w.flight {
return
}
cache.finishLocked(&w.key, w.flight)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the topic of mutexes, I am not sure if Lease interacting directly with Cache internal types is the best design, but honestly finding it hard to think of a better way to model this.

Just a comment, not required change needs to be associated with it

Comment thread rpc/tracecache/cache.go Outdated
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @danielntmd's task in 16m 35s —— View job


Review complete

Scope: rpc/tracecache/{cache,result,trace}.go + tests, vm/vm_test.go. Verified against latest commit (d0024d780), which already addresses nearly all of @rodrodros's earlier round (doc comments rewritten with usage example, wl rename, cacheLoadcacheLease rename, one-field-per-line struct literals, tests moved to tracecache_test black-box package, FromVM errors now include expected/received counts). go build succeeds and CI's race-enabled Juno Test job passed on all three runners, which covers the synctest-based concurrency tests in cache_test.go. I could not invoke go test/go vet directly in this sandboxed environment (no permission for go subcommands), so I relied on CI's green race-detector run plus static reading of the locking logic.

Correctness/concurrency: Cache.Acquire/lookupOrStart/Publish/Abort all mutate records/flights only under c.mu, waiters retry via a closed-channel signal that's safe to observe multiple times, and stale leases are guarded by the cache.flights[key] != lease.flight identity check before publish/abort — this correctly prevents a superseded lease from clobbering a newer one's cached value or double-closing its channel. I didn't find a race or deadlock in this path.

Nits:

  • rpc/tracecache/result.go:57 — the FromFeeder mismatch error still doesn't carry expected/received counts, unlike the two errors in FromVM that were already fixed for the same earlier comment. Left an inline suggestion.
  • The single-owner design means a lease that's never Abort()/Publish()ed (e.g., caller panics before the defer) permanently stalls all future Acquire calls for that key — this was flagged by the automated PR reviewer bot on push. It's called out in the Acquire doc comment as a caller responsibility, and since this package has no callers yet (it's foundation-only, per the PR description), it's acceptable to land as documented; worth keeping in mind when the follow-up PR wires up real RPC handlers with proper defer discipline.

No blockers. The design (single in-flight owner per key, eviction independent of active leases, non-mutating cache reads) is sound and well exercised by the synctest tests covering publication, replacement, eviction-during-ownership, cancellation, and retry-after-abort.

@github-actions

Copy link
Copy Markdown
Contributor

Standalone PR Review

PR-Agent could not safely update the persistent review. This standalone result will not replace the canonical review.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
⚠️ Risk level: Medium
📂 Priority files

  • rpc/tracecache/cache.go
  • rpc/tracecache/cache_test.go
🏅 Score: 70
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Likely compile error

Tests repeatedly call new("key") (e.g. new("key"), new("other")) to get a *string. The builtin new only accepts a type argument, not a value, so new("key") is not valid Go and would fail to compile unless a package-local generic helper named new (e.g. func new[T any](v T) *T) is defined somewhere. No such helper is visible in this diff, and this is a brand-new package, so it's unclear where it would come from. If it is missing, the whole test file fails to build.

key := "key"
value, owner, err := cache.Acquire(t.Context(), &key, nil)
require.NoError(t, err)
require.NotNil(t, owner)
defer owner.Abort()
require.Empty(t, value)
key = "other" // The lease retains its own key.

const count = 16
waiters := make([]<-chan acquireResult, count)
for i := range waiters {
	waiters[i] = acquireAsync(t.Context(), cache, new("key"), nil)
}

Comment thread rpc/tracecache/result.go Outdated
@danielntmd
danielntmd force-pushed the danielntmd/trace-cache-primitives branch from d0024d7 to f7cda0b Compare September 15, 2026 17:13
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @danielntmd's task in 9m 56s —— View job


Review complete

Scope: rpc/tracecache/{cache,result,trace}.go + tests, vm/vm_test.go, verified against the latest commit (f7cda0b6b).

go build and go vet pass for rpc/tracecache and vm. CI's race-enabled Juno Test run (which exercises the synctest-based concurrency tests in cache_test.go) completed successfully, confirming no detected race or deadlock in Acquire/Publish/Abort.

This revision already resolves every open item from the earlier review rounds:

  • FromFeeder's mismatch error now carries expected/received counts (result.go:56-61), matching the two FromVM errors fixed for the same feedback.
  • wl rename for Lease receivers, cacheLoadcacheLease rename for clarity.
  • Cache/Lease/Acquire doc comments rewritten with a concrete usage example and explicit caller responsibilities.
  • Tests moved to the black-box tracecache_test package, exercising only the public API.
  • The automated reviewer's "likely compile error" flag on new("key") is a false positive — go build ./rpc/tracecache/... succeeds; this module targets Go 1.27 (go.mod), where new accepts a value expression and returns a pointer to it, not just a type.

Design: single in-flight owner per key, non-mutating cache reads, eviction independent of active leases — sound and well covered by tests for publication, replacement, eviction-during-ownership, cancellation, and retry-after-abort.

Nit (already acknowledged, no action needed for this PR): a Lease that's never Abort()'d or Publish()'d (e.g., a caller panics before its defer) permanently stalls future Acquire calls for that key. This is documented as a caller responsibility in the Acquire doc comment, and since this package has no callers yet (foundation-only per the PR description), it's fine to land as-is — worth keeping in mind when the follow-up PR wires up real RPC handlers with proper defer discipline.

No blockers. Nothing new to add beyond what's already been addressed in this thread.
· Branch

@github-actions

Copy link
Copy Markdown
Contributor

Standalone PR Review

PR-Agent could not safely update the persistent review. This standalone result will not replace the canonical review.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
⚠️ Risk level: Medium
📂 Priority files

  • rpc/tracecache/cache.go
  • rpc/tracecache/cache_test.go
🏅 Score: 65
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Likely compile failure

Multiple tests call new("key") (and similar) expecting it to return a *string pointer to the given value. The builtin new only accepts a type argument, not a value, so new("key") is not valid Go and would fail to compile unless a package-local generic helper func new[T any](v T) *T is defined somewhere. No such definition appears anywhere in this new package's diff (cache.go, result.go, trace.go, or either test file), so as shown this test file will not build.

			waiters[i] = acquireAsync(t.Context(), cache, new("key"), nil)
		}
		synctest.Wait()
		for _, waiter := range waiters {
			require.Empty(t, waiter, "requests must wait for publication")
		}
		owner.Publish("value")
		for _, waiter := range waiters {
			result := <-waiter
			require.NoError(t, result.err)
			require.Nil(t, result.lease)
			require.Equal(t, "value", result.value)
		}
	})
}

func TestCacheReplacementPreservesAcceptedValue(t *testing.T) {
	synctest.Test(t, func(t *testing.T) {
		cache := tracecache.New[string, string](1)
		key := new("key")
Likely compile failure

Same use of new(...) with a value argument (e.g. new("key"), new(key)) recurs across TestCacheReplacementPreservesAcceptedValue, TestCacheEvictionDoesNotReleaseOwner, TestAcquireCancellation, and TestAcquireRetryAfterAbort. If the custom generic new helper is missing from the package, none of these tests compile.

		key := new("key")
		_, seed, err := cache.Acquire(t.Context(), key, nil)
		require.NoError(t, err)
		seed.Publish("old")
		value, owner, err := cache.Acquire(t.Context(), key, func(string) bool { return false })
		require.NoError(t, err)
		require.NotNil(t, owner)
		defer owner.Abort()
		_, other, err := cache.Acquire(t.Context(), new("other"), nil)
		require.NoError(t, err)
		other.Publish("other value")
		require.Equal(t, "old", value, "the caller retains the evicted value")

		waiting := acquireAsync(t.Context(), cache, key, nil)
		synctest.Wait()
		require.Empty(t, waiting)
		owner.Publish("new")
		result := <-waiting
		require.NoError(t, result.err)
		require.Nil(t, result.lease)
		require.Equal(t, "new", result.value)
	})
}

func TestCacheInstancesAndKeysAreIndependent(t *testing.T) {
	type key struct {
		revision    uint64
		transaction string
	}
	first, second := tracecache.New[key, *int](2), tracecache.New[key, *int](2)
	original := key{revision: 1, transaction: "tx"}
	revised := key{revision: 2, transaction: "tx"}
	// Even a zero value is a valid published entry; presence is independent of value.
	_, owner, err := first.Acquire(t.Context(), &original, nil)
	require.NoError(t, err)
	owner.Publish(nil)
	value, lease, err := first.Acquire(t.Context(), &original, nil)
	require.NoError(t, err)
	require.Nil(t, lease)
	require.Nil(t, value)
	value, lease, err = first.Acquire(t.Context(), &revised, nil)
	require.NoError(t, err)
	require.NotNil(t, lease)
	defer lease.Abort()
	require.Nil(t, value)
	value, lease, err = second.Acquire(t.Context(), &original, nil)
	require.NoError(t, err)
	require.NotNil(t, lease)
	defer lease.Abort()
	require.Nil(t, value)
}

func TestAcquireCancellation(t *testing.T) {
	cache := tracecache.New[string, string](1)
	_, owner, err := cache.Acquire(t.Context(), new("key"), nil)
	require.NoError(t, err)
	defer owner.Abort()
	ctx, cancel := context.WithCancel(t.Context())
	cancel()
	_, lease, err := cache.Acquire(ctx, new("key"), nil)
	require.ErrorIs(t, err, context.Canceled)
	require.Nil(t, lease)
	owner.Publish("old")
	value, lease, err := cache.Acquire(t.Context(), new("key"), nil)
	require.NoError(t, err)
	require.Nil(t, lease)
	require.Equal(t, "old", value)
}

func TestAcquireRetryAfterAbort(t *testing.T) {
	synctest.Test(t, func(t *testing.T) {
		cache := tracecache.New[string, string](1)
		key := new("key")
		_, seed, err := cache.Acquire(t.Context(), key, nil)

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @danielntmd's task in 15m 6s —— View job


Review complete

Scope: rpc/tracecache/{cache,result,trace}.go + tests, vm/vm_test.go, verified against latest commit 1beff7a34 (post doc-comment cleanup).

Checks performed: go build ./rpc/tracecache/..., go vet ./rpc/tracecache/... ./vm/..., gofmt -l, and a manual walkthrough of the locking/lease logic in cache.go (this sandbox doesn't have permission to run go test, but golangci-lint and the earlier race-enabled Juno Test CI runs against this same code have passed).

  • Gather context (PR diff, changed files, prior review threads)
  • Read repo CLAUDE.md for conventions (none present in this repo)
  • Review rpc/tracecache/cache.go
  • Review rpc/tracecache/result.go
  • Review rpc/tracecache/trace.go
  • Review tests for coverage/races
  • Post inline comments for findings
  • Post final summary

Findings: none new. This PR has already been through several review rounds (rodrodros + automated bots), and every substantive item was addressed in the current revision:

  • FromFeeder's mismatch error now includes expected/received counts (result.go:56-61), matching FromVM.
  • Doc comments on Cache/Lease/Acquire were rewritten with concrete semantics and a usage example (cache.go:10-87).
  • Tests moved to the black-box tracecache_test package, exercising only the public API (cache_test.go, result_test.go).
  • cacheLoadcacheLease rename, wl receiver rename for clarity.
  • The automated reviewer's "likely compile error" on new("key") in tests is a false positive: go.mod targets go 1.27.0, where the new builtin accepts a value expression (not just a type) and returns a pointer to a copy of it — this compiles and go build/go vet confirm it.

Design review (cache.go): single in-flight owner (Lease) per key, guarded by an identity check (cache.flights[key] != lease.flight) before Publish/Abort mutate state — this correctly prevents a superseded lease from clobbering a newer lease's value or double-closing its flight channel. Eviction from the LRU is independent of active leases (TestCacheEvictionDoesNotReleaseOwner), so a lease's caller always keeps a consistent value even if the record is evicted mid-flight. Waiters block on a channel close, which is safe to observe from arbitrarily many goroutines, and retry via lookupOrStart rather than trusting stale state. I did not find a race, deadlock, or nil-dereference in this path.

One design tradeoff, already raised by the automated reviewer and acknowledged by the author: a Lease that is never Abort()'d or Publish()'d (e.g. a caller panics before its defer) permanently stalls future Acquire calls for that key, since nothing times out the flights entry. This is called out explicitly as a caller responsibility in the Acquire doc comment, and since this package has no callers yet (foundation-only per the PR description), it's reasonable to land as-is — worth double-checking defer discipline when the follow-up PR wires up real RPC handlers.

No blockers, no nits to add beyond what's already been resolved in this thread.
· Branch

@github-actions

Copy link
Copy Markdown
Contributor

Standalone PR Review

PR-Agent could not safely update the persistent review. This standalone result will not replace the canonical review.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
⚠️ Risk level: Low
📂 Priority files

  • rpc/tracecache/cache.go
🏅 Score: 88
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@rodrodros rodrodros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot better description, it can still be better.

Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated
Comment thread rpc/tracecache/cache.go Outdated

@rodrodros rodrodros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final comment on style, I will delve into functionality on the next review

Comment thread rpc/tracecache/cache.go
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Claude finished @danielntmd's task in 3m 11s —— View job


Review complete

Scope: rpc/tracecache/{cache,result,trace}.go + tests, vm/vm_test.go, verified against latest commit df96cef7e.

  • Gather context (PR diff, latest commits, changed files)
  • Read repo CLAUDE.md for conventions (none present in this repo)
  • Review rpc/tracecache/cache.go
  • Review rpc/tracecache/result.go
  • Review rpc/tracecache/trace.go
  • Review tests for coverage/races
  • Post inline comments for findings
  • Post final summary

Checks performed: go build ./rpc/tracecache/... ./vm/... and go vet both pass on this revision. I don't have permission to run go test in this sandbox, but CI's race-enabled Juno Test run (which exercises the synctest-based concurrency tests in cache_test.go) has passed on this code in prior rounds, and golangci-lint on this exact commit is green.

What changed since the last full review round (1beff7a34df96cef7e): purely the API refinements @rodrodros requested — Acquire(ctx, key) is now split from AcquireWithCondition(ctx, key, accepts) (removing the confusing nil-as-"accept anything" call pattern), and Lease.Abort was renamed to Lease.Release. Doc comments were restructured into Parameters/Outcomes/Caller-responsibilities sections. I re-verified the locking logic under the new names and found no behavioral change — acquire() (private, shared implementation) is unchanged, and both public entry points route through it correctly.

Correctness/concurrency: Cache.acquire/lookupOrStart/Publish/Release all mutate records/flights only under c.mu. The identity check (cache.flights[key] != lease.flight) before Publish/Release mutate state correctly guards against a superseded or already-released lease clobbering a newer lease's value or double-closing its channel — verified this still holds with the renamed methods. Waiters retry via lookupOrStart after the flight channel closes, rather than trusting stale state, so the thundering-herd-on-release case (tested with 16 concurrent waiters in TestCacheSingleOwnerAndPublication) is handled safely. I did not find a new race, deadlock, or nil-dereference introduced by this revision.

Known, accepted tradeoff (unchanged from prior rounds, no action needed): a Lease that is never Release()'d or Publish()'d (e.g., a caller panics before its defer) permanently stalls future Acquire/AcquireWithCondition calls for that key, since nothing times out a flights entry. This is a caller-responsibility contract, acceptable since this package has no callers yet (foundation-only per the PR description) — worth double-checking defer discipline in the follow-up PR that wires up real RPC handlers.

No blockers, no nits. This revision only mechanically applies already-agreed-upon review feedback and does not introduce new issues.
· Branch

@github-actions

Copy link
Copy Markdown
Contributor

Standalone PR Review

PR-Agent could not safely update the persistent review. This standalone result will not replace the canonical review.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
⚠️ Risk level: Low
📂 Priority files

  • rpc/tracecache/cache.go
  • rpc/tracecache/result.go
🏅 Score: 85
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Nil Dereference Risk

FromFeeder dereferences receipt.TransactionHash and iterates receipts without checking if a receipt element itself is nil. If any caller passes a slice containing a nil *core.TransactionReceipt, this will panic. Also FromVM dereferences transactions[i].Hash() without a nil check; if Hash() can return nil for some transaction types, this panics.

gas := make(map[felt.Felt]*core.GasConsumed, len(receipts))
for _, receipt := range receipts {
	if receipt.ExecutionResources != nil && receipt.ExecutionResources.TotalGasConsumed != nil {
		gas[*receipt.TransactionHash] = receipt.ExecutionResources.TotalGasConsumed
	}
}

Comment thread rpc/tracecache/cache.go
kind cacheLookupKind
value V
done <-chan struct{}
work *Lease[K, V]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you mean this Lease is doing the work. lease might be a better field name

Comment thread rpc/tracecache/cache.go
Comment on lines +135 to +148
if found && (accepts == nil || accepts(value)) {
return cacheLookup[K, V]{kind: cacheHit, value: value}
}
if flight, found := c.flights[*key]; found {
return cacheLookup[K, V]{kind: cacheWait, done: flight}
}
flight := make(chan struct{})
c.flights[*key] = flight
return cacheLookup[K, V]{
kind: cacheLease,
value: value,
work: &Lease[K, V]{cache: c, key: *key, flight: flight},
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: kind looks a bit redundant since it can be inferred form the other values.

It could be set on runtime by doing a call to Kind() function by verifying the values, or it can be skipped altogether by having boolean getters like "IsLease", "IsHit" or "IsWait".

Comment thread rpc/tracecache/trace.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it seems this file could be merged into result.go

@rodrodros rodrodros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, check before merging that we don't have any API just to support RPC v8

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.

2 participants