Skip to content

Commit

Permalink
don't store wasm targets in cachingDB
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Aug 23, 2024
1 parent 7fc4c64 commit 0a37660
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
20 changes: 10 additions & 10 deletions core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ func NewDatabaseWithConfig(db ethdb.Database, config *triedb.Config) Database {
wasmdb, wasmTag := db.WasmDataBase()
cdb := &cachingDB{
// Arbitrum only
activatedAsmCache: lru.NewSizeConstrainedCache[activatedAsmCacheKey, []byte](activatedWasmCacheSize),
wasmTag: wasmTag,
wasmTargets: db.WasmTargets(),
activatedAsmCache: lru.NewSizeConstrainedCache[activatedAsmCacheKey, []byte](activatedWasmCacheSize),
wasmTag: wasmTag,
wasmTargetsRetriever: db,

disk: db,
wasmdb: wasmdb,
Expand All @@ -182,9 +182,9 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *triedb.Database) Database
wasmdb, wasmTag := db.WasmDataBase()
cdb := &cachingDB{
// Arbitrum only
activatedAsmCache: lru.NewSizeConstrainedCache[activatedAsmCacheKey, []byte](activatedWasmCacheSize),
wasmTag: wasmTag,
wasmTargets: db.WasmTargets(),
activatedAsmCache: lru.NewSizeConstrainedCache[activatedAsmCacheKey, []byte](activatedWasmCacheSize),
wasmTag: wasmTag,
wasmTargetsRetriever: db,

disk: db,
wasmdb: wasmdb,
Expand All @@ -202,9 +202,9 @@ type activatedAsmCacheKey struct {

type cachingDB struct {
// Arbitrum
activatedAsmCache *lru.SizeConstrainedCache[activatedAsmCacheKey, []byte]
wasmTag uint32
wasmTargets []ethdb.WasmTarget
activatedAsmCache *lru.SizeConstrainedCache[activatedAsmCacheKey, []byte]
wasmTag uint32
wasmTargetsRetriever ethdb.WasmTargetsRetriever

disk ethdb.KeyValueStore
wasmdb ethdb.KeyValueStore
Expand All @@ -222,7 +222,7 @@ func (db *cachingDB) WasmCacheTag() uint32 {
}

func (db *cachingDB) WasmTargets() []ethdb.WasmTarget {
return db.wasmTargets
return db.wasmTargetsRetriever.WasmTargets()
}

// OpenTrie opens the main account trie at a specific root hash.
Expand Down
7 changes: 5 additions & 2 deletions ethdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ type AncientStore interface {
io.Closer
}

type WasmTarget string

type WasmDataBaseRetriever interface {
WasmDataBase() (KeyValueStore, uint32)
}

type WasmTarget string
type WasmTargetsRetriever interface {
WasmTargets() []WasmTarget
}

Expand All @@ -197,4 +199,5 @@ type Database interface {
Snapshotter
io.Closer
WasmDataBaseRetriever
WasmTargetsRetriever
}

0 comments on commit 0a37660

Please sign in to comment.