Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Add PUSHNULL and ISNULL #208

Merged
merged 11 commits into from
Oct 1, 2019
Merged

Add PUSHNULL and ISNULL #208

merged 11 commits into from
Oct 1, 2019

Conversation

erikzhang
Copy link
Member

@erikzhang erikzhang commented Sep 26, 2019

Related to: neo-project/neo#1112

@codecov-io
Copy link

codecov-io commented Sep 26, 2019

Codecov Report

Merging #208 into master will decrease coverage by 0.44%.
The diff coverage is 39.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #208      +/-   ##
==========================================
- Coverage   79.32%   78.87%   -0.45%     
==========================================
  Files          16       17       +1     
  Lines        1422     1444      +22     
==========================================
+ Hits         1128     1139      +11     
- Misses        294      305      +11
Impacted Files Coverage Δ
src/neo-vm/ExecutionEngine.cs 69.93% <0%> (-0.87%) ⬇️
src/neo-vm/Types/Null.cs 63.63% <63.63%> (ø)
src/neo-vm/StackItem.cs 98.3% <66.66%> (-1.7%) ⬇️
src/neo-vm/Types/ByteArray.cs 100% <0%> (+13.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6676592...105a511. Read the comment docs.

shargon
shargon previously approved these changes Sep 26, 2019
@igormcoelho
Copy link
Contributor

I'm glad a new Stack Item is not being created... I'll check this. Any way to avoid impacting XDROP?

src/neo-vm/OpCode.cs Show resolved Hide resolved
@shargon
Copy link
Member

shargon commented Sep 26, 2019

I'm glad a new Stack Item is not being created...

It was created xD

@igormcoelho
Copy link
Contributor

Really? Why?

@shargon
Copy link
Member

shargon commented Sep 26, 2019

How we can ensure that a byte[0] is an empty array or null?

Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very dangerous changes were made, specially the relocation of DUPFROMALTSTACK. Can someone explain why this is a good thing?

@igormcoelho
Copy link
Contributor

igormcoelho commented Sep 26, 2019

How we can ensure that a byte[0] is an empty array or null?

Simple. new ByteArray(null) could have a constructor that receives null and indicates this in a local flag.

Another possibility is using Interop stack item, which already assumes null in many situations. If you want this for JSON, it's simpler to have JSON as an interop stack item, no?

The point is, we have many options for this. But in the end, what bother me even more, is so many dangerous side changes made here... why? What about these many opcode relocations on basic stack operations? Are you all aware that these things may break virtually everything written down on NeoVM so far? https://neoresearch.io/nvm-learn/#stack-operations

@igormcoelho
Copy link
Contributor

Can we reorder opcodes in another PR, and focus only on the null situation here? I think this helps a quicker agreement.

@igormcoelho
Copy link
Contributor

@erikzhang and @shargon , I reverted stack operation changes. I propose that we create a new PR and reorder everything from scratch. If we redesign all opcode positions, we can get much better distribution, and more clear separation between prefixes. What do you think?
I'll focus on Null now. I may try an alternative proposal (without a new stack item), if it's not good, we can just revert it.

@igormcoelho
Copy link
Contributor

igormcoelho commented Sep 27, 2019

For the next commit, I opened a PR here: #210
I'm still stuck in details... if you could help @shargon... otherwise, you can move on (or even discard my last two commits).

[UPDATE]: I tried the ByteArray(null) approach, and it became worse than a Null stackitem. The reason is that, because of the change I made, every time we got a bytearray from the ByteArray stackitem, we would need to ensure it is null or not, which is terrible for bugs. In this sense,although it solves the problem,bug surface increases on ByteArray, which is a fundamental type. Better keep it non-null,and Null constrained to a new type.

Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted unrelated changes, trying another approach on PR #210

[UPDATE]: that didn't work, this approach here is better.

Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to make it better, but I couldn't. This approach with a new stack item seems reasonable to me, given the problem it's trying to solve.
Regarding opcode positions, I would prefer in another PR and had reverted some decisions made here... but after that, I re-reverted everything (to the way it was before my participation). This way, you are free to move on. Congratulations for the good work, as always ;)

@shargon
Copy link
Member

shargon commented Oct 1, 2019

Could be merged?

@erikzhang erikzhang merged commit e88604b into master Oct 1, 2019
@erikzhang erikzhang deleted the 3.0/opcodes-null branch October 1, 2019 15:35
@name-unavailable
Copy link

hi, I wonder how much is the systemfee of these two opcodes?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants