Skip to content

Recent change in behavior for in-memory database: possible regression? #20106

@wuestholz

Description

@wuestholz

I observed a recent change in behavior for the in-memory database. For commit 63b1802 the following piece of code produces a different outcome than in older versions (e.g., 396f1dd8):

db := rawdb.NewMemoryDatabase()
sdb, _ = state.New(common.Hash{}, state.NewDatabase(db))
addr := common.HexToAddress("0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe")
sdb.SetBalance(addr, big.NewInt(42))
fmt.Printf("balance: %v\n", sdb.GetBalance(addr))
nsdb := sdb.Copy()
nsdb.Commit(false)
cnsdb := nsdb.Copy()
fmt.Printf("balance: %v\n", cnsdb.GetBalance(addr))

This looks like a possible regression.

System information

OS & Version: Windows
Commit hash : 63b1802

Expected behaviour

The code should probably print the following:

balance: 42
balance: 42

Actual behaviour

The code prints the following:

balance: 42
balance: 0

Steps to reproduce the behaviour

Run the piece of code above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions