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

Add ASSERT and ABORT opcode #300

Merged
merged 12 commits into from
Mar 20, 2020
Merged

Conversation

Tommo-L
Copy link
Contributor

@Tommo-L Tommo-L commented Mar 16, 2020

close #299

  1. add ABORT(0x37) , ASSERT(0x38) opcodes
  2. remove THROWIF, THROWIFNOT opcodes
  3. reorder THROW opcode, change value from 0x37 to 0x3A.

@Tommo-L Tommo-L changed the title add ASSERT opcode Add ASSERT opcode Mar 16, 2020
@shargon
Copy link
Member

shargon commented Mar 16, 2020

It will require 2 opcodes for ASSERT IF NOT

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Perhaps this will be more clear than Throw and easier to use.
Good job.

@Tommo-L
Copy link
Contributor Author

Tommo-L commented Mar 17, 2020

It will require 2 opcodes for ASSERT IF NOT

I don't like these *_IFNOT opcode, it doesn't save much storage. But if you prefer to add, I'll add them.

shargon
shargon previously approved these changes Mar 17, 2020
src/neo-vm/ExecutionEngine.cs Outdated Show resolved Hide resolved
src/neo-vm/OpCode.cs Outdated Show resolved Hide resolved
@Tommo-L Tommo-L changed the title Add ASSERT opcode Add ASSERT and ABORT opcode Mar 18, 2020
erikzhang
erikzhang previously approved these changes Mar 18, 2020
@erikzhang erikzhang mentioned this pull request Mar 18, 2020
src/neo-vm/OpCode.cs Outdated Show resolved Hide resolved
/// <summary>
/// It turns the vm state to FAULT immediately, but it can be caught.
/// </summary>
THROW = 0x3A,
Copy link
Member

@shargon shargon Mar 18, 2020

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think THROW is more close to TRY and CATCH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer this order of instructions:

THROW
// TRY - ENDF
ASSERT
ABORT
RET

src/neo-vm/ExecutionEngine.cs Outdated Show resolved Hide resolved
src/neo-vm/OpCode.cs Outdated Show resolved Hide resolved
@erikzhang erikzhang merged commit f6234fd into neo-project:master Mar 20, 2020
@Tommo-L Tommo-L deleted the add_assert branch March 24, 2020 06:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ASSERT opcode
4 participants