-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add AccountRestorationProcessor for Improved Key Rotation and Multi-Key Account Discoverability #660
base: main
Are you sure you want to change the base?
Conversation
@0xjunha would you mind adding some screenshots of rows from local DB with explanations confirming expected behavior please? |
Edited the PR description to include some screenshots! @dermanyang |
}) | ||
}, | ||
_ => Err(anyhow::anyhow!( | ||
"Invalid db config for AccountTransactionsProcessor {:?}", |
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.
"Invalid db config for AccountTransactionsProcessor {:?}", | |
"Invalid db config for AccountRestorationProcessor {:?}", |
#[derive(Clone, Debug, Default, Deserialize, FieldCount, Identifiable, Insertable, Serialize)] | ||
#[diesel(primary_key(address))] | ||
#[diesel(table_name = auth_key_account_addresses)] | ||
pub struct AuthKeyAccountAddress { |
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.
Can you add some context into a doc string above this struct please? Same with the other structs. Just copy pasting the descriptions you have in the PR about the tables is sufficient imo. Thanks!
Description
This PR introduces a new sdk-processor
AccountRestorationProcessor
to help solve account discoverability challenges for key rotation and offchain multi-key.By indexing (auth key -> account) mappings for all account types and (public keys -> auth key derivation) & (auth key -> multi-key layout) mappings for multi-key accounts, a wallet can quickly find all account addresses tied to a public key and avoid losing access when an account rotation happens.
To implement this, the PR introduces the
AccountRestorationProcessor
and the following three new tables.New tables
AuthKeyAccountAddress
address
Example
auth_key
andaddress
, indicating that the account had been rotated.AuthKeyMultikeyLayout
auth_key
multikey_layout_with_prefixes
is an ordered list of public keys with 1-byte prefixes indicating key type of each public key (e.g.,0x00
for Ed25519 Generalized). If the prefix is missing, the public key is legacy Ed25519 type.Example
multikey_layout_with_prefixes
column value are prefixed with public key types (0x00
and0x01
)multi_ed25519
multi-key type, public keys won't have any prefixes.PublicKeyAuthKey
public_key
,public_key_type
,auth_key
)public_key
is not prefixed with the key type. Instead, there's a dedicated String column for that (public_key_type
).Example
verified==TRUE
means that the public key was historically used at least once for authenticating a transaction. E.g., for theauth_key
0xb697...
,public_key
s0x0450...
and0x7226...
were used for authenticating a transaction (2-of-3 multi-key scheme)Notes
sdk-processor
s rely on transaction parsing logic from legacyprocessor
s, this PR places the relevant logic in anaccount_restoration_utils
module underrust/processor/src/db/postgres/models/account_restoration_models/
, since there isn't an existingprocessor
equivalent.Links
Tests