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

core: use loop.Keystore, support arbitrarily prefixed Cosmos addresses #10416

Merged
merged 4 commits into from
Sep 6, 2023

Conversation

cfal
Copy link
Contributor

@cfal cfal commented Aug 31, 2023

BCI-1740

  • adds a loop.Keystore implementation using keystore.Cosmos and uses it; note that this is still for unprefixed keys, such that key management using the key controller follows existing conventions (ie. manage a single Cosmos keystore key used across Cosmos chains)
  • adds a cosmostxm.KeystoreAdapter that translates loop.Keystore accounts into prefixed Cosmos addresses
  • updates cosmostxm.KeyWrapper to wrap a KeystoreAdapter instance for a specific prefixed Cosmos address

@github-actions
Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@cfal
Copy link
Contributor Author

cfal commented Aug 31, 2023

working on fixing the SigScanner check..

@cfal cfal requested review from jmank88, krehermann, yongkangc and calvwang9 and removed request for RyanRHall August 31, 2023 08:09
@cfal cfal force-pushed the cosmos-keystore branch 2 times, most recently from 3adf76a to 2a416d0 Compare August 31, 2023 10:47
Copy link
Contributor

@krehermann krehermann 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 to me upto the question about a mutex.

out of curiousity - how burdensome was it to understand what to write? i'm excited that you could figure it out and i'm wondering if we could have made it easier to understand. based on the code, i'm guessing that starknet was a good example

@cfal cfal force-pushed the cosmos-keystore branch 2 times, most recently from ce1948b to a8b1f78 Compare August 31, 2023 18:43
@cfal
Copy link
Contributor Author

cfal commented Aug 31, 2023

thanks for the quick reviews! waiting on the fix for the sigscanner check :)

out of curiousity - how burdensome was it to understand what to write? i'm excited that you could figure it out and i'm wondering if we could have made it easier to understand. based on the code, i'm guessing that starknet was a good example

it wasn't too bad, i spent most of the time thinking on what Sign() should be doing since there's only a single []byte param, and since the common tx signing function in cosmos-sdk requires other metadata params: https://github.com/cosmos/cosmos-sdk/blob/3e07c80ebc5913e20c87cc34b881afe42e94b2bd/client/tx/tx.go#L166

making it as basic as possible (priv key signing a blob, instead of tx-scoped) seemed to work out, and even if the loop.Keystore cound be bech32-prefix-aware and support other metadata fields when signing, it would have required other changes (eg. what should Accounts() return?)

there's still the question of how chain operators would know the addresses on different chains, since the key controller/operator ui/keystore.Cosmos only shows a non-prefixed pubkey, but i think we can address that at a later point.

@cfal cfal force-pushed the cosmos-keystore branch 3 times, most recently from 06e9f3f to 6493651 Compare August 31, 2023 19:33
@cfal cfal requested review from jmank88 and krehermann August 31, 2023 19:53
@cfal cfal force-pushed the cosmos-keystore branch 2 times, most recently from 1990100 to 9b6b6a0 Compare August 31, 2023 20:17
@cfal cfal requested a review from krehermann August 31, 2023 20:17
pubKey, err := a.adapter.PubKey(a.account)
if err != nil {
// return an empty pubkey if it's not found.
return &secp256k1.PubKey{Key: []byte{}}
Copy link
Contributor

Choose a reason for hiding this comment

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

whats the reasoning behind empty pubkey vs panicking?

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 reasoning was that we don't want the node/process to crash - for example, if account was mistyped. addresses can be specified via TOML for transmitter address, although i didn't bother to trace the code path to see if user input could actually end up here.

core/chains/cosmos/cosmostxm/keystore_adapter.go Outdated Show resolved Hide resolved
@cfal cfal requested review from jmank88 and calvwang9 and removed request for yongkangc September 1, 2023 19:03
@cfal cfal force-pushed the cosmos-keystore branch 2 times, most recently from 7eef30e to df527fd Compare September 4, 2023 07:08
jmank88
jmank88 previously approved these changes Sep 5, 2023
krehermann
krehermann previously approved these changes Sep 5, 2023
@cfal cfal dismissed stale reviews from krehermann and jmank88 via 05c95e2 September 6, 2023 09:09
@cfal cfal requested review from jmank88 and krehermann September 6, 2023 09:10
@cl-sonarqube-production
Copy link

SonarQube Quality Gate

Quality Gate failed

Failed condition 69.4% 69.4% Coverage on New Code (is less than 80%)

See analysis details on SonarQube

@jmank88 jmank88 added this pull request to the merge queue Sep 6, 2023
Merged via the queue into develop with commit 19eb5fc Sep 6, 2023
@jmank88 jmank88 deleted the cosmos-keystore branch September 6, 2023 13:18
@augustbleeds augustbleeds restored the cosmos-keystore branch September 6, 2023 15:40
@augustbleeds
Copy link
Contributor

^ keeping the branch restored so it can be used for tests on chainlink-cosmos

@cfal cfal deleted the cosmos-keystore branch September 11, 2023 08:20
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.

5 participants