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

Wallet has no warning for stale balance #5855

Closed
SWvheerden opened this issue Oct 23, 2023 · 0 comments · Fixed by #5949
Closed

Wallet has no warning for stale balance #5855

SWvheerden opened this issue Oct 23, 2023 · 0 comments · Fixed by #5949
Assignees
Labels
release-blocker Something that needs to be fixed before a release can be made

Comments

@SWvheerden
Copy link
Collaborator

SWvheerden commented Oct 23, 2023

The wallet returns stale balance results with no warning to the user if it cannot
get a live state from the base node. This will lead clients to use stale results.
There is no way to distinguish between stale and updated results.
This is because the GetBalance operation uses the get_chain_metadata function to
calculate the current tip. GetChainMetadata in turn will return an Ok result even
when it fetches possibly outdated data from its database.

            OutputManagerRequest::GetBalance => {
                let current_tip_for_time_lock_calculation = match 
self.base_node_service.get_chain_metadata().await {
                    Ok(metadata) => metadata.map(|m| 
m.height_of_longest_chain()),
                    Err(_) => None,
                };
                self.get_balance(current_tip_for_time_lock_calculation)
                    .map(OutputManagerResponse::Balance)
            },
            BaseNodeServiceRequest::GetChainMetadata => match 
self.get_state().await.chain_metadata {
                Some(metadata) => 
Ok(BaseNodeServiceResponse::ChainMetadata(Some(metadata))),
                None => {
                    // if we don't have live state, check if we've 
previously stored state in the wallet db
                    let metadata = self.db.get_chain_metadata()?;
                    
Ok(BaseNodeServiceResponse::ChainMetadata(metadata))
                },
            },

Provide a clear warning to users that they are getting outdated data

@SWvheerden SWvheerden added the release-blocker Something that needs to be fixed before a release can be made label Oct 23, 2023
@SWvheerden SWvheerden self-assigned this Nov 13, 2023
SWvheerden added a commit that referenced this issue Nov 16, 2023
Description
---
block wallet from sending if metadata from base node is stale and older
than 15 mins
The console wallet will print out a warning if the connection is stale. 

Motivation and Context
---
Sending via old metadata can cause issues with wallets using old data.
The transactions might not be valid anymore


Fixes: #5855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocker Something that needs to be fixed before a release can be made
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant