From 17188dfcb1e159332ce87e92b41b9ac2e5effa48 Mon Sep 17 00:00:00 2001 From: andri lim Date: Fri, 15 Feb 2019 08:37:54 +0700 Subject: [PATCH] fixes memory write: no padding --- nimbus/vm/interpreter/opcodes_impl.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 07c5e471e..40197d7ff 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -223,13 +223,14 @@ proc writePaddedResult(mem: var Memory, mem.extend(memPos, len) let dataEndPosition = dataPos.int64 + len - 1 let sourceBytes = data[min(dataPos, data.len) .. min(data.len - 1, dataEndPosition)] - mem.write(memPos, sourceBytes) - # Don't duplicate zero-padding of mem.extend - let paddingOffset = memPos + sourceBytes.len - # TODO: avoid unnecessary memory allocation - mem.write(paddingOffset, repeat(paddingValue, max(prevLen - paddingOffset, 0))) + # geth doesn't do padding, it causes block validation error + when false: + # Don't duplicate zero-padding of mem.extend + let paddingOffset = memPos + sourceBytes.len + # TODO: avoid unnecessary memory allocation + mem.write(paddingOffset, repeat(paddingValue, max(prevLen - paddingOffset, 0))) op address, inline = true: ## 0x30, Get address of currently executing account.