From 741dfeb46120b85376ba0f2fa89d47b425018fbb Mon Sep 17 00:00:00 2001 From: Austin Abell Date: Wed, 30 Oct 2019 11:16:00 -0400 Subject: [PATCH] Revert journal changes from simulated transactions (#132) --- x/evm/types/state_transition.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x/evm/types/state_transition.go b/x/evm/types/state_transition.go index 0e1eff0e..700677b3 100644 --- a/x/evm/types/state_transition.go +++ b/x/evm/types/state_transition.go @@ -44,10 +44,13 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result) // This gas limit the the transaction gas limit with intrinsic gas subtracted gasLimit := st.GasLimit - ctx.GasMeter().GasConsumed() + var snapshot int if st.Simulate { // gasLimit is set here because stdTxs incur gaskv charges in the ante handler, but for eth_call // the cost needs to be the same as an Ethereum transaction sent through the web3 API gasLimit = st.GasLimit - cost + + snapshot = st.Csdb.Snapshot() } // Create context for evm @@ -106,6 +109,10 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result) return nil, res } + if st.Simulate { + st.Csdb.RevertToSnapshot(snapshot) + } + // TODO: Refund unused gas here, if intended in future st.Csdb.Finalise(true) // Change to depend on config