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

Pico consensus #3285

Open
wants to merge 4 commits into
base: albatross
Choose a base branch
from
Open

Pico consensus #3285

wants to merge 4 commits into from

Conversation

viquezclaudio
Copy link
Member

@viquezclaudio viquezclaudio commented Feb 11, 2025

Pico Consensus Implementation

The PicoMacroSync is a macro sync mechanism that pushes the latest election block
that is obtained from a peer, if subsequent (sufficient) peers also have the same latest election
(and latest checkpoint blocks) then we move all the peers to live sync and we establish consensus.
If some peer has a different state than the initial state we obtained, we need to fallback to the
regular light macro sync.

To use it or try it in the web client:
web-client/src/client/lib.rs

let mut config = builder.volatile().pico().build().expect("Build configuration failed");

You can also set consensus sync mode to 'pico' if you want to test it in a light client

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@viquezclaudio viquezclaudio force-pushed the viquezcl/pico-consensus branch 8 times, most recently from 872c575 to 29a54cf Compare February 12, 2025 22:34
@viquezclaudio viquezclaudio marked this pull request as ready for review February 12, 2025 22:35
@@ -4,4 +4,4 @@ mod sync_stream;
#[cfg(feature = "full")]
mod validity_window;

pub use sync::LightMacroSync;
pub use sync::{EpochIds, LightMacroSync, PeerMacroRequests};
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to make it public?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because they need to be accesible from the pico variant, otherwise:

rror[E0432]: unresolved imports `crate::sync::light::EpochIds`, `crate::sync::light::PeerMacroRequests`
  --> consensus/src/sync/pico/sync_requests.rs:17:17
   |
17 |         light::{EpochIds, PeerMacroRequests},
   |                 ^^^^^^^^  ^^^^^^^^^^^^^^^^^ no `PeerMacroRequests` in `sync::light`
   |                 |
   |                 no `EpochIds` in `sync::light`
   |
note: these structs exist but are inaccessible

Copy link
Member Author

Choose a reason for hiding this comment

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

Another option would be to move those structs to some shared file between light and macro sync

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, to me it means they maybe don't belong here

));
}
} else {
// We only accept macro blocks from the current epoch
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we check this is a macro block?

@jsdanielh
Copy link
Member

Could you also consider adding a pico node to the devnet scenarios? I think it would be valuable to test it as well

@viquezclaudio viquezclaudio force-pushed the viquezcl/pico-consensus branch 2 times, most recently from 8e4b560 to ba33b5e Compare February 14, 2025 16:43
The PicoMacroSync is a macro sync mechanism that pushes the latest election block
that is obtained from a peer, if subsequent (sufficient) peers also have the same latest election
(and latest checkpoint blocks) then we move all the peers to live sync and we establish consensus.
If some peer has a different state than the initial state we obtained, we need to fallback to the
regular light macro sync.
@viquezclaudio viquezclaudio force-pushed the viquezcl/pico-consensus branch from ba33b5e to cd63bab Compare February 14, 2025 16:58
Create a sync_interface file where common functionality from the different
sync implementations can be imported
@viquezclaudio viquezclaudio force-pushed the viquezcl/pico-consensus branch from e750ddc to b1b7cdd Compare February 14, 2025 20:40
@viquezclaudio viquezclaudio force-pushed the viquezcl/pico-consensus branch from 3ab735b to da6079e Compare February 17, 2025 16:17
When processing epoch ids it could happen that by the time we requested the epoch ids
and the time we received those we no longer have anything new to learn from the peer,
so we emit it as good.
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.

2 participants