@@ -33,6 +33,9 @@ import (
33
33
)
34
34
35
35
const (
36
+ // Arbitrum: Cache size granted for caching clean compiled wasm code.
37
+ activatedWasmCacheSize = 64 * 1024 * 1024
38
+
36
39
// Number of codehash->size associations to keep.
37
40
codeSizeCacheSize = 100000
38
41
@@ -48,6 +51,10 @@ const (
48
51
49
52
// Database wraps access to tries and contract code.
50
53
type 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
+
51
58
// OpenTrie opens the main account trie.
52
59
OpenTrie (root common.Hash ) (Trie , error )
53
60
@@ -152,6 +159,10 @@ func NewDatabase(db ethdb.Database) Database {
152
159
// large memory cache.
153
160
func NewDatabaseWithConfig (db ethdb.Database , config * trie.Config ) Database {
154
161
cdb := & cachingDB {
162
+ // Arbitrum only
163
+ activatedAsmCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
164
+ activatedModuleCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
165
+
155
166
disk : db ,
156
167
codeSizeCache : lru.NewCache [common.Hash , int ](codeSizeCacheSize ),
157
168
codeCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](codeCacheSize ),
@@ -163,6 +174,10 @@ func NewDatabaseWithConfig(db ethdb.Database, config *trie.Config) Database {
163
174
// NewDatabaseWithNodeDB creates a state database with an already initialized node database.
164
175
func NewDatabaseWithNodeDB (db ethdb.Database , triedb * trie.Database ) Database {
165
176
cdb := & cachingDB {
177
+ // Arbitrum only
178
+ activatedAsmCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
179
+ activatedModuleCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](activatedWasmCacheSize ),
180
+
166
181
disk : db ,
167
182
codeSizeCache : lru.NewCache [common.Hash , int ](codeSizeCacheSize ),
168
183
codeCache : lru.NewSizeConstrainedCache [common.Hash , []byte ](codeCacheSize ),
@@ -172,6 +187,10 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database {
172
187
}
173
188
174
189
type cachingDB struct {
190
+ // Arbitrum
191
+ activatedAsmCache * lru.SizeConstrainedCache [common.Hash , []byte ]
192
+ activatedModuleCache * lru.SizeConstrainedCache [common.Hash , []byte ]
193
+
175
194
disk ethdb.KeyValueStore
176
195
codeSizeCache * lru.Cache [common.Hash , int ]
177
196
codeCache * lru.SizeConstrainedCache [common.Hash , []byte ]
0 commit comments