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 BlockState utility functions (IsDescendantOf, LowestCommonAncestor, Range) #4469

Open
timwu20 opened this issue Jan 14, 2025 · 0 comments

Comments

@timwu20
Copy link
Contributor

timwu20 commented Jan 14, 2025

Issue Summary

From design doc:

The utilization of already introduced utility functions and types can be used to implement the following BlockState methods.

IsDescendantOf(parent, child common.Hash) (bool, error)
LowestCommonAncestor(a, b common.Hash) (common.Hash, error)
Range(startHash, endHash common.Hash) (hashes []common.Hash, err error)
RangeInMemory(start, end common.Hash) ([]common.Hash, error)

IsDescendantOf can be found in client/api/utils (see code).

LowestCommonAncestor can be found in primitives/blockchain (see code)

Range and RangeInMemory can be implemented by using blockchain.TreeRoute. The constructor NewTreeRoute takes a start and end block hash. We should also remove the usage of RangeInMemory given that all finalized and non-finalized blocks are now in the same db.Backend. So a small refactor to the only external usage in dot/core should be updated to use Range.

These functions should be added to the translation shim since they are used externally from dot/state.

Acceptance Criteria

  • Implementation of utility functions.
  • Unit tests.
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

No branches or pull requests

1 participant