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 test CLI for new registration and signing flows #1008

Merged
merged 15 commits into from
Aug 20, 2024

Conversation

HCastano
Copy link
Collaborator

This PR adds support for the new registration and signing flows to the
entropy-test-cli. To do so I added a new flag to the register command, --on-chain
which indicates that a user wants to register using the new flow. If the flag is not
added the old flow will continue to be used.

For signing, a user doesn't have to do anything special. They can use the same command as
before and the CLI will resolve which flow to use internally.

To try this out on a local network:

  1. Run docker compose up, I've been using ones built from the branch locally, but the
    images from master should work too.
  2. cargo run -p entropy-test-cli -- jumpstart-network, this needs to be done before the
    new registration flow is available
  3. cargo run -p entropy-test-cli -- register ./crates/testing-utils/template_barebones.wasm -m //Alice --on-chain
  4. cargo run -p entropy-test-cli -- sign $VERIFYING_KEY "Hello, GitHub!"

Comment on lines 371 to 374
/// TODO (Nando): This was copied from `entropy-tss::helpers::substrate`
///
/// What's the best place for this? Ideally here, and then we import this into the entropy-tss, but
/// we need the `full-client` feature enabled...
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 you got any thoughts on the best place to put this is? I'd rather not have this duplicated throughout

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea is that this client file is for things which are only used client-side, and since entropy-tss doesn't need them apart from in testing, they are behind the full-client feature.

Anything outside of this file is accessible to both client and server, so this could go in user.rs (or substrate.rs since it is currently in helpers::substrate in entropy-tss)

@@ -89,6 +92,7 @@ enum CliCommand {
/// Optional auxiliary data passed to the program, given as hex
auxilary_data: Option<String>,
/// The mnemonic to use for the call
#[arg(short, long)]
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 does this trigger you 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. well less so for sign because it doesn't really matter what this is. but for the commands which submit extrinsics, it seems insane that its 'optional' to specify which account to use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we do use the CLI for development purposes it's not that crazy- we just default to //Alice otherwise. But yeah should definitely try and clarify the UX around this at some point

panic!("Failed to register an account!")
}

// The CLI currently doesn't support sending multiple registration requests in a single
Copy link
Member

Choose a reason for hiding this comment

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

nor really should it, may be cleaner to just return the first registration from the above function

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 all working ⭐

Can confirm the docker-compose stuff works my end.

Comment on lines 371 to 374
/// TODO (Nando): This was copied from `entropy-tss::helpers::substrate`
///
/// What's the best place for this? Ideally here, and then we import this into the entropy-tss, but
/// we need the `full-client` feature enabled...
Copy link
Contributor

Choose a reason for hiding this comment

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

The idea is that this client file is for things which are only used client-side, and since entropy-tss doesn't need them apart from in testing, they are behind the full-client feature.

Anything outside of this file is accessible to both client and server, so this could go in user.rs (or substrate.rs since it is currently in helpers::substrate in entropy-tss)

)
.await?;
on_chain: bool,
) -> Result<Vec<([u8; VERIFYING_KEY_LENGTH], RegisteredInfo)>, ClientError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should return a vec. When i call register, i am interested in getting the verifying key of the account which has the configuration (programs and program configurations) that i give as arguments. I don't want to get it together with some other accounts i registered before and need to sift through them and find the one i am interested in. That should happen in this function.

If i call this function twice with with two identical configurations in the same block, there should be some mechanism to ensure that this function will not return the same verifying key for each. Eg: it should return the account with the lowest / highest derivation path.

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 think this should return a vec. When i call register, i am interested in getting the verifying key of the account which has the configuration (programs and program configurations) that i give as arguments. I don't want to get it together with some other accounts i registered before and need to sift through them and find the one i am interested in. That should happen in this function.
I figured that in the future we could allow the possibility for a register-batch command where a single account could register a lot of accounts on-chain in one go. This is supported by the on-chain flow.

The register command as it stands now only sends one transaction per invocation anyways, so this isn't really a problem.

If i call this function twice with with two identical configurations in the same block, there should be some mechanism to ensure that this function will not return the same verifying key for each. Eg: it should return the account with the lowest / highest derivation path.

While this is easy right now since we have a count on-chain, I'd hesitate to make that assumption in the TSS since we could change the way we do derivations. Not sure if this filtering is something I'll implement for this PR, but I'll think about it as I go through the fixes

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 quickly tried to send a few transactions back to back but it doesn't work atm because of how the nonce management is done for the registering account. So I guess technically this isn't an issue then lol

Copy link
Contributor

Choose a reason for hiding this comment

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

ok well i don't know if thats good or bad - but im happy that this now returns just one set of registering details.

Does that mean we can make at most one registration per account per block? Doesn't seem so bad but i might have misunderstood the issue.

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 no, the chain can support multiple registrations per account per block. It's just the test CLI that doesn't

@@ -89,6 +92,7 @@ enum CliCommand {
/// Optional auxiliary data passed to the program, given as hex
auxilary_data: Option<String>,
/// The mnemonic to use for the call
#[arg(short, long)]
Copy link
Contributor

Choose a reason for hiding this comment

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

yes. well less so for sign because it doesn't really matter what this is. but for the commands which submit extrinsics, it seems insane that its 'optional' to specify which account to use.

@HCastano HCastano merged commit bba31a3 into master Aug 20, 2024
8 checks passed
@HCastano HCastano deleted the hc/update-test-cli branch August 20, 2024 21:01
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