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

Call blockprod::find_timestamps_for_staking directly from wallet cli #1748

Conversation

ImplOfAnImpl
Copy link
Contributor

This addresses the problem from #1747 where the timestamp search RPC call from wallet-cli to wallet-rpc-daemon would timeout if the search takes a long time.

To solve the problem, the call to blockprod::find_timestamps_for_staking was moved from the wallet controller to wallet-cli itself. Since the call needs PoSTimestampSearchInputData, I had to add the get_timestamp_search_input_data function to wallet RPC that returns the data. And since the data contains the private vrf key, I had to use e2e encryption for it.

In the end, I'm not sure it's worth the added complexity, because the timeout problem only exists if wallet-cli connects to wallet-rpc-daemon.
Given that FindTimestampsForStaking is a "niche" (and hidden) command, probably no one will ever use it in this scenario.

@ImplOfAnImpl ImplOfAnImpl marked this pull request as ready for review May 7, 2024 17:22
@ImplOfAnImpl ImplOfAnImpl force-pushed the blockprod_timestamp_searcher branch from d6fabf2 to 9cc49cf Compare May 8, 2024 10:03
@ImplOfAnImpl ImplOfAnImpl force-pushed the blockprod_timestamp_searcher_call_from_wallet_cli branch from 4692e08 to e4040af Compare May 8, 2024 10:03
Comment on lines +721 to +738
let mut rng = make_true_rng();
let our_private_key = EndToEndPrivateKey::new_from_rng(&mut rng);
let our_public_key = our_private_key.public_key();

let wallet = self.wallet().await?;

let callee_public_key = wallet.e2e_public_key().await?.take();

let encrypted_input_data = wallet
.get_timestamp_search_input_data(
HexEncoded::new(our_public_key.clone()),
pool_id,
)
.await?;
let shared_secret = our_private_key.shared_secret(&callee_public_key);
let secret_input_data = shared_secret
.decrypt_then_decode::<PoSTimestampSearchInputData>(&encrypted_input_data)?;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we pack all this in one function or something, instead of doing it here inline?

Copy link
Collaborator

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

I don't think this is a good idea. We should attempt to do it through tower first.

Copy link
Collaborator

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

Obviously, this isn't a priority. I'm OK with putting this in the backlog.

@ImplOfAnImpl ImplOfAnImpl force-pushed the blockprod_timestamp_searcher branch from 9cc49cf to e480095 Compare May 9, 2024 10:51
@ImplOfAnImpl
Copy link
Contributor Author

Obviously, this isn't a priority. I'm OK with putting this in the backlog.

I've added an issue for this - #1749

@ImplOfAnImpl
Copy link
Contributor Author

Closing this for now. It can be re-visited after #1749 is implemented.

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.

None yet

2 participants