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

Signing flow with derived accounts #990

Merged
merged 19 commits into from
Aug 14, 2024
Merged

Signing flow with derived accounts #990

merged 19 commits into from
Aug 14, 2024

Conversation

HCastano
Copy link
Collaborator

@HCastano HCastano commented Aug 7, 2024

This PR allows signature requests to happen using the new derived account flow that was
implemented in #955. I've implemented it in such a way that the old registration and signing
flow is also valid as I didn't want to break everything.

I want to have a few follow up PRs related to this in order to keep the review queue
manageable:

  • After this gets merged I want to update the entropy-test-cli to support the new
    derived flows and ensure everything works
  • Following that we can start getting rid of old code
  • Related to the above, at that point I want to start improving the test coverage for
    both the registration and signing flows, using the tests from the old flows as a
    reference to try and avoid losing coverage
  • Implement the message passing as described in the Tofino spec

@HCastano HCastano force-pushed the hc/new-signing-flow branch from 1a4a39c to 117d420 Compare August 12, 2024 16:15
@HCastano HCastano marked this pull request as ready for review August 13, 2024 16:50
@HCastano HCastano requested review from JesseAbram and ameba23 August 13, 2024 16:50
@@ -119,6 +119,8 @@ pub mod pallet {
pub struct RegisteredInfo<T: Config> {
pub programs_data: BoundedVec<ProgramInstance<T>, T::MaxProgramHashes>,
pub program_modification_account: T::AccountId,
/// The SCALE encoded BIP-32 `DerivationPath` used to register this account.
pub derivation_path: Option<Vec<u8>>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JesseAbram do you know what kind of runtime version bump we'd need for this? For the release it doesn't make a difference since we're bumping everything anyways, but I'm more curious in case we ever do this as a one-off thing

Copy link
Member

Choose a reason for hiding this comment

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

tbh I just click all of them and let you tell me which one it was

pub signature_verifying_key: Vec<u8>,
}

pub async fn get_signers_from_chain(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
with_parent_key: bool,
Copy link
Member

Choose a reason for hiding this comment

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

ehhh maybe a get signers from chain and a get validators from chain function makes more sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't disagree, but for the case of this function it is always getting the signers. The difference between both arms here is that the signers are either: queried directly or grabbed from the validator set.

@@ -119,6 +119,8 @@ pub mod pallet {
pub struct RegisteredInfo<T: Config> {
pub programs_data: BoundedVec<ProgramInstance<T>, T::MaxProgramHashes>,
pub program_modification_account: T::AccountId,
/// The SCALE encoded BIP-32 `DerivationPath` used to register this account.
pub derivation_path: Option<Vec<u8>>,
Copy link
Member

Choose a reason for hiding this comment

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

tbh I just click all of them and let you tell me which one it was

crates/threshold-signature-server/Cargo.toml Show resolved Hide resolved
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.

Great to see this working. This all happened faster than i imagined it would.

And im looking forwards to seeing the old stuff removed and hopefully everything a bit cleaner. Also looking forwards to being able to try this out with docker-compose and the test cli.

crates/client/src/client.rs Show resolved Hide resolved
// TODO #899 For now we just take the first t validators as the ones to perform signing
validators.sort();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine for now to not sort - but the reason we have this was because of query results coming back in a different order with polkadot js vs subxt. So the idea was to sort before truncating.

If the plan is that this fn should no longer be called by both the client and the TS server then we need to remove it from entropy-client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it will still be called by both. Probably safer to keep the sorting

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ameba23 when I sorted the signers coming from the on-chain flow the signing test started failing. Not entirely sure why 🤷

@@ -207,22 +213,41 @@ pub async fn sign_tx(
request_author,
};

let _has_key = check_for_key(&string_verifying_key, &app_state.kv_store).await?;
// In the new registration flow we don't store the verifying key in the KVDB, so we only do this
// check if we're using the old registration flow
Copy link
Contributor

Choose a reason for hiding this comment

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

But we could still check here if we are currently in the signing committee. But i guess theres no point as we are about to attempt to get the parent keyshare in get_sign_context anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We weren't checking for inclusion in the signing committee here anyways, so maybe I'm misunderstanding your comment

@@ -362,6 +364,134 @@ async fn test_sign_tx_no_chain() {
clean_tests();
}

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

Choose a reason for hiding this comment

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

Could we now remove the new registration flow test below? Is there anything in it which is not repeated here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to keep them separate. We already have enough tests that conflate what their actual purpose is. What I'd want to do instead is trim down some of the code in the signing test to be the bare minimum setup we need - but I wasn't sure what the best way to do that yet so I left it in full.

@HCastano HCastano added the Bump `spec_version` A change which affects the current runtime behaviour label Aug 14, 2024
Turns out this breaks the signing flow for some reason 🤷
@HCastano HCastano merged commit 13a365f into master Aug 14, 2024
14 checks passed
@HCastano HCastano deleted the hc/new-signing-flow branch August 14, 2024 21:58
ameba23 added a commit that referenced this pull request Aug 15, 2024
* master:
  Bump serde_json from 1.0.124 to 1.0.125 in the patch-dependencies group (#1007)
  Signing flow with derived accounts (#990)
  Add `network-jumpstart` command to `entropy-test-cli` (#1004)
  Refactor reshare (#994)
  Migrate circle-ci workflow to github actions (#991)
  Delete old keyshare if not in next_signers (#999)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bump `spec_version` A change which affects the current runtime behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants