Skip to content

Commit 40e7fc7

Browse files
authored
op-program: Remove caching for transition states. (#13714)
1 parent ca1f777 commit 40e7fc7

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

op-program/client/l2/cache.go

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,24 @@ const nodeCacheSize = 100_000
1515
const codeCacheSize = 10_000
1616

1717
type CachingOracle struct {
18-
oracle Oracle
19-
blocks *simplelru.LRU[common.Hash, *types.Block]
20-
nodes *simplelru.LRU[common.Hash, []byte]
21-
codes *simplelru.LRU[common.Hash, []byte]
22-
outputs *simplelru.LRU[common.Hash, eth.Output]
23-
transitionStates *simplelru.LRU[common.Hash, *interopTypes.TransitionState]
18+
oracle Oracle
19+
blocks *simplelru.LRU[common.Hash, *types.Block]
20+
nodes *simplelru.LRU[common.Hash, []byte]
21+
codes *simplelru.LRU[common.Hash, []byte]
22+
outputs *simplelru.LRU[common.Hash, eth.Output]
2423
}
2524

2625
func NewCachingOracle(oracle Oracle) *CachingOracle {
2726
blockLRU, _ := simplelru.NewLRU[common.Hash, *types.Block](blockCacheSize, nil)
2827
nodeLRU, _ := simplelru.NewLRU[common.Hash, []byte](nodeCacheSize, nil)
2928
codeLRU, _ := simplelru.NewLRU[common.Hash, []byte](codeCacheSize, nil)
3029
outputLRU, _ := simplelru.NewLRU[common.Hash, eth.Output](codeCacheSize, nil)
31-
transitionStates, _ := simplelru.NewLRU[common.Hash, *interopTypes.TransitionState](codeCacheSize, nil)
3230
return &CachingOracle{
33-
oracle: oracle,
34-
blocks: blockLRU,
35-
nodes: nodeLRU,
36-
codes: codeLRU,
37-
outputs: outputLRU,
38-
transitionStates: transitionStates,
31+
oracle: oracle,
32+
blocks: blockLRU,
33+
nodes: nodeLRU,
34+
codes: codeLRU,
35+
outputs: outputLRU,
3936
}
4037
}
4138

@@ -87,11 +84,6 @@ func (o *CachingOracle) BlockDataByHash(agreedBlockHash, blockHash common.Hash,
8784
}
8885

8986
func (o *CachingOracle) TransitionStateByRoot(root common.Hash) *interopTypes.TransitionState {
90-
state, ok := o.transitionStates.Get(root)
91-
if ok {
92-
return state
93-
}
94-
state = o.oracle.TransitionStateByRoot(root)
95-
o.transitionStates.Add(root, state)
96-
return state
87+
// Don't bother caching as this is only requested once as part of the bootstrap process
88+
return o.oracle.TransitionStateByRoot(root)
9789
}

0 commit comments

Comments
 (0)