-
Notifications
You must be signed in to change notification settings - Fork 253
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
zcash_client_sqlite: Assign UUIDs to each account #1631
base: main
Are you sure you want to change the base?
Conversation
I discovered that the Android SDK is misusing |
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.
utACK with comments.
c8aff5b
to
bf42ec2
Compare
Force-pushed to replace |
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.
utACK with this suggestion: https://github.com/zcash/librustzcash/pull/1631/files#r1855319372
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.
If we're going to make this change, we should do so wholesale: replace the contents of the AccountId
type with the UUID, and change all the queries to take the UUID (and join to the accounts
table if necessary).
4885b4d
to
03e68c6
Compare
|
||
st.reset(); | ||
|
||
// Account creation and DFVK derivation should be deterministic. | ||
let (_, restored_usk) = st.wallet_mut().create_account(&seed, &birthday).unwrap(); | ||
let (account1, restored_usk) = st.wallet_mut().create_account(&seed, &birthday).unwrap(); |
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.
This change is necessary because we get new account UUIDs when we regenerate the wallet.
…`AccountUuid` This requires a few annoying changes to migrations in order to avoid hitting cases where account UUIDs are expected before they exist in the database schema.
03e68c6
to
546481e
Compare
This is now consistent with how we name other internal primary key type wrappers.
@@ -129,7 +124,7 @@ pub enum SqliteClientError { | |||
/// ephemeral address outputs have been mined. The parameters are the account id and |
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.
/// ephemeral address outputs have been mined. The parameters are the account id and | |
/// ephemeral address outputs have been mined. The parameters are the account UUID and |
Also s/account_id/account_uuid/
on lines 190 and 192.
@@ -181,8 +176,7 @@ impl fmt::Display for SqliteClientError { | |||
SqliteClientError::UnknownZip32Derivation => write!(f, "ZIP-32 derivation information is not known for this account."), | |||
SqliteClientError::KeyDerivationError(acct_id) => write!(f, "Key derivation failed for account {}", u32::from(*acct_id)), |
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.
SqliteClientError::KeyDerivationError(acct_id) => write!(f, "Key derivation failed for account {}", u32::from(*acct_id)), | |
SqliteClientError::KeyDerivationError(zip32_index) => write!(f, "Key derivation failed for ZIP 32 account index {}", u32::from(*zip32_index)), |
@@ -181,8 +176,7 @@ impl fmt::Display for SqliteClientError { | |||
SqliteClientError::UnknownZip32Derivation => write!(f, "ZIP-32 derivation information is not known for this account."), | |||
SqliteClientError::KeyDerivationError(acct_id) => write!(f, "Key derivation failed for account {}", u32::from(*acct_id)), | |||
SqliteClientError::BadAccountData(e) => write!(f, "Failed to add account: {}", e), | |||
SqliteClientError::AccountIdDiscontinuity => write!(f, "Wallet account identifiers must be sequential."), | |||
SqliteClientError::AccountIdOutOfRange => write!(f, "Wallet account identifiers must be less than 0x7FFFFFFF."), | |||
SqliteClientError::Zip32AccountIndexOutOfRange => write!(f, "ZIP 32 account identifiers must be less than 0x7FFFFFFF."), | |||
SqliteClientError::AccountCollision(id) => write!(f, "An account corresponding to the data provided already exists in the wallet with internal identifier {}.", id.0), |
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.
SqliteClientError::AccountCollision(id) => write!(f, "An account corresponding to the data provided already exists in the wallet with internal identifier {}.", id.0), | |
SqliteClientError::AccountCollision(account_uuid) => write!(f, "An account corresponding to the data provided already exists in the wallet with UUID {account_uuid:?}."), |
(probably needs a rustfmt)
@@ -818,7 +848,10 @@ impl<P: consensus::Parameters> WalletWrite for WalletDb<rusqlite::Connection, P> | |||
) | |||
})?; | |||
let account_index = wallet::max_zip32_account_index(wdb.conn.0, &seed_fingerprint)? |
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.
Rename to zip32_account_index
.
This provides equivalent uniqueness to the
accounts
table primary key, but avoids collisions across wallet recreation events (to defend against downstream crate users who don't flush any persisted account IDs at those events).Closes #1629.