Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve custom instruction usage #4778

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

mversic
Copy link
Contributor

@mversic mversic commented Jun 26, 2024

Description

Linked issue

Closes #{issue_number}

Benefits

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

@github-actions github-actions bot added the api-changes Changes in the API for client libraries label Jun 26, 2024
@mversic mversic force-pushed the remove_seal branch 3 times, most recently from f04596c to 8b95d9e Compare June 27, 2024 12:57
@mversic mversic enabled auto-merge (squash) June 27, 2024 12:58
Copy link
Contributor

@DCNick3 DCNick3 left a comment

Choose a reason for hiding this comment

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

As far as I can see, this PR:

  • adds a custom parameter and an empty file for custom permissions to the executor_custom_data_model test smartcontract
  • removes Fail instruction; replaces its uses in tests with unregistering of a non-existent domain
  • renames Custom instruction to CustomInstruction
  • in addition to Instruction trait, adds BuiltInInstruction, allowing Instruction to be not sealed
  • in addition to Query trait, adds a sealed BuiltInQuery trait, by analogy with the Instruction trait.
  • makes it so that in smart contracts, only BuiltInInstruction and BuiltInQuery can be executed.

My guess that the main point of it is the last change: to not allow custom instructions to be executed from wasm. While I see how it's beneficial to prevent this for executor (it's kind of recursive otherwise), I am not sure that regular smart-contracts & triggers should be prohibited from doing so...

@mversic
Copy link
Contributor Author

mversic commented Jun 27, 2024

adds a custom parameter and an empty file for custom permissions to the executor_custom_data_model test smartcontract

that was an accidental leftover

removes Fail instruction; replaces its uses in tests with unregistering of a non-existent domain

this can now be expressed with a custom ISI

in addition to Query trait, adds a sealed BuiltInQuery trait, by analogy with the Instruction trait.

reverted, since as you point out it has no benefit

My guess that the main point of it is the last change: to not allow custom instructions to be executed from wasm. While I see how it's beneficial to prevent this for executor (it's kind of recursive otherwise), I am not sure that regular smart-contracts & triggers should be prohibited from doing so...

I tried initially but there were practical problems. Like I had to derive Decode/Encode, implement encode_as_instruction_box which depended on EnumRef. It was becoming a rabbit hole, but you raise a good point about smart contracts

@mversic mversic force-pushed the remove_seal branch 3 times, most recently from d26baec to 648257b Compare June 27, 2024 15:00
@mversic
Copy link
Contributor Author

mversic commented Jun 27, 2024

@DCNick3 I agree it's quite unfortunate that this doesn't work from within smart contracts, but it's still an improvement. Like was previously possible, from within smart contracts user would have to convert instruction into CustomInstruction and then execute. I will open a ticket to explore this. Created #4784

@mversic mversic disabled auto-merge June 27, 2024 15:10
@mversic mversic enabled auto-merge (squash) June 27, 2024 15:10
@mversic mversic disabled auto-merge June 27, 2024 15:10
@mversic mversic enabled auto-merge (squash) June 27, 2024 15:11
@mversic mversic disabled auto-merge June 27, 2024 15:15
@mversic mversic merged commit 8fecf74 into hyperledger-iroha:main Jun 27, 2024
11 of 13 checks passed
@mversic mversic deleted the remove_seal branch June 27, 2024 15:18
hollermay pushed a commit to hollermay/iroha that referenced this pull request Jun 28, 2024
* remove `Fail` instruction
* rename `Custom` to `CustomInstruction`
* enable direct use of custom instructions

Signed-off-by: Marin Veršić <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants