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

Add nomad v1 primitives #79

Merged

Conversation

luketchang
Copy link
Contributor

Adds necessary Nomad primitives to Avail

  • Moves Avail-specific primitives into its own crate primitives/avail
  • Adds primitives/nomad which contains:
    • merkle: light merkle tree implementation
    • signature: Ethereum-specific ECDSA signature implementation
    • nomad-core: core message and update types
    • nomad-base: abstraction around Nomad updater and domain-specific info

primitives/avail/src/traits.rs Outdated Show resolved Hide resolved
primitives/nomad/merkle/src/lib.rs Outdated Show resolved Hide resolved
primitives/nomad/merkle/src/light.rs Show resolved Hide resolved
primitives/nomad/merkle/src/light.rs Outdated Show resolved Hide resolved
primitives/nomad/merkle/src/light.rs Outdated Show resolved Hide resolved
primitives/nomad/nomad-core/src/utils.rs Outdated Show resolved Hide resolved
primitives/nomad/signature/src/signature.rs Outdated Show resolved Hide resolved
primitives/nomad/signature/src/signature.rs Outdated Show resolved Hide resolved
sig[32..64].copy_from_slice(&s_bytes);
// TODO: What if we try to serialize a signature where
// the `v` is not normalized?
sig[64] = src.v as u8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Casting from a larger integer to a smaller integer (e.g. u32 -> u8) will truncate.
If that is not safe, pls use u8::try_from(src.v) instead.

Copy link
Contributor Author

@luketchang luketchang Sep 15, 2022

Choose a reason for hiding this comment

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

This is safe because sig.v can only ever be 27 or 28 here. Regarding EIP-155 (which isn't relevant because this signature is only for attestations not txs), this is only applied for transaction signing and this happens after the fact (after signature is created, you manually change the v value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment above line to clarify

primitives/nomad/signature/src/utils.rs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Base: 46.96% // Head: 44.91% // Decreases project coverage by -2.05% ⚠️

Coverage data is based on head (a38bd88) compared to base (40145ca).
Patch coverage: 64.92% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #79      +/-   ##
===========================================
- Coverage    46.96%   44.91%   -2.06%     
===========================================
  Files           44       61      +17     
  Lines         9815    11509    +1694     
===========================================
+ Hits          4610     5169     +559     
- Misses        5205     6340    +1135     
Impacted Files Coverage Δ
primitives/avail/src/asdr.rs 87.50% <ø> (ø)
...imitives/avail/src/asdr/app_unchecked_extrinsic.rs 73.04% <ø> (ø)
primitives/avail/src/asdr/data_lookup.rs 91.66% <ø> (ø)
primitives/avail/src/asdr/get_app_id.rs 100.00% <ø> (ø)
primitives/avail/src/header.rs 48.44% <0.00%> (ø)
primitives/avail/src/kate_commitment.rs 43.24% <ø> (ø)
primitives/avail/src/lib.rs 11.11% <ø> (ø)
primitives/avail/src/traits.rs 7.08% <0.00%> (ø)
primitives/nomad/merkle/src/error.rs 7.56% <2.94%> (ø)
primitives/nomad/merkle/src/lib.rs 14.28% <14.28%> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@aterentic-ethernal aterentic-ethernal left a comment

Choose a reason for hiding this comment

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

@luketchang , thanks for contribution, Ill merge this PR. Just small note, if possible, lets clean up top level dependencies in next PRs.

@aterentic-ethernal aterentic-ethernal merged commit 799a215 into availproject:develop Sep 18, 2022
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.

5 participants