-
Notifications
You must be signed in to change notification settings - Fork 146
Conversation
…cuting `RET` instruction
…ALL_ET`, `CALL_EDT`
@lightszero @localhuman @shargon @anthdm Can you guys check this PR for your repositories so that:
|
In progress now! |
A lot of changes to review, give me a couple of days please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still reviewing, the first problem that i find is this
PUSH1
(without RET)
Before the update:
Result: HALT, EvaluationStack[]{true};
After the update:
Result: HALT, ResultStack{}
If exists any script like this in all Blockchain, without versioning, is impossible to reconstruct the chain from the beginning
@@ -50,15 +63,21 @@ public void Push(T item) | |||
public T Remove(int index) | |||
{ | |||
if (index >= list.Count) throw new InvalidOperationException(); | |||
T item = list[list.Count - index - 1]; | |||
list.RemoveAt(list.Count - index - 1); | |||
if (index < 0) index += list.Count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (index < 0) index = list.Count;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to pass -2 or -3?
neo-vm/src/neo-vm/ExecutionEngine.cs Line 976 in f014d93
|
State |= VMState.FAULT; | ||
return; | ||
} | ||
ExecutionContext context_call = LoadScript(context.Script, rvcount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, i love this change :) , but this is other point to consider
Maybe we need to define a new like this class:
class Script
{
public readonly byte[] Data;
public byte[] Hash;
...
}
Because i see a problem on optimization, now and before the change. When we make a CALL
we copy all the current script in a new byte array (ExecutionContext) and yield it, but this is not neccessary, because we can use the same ScriptObject, without copy this values and save memory and time per any CALL
I think that in this line https://github.com/neo-project/neo-vm/pull/39/files#diff-c388295e4ed09df607113cde924c9fadR43 .net framework clone the byte array internally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens too when we compute the hash of the script, this class would optimize this multiple calls a lot of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, byte array in .net is a reference type, which means it won't be cloned automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But not the hash, this will be calculated in all ExecutionContext right? maybe we can save a lot of calls to SHA256
You can create a separate issue for it. |
Do you have a sample for test the new opcodes? the old part (CALL,RET..) is reviewed and seems perfect! |
No. |
@@ -53,28 +58,23 @@ public void Execute() | |||
|
|||
private void ExecuteOp(OpCode opcode, ExecutionContext context) | |||
{ | |||
if (opcode > OpCode.PUSH16 && opcode != OpCode.RET && context.PushOnly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that this might effect reprocessing the chain? Seems like executions of PushOnly = true
scripts might now succeed where before they failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. PushOnly
will only be used in the verification process, and the verification result of history transactions will not change.
Can I merge it now? |
I tested the old opcodes and works fine, i need more test with the new opCodes, but it's fine to merge for pre-release |
Pre-release has been published to nuget: https://www.nuget.org/packages/Neo.VM/2.3.0-preview1 |
The compiler is not finished? i would like to test the new opcodes with a real smart contract. The code looks good |
Compiler is here: https://github.com/neo-project/neo-compiler/pull/109 |
@shargon Any update? |
Sorry about my delay, i wasn't see the last notification, im working on it |
@shargon The compiler issue has been fixed. neo-project/neo-compiler@282604fc4f8ff45a2a7456e073dadb5cf0ef8bbb |
Ok, I will try again :) |
It works :) |
@erikzhang ETA on when this will be live? I want to make sure NEO-ONE is updated. |
I hope we can test this on testnet for a little while before going live 😉 |
Sure, it will be tested on testnet before being merged into neo-project/neo |
This is a great upgrade! great work @erikzhang :) |
Implement NEP-8: Stack Isolation
neo-project/proposals#22
Close #35