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

Update Synedrion usage to v0.0.12 #535

Merged
merged 2 commits into from
Nov 28, 2023
Merged

Update Synedrion usage to v0.0.12 #535

merged 2 commits into from
Nov 28, 2023

Conversation

fjarri
Copy link
Member

@fjarri fjarri commented Nov 28, 2023

(had to move #525 from my fork to the main repo because CircleCI sucks)

  • Fixes Move to a tagged release of synedrion, not a branch with a fix #509
  • Fixes Refactor pre protocol execution  #416
  • Public vs AccountId32 #376 is still open: even though we're using PublicKey instead of Public now, the problem still stands: we have AccountId32 and Public with identical contents.
  • VerifierWrapper was removed, PartyId now implements the necessary traits directly.
  • ProtocolMessage does not make a distinction between broadcast and direct messages anymore, since our messaging is direct-only. There is still a distinction in the protocol execution loop, but it will be removed when message bundling is implemented (see Message bundling synedrion#62)
  • Removed a check for messages sent to ourselves in the protocol loop because evidently it is now checked in protocol_transport/mod.rs
  • Generalized the three protocol loops.
  • Note that "my_idx" is not being passed anymore from the upper levels; this information is already present in the relation between the signer and the verifiers, and if the signer's key is not present among the verifiers, there will be an error on the session creation stage (synedrion::sessions::Error::Local).

Copy link

vercel bot commented Nov 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
entropy-core 🔄 Building (Inspect) Visit Preview Nov 28, 2023 8:01pm

Copy link
Contributor

@ameba23 ameba23 left a comment

Choose a reason for hiding this comment

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

i already approved the PR from the fork version - assuming this is the same

@fjarri fjarri merged commit bee9f71 into master Nov 28, 2023
10 checks passed
@fjarri fjarri deleted the fjarri/update-synedrion branch November 28, 2023 21:12
Copy link
Collaborator

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Mostly just questions since I'm not familiar with this stuff yet 😄

.into_iter()
.map(|acc| VerifierWrapper(sr25519::Public(acc.0)))
.collect::<Vec<_>>();
let pair = PairWrapper(threshold_pair.clone());

// TODO (#375): this should come from whoever initiates the signing process,
// (or as some deterministic function, e.g. the hash of the last block mined)
// and be the same for all participants.
let shared_randomness = b"123456";
Copy link
Collaborator

Choose a reason for hiding this comment

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

lol

@@ -27,7 +27,6 @@ pub async fn do_dkg(
signer: &PairSigner<EntropyConfig, sr25519::Pair>,
state: &ListenerState,
sig_request_account: AccountId32,
my_subgroup: &u8,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll need to remove this from the fields list above

from: &PartyId,
to: &PartyId,
payload: SignedMessage<sr25519::Signature>,
) -> Self {
Self { from: from.clone(), to: Some(to.clone()), payload }
Self { from: from.clone(), to: to.clone(), payload }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you didn't introduce this, but it might be nicer to take owned values in the function and have the caller potentially allocate up-front

Copy link
Member Author

Choose a reason for hiding this comment

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

Even better, PartyId should just implement Copy.

fn to_public(&self) -> sr25519::Public {
// TODO (#376): assuming that `Public` and `AccountId32` represent the same 32 bytes.
// Ideally we should use only one of those throughout the code, probably `Public`.
sr25519::Public(self.0 .0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bit of a random question, but do you know why this gets formatted like this instead of self.0.0?

// Send out broadcasts
let destinations = session.broadcast_destinations();
if let Some(destinations) = destinations {
// TODO: this can happen in a spawned task
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should make an issue for this and either annotate the TODOs or get rid of them

tx.send(ProtocolMessage::new(&my_id, destination, message))?;

// This will happen in a host task
accum.add_artefact(artefact)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
accum.add_artefact(artefact)?;
accum.add_artifact(artifact)?;

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I was using British spelling here, which I thought was the only one, but only later realized that there are two variants. I don't mind switching to the American spelling, but I need to change it in Synedrion for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha, didn't realize there was a British spelling for this. For APIs though I'd stick to American English since that's the most common thing in tech

Ok(())
} else {
Err(signature::Error::new())
async fn execute_protocol_generic<Res: ProtocolResult>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be useful to annotate this with #[tracing::instrument] and have some events throughout the execution flow

loop {
let mut accum = session.make_accumulator();

// Send out broadcasts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since I'm not familiar with this bit of the code, can you explain the difference between sending out and broadcast and sending direct messages and why both are needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

The difference is basically that the broadcast message is prepared once for all destinations, and the direct ones are prepared for each destination separately. Since it takes some times to generate the proofs (and I wanted to leave a possibility of parallelizing the process), it is a meaningful distinction. It could also affect the way we send the messages out, but since we don't have access to a broadcast channel, it doesn't.

That said, I'm planning to simplify the API by only sending one message per destination - entropyxyz/synedrion#62

accum.add_processed_message(processed)??;
}

while !session.can_finalize(&accum)? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does it mean for a session to get "finalized"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, perhaps a better name for this object is Round, since we create a new one for every round. If that is what you meant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or I suppose the method can be called finalize_round()

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was more asking about the conditions around a session/round being finalized, and any guarantees or assumptions that can come afterwards

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, at this stage you merge the info you got from all the other parties during the round. finalize() contains anything that needs more than just the initial state of the round and the message from one node. For example, summing up secret share changes coming from other nodes. If it fails, that's when the "correctness proofs" become necessary, because you can't pinpoint the malicious node, so you can only generate a proof that you yourself did everything correctly and publish it.

@HCastano HCastano changed the title Fjarri/update synedrion Update Synedrion usage to v0.0.12 Nov 30, 2023
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.

Move to a tagged release of synedrion, not a branch with a fix Refactor pre protocol execution
3 participants