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

Custom masp epoch tracker #3318

Merged
merged 17 commits into from
Jun 6, 2024
Merged

Custom masp epoch tracker #3318

merged 17 commits into from
Jun 6, 2024

Conversation

grarco
Copy link
Contributor

@grarco grarco commented May 27, 2024

Describe your changes

Closes #2833.

This PR tracks masp epochs differently from the usuale Epoch. A new protocol parameter defines a multiplicative factor that defines a masp epoch in terms on normal epoch (as in, every x normal epochs a new masp epochs starts). This way we can decouple the update logic of the the masp conversion tree from the rest of the protocol.

A new MaspEpoch is introduced: this is just a wrapper type around Epoch to make sure we don't pass the wrong epoch to masp functions that deal with masp epochs.

Indicate on which release or other PRs this topic is based on

v0.38.1

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

grarco added a commit that referenced this pull request May 27, 2024
Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 52.04082% with 94 lines in your changes missing coverage. Please review.

Project coverage is 54.05%. Comparing base (883bd0f) to head (786dce4).

Files Patch % Lines
crates/namada/src/ledger/native_vp/masp.rs 0.00% 17 Missing ⚠️
crates/core/src/masp.rs 59.37% 13 Missing ⚠️
crates/node/src/shell/testing/node.rs 0.00% 13 Missing ⚠️
crates/sdk/src/queries/shell.rs 0.00% 13 Missing ⚠️
crates/apps_lib/src/client/rpc.rs 0.00% 9 Missing ⚠️
crates/sdk/src/rpc.rs 0.00% 7 Missing ⚠️
crates/sdk/src/masp.rs 0.00% 6 Missing ⚠️
crates/node/src/bench_utils.rs 0.00% 5 Missing ⚠️
crates/apps_lib/src/cli.rs 0.00% 4 Missing ⚠️
crates/apps_lib/src/client/tx.rs 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3318    +/-   ##
========================================
  Coverage   54.05%   54.05%            
========================================
  Files         315      315            
  Lines      106296   106433   +137     
========================================
+ Hits        57461    57536    +75     
- Misses      48835    48897    +62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cwgoes cwgoes mentioned this pull request May 28, 2024
@grarco grarco force-pushed the grarco/masp-custom-epoch branch 2 times, most recently from d778188 to 9eef322 Compare May 28, 2024 23:19
@grarco grarco marked this pull request as ready for review May 29, 2024 09:03
@grarco grarco requested review from murisi, sug0, batconjurer and yito88 and removed request for sug0 May 29, 2024 09:03
@@ -579,10 +579,13 @@ fn pgf_over_ibc_with_hermes() -> Result<()> {

#[test]
fn proposal_ibc_token_inflation() -> Result<()> {
const MASP_EPOCH_MULTIPLIER: u64 = 2;
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 param seems to make the test fail (if we set it to 1 instead it works). @yito88 investigated the issue and found out that an update to Hermes solves it and makes this test pass

@brentstone brentstone mentioned this pull request May 31, 2024
crates/core/src/masp.rs Outdated Show resolved Hide resolved
crates/core/src/masp.rs Outdated Show resolved Hide resolved
crates/core/src/masp.rs Show resolved Hide resolved
@@ -46,6 +46,9 @@ pub struct Parameters {
pub implicit_vp_code_hash: Option<Hash>,
/// Expected number of epochs per year (read only)
pub epochs_per_year: u64,
/// The multiplier for masp epochs (it requires this amount of epochs to
/// transition to the next masp epoch)
pub masp_epoch_multiplier: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub masp_epoch_multiplier: u64,
pub masp_epoch_multiplier: NonZeroU64,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this one but we have also other parameters that could benefit from this. Should this become a wider refactor?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, replacing primitive integer types with their nonzero equivalents where prudent

Choose a reason for hiding this comment

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

Definitely helpful, because if max_proposal_bytes_key is set to 0, it will cause a consensus failure, crash the nodes and halt the chain.

Also, setting max_block_gas to 0, or at least lower than the minimum required for a transaction, will make the chain non-interactable, but the protocol people told me that is acceptable risk.

crates/node/src/shell/finalize_block.rs Show resolved Hide resolved
crates/node/src/shell/finalize_block.rs Show resolved Hide resolved
crates/node/src/shell/testing/node.rs Show resolved Hide resolved
crates/node/src/shell/testing/node.rs Show resolved Hide resolved
@sug0 sug0 self-requested a review June 2, 2024 07:50
@grarco grarco mentioned this pull request Jun 2, 2024
Copy link
Contributor

@murisi murisi left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks!

Fraccaman added a commit that referenced this pull request Jun 3, 2024
* up/grarco/masp-custom-epoch:
  Const masp epoch functions
  Fmt
  Changelog #3318
  Changes masp epoch multiplier in ibc proposal test
  Fixes benchmarks
  Fixes ibc e2e test
  Fixes integration tests
  Adds test for masp epoch progression
  Helper function for masp epoch parameter. Fixes bug in masp epoch detection
  Tracks `masp_epoch_multiplier` parameter
  Fallible masp epoch conversion
  Refactors `is_masp_new_epoch`
  Refactors `calculate_masp_rewards`
  Introduces `MaspEpoch` for type safety and a covnersion method from a normal `Epoch`
  Changes epochs to masp epochs where needed. Extends some traits to return this value
  Refactors masp epoch
  Adds masp custom epoch
brentstone added a commit that referenced this pull request Jun 5, 2024
* origin/grarco/masp-custom-epoch:
  Const masp epoch functions
  Fmt
  Changelog #3318
  Changes masp epoch multiplier in ibc proposal test
  Fixes benchmarks
  Fixes ibc e2e test
  Fixes integration tests
  Adds test for masp epoch progression
  Helper function for masp epoch parameter. Fixes bug in masp epoch detection
  Tracks `masp_epoch_multiplier` parameter
  Fallible masp epoch conversion
  Refactors `is_masp_new_epoch`
  Refactors `calculate_masp_rewards`
  Introduces `MaspEpoch` for type safety and a covnersion method from a normal `Epoch`
  Changes epochs to masp epochs where needed. Extends some traits to return this value
  Refactors masp epoch
  Adds masp custom epoch
@brentstone brentstone merged commit 29a2e72 into main Jun 6, 2024
15 of 19 checks passed
@brentstone brentstone deleted the grarco/masp-custom-epoch branch June 6, 2024 07:53
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.

Investigate whether we can create a second MASP epoch tracker
5 participants