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

Utility functions to check storage and network tip status #293

Merged
merged 10 commits into from
Jan 12, 2021

Conversation

septerr
Copy link
Contributor

@septerr septerr commented Jan 12, 2021

Fixes # .

Motivation

Rosetta CLI checks to see if it is at tip at a few different places. These checks are not consistent.

For instance, before constructing transactions, the CLI checks if it is a tip based on (1) if the stored current block is within tip delay or (2) block returned by network/status is at tip (it is within tip delay or has sync status of true) and it is same as the stored current block.

Before broadcasting transactions, the CLI checks if it is at tip based only on if the stored current block is within tip delay.

These inconsistent checks were leading to the CLI getting stuck during transaction broadcast for chains that use sync status rather than tip delays.

Solution

Added CheckStorageTip and CheckNetworkTip functions to SDK utils, to provide clients like the Rosetta CLI a utility method to perform these checks consistently. The CLI would use CheckStorageTip to determine if it is at tip.

Future Work

  • Return bool indicating if synced and always return must recent block

@coveralls
Copy link

coveralls commented Jan 12, 2021

Pull Request Test Coverage Report for Build 14212

  • 30 of 32 (93.75%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 77.937%

Changes Missing Coverage Covered Lines Changed/Added Lines %
utils/utils.go 30 32 93.75%
Totals Coverage Status
Change from base Build 14133: 0.03%
Covered Lines: 8287
Relevant Lines: 10633

💛 - Coveralls

}

return AtTip(tipDelay, status.CurrentBlockTimestamp), nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is not used by the SDK or the CLI and we are assuming no one else is using it either.

@septerr septerr changed the title Utility function to check storage and network tip status Utility functions to check storage and network tip status Jan 12, 2021
@patrick-ogrady patrick-ogrady merged commit 3a557da into master Jan 12, 2021
@patrick-ogrady patrick-ogrady deleted the sgupta/utils-tip-method branch January 12, 2021 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants