From 51f73873f88427f300e6b732150626c06dc5bfd1 Mon Sep 17 00:00:00 2001 From: Klimov Sergei Date: Sat, 7 Feb 2026 08:44:45 +0800 Subject: [PATCH] Refactor context cancellation for EVM execution --- internal/ethapi/api.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 5fbe7db694..f9d70e07e7 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -741,10 +741,7 @@ func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *s func applyMessageWithEVM(ctx context.Context, evm *vm.EVM, msg *core.Message, timeout time.Duration, gp *core.GasPool) (*core.ExecutionResult, error) { // Wait for the context to be done and cancel the evm. Even if the // EVM has finished, cancelling may be done (repeatedly) - go func() { - <-ctx.Done() - evm.Cancel() - }() + context.AfterFunc(ctx, evm.Cancel) // Execute the message. result, err := core.ApplyMessage(evm, msg, gp)