-
Notifications
You must be signed in to change notification settings - Fork 79
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
rpc: refactor invokecontractverify #1825
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1825 +/- ##
==========================================
- Coverage 83.38% 83.38% -0.01%
==========================================
Files 281 281
Lines 22370 22384 +14
==========================================
+ Hits 18654 18664 +10
- Misses 2575 2578 +3
- Partials 1141 1142 +1
Continue to review full report at Codecov.
|
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 would suggest to propose the same changes in C# repo.
Yep, we need an issue for that.
2159d02
to
a2599ad
Compare
It needs only VM and function to get contract state. Also exposed this method and extended Blockchainer. These changes are needed for the next commit.
In `(c *Client) AddNetworkFee` we define network fee for contract witness verification via `invokecontractverify` RPC call, and that's the initial purpose of this RPC method. But it was not implemented correctly. It used `System.Contract.Call` instead of beheiving like `initVerificationVM`. During real contract witness verification the whole contract's script is loaded into VM, and then we jump to the `verify` method. Thus, to define exact contract verification price, we should act like this (and not just perform `System.Contract.Call` of `verify` method). Tests are added. This bug is the reason of adding extra GAS (c.notary.extraVerifyFee) to pre-calculated value in https://github.com/nspcc-dev/neofs-node/pull/404/files#diff-639db437ca2578db46c9e8cbf18f9aa01f8ca5aee30e0fa7e70ba0354822d7b3R237
a2599ad
to
edfca68
Compare
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.
Good, but let's wait for neo-project/neo-modules#564 to ensure we're compatible.
Close #1799.
Problem
In
(c *Client) AddNetworkFee
we define network fee for contractwitness verification via
invokecontractverify
RPC call, and that's theinitial purpose of this RPC method. But it was not implemented
correctly. It used
System.Contract.Call
instead of beheiving likeinitVerificationVM
.During real contract witness verification the whole contract's script is
loaded into VM, and then we jump to the
verify
method. Thus, to defineexact contract verification price, we should act like this (and not just
perform
System.Contract.Call
ofverify
method).Tests are added.
This bug is the reason of adding extra GAS (c.notary.extraVerifyFee) to
pre-calculated value in
pkg/morph/client/notary.go
, L237.Solution
I would suggest to propose the same changes in C# repo.
Additional info
Our
(c *Client) AddNetworkFee
still is working properly with only those contracts which do not have arguments forverify
method (because of the line 773). It may be fixed in a separate PR (if needed).