-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
crates/client/src/client.rs
Outdated
/// 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... |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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 😆
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
crates/test-cli/src/lib.rs
Outdated
panic!("Failed to register an account!") | ||
} | ||
|
||
// The CLI currently doesn't support sending multiple registration requests in a single |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
crates/client/src/client.rs
Outdated
/// 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... |
There was a problem hiding this comment.
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
)
crates/client/src/client.rs
Outdated
) | ||
.await?; | ||
on_chain: bool, | ||
) -> Result<Vec<([u8; VERIFYING_KEY_LENGTH], RegisteredInfo)>, ClientError> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 aregister-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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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.
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 theregister
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:
docker compose up
, I've been using ones built from the branch locally, but theimages from
master
should work too.cargo run -p entropy-test-cli -- jumpstart-network
, this needs to be done before thenew registration flow is available
cargo run -p entropy-test-cli -- register ./crates/testing-utils/template_barebones.wasm -m //Alice --on-chain
cargo run -p entropy-test-cli -- sign $VERIFYING_KEY "Hello, GitHub!"