Conversation
AlCutter
force-pushed
the
tighten_client_nodecache
branch
from
September 18, 2026 14:53
6ad99d1 to
dd98586
Compare
nodeCache was very relaxed in terms of the node IDs it would serve and the tiles it would accept from a fetcher. This PR tightens both, and removes a potential correctness issue. * GetNode explicitly rejects out-of-range nodes. * fetchTileNodes now asserts that a tile is either the precise partial size requested, or a full tile (i.e. the fetcher fell-back to requesting a full tile) * Removed call to GetRootHash. This was unnecessary, but also incorrectly populated the cache with ephemeral nodes.
AlCutter
force-pushed
the
tighten_client_nodecache
branch
from
September 18, 2026 15:59
dd98586 to
21fedf9
Compare
roger2hk
approved these changes
Sep 19, 2026
| // Trim the full tile down to the size of the requested partial tile. | ||
| tile.Nodes = tile.Nodes[:wantSize] | ||
| default: | ||
| return nil, fmt.Errorf("invalid tile: expected %d or %d nodes, got %d", wantSize, layout.TileWidth, gotLen) |
Contributor
There was a problem hiding this comment.
If wantSize is 256 and p = 0, the error message would become:
invalid tile: expected 256 or 256 nodes, got 255
Having 256 twice seems confusing.
| return otel.Trace(ctx, "tessera.client.nodecache.fetchTileNodes", tracer, func(ctx context.Context, span trace.Span) (map[compact.NodeID][]byte, error) { | ||
| tileRaw, err := n.getTile(ctx, tileLevel, tileIndex, p) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch tile: %v", err) |
Contributor
There was a problem hiding this comment.
The change in L489 is ineffective because the os.ErrNotExist is not returned here.
Suggested change
| return nil, fmt.Errorf("failed to fetch tile: %w", err) |
|
|
||
| func TestNodeCacheHandlesInvalidRequest(t *testing.T) { | ||
| func TestNodeCache(t *testing.T) { | ||
| ctx := context.Background() |
Contributor
There was a problem hiding this comment.
Suggested change
| ctx := context.Background() | |
| ctx := t.context() |
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.
nodeCache was very relaxed in terms of the node IDs it
would serve and the tiles it would accept from a fetcher.
This PR tightens both, and removes a potential correctness issue:
size requested, or a full tile (i.e. the fetcher fell-back to
requesting a full tile)
also incorrectly populated the cache with ephemeral nodes.