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

rpc: refactor invokecontractverify #1825

Merged
merged 2 commits into from
Mar 17, 2021
Merged

Conversation

AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Mar 11, 2021

Close #1799.

Problem

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 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 for verify method (because of the line 773). It may be fixed in a separate PR (if needed).

@AnnaShaleva AnnaShaleva added the bug Something isn't working label Mar 11, 2021
@codecov
Copy link

codecov bot commented Mar 11, 2021

Codecov Report

Merging #1825 (edfca68) into master (f7d7419) will decrease coverage by 0.00%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pkg/rpc/server/server.go 78.82% <87.50%> (+0.12%) ⬆️
pkg/core/blockchain.go 79.80% <100.00%> (-0.03%) ⬇️
pkg/rpc/request/txBuilder.go 96.47% <100.00%> (ø)
pkg/core/interop_system.go 92.98% <0.00%> (-1.76%) ⬇️
pkg/consensus/consensus.go 68.35% <0.00%> (-0.64%) ⬇️
pkg/services/oracle/request.go 53.03% <0.00%> (+1.51%) ⬆️

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 f7d7419...edfca68. Read the comment docs.

Copy link
Member

@roman-khimov roman-khimov left a 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.

pkg/rpc/server/server.go Outdated Show resolved Hide resolved
pkg/rpc/server/server.go Show resolved Hide resolved
pkg/rpc/server/server_test.go Outdated Show resolved Hide resolved
pkg/rpc/server/server.go Outdated Show resolved Hide resolved
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
Copy link
Member

@roman-khimov roman-khimov left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rpc: ensure that (*Client).AddNetworkFee can properly calculate network fee for main Notary transaction
3 participants