Skip to content

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

@mulmarta

Description

@mulmarta

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions