Make EVMError Catchable and only catch CatchableError in the execPrecompiles

This commit is contained in:
kdeme 2019-07-19 11:39:54 +02:00 committed by zah
parent f6d784c8b0
commit 1a3a29c419
2 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
type type
EVMError* = object of Exception EVMError* = object of CatchableError
## Base error class for all evm errors. ## Base error class for all evm errors.
BlockNotFound* = object of EVMError BlockNotFound* = object of EVMError

View File

@ -233,7 +233,7 @@ proc modExp*(computation: BaseComputation) =
elif maxBytes <= 1024: elif maxBytes <= 1024:
computation.modExpInternal(base_len, exp_len, mod_len, StUint[8192]) computation.modExpInternal(base_len, exp_len, mod_len, StUint[8192])
else: else:
raise newException(ValueError, "The Nimbus VM doesn't support modular exponentiation with numbers larger than uint8192") raise newException(EVMError, "The Nimbus VM doesn't support modular exponentiation with numbers larger than uint8192")
proc bn256ecAdd*(computation: BaseComputation) = proc bn256ecAdd*(computation: BaseComputation) =
computation.gasMeter.consumeGas(GasECAdd, reason = "ecAdd Precompile") computation.gasMeter.consumeGas(GasECAdd, reason = "ecAdd Precompile")
@ -335,7 +335,7 @@ proc execPrecompiles*(computation: BaseComputation, fork: Fork): bool {.inline.}
let msg = getCurrentExceptionMsg() let msg = getCurrentExceptionMsg()
# cannot use setError here, cyclic dependency # cannot use setError here, cyclic dependency
computation.error = Error(info: msg, burnsGas: true) computation.error = Error(info: msg, burnsGas: true)
except: except CatchableError:
let msg = getCurrentExceptionMsg() let msg = getCurrentExceptionMsg()
if fork >= FKByzantium and precompile > paIdentity: if fork >= FKByzantium and precompile > paIdentity:
computation.error = Error(info: msg, burnsGas: true) computation.error = Error(info: msg, burnsGas: true)