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

Implement getrawnotaryrequest and getrawnotarytransaction RPC extensions #3098

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

tatiana-nspcc
Copy link
Contributor

@tatiana-nspcc tatiana-nspcc commented Aug 22, 2023

Problem

We have notary pool subscriptions, but it's not enough for debugging some unexpected things that may happen while submitting notary requests.
The problem is described in #2951

Solution

Add the following RPC extensions:

  • getRawNotaryPool returns hashes from all the verified transactions, including both main and fallback transactions.

  • getRawNotaryRequest takes a transaction hash and attempts to find the corresponding transaction in the notary requests mempool. It searches through all the verified main and fallback transactions.

Close #2951.

@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Merging #3098 (7afa950) into master (f330aaf) will decrease coverage by 0.06%.
Report is 4 commits behind head on master.
The diff coverage is 90.52%.

@@            Coverage Diff             @@
##           master    #3098      +/-   ##
==========================================
- Coverage   84.89%   84.83%   -0.06%     
==========================================
  Files         329      330       +1     
  Lines       44239    44334      +95     
==========================================
+ Hits        37555    37611      +56     
- Misses       5172     5211      +39     
  Partials     1512     1512              
Files Changed Coverage Δ
pkg/neorpc/result/raw_notary_pool.go 70.00% <70.00%> (ø)
pkg/rpcclient/rpc.go 82.71% <88.46%> (+0.17%) ⬆️
pkg/core/mempool/mem_pool.go 97.25% <100.00%> (+0.05%) ⬆️
pkg/services/rpcsrv/server.go 80.92% <100.00%> (+0.33%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

The comment about PR structure:

  1. Change the PR name, it should describe what you are implementing/optimizing/fixing/doing in this PR. What you are doing here is supporting the getrawnotarypool and getrawnotarytransaction RPC extensions. Thus, PR may be named "implement getrawnotaryrequest and getrawnotarytransaction RPC extensions".
  2. Adjust the PR description: it should contain any of "Close Add getrawnotaryrequestpool RPC extension #2951." or "Closes Add getrawnotaryrequestpool RPC extension #2951." or "Fixes Add getrawnotaryrequestpool RPC extension #2951." keywords to let the GitHub know that your PR is not just references the initial issue, but closes it. I.e. "The problem is described in Add getrawnotaryrequestpool RPC extension #2951" is not enough for this.

Note, that these comments are relevant for any other PR.

Note about PR content:

  1. We should support the same methods for RPC Client.
  2. Documentation should be updated (a part about RPC extensions).
  3. New mempool APIs should be tested (but this can be doe after APIs finalisation).

pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
@tatiana-nspcc tatiana-nspcc force-pushed the 2951-getrawnotarypool branch 2 times, most recently from 565296b to 3bb20bb Compare August 27, 2023 19:16
@tatiana-nspcc tatiana-nspcc changed the title getRawNotaryPool and getRawNotaryRequest Implement getrawnotaryrequest and getrawnotarytransaction RPC extensions Aug 27, 2023
pkg/core/mempool/mem_pool.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool_test.go Outdated Show resolved Hide resolved
pkg/core/mempool/mem_pool_test.go Outdated Show resolved Hide resolved
pkg/rpcclient/doc.go Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
@tatiana-nspcc tatiana-nspcc force-pushed the 2951-getrawnotarypool branch 2 times, most recently from c7ead95 to 9f8f44c Compare August 28, 2023 17:04
pkg/core/mempool/mem_pool_test.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc.go Show resolved Hide resolved
pkg/rpcclient/doc.go Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
AnnaShaleva added a commit that referenced this pull request Aug 29, 2023
Forbid Notary service to change the fallback's witnesses in any way.
Fix the problem described in #3098 (comment).

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit that referenced this pull request Aug 29, 2023
Forbid Notary service to change the fallback's witnesses in any way.
Fix the problem described in review comment:
#3098 (comment).

Signed-off-by: Anna Shaleva <[email protected]>
AnnaShaleva added a commit that referenced this pull request Aug 29, 2023
Forbid Notary service to change the fallback's witnesses in any way.
Fix the problem described in review comment:
#3098 (comment).

Signed-off-by: Anna Shaleva <[email protected]>
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server_test.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc_test.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc_test.go Outdated Show resolved Hide resolved
pkg/rpcclient/rpc_test.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
@tatiana-nspcc tatiana-nspcc force-pushed the 2951-getrawnotarypool branch 3 times, most recently from 678d021 to 5a1b5bc Compare August 31, 2023 06:48
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/neorpc/result/raw_notary_pool.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/server_test.go Show resolved Hide resolved
pkg/rpcclient/rpc_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/client_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/client_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/client_test.go Outdated Show resolved Hide resolved
@AnnaShaleva
Copy link
Member

Otherwise LGTM.

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

LGTM.

@roman-khimov, could you review?
@tatiana-nspcc, please, convert the PR from draft.

@AnnaShaleva
Copy link
Member

@tatiana-nspcc, could you also rebase onto the current master, please?

@tatiana-nspcc tatiana-nspcc marked this pull request as ready for review August 31, 2023 14:48
@tatiana-nspcc
Copy link
Contributor Author

It was rebased before the last push. As I see it's still based on a current master state.

@AnnaShaleva
Copy link
Member

It was rebased before the last push. As I see it's still based on a current master state.

That's true, which means I broke our CodeQL job in the #3113.

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.

Perfectly fine otherwise.

pkg/core/mempool/mem_pool_test.go Outdated Show resolved Hide resolved
docs/rpc.md Outdated Show resolved Hide resolved
IterateVerifiedTransactions iterates through verified transactions in
memory pool and invokes function cont. Where cont callback returns
whether we should continue with the traversal process.

Signed-off-by: Tatiana Nesterenko <[email protected]>
`getrawnotarytransaction` takes a transaction hash and attempts to find
the corresponding transaction in the notary requests mempool. It searches
through all the verified main and fallback transactions.
`getrawnotarypool` returns hashes of all the verified transactions,
including both main and fallback transactions.

Additionally add struct result.RawNotaryPool.

Close #2951

Signed-off-by: Tatiana Nesterenko <[email protected]>
…ethods

GetRawNotaryTransaction returns a fallback or main transaction that was
previously added to the memory pool by P2PNotaryRequest. This function
invokes the RPC server's `getrawnotarytransaction` method.
GetRawNotaryPool returns hashes from all the verified transactions,
including both main and fallback transactions. This function invokes
the RPC server's `getrawnotarypool` method.

Also, these functions were added to doc.go.

Signed-off-by: Tatiana Nesterenko <[email protected]>
@roman-khimov roman-khimov merged commit 0d30c83 into master Aug 31, 2023
13 of 18 checks passed
@roman-khimov roman-khimov deleted the 2951-getrawnotarypool branch August 31, 2023 19:05
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.

Add getrawnotaryrequestpool RPC extension
3 participants