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

docs: Add evmAddress type to generateKey #211

Merged
merged 5 commits into from
Jun 3, 2024

Conversation

rwalworth
Copy link
Contributor

This PR adds an evmAddress type to generateKey, which will allow the TCK to utilize the SDKs to generate EVM addresses for use in testing. It also removes protobufBytes as a parameter as the evmAddress type will be used to generate an alias instead.

Related issue(s):

Fixes #210

…rotobufBytes

Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
@rwalworth rwalworth added the documentation Improvements or additions to documentation label May 15, 2024
@rwalworth rwalworth self-assigned this May 15, 2024
@rwalworth rwalworth linked an issue May 15, 2024 that may be closed by this pull request
@rwalworth rwalworth requested a review from agadzhalov May 15, 2024 20:29
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
@@ -106,19 +106,18 @@ Method used to generate a Hedera Key.

#### Input Parameters

Choose a reason for hiding this comment

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

I am confused what happens if type or fromKey is not provided, I understand that random key type should be returned then, but like what would be the use case for that?

Copy link
Contributor Author

@rwalworth rwalworth May 28, 2024

Choose a reason for hiding this comment

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

There isn't a particular use case necessarily, it's mostly for developer convenience. If a test just requires any valid key but it doesn't matter if it's public, private, ED25519, or ECDSAsecp256k1, then the developer won't need to fill in those params but they'll get a usable key. fromKey helps in the case you need to get the associate public key of a private key, or the EVM address from an ECDSAsecp256k1 key. If fromKey is not provided, then the SDK server should assume a new key or EVM address should be generated.

Choose a reason for hiding this comment

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

Understood.

then the developer won't need to fill in those params but they'll get a usable key

I am for deterministic way of testing in TCK, meaning that in this case there should be no randomness, only things specified by developer.

Would like to have opinions from other team members as well 🙂

Choose a reason for hiding this comment

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

I agree with Rob on the fact that this can be there for developer convenience most of the times. But Nikita also has a point here because it makes sense to have a function called which does not depend on randomness when used in TCK scope. If a scenario exists in which this randomness can affect us we would have to remove this(So maybe it would be less risky to not have it).

(Example)
The developer gets used to that function providing him with a working key and gets lazy in specification. Tries to create TCK specifications for EthereumTransaction and signs with a random key(not ECDSA).

So if there is no risk to begin with maybe we would be better off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to remove the randomness that's fine, I mostly just wanted something where we didn't have to specify a type every time we call generateKey if it doesn't matter what the key is. Maybe we can just default to an ed25519PrivateKey if a type isn't specified?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to remove all the randomness and keep up with the deterministic way of testing. In my opinion everything in the TCK should be set explicitly.

Copy link
Contributor Author

@rwalworth rwalworth May 30, 2024

Choose a reason for hiding this comment

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

If we add in utility.md that generateKey without a specified "type" will return an ed25519PrivateKey, do we think that would be explicit enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would go with setting the type explicitly every time. I know it's not convenient but it's way clearer and straightforward, for example you can easily read whether it's ECDSA or ED25519, without having to check the default type.

Copy link
Contributor Author

@rwalworth rwalworth May 31, 2024

Choose a reason for hiding this comment

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

If that's what everyone prefers we can go that way, I'll add it to this.

Just a note, the functionality of returning a random key if no type was provided wasn't added in this PR, but in #200. There was even a question about it which was marked resolved (#200 (comment)) and the work was approved. I would ask going forward that these discussions/change requests take place in the PR the specifications were added. I've already done some work with the assumption that this was how we wanted to do it (since it was approved), so now I'm going to have to go back and "undo" that work. It isn't too much, but going forward we should definitely try to iron out these inefficiencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rwalworth that's a valid point you've raised. Just keep in mind we are four people reviewing TCK PRs and sometimes it's possible to miss some details or comments. We will be aware of this in the future!

rwalworth added 3 commits May 30, 2024 10:09
…d language to other parameters that they're ignored based on input type

Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Copy link

@thenswan thenswan left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @rwalworth

Copy link
Contributor

@agadzhalov agadzhalov left a comment

Choose a reason for hiding this comment

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

LGTM, tyvm @rwalworth

@rwalworth rwalworth merged commit adc2b1c into main Jun 3, 2024
5 checks passed
@rwalworth rwalworth deleted the 00210-add-evmaddress-as-a-type-for-generatekey branch June 3, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add EvmAddress as a type for generateKey
4 participants