Skip to content

allow CheckWitness to work when using invokescript#335

Merged
shargon merged 9 commits intoneo-project:masterfrom
trueinsider:invokescript-checkwitness
Jul 23, 2019
Merged

allow CheckWitness to work when using invokescript#335
shargon merged 9 commits intoneo-project:masterfrom
trueinsider:invokescript-checkwitness

Conversation

@trueinsider
Copy link
Copy Markdown
Contributor

This change will allow execution of smart contracts with CheckWitness call inside them by passing script hash (as optional parameter) for which CheckWitness should be successful to invokescript.

This change was made with this issue in mind: nos/client#133 but I hope it will make life of smart contract devs easier.

cc @deanpress @mhuggins @jeroenptrs

@trueinsider
Copy link
Copy Markdown
Contributor Author

@erikzhang could you please take a look?

@erikzhang
Copy link
Copy Markdown
Member

Perhaps creating a real InvocationTransaction would be better than creating a CheckWitnessHashes.

@trueinsider
Copy link
Copy Markdown
Contributor Author

@erikzhang That is the way I tried it at first, but unsuccessfully. To spoof witness with InvocationTransaction I need to spoof Inputs of that transaction. And transaction verification would fail without real signature generated with real private key. That makes it impossible to spoof random address for CheckWitness()

@erikzhang
Copy link
Copy Markdown
Member

You can attach a TransactionAttribute to the InvocationTransaction for CheckWitness().

https://github.com/neo-project/neo/blob/master/neo/Core/TransactionAttributeUsage.cs#L25

@dicarlo2
Copy link
Copy Markdown

FWIW: neo-one has an additional rpc method testinvocation that accepts an InvocationTransaction and executes it.

@igormcoelho
Copy link
Copy Markdown
Contributor

igormcoelho commented Oct 3, 2018

