mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
fixes ECRecover precompiles
This commit is contained in:
parent
96ae5ee05a
commit
71e7ee2dae
@ -43,6 +43,13 @@ proc contractCall(t: Transaction, vmState: BaseVMState, sender: EthAddress, fork
|
||||
vmState.clearLogs()
|
||||
return t.gasLimit.u256 * t.gasPrice.u256
|
||||
|
||||
# this proc should not be here, we need to refactor
|
||||
# processTransaction
|
||||
proc isPrecompiles*(address: EthAddress): bool {.inline.} =
|
||||
for i in 0..18:
|
||||
if address[i] != 0: return
|
||||
result = address[19] >= 1.byte and address[19] <= 8.byte
|
||||
|
||||
proc processTransaction*(t: Transaction, sender: EthAddress, vmState: BaseVMState): UInt256 =
|
||||
## Process the transaction, write the results to db.
|
||||
## Returns amount of ETH to be rewarded to miner
|
||||
@ -86,7 +93,7 @@ proc processTransaction*(t: Transaction, sender: EthAddress, vmState: BaseVMStat
|
||||
|
||||
else:
|
||||
let code = db.getCode(t.to)
|
||||
if code.len == 0:
|
||||
if code.len == 0 and not isPrecompiles(t.to):
|
||||
# Value transfer
|
||||
trace "Transfer", value = t.value, sender, to = t.to
|
||||
|
||||
|
@ -196,7 +196,12 @@ proc applyMessage(computation: var BaseComputation, opCode: static[Op]) =
|
||||
snapshot.commit()
|
||||
except VMError:
|
||||
snapshot.revert(true)
|
||||
debug "applyMessage failed",
|
||||
debug "VMError applyMessage failed",
|
||||
msg = computation.error.info,
|
||||
depth = computation.msg.depth
|
||||
except EVMError:
|
||||
snapshot.revert() # TODO: true or false?
|
||||
debug "EVMError applyMessage failed",
|
||||
msg = computation.error.info,
|
||||
depth = computation.msg.depth
|
||||
|
||||
|
@ -255,5 +255,6 @@ proc executeOpcodes*(computation: var BaseComputation) =
|
||||
computation.updateOpcodeExec(fork)
|
||||
except VMError:
|
||||
computation.error = Error(info: getCurrentExceptionMsg())
|
||||
debug "executeOpcodes() failed", error = getCurrentExceptionMsg()
|
||||
|
||||
debug "VM Error executeOpcodes() failed", error = getCurrentExceptionMsg()
|
||||
except EVMError:
|
||||
debug "EVM Error executeOpcodes() failed", error = getCurrentExceptionMsg()
|
||||
|
@ -28,7 +28,8 @@ proc getSignature*(computation: BaseComputation): (array[32, byte], Signature) =
|
||||
# Note that we need to rearrange to R, S, V
|
||||
bytes[0..63] = data[64..127]
|
||||
let v = data[63] # TODO: Endian
|
||||
assert v.int in 27..28
|
||||
if v.int notin 27..28:
|
||||
raise newException(ValidationError, "Invalid V in getSignature")
|
||||
bytes[64] = v - 27
|
||||
|
||||
if recoverSignature(bytes, result[1]) != EthKeysStatus.Success:
|
||||
|
Loading…
x
Reference in New Issue
Block a user