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

zcash_client_sqlite: Migrate from schemer to schemerz #1575

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ subtle = "2.2.3"
# CocoaPods, due to being bound to React Native. We need to ensure that the SQLite
# version required for `rusqlite` is a version that is available through CocoaPods.
rusqlite = { version = "0.29.0", features = ["bundled"] }
schemer = "0.2"
schemer-rusqlite = "0.2.2"
schemerz = "0.1"
schemerz-rusqlite = "0.290"
time = "0.3.22"
uuid = "1.1"

Expand Down
12 changes: 12 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,18 @@ user-id = 169181 # Kris Nuttycombe (nuttycom)
start = "2024-08-12"
end = "2025-08-12"

[[trusted.schemerz]]
criteria = "safe-to-deploy"
user-id = 6289 # Jack Grigg (str4d)
start = "2024-10-15"
end = "2025-10-15"

[[trusted.schemerz-rusqlite]]
criteria = "safe-to-deploy"
user-id = 6289 # Jack Grigg (str4d)
start = "2024-10-15"
end = "2025-10-15"

[[trusted.shardtree]]
criteria = "safe-to-deploy"
user-id = 169181 # Kris Nuttycombe (nuttycom)
Expand Down
8 changes: 0 additions & 8 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1042,14 +1042,6 @@ criteria = "safe-to-deploy"
version = "0.5.0"
criteria = "safe-to-deploy"

[[exemptions.schemer]]
version = "0.2.1"
criteria = "safe-to-deploy"

[[exemptions.schemer-rusqlite]]
version = "0.2.2"
criteria = "safe-to-deploy"

[[exemptions.scopeguard]]
version = "1.1.0"
criteria = "safe-to-deploy"
Expand Down
14 changes: 14 additions & 0 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ user-id = 169181
user-login = "nuttycom"
user-name = "Kris Nuttycombe"

[[publisher.schemerz]]
version = "0.1.0"
when = "2024-10-15"
user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"

[[publisher.schemerz-rusqlite]]
version = "0.290.0"
when = "2024-10-15"
user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"

[[publisher.shardtree]]
version = "0.5.0"
when = "2024-10-04"
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_sqlite/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this library adheres to Rust's notion of
- Exposed `AccountId::from_u32` and `AccountId::as_u32` conversions under the
`unstable` feature flag.

### Changed
- Migrated from `schemer` to our fork `schemerz`.

## [0.12.1] - 2024-10-10

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ shardtree = { workspace = true, features = ["legacy-api"] }

# - SQLite databases
rusqlite = { workspace = true, features = ["time", "array"] }
schemer.workspace = true
schemer-rusqlite.workspace = true
schemerz.workspace = true
schemerz-rusqlite.workspace = true
time.workspace = true
uuid.workspace = true
regex = "1.4"
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_sqlite/src/chain/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::BlockDb;
use {
super::migrations,
crate::FsBlockDb,
schemer::{Migrator, MigratorError},
schemer_rusqlite::RusqliteAdapter,
schemerz::{Migrator, MigratorError},
schemerz_rusqlite::RusqliteAdapter,
};

/// Sets up the internal structure of the cache database.
Expand Down
6 changes: 3 additions & 3 deletions zcash_client_sqlite/src/chain/migrations/blockmeta.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;

pub fn all_migrations() -> Vec<Box<dyn RusqliteMigration<Error = rusqlite::Error>>> {
vec![Box::new(init::Migration {})]
}

