From 5fac39db38ed302af421e56f321b979200332287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Thu, 2 Sep 2021 19:47:39 +0200 Subject: [PATCH] evm: conditional hook snapshot (#520) --- x/evm/keeper/state_transition.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 77d08c2f..5f8fb993 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -175,8 +175,11 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT panic("context stack shouldn't be dirty before apply message") } - // Contains the tx processing and post processing in same scope - revision := k.Snapshot() + var revision int + if k.hooks != nil { + // snapshot to contain the tx processing and post processing in same scope + revision = k.Snapshot() + } // pass false to execute in real mode, which do actual gas refunding res, err := k.ApplyMessage(evm, msg, ethCfg, false)