diff --git a/cosmos/x/evm/plugins/precompile/plugin.go b/cosmos/x/evm/plugins/precompile/plugin.go index 48df28597..b68cce759 100644 --- a/cosmos/x/evm/plugins/precompile/plugin.go +++ b/cosmos/x/evm/plugins/precompile/plugin.go @@ -179,7 +179,7 @@ func (p *plugin) enableReentrancy(sdb vm.PolarisStateDB) { // end precompile execution => stop emitting Cosmos event as Eth logs for now cem := utils.MustGetAs[state.ControllableEventManager](sdkCtx.EventManager()) - cem.DisableEthLogging() + cem.EndPrecompileExecution() // remove Cosmos gas consumption so gas is consumed only per OPCODE p.sp.SetGasConfig(storetypes.GasConfig{}, storetypes.GasConfig{}) @@ -197,7 +197,7 @@ func (p *plugin) disableReentrancy(sdb vm.PolarisStateDB) { // resume precompile execution => begin emitting Cosmos event as Eth logs again cem := utils.MustGetAs[state.ControllableEventManager](sdkCtx.EventManager()) - cem.EnableEthLogging(sdb) + cem.BeginPrecompileExecution(sdb) // restore ctx gas configs for continuing precompile execution p.sp.SetGasConfig(p.kvGasConfig, p.transientKVGasConfig) diff --git a/cosmos/x/evm/plugins/precompile/plugin_test.go b/cosmos/x/evm/plugins/precompile/plugin_test.go index 7eda4f15a..96abeef44 100644 --- a/cosmos/x/evm/plugins/precompile/plugin_test.go +++ b/cosmos/x/evm/plugins/precompile/plugin_test.go @@ -167,7 +167,7 @@ func (msf *mockStateful) RegistryKey() common.Address { // panics if modifying state on read-only. func (msf *mockStateful) Run( ctx context.Context, _ precompile.EVM, input []byte, - caller common.Address, _ *big.Int, + _ common.Address, _ *big.Int, ) ([]byte, error) { if input[0] == byte(2) { panic(vm.ErrWriteProtection) diff --git a/cosmos/x/evm/plugins/state/events/manager.go b/cosmos/x/evm/plugins/state/events/manager.go index 6be47348a..bde56a015 100644 --- a/cosmos/x/evm/plugins/state/events/manager.go +++ b/cosmos/x/evm/plugins/state/events/manager.go @@ -67,17 +67,17 @@ func (m *manager) SetReadOnly(readOnly bool) { m.readOnly = readOnly } -// EnableEthLogging is called when Cosmos events from precompiles should be emitted as Eth logs. -// This function sets the `LogsDB` to the given `ldb` so that the `EmitEvent` and `EmitEvents` -// methods can add logs to the journal. -func (m *manager) EnableEthLogging(ldb LogsDB) { +// BeginPrecompileExecution is called when a precompile is about to be executed. This function +// sets the `LogsDB` to the given `ldb` so that the `EmitEvent` and `EmitEvents` methods can +// add logs to the journal. +func (m *manager) BeginPrecompileExecution(ldb LogsDB) { m.ldb = ldb } -// DisableEthLogging is called when Cosmos events from precompiles should be emitted as Eth logs. -// This function sets the `LogsDB` to nil so that the `EmitEvent` and `EmitEvents` methods don't -// add logs to the journal. -func (m *manager) DisableEthLogging() { +// EndPrecompileExecution is called when a precompile has finished executing. This function +// sets the `LogsDB` to nil so that the `EmitEvent` and `EmitEvents` methods don't add logs +// to the journal. +func (m *manager) EndPrecompileExecution() { m.ldb = nil } diff --git a/cosmos/x/evm/plugins/state/events/manager_test.go b/cosmos/x/evm/plugins/state/events/manager_test.go index 2021e2288..9b454393a 100644 --- a/cosmos/x/evm/plugins/state/events/manager_test.go +++ b/cosmos/x/evm/plugins/state/events/manager_test.go @@ -75,7 +75,7 @@ var _ = Describe("Manager", func() { }) It("should panic when building eth logs fails", func() { - cem.EnableEthLogging(ldb) + cem.BeginPrecompileExecution(ldb) Expect(func() { ctx.EventManager().EmitEvent(sdk.NewEvent("non-eth-event")) @@ -83,7 +83,7 @@ var _ = Describe("Manager", func() { }) It("should build eth logs from cosmos events during precompile", func() { - cem.EnableEthLogging(ldb) + cem.BeginPrecompileExecution(ldb) ctx.EventManager().EmitEvent(sdk.NewEvent("2")) Expect(ctx.EventManager().Events()).To(HaveLen(2)) @@ -96,7 +96,7 @@ var _ = Describe("Manager", func() { Expect(ctx.EventManager().Events()).To(HaveLen(4)) Expect(ldb.AddLogCalls()).To(HaveLen(3)) - cem.DisableEthLogging() + cem.EndPrecompileExecution() Expect(func() { cem.Finalize() }).ToNot(Panic()) }) diff --git a/cosmos/x/evm/plugins/state/interfaces.go b/cosmos/x/evm/plugins/state/interfaces.go index 07770cb3d..9ed2239cc 100644 --- a/cosmos/x/evm/plugins/state/interfaces.go +++ b/cosmos/x/evm/plugins/state/interfaces.go @@ -38,10 +38,10 @@ type ControllableEventManager interface { libtypes.Controllable[string] sdk.EventManagerI - // EnableEthLogging sets the logs DB to begin emitting Cosmos events as Eth logs. - EnableEthLogging(events.LogsDB) - // DisableEthLogging resets the logs DB to nil to stop emitting Cosmos events as Eth logs. - DisableEthLogging() + // BeginPrecompileExecution begins a precompile execution by setting the logs DB. + BeginPrecompileExecution(events.LogsDB) + // EndPrecompileExecution ends a precompile execution by resetting the logs DB to nil. + EndPrecompileExecution() // IsReadOnly returns true if the EventManager is read-only. IsReadOnly() bool