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

[1.x] Externalize group state storage, an alternative #256

Open
mulmarta opened this issue Feb 18, 2025 · 0 comments
Open

[1.x] Externalize group state storage, an alternative #256

mulmarta opened this issue Feb 18, 2025 · 0 comments

Comments

@mulmarta
Copy link
Contributor

Problem:

We want to remove the GroupStateStorage trait in favor of application managing storage. This is a possible alternative to #211.

Solution:

A group member will use the following code to process a proposal_message and a commit_message that includes proposal_message by reference.

// Receive proposal
let ProtocolMessage {
    group_id: &'a [u8],
    epoch_id: u64,
    content_type: ContentType::Proposal,
} = proposal_message.description()
else {
    // Do something else
};

let epoch = my_storage.load_epoch(group_id, epoch_id)?;

// Decrypt and verify auth of proposal
let proposal: Proposal = client.process_proposal(&epoch, proposal_message)?;

// Receive commit
let ProtocolMessage {
    content_type: ContentType::Commit,
    ..
} = commit_message.description()
else {
    // Do something else
};

// Currently `new_epoch_builder` would be `commit_processor`
let commit_effect = client
    .new_epoch_builder(epoch, commit_message)?
    .with_proposal(proposal)
    .with_psk(my_storage.load_psk(builder.required_psks()[0])?)
    .override_proposals(my_proposal_rules(builder.proposals())?)
    .build()?;

// Delete epoch for that group. Store updated epoch and past epoch for late application messages
my_storage.store_epoch(commit_effect.new_epoch, commit_effect.past_epoch)?;

where

CommitEffect {
    epoch: Option<GroupState>, // None if we're removed
    past_epoch: PastEpoch,
    // other info
}
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

1 participant