mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
core/txpool/blobpool: fall back on cache version mismatch
This commit is contained in:
parent
769c8c52c5
commit
e34f2a2d5d
2 changed files with 24 additions and 3 deletions
|
|
@ -201,9 +201,7 @@ func (c *Cache) GetBlobs(ctx context.Context, vhashes []common.Hash, version byt
|
||||||
cached := c.entries[vhash]
|
cached := c.entries[vhash]
|
||||||
if cached == nil || cached.version != version {
|
if cached == nil || cached.version != version {
|
||||||
cacheMiss += n
|
cacheMiss += n
|
||||||
if cached == nil {
|
|
||||||
misses = append(misses, vhash)
|
misses = append(misses, vhash)
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cacheHits += n
|
cacheHits += n
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,29 @@ func TestCacheGetBlobs(t *testing.T) {
|
||||||
tc.expectEntries(t, tc.vhashes[1]...)
|
tc.expectEntries(t, tc.vhashes[1]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCacheGetBlobsFallsBackOnVersionMismatch(t *testing.T) {
|
||||||
|
tc := newTestCache(t, []txSpec{
|
||||||
|
{blobs: 1, tip: 100},
|
||||||
|
})
|
||||||
|
vhash := tc.vhashes[0][0]
|
||||||
|
tc.expectEntries(t, vhash)
|
||||||
|
|
||||||
|
tc.mu.Lock()
|
||||||
|
tc.entries[vhash].version = types.BlobSidecarVersion0
|
||||||
|
tc.mu.Unlock()
|
||||||
|
|
||||||
|
blobs, _, proofs, err := tc.GetBlobs(context.Background(), []common.Hash{vhash}, types.BlobSidecarVersion1)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("GetBlobs: %v", err)
|
||||||
|
}
|
||||||
|
if blobs[0] == nil {
|
||||||
|
t.Fatal("blob missing in GetBlobs response")
|
||||||
|
}
|
||||||
|
if len(proofs[0]) == 0 {
|
||||||
|
t.Fatal("proofs missing in GetBlobs response")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestCacheTopKRefresh verifies that when a more profitable tx appears in the
|
// TestCacheTopKRefresh verifies that when a more profitable tx appears in the
|
||||||
// pool, the next topK tick replaces the cached entry with the better one.
|
// pool, the next topK tick replaces the cached entry with the better one.
|
||||||
func TestCacheTopKRefresh(t *testing.T) {
|
func TestCacheTopKRefresh(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue