From 58c4e1636520b9f17b9c0a82109602abc7801b60 Mon Sep 17 00:00:00 2001 From: andri lim Date: Fri, 10 May 2019 15:02:39 +0700 Subject: [PATCH] add some comments --- nimbus/vm/interpreter/opcodes_impl.nim | 14 +++++++++++--- tests/test_generalstate_failing.nim | 6 ++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index d2f9938a1..64c35dff6 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -906,17 +906,25 @@ op shrOp, inline = true, shift, num: op sarOp, inline = true: let shiftLen = computation.stack.popInt().safeInt - let num = cast[Int256](computation.stack.popInt()) + let x = computation.stack.popInt() + #let num = cast[Int256](computation.stack.popInt()) if shiftLen >= 256: - if num.isNegative: + #if num.isNegative: + if cast[Int256](x).isNegative: push: cast[Uint256]((-1).i256) else: push: 0 else: - push: cast[Uint256](ashr(num, shiftLen)) + # ashr depends on nim-stint/#76 + # push: cast[Uint256](ashr(num, shiftLen)) + # while waiting for stint/#76 merged, we use this workaround + push: (x shr shiftLen) or (((0-(x shr 255)) shl 1) shl (255-shiftLen)) op extCodeHash, inline = true: let address = computation.stack.popAddress() + # this is very inefficient, it calls underlying + # database too much, we can reduce it by implementing accounts + # cache if not computation.vmState.readOnlyStateDB.accountExists(address): push: 0 return diff --git a/tests/test_generalstate_failing.nim b/tests/test_generalstate_failing.nim index b6991caf5..672fcbb9b 100644 --- a/tests/test_generalstate_failing.nim +++ b/tests/test_generalstate_failing.nim @@ -13,7 +13,13 @@ # being mostly used for short-term regression prevention. func allowedFailingGeneralStateTest*(folder, name: string): bool = let allowedFailingGeneralStateTests = @[ + # conflicts between native int and big int. + # gasFee calculation in modexp precompiled + # contracts "modexp.json", + # perhaps a design flaw with create/create2 opcode. + # a conflict between balance checker and + # static call context checker "create2noCash.json", ] result = name in allowedFailingGeneralStateTests