From 2a7ccceb3ef6015232e9612584f467b67b3e28b0 Mon Sep 17 00:00:00 2001 From: Jamie Lokier Date: Fri, 30 Apr 2021 01:12:00 +0100 Subject: [PATCH] EVM: Make continuation exceptions behave as they did before The account database code is not supposed to raise exceptions in the EVM, and the behaviour is not well defined if it does. It isn't compliant with EVMC spec either. But that will be dealt with properly when the account state-cache is dealt with, as there is some work to be done on it. Meanwhile, if it raises in code under `chainTo` and then `(continuation)()`, the behaviour was changed slightly by the stack-shrink patches. Before those patches, an exception after the recursion-point was converted to `c.setError` "Opcode Dispatch Error" in `executeOpcodes. After, it would propagate out, a different behaviour. (It still correctly walked the chain of `c.dispose()` calls to clean up.) It's easy to restore the original behaviour just by moving the continuation call, so let's do that. Signed-off-by: Jamie Lokier --- nimbus/vm/interpreter_dispatch.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nimbus/vm/interpreter_dispatch.nim b/nimbus/vm/interpreter_dispatch.nim index f2a2f0710..b3397095e 100644 --- a/nimbus/vm/interpreter_dispatch.nim +++ b/nimbus/vm/interpreter_dispatch.nim @@ -386,13 +386,13 @@ proc executeOpcodes(c: Computation) = let fork = c.fork block: - if not c.continuation.isNil: - (c.continuation)() - c.continuation = nil - elif c.execPrecompiles(fork): + if c.continuation.isNil and c.execPrecompiles(fork): break try: + if not c.continuation.isNil: + (c.continuation)() + c.continuation = nil c.selectVM(fork) except CatchableError as e: c.setError(&"Opcode Dispatch Error msg={e.msg}, depth={c.msg.depth}", true)