pub mod init {
use rusqlite::{self};
use schemer::{self, migration};
use schemer_rusqlite::RusqliteMigration;
use schemerz::{self, migration};
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;

pub struct Migration;
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_sqlite/src/wallet/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ pub(super) const INDEX_NF_MAP_LOCATOR_IDX: &str =
// Internal tables
//

/// Internal table used by [`schemer`] to manage migrations.
pub(super) const TABLE_SCHEMER_MIGRATIONS: &str = "
/// Internal table used by [`schemerz`] to manage migrations.
pub(super) const TABLE_SCHEMERZ_MIGRATIONS: &str = "
CREATE TABLE schemer_migrations (
id blob PRIMARY KEY
)";
Expand Down
14 changes: 7 additions & 7 deletions zcash_client_sqlite/src/wallet/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::fmt;
use std::rc::Rc;

use regex::Regex;
use schemer::{Migrator, MigratorError};
use schemer_rusqlite::RusqliteAdapter;
use schemerz::{Migrator, MigratorError};
use schemerz_rusqlite::RusqliteAdapter;
use secrecy::SecretVec;
use shardtree::error::ShardTreeError;
use uuid::Uuid;
Expand Down Expand Up @@ -240,7 +240,7 @@ fn sqlite_client_error_to_wallet_migration_error(e: SqliteClientError) -> Wallet
/// In order to correctly apply migrations to accounts derived from a seed, sometimes the
/// optional `seed` argument is required. This function should first be invoked with
/// `seed` set to `None`; if a pending migration requires the seed, the function returns
/// `Err(schemer::MigratorError::Migration { error: WalletMigrationError::SeedRequired, .. })`.
/// `Err(schemerz::MigratorError::Migration { error: WalletMigrationError::SeedRequired, .. })`.
/// The caller can then re-call this function with the necessary seed.
///
/// > Note that currently only one seed can be provided; as such, wallets containing
Expand All @@ -251,8 +251,8 @@ fn sqlite_client_error_to_wallet_migration_error(e: SqliteClientError) -> Wallet
/// _relevance_: if any account in the wallet for which [`Account::source`] is
/// [`AccountSource::Derived`] can be derived from the given seed, the seed is relevant to
/// the wallet. If the given seed is not relevant, the function returns
/// `Err(schemer::MigratorError::Migration { error: WalletMigrationError::SeedNotRelevant, .. })`
/// or `Err(schemer::MigratorError::Adapter(WalletMigrationError::SeedNotRelevant))`.
/// `Err(schemerz::MigratorError::Migration { error: WalletMigrationError::SeedNotRelevant, .. })`
/// or `Err(schemerz::MigratorError::Adapter(WalletMigrationError::SeedNotRelevant))`.
///
/// We do not check whether the seed is relevant to any imported account, because that
/// would require brute-forcing the ZIP 32 account index space. Consequentially, imported
Expand Down Expand Up @@ -480,7 +480,7 @@ mod tests {
db::TABLE_SAPLING_TREE_CHECKPOINTS,
db::TABLE_SAPLING_TREE_SHARDS,
db::TABLE_SCAN_QUEUE,
db::TABLE_SCHEMER_MIGRATIONS,
db::TABLE_SCHEMERZ_MIGRATIONS,
db::TABLE_SENT_NOTES,
db::TABLE_SQLITE_SEQUENCE,
db::TABLE_TRANSACTIONS,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod tests {
);
assert_matches!(
init_wallet_db(&mut db_data, Some(Secret::new(other_seed.to_vec()))),
Err(schemer::MigratorError::Adapter(
Err(schemerz::MigratorError::Adapter(
WalletMigrationError::SeedNotRelevant
))
);
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_sqlite/src/wallet/init/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod wallet_summaries;

use std::rc::Rc;

use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use secrecy::SecretVec;
use uuid::Uuid;
use zcash_protocol::consensus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::collections::HashSet;

use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;
use zcash_primitives::consensus::{self, NetworkUpgrade};

Expand All @@ -18,7 +18,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}

impl<P> schemer::Migration for Migration<P> {
impl<P> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::collections::HashSet;

use rusqlite::{self, types::ToSql, OptionalExtension};
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;

use zcash_primitives::{
Expand All @@ -25,7 +25,7 @@ const DEPENDENCIES: &[Uuid] = &[

pub(crate) struct Migration;

impl schemer::Migration for Migration {
impl schemerz::Migration for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! A migration that adds an identifier for the account that received a UTXO to the utxos table
use rusqlite;
use schemer;
use schemer_rusqlite::RusqliteMigration;

use schemerz_rusqlite::RusqliteMigration;
use std::collections::HashSet;
use uuid::Uuid;
use zcash_primitives::consensus;
Expand Down Expand Up @@ -34,7 +33,7 @@ pub(super) struct Migration<P> {
pub(super) _params: P,
}

impl<P> schemer::Migration for Migration<P> {
impl<P> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::collections::HashSet;

use rusqlite::{named_params, Transaction};
use schemer;
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;
use zcash_client_backend::{address::Address, keys::UnifiedFullViewingKey};
use zcash_keys::{address::UnifiedAddress, encoding::AddressCodec, keys::UnifiedAddressRequest};
Expand All @@ -26,7 +25,7 @@ pub(crate) struct Migration<P: consensus::Parameters> {
pub(crate) params: P,
}

impl<P: consensus::Parameters> schemer::Migration for Migration<P> {
impl<P: consensus::Parameters> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::collections::HashSet;

use rusqlite::named_params;
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;

use zcash_client_backend::keys::{
Expand All @@ -21,7 +21,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}

impl<P> schemer::Migration for Migration<P> {
impl<P> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! The migration that records ephemeral addresses for each account.
use std::collections::HashSet;

use rusqlite;
use schemer;
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;
use zcash_protocol::consensus;

Expand All @@ -23,7 +21,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}

impl<P> schemer::Migration for Migration<P> {
impl<P> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
//! reorg handling.
use std::collections::HashSet;

use rusqlite::{self, OptionalExtension};
use schemer;
use schemer_rusqlite::RusqliteMigration;
use rusqlite::OptionalExtension;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;
use zcash_protocol::consensus::{self, BlockHeight};

Expand All @@ -21,7 +20,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}

impl<P> schemer::Migration for Migration<P> {
impl<P> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::HashSet, rc::Rc};

use crate::wallet::{account_kind_code, init::WalletMigrationError};
use rusqlite::{named_params, OptionalExtension, Transaction};
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use secrecy::{ExposeSecret, SecretVec};
use uuid::Uuid;
use zcash_client_backend::{
Expand Down Expand Up @@ -33,7 +33,7 @@ const DEPENDENCIES: &[Uuid] = &[
wallet_summaries::MIGRATION_ID,
];

impl<P: consensus::Parameters> schemer::Migration for Migration<P> {
impl<P: consensus::Parameters> schemerz::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! The migration that performs the initial setup of the wallet database.
use std::collections::HashSet;

use rusqlite;
use schemer;
use schemer_rusqlite::RusqliteMigration;
use schemerz_rusqlite::RusqliteMigration;
use uuid::Uuid;

use crate::wallet::init::WalletMigrationError;
Expand All @@ -13,7 +11,7 @@ pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbc4f5e57_d600_4b6c_990f_

pub(super) struct Migration;

impl schemer::Migration for Migration {
impl schemerz::Migration for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}
Expand Down
Loading
Loading