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

Add test environment with four TS servers #1029

Merged
merged 20 commits into from
Sep 2, 2024
Merged

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Aug 26, 2024

For some tests it would be useful to have four TS servers - in particular the reshare tests, so that we can test adding and removing members of the signing committee during a reshare.

My personal motivation is that i am thinking to request an attestation from the new member of the signing committee before doing a reshare - and ideally i would like to test the new session handler as part of this.

This PR makes the integration test chainspec have 4 TS servers, and leaves the 'dev' chainspec with only 3 as before. Since the extra node, Dave, is not in the initial signing committee and has no initial keyshares, most of our exisiting tests which use the integration test chainspec should continue to work as they are.

This also extends the reshare test to demonstrate siging a message after a reshare. This closes #981 and partially #1010 - i say partially because although we test signing after a reshare, we mock the initial jumpstart DKG part - so its not really testing the complete process.

Im willing to close this if people think that testing with 4 TS servers is going to make our tests too heavy in terms of resources.

@ameba23 ameba23 marked this pull request as draft August 26, 2024 10:04
next_signers: self.mock_signer_rotate.clone().1,
confirmations: vec![],
});
let next_signers = &mut self.mock_signer_rotate.1.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hasn't changed how we interpret mock_signer_rotate - but it wasn't working for me as it was. I think it was mutating a clone of self.mock_signer_rotate but then using a different clone for next signers.

@ameba23 ameba23 marked this pull request as ready for review August 28, 2024 10:35

/// A helper for setting up tests which starts both a set of TS servers and a chain node and returns
/// the chain API as well as IP addresses and PartyId of the started validators
pub async fn spawn_tss_nodes_and_start_chain(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't strictly related to this PR, but since adding a way to specify which chainspec you want to use, i also added this helper which could slightly reduce boilerplate in our tests.

So this would go at the beginning of most of our tests. I haven't actually called this anywhere yet though - i wanted to run it by yous first.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this for sure 👍

use sp_keyring::AccountKeyring;
use subxt::utils::AccountId32;
use synedrion::k256::ecdsa::VerifyingKey;

#[tokio::test]
#[serial]
async fn test_reshare() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we try out the 4 node setup with a reshare moving the signers from alice, bob and charlie to bob, charlie and dave.

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.

Tbh not a fan of spinning up four nodes as part of each test, but it's one of those things that if we need to do it to get sufficient test coverage then it is what is it 🤷

Would be curious about what kind of system resources we're consuming and if this is really a concern though.

crates/threshold-signature-server/src/helpers/tests.rs Outdated Show resolved Hide resolved
},
Hasher,
};
use entropy_client::{register, sign, store_program};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm personally a fan of the use entropy_client as test _client import since in the test it's clear that these functions are coming from the client and not part of this crate


/// A helper for setting up tests which starts both a set of TS servers and a chain node and returns
/// the chain API as well as IP addresses and PartyId of the started validators
pub async fn spawn_tss_nodes_and_start_chain(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this for sure 👍

@ameba23
Copy link
Contributor Author

ameba23 commented Aug 30, 2024

Tbh not a fan of spinning up four nodes as part of each test, but it's one of those things that if we need to do it to get sufficient test coverage then it is what is it 🤷

I hear you. Having choice between development or integration test setup is not so helpful, because if i understand correctly, we need the integration test setup's force authoring thingy in order to jumpstart the network - which is pretty much all of our tests - meaning we always use four nodes.

It is actually possible to use the integration test chainspec and only 3 TSS nodes. I tried it and for registering and signing, no-one complains that dave is not there. Its only for a reshare that dave is needed. But it still kinda feels wrong to have dave in the chainspec and not be running.

So one option to solve this might be to add the force authoring stuff to the development chainspec, and then use that for all the tests which don't involve a reshare.

Would be curious about what kind of system resources we're consuming and if this is really a concern though.

Tbh i think in comparison to the chain node it is relatively little. Especially as we don't actually run the TSS servers in separate OS processes - its just one entropy-tss process with axum serving on different ports and using different files for the kvdb.

@ameba23 ameba23 merged commit 4c99706 into master Sep 2, 2024
8 checks passed
@ameba23 ameba23 deleted the peg/test-with-4-tss-nodes branch September 2, 2024 17:35
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.

Key reshare test should demonstrate signing a message following a reshare
2 participants