I'm trying to develop an AVM execution Simulator for Neo on JavaScript, that will serve for these situations when you want the exact execution output, without the actual execution.
https://github.com/NeoResearch/NeoSim.js
This project will basically be the NeoVM.js (neo-vm on javascript: https://github.com/NeoResearch/NeoVM.js) together with some external storage service that could provide storage access on any desired block, without needing to be a heavy node (so it will work on any browser). I believe this is safer than having RPC nodes to simulate invocations.
These projects have started a few months ago, so they are intended to be ready in a few weeks (months at most).

@dicarlo2
Copy link
Copy Markdown

@igormcoelho fyi: we've already implemented a full javascript (well, typescript) vm in neo-one that we've been using in production for over a year now.

@igormcoelho
Copy link
Copy Markdown
Contributor

igormcoelho commented Oct 12, 2018

Good to hear that! I never found some vm codes on js, even recently looked at neo-one ,so I just assumed it has never been fully implemented. Im also reproducing application engine on js too... but I imagine you may also have that too. In this case, I reinforce that price calculation should be done on interfaces, not rpc nodes, using neo-one or any other js client vm.

@shargon
Copy link
Copy Markdown
Member

shargon commented May 21, 2019

I like it, is the same behavior that i use in unit testing. We should be able to do that

@shargon
Copy link
Copy Markdown
Member

shargon commented May 27, 2019

Conflicts with SVM

@vikkkko
Copy link
Copy Markdown

vikkkko commented May 29, 2019

I think it's very meaningful to be able to use CheckWitness in invokescript. This way we can get the specific gas to be consumed before sending the transaction and add the system fee accordingly.
There is a testMode parameter in ApplicationEngine.Run, but no actual effect is found. The parameter passed in and used defaults to be false. Have you considered using testmode for some methods in invoke, so that you can successfully execute the contract when you invoke it.

@vncoelho vncoelho added this to the NEO 3.0 milestone Jun 3, 2019
@vncoelho
Copy link
Copy Markdown
Member

vncoelho commented Jun 3, 2019

I will set this as a goal for NEO 3.0 because for 2.x it will surely not be merged.

In this sense, we can keep this discussion thinking in the new design for NEO 3.

@igormcoelho
Copy link
Copy Markdown
Contributor

Very good idea @wowoyinwei . In fact, I always thought that was already the current behavior... hahahah it's always possible to improve things indeed :) We are in another discussion for Neo 3, regarding what should be accepted for verification, and how to charge for it. But I believe it will be compatible with this proposal as well.

@lock9
Copy link
Copy Markdown
Contributor

lock9 commented Jul 16, 2019

@wowoyinwei, do you need help with this? If you could rebase / fix conflicts, I think it is ready to merge.
This is very important, thanks!

shargon
shargon previously approved these changes Jul 20, 2019
@lock9
Copy link
Copy Markdown
Contributor

lock9 commented Jul 20, 2019

@shargon we have to checkout to the branch and fix some issues. Is it possible for us to do that without having to wait for him? We made @trueinsider wait too much, it is understandable that he may have lost interest in it 😢
It is not compiling

@lock9 lock9 requested a review from shargon July 20, 2019 22:13
@shargon
Copy link
Copy Markdown
Member

shargon commented Jul 21, 2019

I will fix it soon

@erikzhang erikzhang removed this from the NEO 3.0 milestone Jul 22, 2019
Copy link
Copy Markdown
Contributor

@lock9 lock9 left a comment

Choose a reason for hiding this comment

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

Any chance we add this to neo 2? Looks quite simple and very impacting.

@shargon shargon merged commit d048805 into neo-project:master Jul 23, 2019
@shargon
Copy link
Copy Markdown
Member

shargon commented Jul 23, 2019

@lock9 you know my opinion, neo2 just for fix bugs

@gsmachado
Copy link
Copy Markdown
Contributor

gsmachado commented Sep 5, 2019

@lock9, @vncoelho, @igormcoelho, @shargon, @erikzhang , guys:
I urge to have this on NEO2... 😃
Ok, jokes aside, this is important for neow3j, other libraries, and maybe other apps. Given the timeline for NEO3, I would really do this for NEO2.
Without this fix, some features in the SDKs side are simply unusable. Users are complaining about that. 😄

@lock9
Copy link
Copy Markdown
Contributor

lock9 commented Sep 5, 2019

Well, you just used the words "user" and "complaining" in the same phrase, for me this is enough arguments why this should be implemented 😂
@neo-project/core I understand we don't want to make more releases, because (today) it is quite painful, however, this code is quite short and does not introduce breaking changes.

@shargon
Copy link
Copy Markdown
Member

shargon commented Sep 5, 2019

We can do that

@gsmachado
Copy link
Copy Markdown
Contributor

Any news on when this will be released on NEO2?

@shargon
Copy link
Copy Markdown
Member

shargon commented Sep 24, 2019

@gsmachado Please, could you create an issue?

@gsmachado
Copy link
Copy Markdown
Contributor

@shargon: yes, I create this issue. Feel free to change the label or to ask further questions. 👍 😄

Thacryba pushed a commit to simplitech/neo that referenced this pull request Feb 17, 2020
* Create exchange.md

* Create blank

* Add files via upload

* Delete blank

* Update exchange.md

* Update exchange.md

* Update exchange.md

* Delete gasflow_jp.PNG

* Create blank

* Add files via upload

* Delete blank

* Create dumpprivkey.md

* Create getnewaddress.md

* Create getblocksysfee.md

* Update toc.yml

* Update api.md

* Update api.md

* Delete gasflow_jp.png

* Create blank

* Add files via upload

* Delete blank

* Create getting-started-python.md

* Added Getting Started (Python) document

* Create compiler.md

* Added Python Compiler

* Create whitepaper.md

* Update whitepaper.md

* Added consensus document links

* Create contributors.md

* Added Contributors link

* Update exchange.md

* Update dumpprivkey.md

* Update getnewaddress.md

* Update getting-started-python.md

* Update compiler.md

* Update whitepaper.md

* Update contributors.md

* Update contributors.md

* Update contributors.md

* Create invokefunction.md

* Create invokescript.md

* Create sendmany.md

* Create validateaddress.md

* Create invoke.md

* Create getversion.md

* Create getpeers.md

* Update sendmany.md

* Update getpeers.md

* Update invoke.md

* Update invokefunction.md

* Update invokescript.md

* Update toc.yml

* Update api.md

* Update api.md

* Update api.md

* Update contributors.md
Tommo-L pushed a commit to Tommo-L/neo that referenced this pull request Jun 22, 2020
* allow CheckWitness to work when using invokescript

* Fix

* Update RpcServer.cs

* Allow more than one signature

* Reorder properties
@devhawk devhawk mentioned this pull request Sep 15, 2020
44 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants