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

Fix how pre-generated keyshares are added for tests #1061

Merged
merged 22 commits into from
Sep 25, 2024

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Sep 23, 2024

#1053 introduced random selection of initial signing set on jumpstart, but our pre-generated keyshares were always being added to alice, bob and charlies kvdbs, regardless of whether they were selected as initial signers.

This fixes that - the pre-generated keyshares are given to whoever is initially selected to be a signer.

@ameba23 ameba23 mentioned this pull request Sep 23, 2024
chain_spec_type: ChainSpecType,
) -> (OnlineClient<EntropyConfig>, LegacyRpcMethods<EntropyConfig>, Vec<String>, Vec<PartyId>) {
let (validator_ips, validator_ids) =
spawn_testing_validators(add_parent_key, chain_spec_type.clone()).await;
let (validator_ips, validator_ids) = spawn_testing_validators(chain_spec_type.clone()).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ty

Comment on lines 228 to 234
let port = match validator_name {
ValidatorName::Alice => 3001,
ValidatorName::Bob => 3002,
ValidatorName::Charlie => 3003,
ValidatorName::Dave => 3004,
_ => panic!("Unexpected validator name"),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

If the ValidatorName enum is just for testing, you could use the discriminant to calculate the port:

let port = ValidatorName::Bob as usize + 2

You can also just set the enum variant discriminant directly if you want.

_ => panic!("Unexpected validator name"),
};

// let port = 3001 + (validator_name as usize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, missed this. Why not do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gonna do this 👍

Comment on lines +306 to +310
.is_ok()
{
put_keyshares_in_db(keyshare_index, validator_name).await;
keyshare_index += 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work here to get rid of the if?

.await
  .and_then(|| {
    put_keyshares_in_db(keyshare_index, validator_name).await;
    keyshare_index += 1;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is the await. Do you know how to do that async?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm terrible at async rust but it feels like it should be possible. :/

Copy link
Member

Choose a reason for hiding this comment

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

it should be ok to do a .and_then(|| async { should be maybe probably

@ameba23
Copy link
Contributor Author

ameba23 commented Sep 23, 2024

Converting to draft as two tests are failing locally (And CI is stuck: https://github.com/entropyxyz/devops-infrastructure/issues/66 )

@ameba23 ameba23 marked this pull request as draft September 23, 2024 11:17
@ameba23
Copy link
Contributor Author

ameba23 commented Sep 24, 2024

I am a little bit stuck on getting the reshare test to pass.

There are some issues with the block number having 1 subtracted from it which were not made clear before, because the OcwMessage which actually got passed from the chain was not needed since alice was no longer a signer, and the other OcwMessages which were mocked worked correctly. Now we do need alice to participate in the reshare, and things are not working.

@JesseAbram JesseAbram marked this pull request as ready for review September 24, 2024 21:45
@JesseAbram JesseAbram merged commit 2800d61 into master Sep 25, 2024
8 checks passed
@JesseAbram JesseAbram deleted the peg/fix-pregenerated-keyshares branch September 25, 2024 18:06
ameba23 added a commit that referenced this pull request Oct 2, 2024
* master:
  Bump clap from 4.5.18 to 4.5.19 in the patch-dependencies group (#1091)
  Avoid panic by checking that we have a non-signing validator before selecting one (#1083)
  Fix master build (#1088)
  Small fixes to `test-cli` (#1084)
  Pregenerate keyshares sets for all possible initial signer comittees (#1073)
  Fix master build (#1079)
  Bump reqwest from 0.12.7 to 0.12.8 in the patch-dependencies group (#1082)
  Block tss chain when signer (#1078)
  Run multiple test validator (#1074)
  Bump tempfile from 3.12.0 to 3.13.0 (#1076)
  Bump axum from 0.7.6 to 0.7.7 in the patch-dependencies group (#1075)
  Unignore register and sign integration test, and do a non-mock jumpstart (#1070)
  No unbonding when signer or next signer (#1031)
  Add `/relay_tx` endpoint (#1050)
  Fix how pre-generated keyshares are added for tests (#1061)
  Handle Provisioning Certification Keys (PCKs) (#1051)
  Bump async-trait from 0.1.82 to 0.1.83 in the patch-dependencies group (#1067)
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.

3 participants