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

gossip: process duplicate proofs for chained merkle root conflicts #1352

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AshwinSekar
Copy link

@AshwinSekar AshwinSekar commented May 14, 2024

Problem

With the addition of chained merkle shreds, there is a new class of duplicate proofs available to be gossiped

Summary of Changes

Add a check for chained merkle root conflict proofs:

  • Lower fec set shred must be a coding shred
  • Fec sets are adjacent
  • Merkle root of the lower fec set must not equal the chained merkle root of the higher fec set

Fixes solana-labs#34897

@AshwinSekar AshwinSekar force-pushed the gossip-chain-dup-proof branch 3 times, most recently from 3d54b25 to 18f0922 Compare June 4, 2024 16:52
@AshwinSekar AshwinSekar marked this pull request as ready for review June 4, 2024 16:54
});

if let Some(erasure_meta) = ErasureMeta::from_coding_shred(first_shred) {
if allow_chained_duplicate_proofs
Copy link
Author

Choose a reason for hiding this comment

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

we need to feature gate this because until chained merkle shreds are turned on, this check can be exploited to mark every block as duplicate.

Choose a reason for hiding this comment

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

Shouldn't this whole thing be inside if allow_chained_duplicate_proofs { ... } block?

Choose a reason for hiding this comment

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

also can you please include this github comment in the code as a comment?

leader_schedule,
&shred,
&other_shred,
/* allow_chained_duplicate_proofs */ true,
Copy link
Author

Choose a reason for hiding this comment

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

we don't need to feature gate this because it is already gated in window service.

Choose a reason for hiding this comment

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

can you please include this comment in the code.

Choose a reason for hiding this comment

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

also this is pretty risky assumption that the caller will not invoke this code if the feature is not activated.
Is it possible to expose this as an argument to this function and let a caller higher in the stack set it to true.

Copy link

mergify bot commented Jun 4, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

Copy link

@behzadnouri behzadnouri left a comment

Choose a reason for hiding this comment

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

the feature-gate thing makes this a bit more complicated and difficult to understand.
is it possible to wait until chained merkle shreds are activated before merging this change?

the code is not going to be invoked anyways until chained merkle shreds are activated, and once all shreds are chained, maybe this code will be easier and simpler.

Comment on lines +136 to +141
let first_shred = std::cmp::min_by(shred1, shred2, |s1, s2| {
s1.fec_set_index().cmp(&s2.fec_set_index())
});
let second_shred = std::cmp::max_by(shred1, shred2, |s1, s2| {
s1.fec_set_index().cmp(&s2.fec_set_index())
});

Choose a reason for hiding this comment

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

wouldn't this set first_shred = second_shred = shred1 if both shreds have the same fec_set_index?

});

if let Some(erasure_meta) = ErasureMeta::from_coding_shred(first_shred) {
if allow_chained_duplicate_proofs

Choose a reason for hiding this comment

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

Shouldn't this whole thing be inside if allow_chained_duplicate_proofs { ... } block?

});

if let Some(erasure_meta) = ErasureMeta::from_coding_shred(first_shred) {
if allow_chained_duplicate_proofs

Choose a reason for hiding this comment

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

also can you please include this github comment in the code as a comment?

leader_schedule,
&shred,
&other_shred,
/* allow_chained_duplicate_proofs */ true,

Choose a reason for hiding this comment

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

can you please include this comment in the code.

leader_schedule,
&shred,
&other_shred,
/* allow_chained_duplicate_proofs */ true,

Choose a reason for hiding this comment

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

also this is pretty risky assumption that the caller will not invoke this code if the feature is not activated.
Is it possible to expose this as an argument to this function and let a caller higher in the stack set it to true.

Comment on lines 47 to +51
cached_on_epoch: Epoch,
cached_staked_nodes: Arc<HashMap<Pubkey, u64>>,
cached_slots_in_epoch: u64,
cached_epoch_schedule: EpochSchedule,
cached_feature_set: FeatureSet,

Choose a reason for hiding this comment

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

maybe we should just hold on the root-bank instead of all this.

@AshwinSekar
Copy link
Author

the feature-gate thing makes this a bit more complicated and difficult to understand. is it possible to wait until chained merkle shreds are activated before merging this change?

the code is not going to be invoked anyways until chained merkle shreds are activated, and once all shreds are chained, maybe this code will be easier and simpler.

yep that's fine by me, will make the code a lot simpler as well

@AshwinSekar AshwinSekar marked this pull request as draft June 6, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate duplicate proofs for blocks with incorrectly chained merkle roots
2 participants