aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi
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 22:25:17 +0800
commit46a527d01485102a798bf27f24622fc6274f58d9 (patch)
tree0e99fdcc8befc54548db579b18eeab29bf2189f2 /accounts/abi
parente97b30169b97adefa6e5067df1e307852b226583 (diff)
downloadgo-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.gz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.bz2
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.lz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.xz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.zst
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.zip
[release/1.4.16] 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! (cherry picked from commit 1f1ea18b5414bea22332bb4fce53cc95b5c6a07d)
Diffstat (limited to 'accounts/abi')
-rw-r--r--accounts/abi/bind/backends/simulated.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
index cbd2982df..2f4d39410 100644
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -97,7 +97,8 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
statedb *state.StateDB
)
if pending {
- block, statedb = b.pendingBlock, b.pendingState.Copy()
+ block, statedb = b.pendingBlock, b.pendingState
+ defer statedb.RevertToSnapshot(statedb.Snapshot())
} else {
block = b.blockchain.CurrentBlock()
statedb, _ = b.blockchain.State()
@@ -119,6 +120,7 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
value: new(big.Int),
data: data,
}
+
// Execute the call and return
vmenv := core.NewEnv(statedb, chainConfig, b.blockchain, msg, block.Header(), vm.Config{})
gaspool := new(core.GasPool).AddGas(common.MaxBig)
@@ -146,8 +148,10 @@ func (b *SimulatedBackend) EstimateGasLimit(sender common.Address, contract *com
// Create a copy of the currently pending state db to screw around with
var (
block = b.pendingBlock
- statedb = b.pendingState.Copy()
+ statedb = b.pendingState
)
+ defer statedb.RevertToSnapshot(statedb.Snapshot())
+
// If there's no code to interact with, respond with an appropriate error
if contract != nil {
if code := statedb.GetCode(*contract); len(code) == 0 {