aboutsummaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-04 18:36:02 +0800
committerFelix Lange <fjl@twurst.com>2016-10-06 21:32:16 +0800
commit1f1ea18b5414bea22332bb4fce53cc95b5c6a07d (patch)
treed1aa3051f9c4d9f33a24519c18b70f0dd2f00644 /light
parentab7adb0027dbcf09cf75a533be356c1e24c46c90 (diff)
downloadgo-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.gz
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.bz2
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.lz
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.xz
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.zst
go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.zip
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!
Diffstat (limited to 'light')
-rw-r--r--light/state_test.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/light/state_test.go b/light/state_test.go
index d4fe95022..a6b115786 100644
--- a/light/state_test.go
+++ b/light/state_test.go
@@ -23,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
"golang.org/x/net/context"
@@ -54,16 +53,13 @@ func makeTestState() (common.Hash, ethdb.Database) {
sdb, _ := ethdb.NewMemDatabase()
st, _ := state.New(common.Hash{}, sdb)
for i := byte(0); i < 100; i++ {
- so := st.GetOrNewStateObject(common.Address{i})
+ addr := common.Address{i}
for j := byte(0); j < 100; j++ {
- val := common.Hash{i, j}
- so.SetState(common.Hash{j}, val)
- so.SetNonce(100)
+ st.SetState(addr, common.Hash{j}, common.Hash{i, j})
}
- so.AddBalance(big.NewInt(int64(i)))
- so.SetCode(crypto.Keccak256Hash([]byte{i, i, i}), []byte{i, i, i})
- so.UpdateRoot(sdb)
- st.UpdateStateObject(so)
+ st.SetNonce(addr, 100)
+ st.AddBalance(addr, big.NewInt(int64(i)))
+ st.SetCode(addr, []byte{i, i, i})
}
root, _ := st.Commit()
return root, sdb