Skip to content

fix(chainstore): key fee history cache by request parameters - #978

Merged
minhd-vu merged 1 commit into
0xPolygon:mainfrom
zjuzhongwen:main
Aug 5, 2026
Merged

fix(chainstore): key fee history cache by request parameters#978
minhd-vu merged 1 commit into
0xPolygon:mainfrom
zjuzhongwen:main

Conversation

@zjuzhongwen

@zjuzhongwen zjuzhongwen commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

PassthroughStore.GetFeeHistory currently stores a single cached eth_feeHistory result without recording the parameters that produced it.

However, all three request parameters affect the response:

  • blockCount
  • newestBlock
  • rewardPercentiles

As a result, a request made within the cache TTL can receive a result produced
for a different set of parameters.

For example:

GetFeeHistory(ctx, 1, "latest", nil)
GetFeeHistory(ctx, 100, "0x1234", []float64{10, 50, 90})

If the first result is still cached, the second call returns that result without
sending another RPC request. The returned fee history therefore does not
correspond to the second request.

This change:

  • keys fee history cache entries by blockCount, newestBlock, and rewardPercentiles;
  • uses a deterministic representation of rewardPercentiles;
  • preserves the distinction between nil and an empty percentile list;
  • removes expired entries or otherwise bounds the parameterized cache;
  • adds regression tests for cache hits, parameter isolation, and TTL expiry.

There are no breaking API changes.

Jira / Linear Tickets

Testing

  • Test A
  • Test B

Signed-off-by: zjuzhongwen <zjuzhongwen@outlook.com>
@minhd-vu
minhd-vu merged commit c7051cc into 0xPolygon:main Aug 5, 2026
11 checks passed
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