Skip to content

Commit

Permalink
use verdb in accepted and metadb (#1375)
Browse files Browse the repository at this point in the history
Co-authored-by: Darioush Jalali <[email protected]>
  • Loading branch information
ceyonur and darioush authored Nov 5, 2024
1 parent 4e0e5d2 commit 951e875
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,8 @@ func (vm *VM) initializeDBs(avaDB database.Database) error {
// remains the same regardless of the provided baseDB type.
vm.chaindb = rawdb.NewDatabase(Database{prefixdb.NewNested(ethDBPrefix, db)})
vm.db = versiondb.New(db)
vm.acceptedBlockDB = prefixdb.New(acceptedPrefix, db)
vm.metadataDB = prefixdb.New(metadataPrefix, db)
vm.acceptedBlockDB = prefixdb.New(acceptedPrefix, vm.db)
vm.metadataDB = prefixdb.New(metadataPrefix, vm.db)
// Note warpDB is not part of versiondb because it is not necessary
// that warp signatures are committed to the database atomically with
// the last accepted block.
Expand Down
7 changes: 5 additions & 2 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ func setupGenesis(
genesisBytes := buildGenesisTest(t, genesisJSON)
ctx := NewContext()

baseDB := memdb.New()

// initialize the atomic memory
atomicMemory := atomic.NewMemory(prefixdb.New([]byte{0}, memdb.New()))
atomicMemory := atomic.NewMemory(prefixdb.New([]byte{0}, baseDB))
ctx.SharedMemory = atomicMemory.NewSharedMemory(ctx.ChainID)

// NB: this lock is intentionally left locked when this function returns.
Expand All @@ -204,7 +206,8 @@ func setupGenesis(
ctx.Keystore = userKeystore.NewBlockchainKeyStore(ctx.ChainID)

issuer := make(chan commonEng.Message, 1)
return ctx, memdb.New(), genesisBytes, issuer, atomicMemory
prefixedDB := prefixdb.New([]byte{1}, baseDB)
return ctx, prefixedDB, genesisBytes, issuer, atomicMemory
}

// GenesisVM creates a VM instance with the genesis test bytes and returns
Expand Down

0 comments on commit 951e875

Please sign in to comment.