core/state: implement reverts by journaling all changes
This commit replaces the deep-copy based state revert mechanism with a linear complexity journal. This commit also hides several internal StateDB methods to limit the number of ways in which calling code can use the journal incorrectly. As usual consultation and bug fixes to the initial implementation were provided by @karalabe, @obscuren and @Arachnid. Thank you!
This commit is contained in:
@ -101,14 +101,7 @@ func BenchVmTest(p string, conf bconf, b *testing.B) error {
|
||||
func benchVmTest(test VmTest, env map[string]string, b *testing.B) {
|
||||
b.StopTimer()
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
statedb, _ := state.New(common.Hash{}, db)
|
||||
for addr, account := range test.Pre {
|
||||
obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty)
|
||||
statedb.SetStateObject(obj)
|
||||
for a, v := range account.Storage {
|
||||
obj.SetState(common.HexToHash(a), common.HexToHash(v))
|
||||
}
|
||||
}
|
||||
statedb := makePreState(db, test.Pre)
|
||||
b.StartTimer()
|
||||
|
||||
RunVm(statedb, env, test.Exec)
|
||||
@ -152,14 +145,7 @@ func runVmTests(tests map[string]VmTest, skipTests []string) error {
|
||||
|
||||
func runVmTest(test VmTest) error {
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
statedb, _ := state.New(common.Hash{}, db)
|
||||
for addr, account := range test.Pre {
|
||||
obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty)
|
||||
statedb.SetStateObject(obj)
|
||||
for a, v := range account.Storage {
|
||||
obj.SetState(common.HexToHash(a), common.HexToHash(v))
|
||||
}
|
||||
}
|
||||
statedb := makePreState(db, test.Pre)
|
||||
|
||||
// XXX Yeah, yeah...
|
||||
env := make(map[string]string)
|
||||
|
Reference in New Issue
Block a user