@@ -33,6 +33,9 @@ import (
3333)
3434
3535const (
36+ // Arbitrum: Cache size granted for caching clean compiled wasm code.
37+ activatedWasmCacheSize = 64 * 1024 * 1024
38+
3639 // Number of codehash->size associations to keep.
3740 codeSizeCacheSize = 100000
3841
@@ -48,6 +51,10 @@ const (
4851
4952// Database wraps access to tries and contract code.
5053type Database interface {
54+ // Arbitrum: Read activated Stylus contracts
55+ ActivatedAsm (moduleHash common.Hash ) (asm []byte , err error )
56+ ActivatedModule (moduleHash common.Hash ) (module []byte , err error )
57+
5158 // OpenTrie opens the main account trie.
5259 OpenTrie (root common.Hash ) (Trie , error )
5360
@@ -152,6 +159,10 @@ func NewDatabase(db ethdb.Database) Database {
152159// large memory cache.
153160func NewDatabaseWithConfig (db ethdb.Database , config * trie.Config ) Database {
154161 cdb := & cachingDB {
162+ // Arbitrum only
163+ activatedAsmCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
164+ activatedModuleCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
165+
155166 disk : db ,
156167 codeSizeCache : lru.NewCache [common.Hash , int ](codeSizeCacheSize ),
157168 codeCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](codeCacheSize ),
@@ -163,6 +174,10 @@ func NewDatabaseWithConfig(db ethdb.Database, config *trie.Config) Database {
163174// NewDatabaseWithNodeDB creates a state database with an already initialized node database.
164175func NewDatabaseWithNodeDB (db ethdb.Database , triedb * trie.Database ) Database {
165176 cdb := & cachingDB {
177+ // Arbitrum only
178+ activatedAsmCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
179+ activatedModuleCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
180+
166181 disk : db ,
167182 codeSizeCache : lru.NewCache [common.Hash , int ](codeSizeCacheSize ),
168183 codeCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](codeCacheSize ),
@@ -172,6 +187,10 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database {
172187}
173188
174189type cachingDB struct {
190+ // Arbitrum
191+ activatedAsmCache * lru.SizeConstrainedCache [common.Hash , []byte ]
192+ activatedModuleCache * lru.SizeConstrainedCache [common.Hash , []byte ]
193+
175194 disk ethdb.KeyValueStore
176195 codeSizeCache * lru.Cache [common.Hash , int ]
177196 codeCache * lru.SizeConstrainedCache [common.Hash , []byte ]
0 commit comments