Comments (14)
@erikzhang
I had checked that.
In IL,when a 'object' == 'another object', it is a ceq opcode.except that object type had a overload equal method.
But the type" byte[]" do not overload equal method.
so byte[]== byte[] is a object==object, got a IL ceq opcode
and int== int got a IL ceq opcode too.
so can't tell is object==object or int==int or byte[]==byte[] just from IL code in current address.
from neo-vm.
I don't think it's the problem. The equality comparison of ByteArray
uses EQUAL
instead of NUMEUQAL
.
from neo-vm.
I can confirm - I stumbled on the issue independently while testing my debugger (I noticed several missing contracts on TestNet after upgrading to 2.10.1) and traced it to this issue - the NEL contracts all use this code in their upgrade
operation before they continue to the Contract.Migrate
call:
if (script == new_script)
return false;
I debugged a past upgrade
operation they did on-chain on TestNet and found that it is indeed using NUMEQUAL
for the comparison as @wowoyinwei said.
from neo-vm.
Thanks for your feedback, the fix was made on #124
from neo-vm.
When I debugged, I found the returned false in the NUMEQUAL instruction that caused the failed execution. Then I removed the size verification in NUMEQUAL and there would be no problem.
Because only the comparison of the contracts is likely to exceed the size limit, it is considered to be the reason.
I will look into it again.
from neo-vm.
@hal0x2328 also found some interesting insights about it. Maybe it has some inconsistency in recent versions. Let's investigate further.
from neo-vm.
reverting this change wont cause any problem, as theres no issue in.comparing.bignum. This limitation only.applies to keeping them.in memory, over 32bytes. So if reverting resolves, I vote for revert.
from neo-vm.
Since I suspect that it is a problem caused by the comparison of scripts, I did a test and first I wrote the following contract:
Public class Test : SmartContract
{
Public static object Main(string method, object[] args)
{
String magicStr = "20190411";
Byte[] script = Blockchain.GetContract(ExecutionEngine.ExecutingScriptHash).Script;
Return script == new byte[] { };
}
}
The contract hash is 0xa4c86aff3437cd7ed76d415f0e5701eb06cac325 deployed on the TestNet
First, I sent an invoke request to the node http://seed2.ngd.network:20332 (version2.10.0). The body of the request is as follows:
{
"jsonrpc": "2.0",
"method": "invokefunction",
"params": [
"0xa4c86aff3437cd7ed76d415f0e5701eb06cac325",
"",
[
]
],
"id": 3
}
What was returned was as follows:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"script": "00c1006725c3ca06eb01570e5f416dd77ecd3734ff6ac8a4",
"state": "HALT, BREAK",
"gas_consumed": "0.143",
"stack": [
{
"type": "Boolean",
"value": false
}
]
}
}
Then I sent the same request to the node http://seed5.ngd.network:20332 (version2.10.1), and what was returned was not the same:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"script": "00c1006725c3ca06eb01570e5f416dd77ecd3734ff6ac8a4",
"state": "FAULT",
"gas_consumed": "0.134",
"stack": []
}
}
I also enabled two nodes locally. The only difference between the two nodes was that one node removed the size verification in the NUMEQUAL instruction. The local node that removed the size verification returned as seed2 did, and the node that retained the size verification returned as seed5 did.
@shargon @erikzhang
from neo-vm.
if (script == new_script)
return false;
Why does ByteArray
comparison use NUMEQUAL
instead of EQUAL
? This is definitely a compiler error.
from neo-vm.
I don't understand. The compiler uses the correct instruction (EQUAL
). Which compiler version are you using? @wowoyinwei
from neo-vm.
The compiled version of the NNC should be 2.3.0.9
The compiled version I tested yesterday is the latest 2.4.1.0
@erikzhang
from neo-vm.
@lightszero Can you find out why the compiler uses NUMEQUAL
instead of EQUAL
?
from neo-vm.
This is really strange @wowoyinwei, I can confirm the strange opcode on 2.3.0.9.
#125 bytes
52 PUSH2 # The number 2 is pushed onto the stack.
c5 NEWARRAY #
6b TOALTSTACK # Puts the input onto the top of the alt stack. Removes it from the main stack.
6c FROMALTSTACK # Puts the input onto the top of the main stack. Removes it from the alt stack.
76 DUP # Duplicates the top stack item.
6b TOALTSTACK # Puts the input onto the top of the alt stack. Removes it from the main stack.
00 PUSH0 #An empty array of bytes is pushed onto the stack
52 PUSH2 # The number 2 is pushed onto the stack.
7a ROLL # The item n back in the stack is moved to the top.
c4 SETITEM #
6c FROMALTSTACK # Puts the input onto the top of the main stack. Removes it from the alt stack.
76 DUP # Duplicates the top stack item.
6b TOALTSTACK # Puts the input onto the top of the alt stack. Removes it from the main stack.
51 PUSH1 # The number 1 is pushed onto the stack.
52 PUSH2 # The number 2 is pushed onto the stack.
7a ROLL # The item n back in the stack is moved to the top.
c4 SETITEM #
61 NOP # Does nothing.
68 SYSCALL 2d53797374656d2e457865637574696f6e456e67696e652e476574457865637574696e6753637269707448617368 # System.ExecutionEngine.GetExecutingScriptHash
61 NOP # Does nothing.
68 SYSCALL 1a4e656f2e426c6f636b636861696e2e476574436f6e7472616374 # Neo.Blockchain.GetContract
61 NOP # Does nothing.
68 SYSCALL 164e656f2e436f6e74726163742e476574536372697074 # Neo.Contract.GetScript
00 PUSH0 #An empty array of bytes is pushed onto the stack
9c NUMEQUAL # <------------------------------ shouldn't be there
61 NOP # Does nothing.
6c FROMALTSTACK # Puts the input onto the top of the main stack. Removes it from the alt stack.
75 DROP # Removes the top stack item.
66 RET #
Somehow, this new byte[] { };
is possibly being considered as a number... but it's very strange and unlikely. I'll try to look into it, it shouldn't be there.
from neo-vm.
let me see see,byte[] in avm is a number,that is fine. i will check why is numequal
from neo-vm.
Related Issues (20)
- **OOM** in OpCode `POW` HOT 7
- Optimise the performance of VM with ObjectPool or reusing the existing objects. HOT 4
- Shallow-copy problem for OrderedDictionary.CopyTo in case of Array & Map type HOT 6
- Add 'utf8Size' opcode HOT 4
- Script checks are incomplete
- Can I integrate this vm in to my custom projects? HOT 1
- Efficient way to pass Map type to contract method? OpCode.PACKMAP? HOT 1
- Adapt code documentation of UNPACK opcode
- ReferenceCounter can become negative HOT 18
- Is this `MEMCPY` expected to push nothing to the stack?
- ScriptBuilder should have an emitPush overload that takes a ReadOnlySpan<byte>
- How to customize an interface in interoperation service layer HOT 3
- Presssure test on v3.3.0 cause execution failed HOT 1
- v3.3.0 need more than 30 hours for syncing mainnet even it's just about 1.7million blocks HOT 2
- What is the purpose of the second assert of this test? HOT 1
- Missing push in APPEND?
- EmitPush(bool) should convert stackitem to right type
- Set Operation in a Get Function HOT 2
- Nullable Project HOT 5
- Script class crashes on `GetInstruction(i).Size` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo-vm.