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

add(scan): Start scanner gRPC server with zebrad #8241

Merged
merged 15 commits into from
Feb 7, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Feb 6, 2024

Motivation

We want the zebrad start command to start the scanner gRPC server.

Closes #8242

PR Author Checklist

Check before marking the PR as ready for review:

  • Will the PR name make sense to users?
  • Does the PR have a priority label?
  • Have you added or updated tests?
  • Is the documentation up to date?
For significant changes:
  • Is there a summary in the CHANGELOG?
  • Can these changes be split into multiple PRs?

If a checkbox isn't relevant to the PR, mark it as done.

Solution

  • Add a spawn_init() fn for the root init() fn in zebra_scan
  • Replace the call to ScanTask::spawn() in zebrad start command with the new spawn_init() fn

Testing

  • This was for manual testing of the ClearResults and DeleteKeys RPC methods and worked as expected.
  • Tests that the scanner RPC server is running, accepts connections, and responds to the GetInfo method.

Review

Anyone can review.

Reviewer Checklist

Check before approving the PR:

  • Does the PR scope match the ticket?
  • Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • Are all the PR blockers dealt with?
    PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

@arya2 arya2 added A-rpc Area: Remote Procedure Call interfaces C-feature Category: New features A-blockchain-scanner Area: Blockchain scanner of shielded transactions P-Medium ⚡ labels Feb 6, 2024
@arya2 arya2 self-assigned this Feb 6, 2024
Base automatically changed from scan-grpc-clear-method to main February 6, 2024 21:08
@arya2 arya2 marked this pull request as ready for review February 7, 2024 00:52
@arya2 arya2 requested a review from a team as a code owner February 7, 2024 00:52
@arya2 arya2 requested review from upbqdn and removed request for a team February 7, 2024 00:52
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

This looks really good however i found a bug that i think we should fix.

Zebra crashes if the shielded-scan database is not ephemeral with error:

The application panicked (crashed).
Message:  Opening database "/home/alfredo/.cache/zebra/private-scan/v1/mainnet" failed: Error { message: "IO error: lock hold by current process, acquire time 1707322113 acquiring thread 359173: /home/alfredo/.cache/zebra/private-scan/v1/mainnet/LOCK: No locks available" }. Hint: Check if another zebrad process is running. Try changing the state cache_dir in the Zebra config.

Works fine if the shielded-scan.ephemeral config field is true. This is the reason why the test does not detect this.

I am not sure why this is happening and if it was introduced in this PR but the ephemeral is false by default so we should fix before merging.

zebra-scan/src/config.rs Outdated Show resolved Hide resolved
zebra-scan/src/bin/rpc_server.rs Show resolved Hide resolved
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
@arya2
Copy link
Contributor Author

arya2 commented Feb 7, 2024

Works fine if the shielded-scan.ephemeral config field is true. This is the reason why the test does not detect this.

I am not sure why this is happening and if it was introduced in this PR but the ephemeral is false by default so we should fix before merging.

I think it's because the default 'cache_dir' is the same for zebra-state and zebra-scan's Storage, I added a TODO in the zebra-scan config to add a const generic to `DbConfig' for specifying the default cache_dir.

@oxarbitrage
Copy link
Contributor

oxarbitrage commented Feb 7, 2024

I think it's because the default 'cache_dir' is the same for zebra-state and zebra-scan's Storage, I added a TODO in the zebra-scan config to add a const generic to `DbConfig' for specifying the default cache_dir.

I think this is not the case, i tried used different directories and the same error happens. Relevant config parts:

[shielded_scan]
cache_dir = "/home/alfredo/.cache/zebra2"
delete_old_database = true
ephemeral = false
listen_addr = "127.0.0.1:8231"

[shielded_scan.sapling_keys_to_scan]

[state]
cache_dir = "/home/alfredo/.cache/zebra"
delete_old_database = true
ephemeral = false

Starting zebra with:

alfredo@spaceship:~/zebra/pr8241/zebra$ ./target/debug/zebrad -c myconf.toml start

oxarbitrage
oxarbitrage previously approved these changes Feb 7, 2024
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

That worked, thanks again.

mergify bot added a commit that referenced this pull request Feb 7, 2024
@mergify mergify bot merged commit 2c0bc3a into main Feb 7, 2024
133 checks passed
@mergify mergify bot deleted the init-scan-rpc-from-zebrad branch February 7, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-scanner Area: Blockchain scanner of shielded transactions A-rpc Area: Remote Procedure Call interfaces C-feature Category: New features P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add(grpc): Start the grpc server when zebrad starts, add config options
2 participants