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

Avoid expect and repeated data deserialization in QBFT #127

Closed
dknopik opened this issue Feb 6, 2025 · 0 comments
Closed

Avoid expect and repeated data deserialization in QBFT #127

dknopik opened this issue Feb 6, 2025 · 0 comments

Comments

@dknopik
Copy link
Member

dknopik commented Feb 6, 2025

Currently, we have several occurrences of expect in QBFT. It would be nicer if we can avoid them altogether through some refactoring. Furthermore, there is some repeated deserialisation in some code paths, which would also be nice to avoid. Ways to achieve this might be:

  1.  struct HashAndData<D: QbftData> {
         hash: D::Hash,
         data: Arc<D>,
     }
    This struct could be introduced and passed around, avoiding multiple deserialisations. It is lightweight, as the full data lives on the stack. We could also put this in our main Qbft struct everywhere where we currently have D::Hash, as we avoid data lookups from the map (and associated expects that way).
  2. Some data is always present if we are in certain states, e.g. proposal_root is always set if we are in state Prepare or further. We could therefore add this as a field to the Prepare and further variants, avoiding the Option and related expects.
  3. Other smaller local refactoring, like pattern matching on slices to assert that something has exactly one element and then getting it.
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

2 participants