Skip to content

Commit 4617754

Browse files
remove missing block cache
1 parent 8805e79 commit 4617754

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

vms/components/missing/block.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var (
15-
ErrMissingBlock = errors.New("missing block")
15+
errMissingBlock = errors.New("missing block")
1616
)
1717

1818
// Block represents a block that can't be found
@@ -25,10 +25,10 @@ func (mb *Block) ID() ids.ID { return mb.BlkID }
2525
func (mb *Block) Height() uint64 { return 0 }
2626

2727
// Accept ...
28-
func (*Block) Accept() error { return ErrMissingBlock }
28+
func (*Block) Accept() error { return errMissingBlock }
2929

3030
// Reject ...
31-
func (*Block) Reject() error { return ErrMissingBlock }
31+
func (*Block) Reject() error { return errMissingBlock }
3232

3333
// Status ...
3434
func (*Block) Status() choices.Status { return choices.Unknown }
@@ -37,7 +37,7 @@ func (*Block) Status() choices.Status { return choices.Unknown }
3737
func (*Block) Parent() snowman.Block { return nil }
3838

3939
// Verify ...
40-
func (*Block) Verify() error { return ErrMissingBlock }
40+
func (*Block) Verify() error { return errMissingBlock }
4141

4242
// Bytes ...
4343
func (*Block) Bytes() []byte { return nil }

vms/rpcchainvm/vm_client.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ var (
4747

4848
const (
4949
decidedCacheSize = 500
50-
missingCacheSize = 500
5150
)
5251

5352
// VMClient is an implementation of VM that talks over RPC.
@@ -70,7 +69,6 @@ type VMClient struct {
7069
blks map[ids.ID]*BlockClient
7170

7271
decidedBlocks cache.Cacher
73-
missingBlocks cache.Cacher
7472

7573
lastAccepted ids.ID
7674
}
@@ -103,16 +101,6 @@ func (vm *VMClient) initializeCaches(registerer prometheus.Registerer, namespace
103101
}
104102
vm.decidedBlocks = decidedCache
105103

106-
missingCache, err := metercacher.New(
107-
fmt.Sprintf("%s_rpcchainvm_missing_cache", namespace),
108-
registerer,
109-
&cache.LRU{Size: missingCacheSize},
110-
)
111-
if err != nil {
112-
return fmt.Errorf("could not initialize missing blocks cache: %w", err)
113-
}
114-
vm.missingBlocks = missingCache
115-
116104
return nil
117105
}
118106

@@ -301,8 +289,6 @@ func (vm *VMClient) BuildBlock() (snowman.Block, error) {
301289
parentID, err := ids.ToID(resp.ParentID)
302290
vm.ctx.Log.AssertNoError(err)
303291

304-
vm.missingBlocks.Evict(id)
305-
306292
return &BlockClient{
307293
vm: vm,
308294
id: id,
@@ -331,7 +317,6 @@ func (vm *VMClient) ParseBlock(bytes []byte) (snowman.Block, error) {
331317
if blkIntf, cached := vm.decidedBlocks.Get(id); cached {
332318
return blkIntf.(*BlockClient), nil
333319
}
334-
vm.missingBlocks.Evict(id)
335320

336321
parentID, err := ids.ToID(resp.ParentID)
337322
vm.ctx.Log.AssertNoError(err)
@@ -363,17 +348,10 @@ func (vm *VMClient) GetBlock(id ids.ID) (snowman.Block, error) {
363348
return blkIntf.(*BlockClient), nil
364349
}
365350

366-
if _, cached := vm.missingBlocks.Get(id); cached {
367-
return nil, missing.ErrMissingBlock
368-
}
369-
370351
resp, err := vm.client.GetBlock(context.Background(), &vmproto.GetBlockRequest{
371352
Id: id[:],
372353
})
373354
if err != nil {
374-
if errors.Is(err, missing.ErrMissingBlock) {
375-
vm.missingBlocks.Put(id, struct{}{})
376-
}
377355
return nil, err
378356
}
379357

0 commit comments

Comments
 (0)