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

[NayNay] Registration verifying keys being stripped at Keyring #353

Merged
merged 24 commits into from
Jun 2, 2024

Conversation

rh0delta
Copy link
Contributor

  • update creation of functional accounts to include existing data
  • issue found when trying to view programs for testnet address, verifying keys list was always empty even tho config contained the keys

Description

GitHub Issue or Linear Task

How Has This Been Tested?

@rh0delta rh0delta marked this pull request as ready for review May 28, 2024 17:48
@mixmix
Copy link
Collaborator

mixmix commented May 28, 2024

@frankiebee review this please

package.json Outdated Show resolved Hide resolved
Comment on lines +66 to 67
keyring: Keyring
signer: Signer
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think that maybe we do keyring or signer but not both. Your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the signer in this case is coming from the deviceKeys account, we could remove the keyring from here and include the deviceKey signer and the registration signer and just switch between the two, thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't comment on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think for now we should leave this as-is until we can solidify that registering is working as expected

@frankiebee
Copy link
Collaborator

This fixes?

issue found when trying to view programs for testnet address, verifying keys list was always empty even tho config contained the keys

you seem to only have only touched the signing file i would imagine the fix would be in sec/programs/index.ts

@rh0delta
Copy link
Contributor Author

This fixes?

issue found when trying to view programs for testnet address, verifying keys list was always empty even tho config contained the keys

you seem to only have only touched the signing file i would imagine the fix would be in sec/programs/index.ts

the issue wasnt with programs, it was due to the data passed to the keyring from the cli not being persisted to the instantiation of the keyring instance, and so even if the account has verifying keys, according to the Keyring instance generated there were no keys or anything. the fix is in src/keys/index.ts. signing was touched because the device keys account had an empty list of verifying keys, so we had to work some magic to use the registration keys

mixmix
mixmix previously requested changes May 30, 2024
Copy link
Collaborator

@mixmix mixmix left a comment

Choose a reason for hiding this comment

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

🦩 🏁

Looks good. I've pointed at what looks like gotchas to me. Great work adding some tests to keys, that feels really good as a guard-rail to me

package.json Outdated
"bundle:watch": "tsup --watch",
"bundle:node": "tsup --platform node ",
"bundle:browser": "tsup --platform browser",
"build": "tsup",
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 rename, AND if it was in a micro-PR by itself it would be already merged 👹

I am not hard-core on this, but just want us to watch that when we do side-tweaks like this, they will get tangles up with the rest of the PR they are in and that delays them being useful.
I do this too FWIW 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i agree with you on this, im going to cut a new smaller PR to just address this change and we can get it merged

src/index.ts Show resolved Hide resolved
Comment on lines +136 to +137
admin.verifyingKeys = [...vk, verifyingKey]
deviceKey.verifyingKeys = [verifyingKey, ...vk]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: you changed the order of the verifyingKeys is that significant?
from : [verifyingKeys, ...vk]
to : [...vk, verifyingKeys]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the order change is to ensure the new verifying key is the first verifying key in the list on the device keys account. this will be the new verifying key used for signing

Copy link
Collaborator

Choose a reason for hiding this comment

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

related to #365

Comment on lines 69 to 71
const masterAccountView = JSON.parse(
JSON.stringify(this.accounts.masterAccountView)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🌶️ at least extract this as a function cloneDeep(this.accounts.masterAccountView)
that way it's

  • self documenting
  • as this pattern spreads, we can re-use one function
  • if we want to improve it we only have to swap one function

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also de-serialization like this is v slow. consider import { cloneDeep } from 'lodash'
Speed probably doesn't matter here much tho

src/keys/index.ts Outdated Show resolved Hide resolved
this.accounts.masterAccountView[childKey][k] = v
setTimeout(
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment why this is necessary/ needed plz
(I know, but I will also forget!)

Comment on lines +66 to 67
keyring: Keyring
signer: Signer
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't comment on this

src/signing/index.ts Show resolved Hide resolved
tests/end-to-end.test.ts Show resolved Hide resolved
tests/keys.test.ts Show resolved Hide resolved
@rh0delta rh0delta force-pushed the naynay/keyring-registration-verifying-keys branch from 6a6bab7 to a9f6e68 Compare May 30, 2024 16:28
@rh0delta rh0delta mentioned this pull request May 31, 2024
@rh0delta
Copy link
Contributor Author

we need to look more into how we are doing the storage for keyrings on the cli

@frankiebee frankiebee self-requested a review May 31, 2024 18:47
frankiebee
frankiebee previously approved these changes Jun 2, 2024
Copy link
Collaborator

@frankiebee frankiebee left a comment

Choose a reason for hiding this comment

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

I'm going to put my stamp of approval on this for now and get it merged in so a rc can be created for cli. But lets address deeper testing in a separate pr @mixmix

Co-authored-by: mix irving <[email protected]>
@frankiebee frankiebee dismissed mixmix’s stale review June 2, 2024 21:11

Most of what you want is in here. will make more tests a priority as of next steps and PR

Copy link
Collaborator

@frankiebee frankiebee left a comment

Choose a reason for hiding this comment

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

Ive commited to the branch some of mixs docs changes! This is good to go!

@frankiebee frankiebee merged commit 1b7e562 into main Jun 2, 2024
1 check passed
@frankiebee frankiebee deleted the naynay/keyring-registration-verifying-keys branch June 2, 2024 21:13
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