Skip to content

Commit

Permalink
Merge pull request #1523 from OffchainLabs/fix-disable-nonce-cache
Browse files Browse the repository at this point in the history
Fix disabling the nonce cache on the sequencer
  • Loading branch information
PlasmaPower authored Mar 16, 2023
2 parents 1ad1ff4 + 288d363 commit cd51708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arbnode/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (c *nonceCache) Update(header *types.Header, addr common.Address, nonce uin
}

func (c *nonceCache) Finalize(block *types.Block) {
// Note: we don't use c.Matches here because the header will have changed
// Note: we don't use c.matches here because the header will have changed
if c.block == block.ParentHash() {
c.block = block.Hash()
c.dirty = nil
Expand All @@ -215,7 +215,7 @@ func (c *nonceCache) Finalize(block *types.Block) {
}

func (c *nonceCache) Caching() bool {
return c.cache != nil
return c.cache != nil && c.cache.Size() > 0
}

func (c *nonceCache) Resize(newSize int) {
Expand Down
7 changes: 7 additions & 0 deletions util/containers/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
type LruCache[K comparable, V any] struct {
inner *simplelru.LRU[K, V]
onEvict func(key K, value V)
size int
}

func NewLruCache[K comparable, V any](size int) *LruCache[K, V] {
Expand All @@ -27,6 +28,7 @@ func NewLruCacheWithOnEvict[K comparable, V any](size int, onEvict func(K, V)) *
return &LruCache[K, V]{
inner: inner,
onEvict: onEvict,
size: size,
}
}

Expand Down Expand Up @@ -83,6 +85,10 @@ func (c *LruCache[K, V]) Len() int {
return c.inner.Len()
}

func (c *LruCache[K, V]) Size() int {
return c.size
}

func (c *LruCache[K, V]) Clear() {
if c.inner == nil {
return
Expand All @@ -102,4 +108,5 @@ func (c *LruCache[K, V]) Resize(newSize int) {
} else {
c.inner.Resize(newSize)
}
c.size = newSize
}

0 comments on commit cd51708

Please sign in to comment.