diff --git a/Cargo.lock b/Cargo.lock index 59f9f8b3a..cfcfb5ab7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,6 +62,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -1719,6 +1731,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "2.1.0" @@ -2125,6 +2149,9 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] [[package]] name = "hashers" @@ -2135,6 +2162,15 @@ dependencies = [ "fxhash", ] +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "headers" version = "0.3.9" @@ -4389,6 +4425,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rusqlite" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +dependencies = [ + "bitflags 2.5.0", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -6505,6 +6555,7 @@ dependencies = [ "rand", "reqwest 0.12.4", "ring 0.17.8", + "rusqlite", "serde", "serde_json", "sha2 0.10.8", @@ -6580,6 +6631,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/bindings_ffi/Cargo.lock b/bindings_ffi/Cargo.lock index 3591f31d9..23a299972 100644 --- a/bindings_ffi/Cargo.lock +++ b/bindings_ffi/Cargo.lock @@ -62,6 +62,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -1603,6 +1615,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "2.0.1" @@ -1976,6 +2000,9 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", +] [[package]] name = "hashers" @@ -1986,6 +2013,15 @@ dependencies = [ "fxhash", ] +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.3", +] + [[package]] name = "heck" version = "0.4.1" @@ -3978,6 +4014,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rusqlite" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +dependencies = [ + "bitflags 2.4.2", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -5992,6 +6042,7 @@ dependencies = [ "rand", "reqwest 0.12.4", "ring 0.17.8", + "rusqlite", "serde", "serde_json", "sha2", @@ -6062,6 +6113,7 @@ dependencies = [ "ethers-core", "futures", "log", + "rusqlite", "tempfile", "thiserror", "thread-id", @@ -6086,6 +6138,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/bindings_ffi/Cargo.toml b/bindings_ffi/Cargo.toml index 562874b0c..7859a584b 100644 --- a/bindings_ffi/Cargo.toml +++ b/bindings_ffi/Cargo.toml @@ -10,6 +10,7 @@ crate-type = ["lib", "cdylib", "staticlib"] env_logger = "0.11.3" futures = "0.3.28" log = { version = "0.4", features = ["std"] } +rusqlite = { version = "0.31.0", features = ["bundled"] } thiserror = "1.0" thread-id = "4.2.1" tokio = { version = "1.28.1", features = ["macros"] } diff --git a/bindings_ffi/Makefile b/bindings_ffi/Makefile index 848c9df24..16c354562 100644 --- a/bindings_ffi/Makefile +++ b/bindings_ffi/Makefile @@ -3,10 +3,10 @@ PROJECT_NAME = xmtpv3 # Simulator config ARCHS_IOS = x86_64-apple-ios aarch64-apple-ios-sim ARCHS_MAC = x86_64-apple-darwin aarch64-apple-darwin -# Not used -# ARCHS_MACCATALYST = x86_64-apple-ios-macabi aarch64-apple-ios-macabi LIB=libxmtpv3.a JAR_DIR=$(shell pwd)/tests/jar +SQLCIPHER_DIR=$(shell pwd)/sqlcipher +SQLCIPHER_LIB=$(SQLCIPHER_DIR)/.libs/libsqlcipher.a GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD) GIT_COMMIT_HASH=$(shell git log -1 --pretty=format:"%h") GIT_COMMIT_DATE=$(shell TZ=UTC git log -1 --date=iso-local --pretty=format:"%ad") @@ -28,22 +28,30 @@ download-toolchains: rustup target add $(ARCHS_MAC) rustup target add aarch64-apple-ios +download-sqlcipher: + git clone https://github.com/sqlcipher/sqlcipher.git $(SQLCIPHER_DIR) + +build-sqlcipher: + cd $(SQLCIPHER_DIR) && \ + ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" && \ + make + all: framework libxmtp-version: echo "Version: $(GIT_COMMIT_HASH)\nBranch: $(GIT_BRANCH)\nDate: $(GIT_COMMIT_DATE)" > libxmtp-version.txt -$(ARCHS_IOS): %: +$(ARCHS_IOS): %: build-sqlcipher cross build --target $@ --target-dir ./target --release --no-default-features mkdir -p build/$@ mv target/$@/release/$(LIB) build/$@/$(LIB) -$(ARCHS_MAC): %: +$(ARCHS_MAC): %: build-sqlcipher cross build --target $@ --target-dir ./target --release --no-default-features mkdir -p build/$@ mv target/$@/release/$(LIB) build/$@/$(LIB) -aarch64-apple-ios: +aarch64-apple-ios: build-sqlcipher cross build --target $@ --target-dir ./target --release mkdir -p build/$@ mv target/$@/release/$(LIB) build/$@/$(LIB) @@ -85,4 +93,4 @@ swift: libxmtp-version swiftlocal: libxmtpv3.a swift framework -.PHONY: $(ARCHS_IOS) $(ARCHS_MAC) framework all aarch64-apple-ios install-jar echo-jar download-toolchains swift lipo +.PHONY: $(ARCHS_IOS) $(ARCHS_MAC) framework all aarch64-apple-ios install-jar echo-jar download-toolchains swift lipo download-sqlcipher build-sqlcipher diff --git a/bindings_node/Cargo.lock b/bindings_node/Cargo.lock index a9c67462e..ffc44468c 100644 --- a/bindings_node/Cargo.lock +++ b/bindings_node/Cargo.lock @@ -62,6 +62,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -1443,6 +1455,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastrand" version = "2.1.0" @@ -1796,6 +1820,9 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] [[package]] name = "hashers" @@ -1806,6 +1833,15 @@ dependencies = [ "fxhash", ] +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "heck" version = "0.4.1" @@ -3742,6 +3778,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rusqlite" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +dependencies = [ + "bitflags 2.5.0", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -5447,6 +5497,7 @@ dependencies = [ "rand", "reqwest 0.12.4", "ring 0.17.8", + "rusqlite", "serde", "serde_json", "sha2", @@ -5503,6 +5554,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.64", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/xmtp_mls/Cargo.toml b/xmtp_mls/Cargo.toml index e7e0b103a..3821074f9 100644 --- a/xmtp_mls/Cargo.toml +++ b/xmtp_mls/Cargo.toml @@ -43,6 +43,7 @@ prost = { workspace = true, features = ["prost-derive"] } rand = { workspace = true } reqwest = { version = "0.12.4", features = ["stream"] } ring = "0.17.8" +rusqlite = { version = "0.31.0", features = ["bundled"] } serde = { workspace = true } serde_json.workspace = true sha2.workspace = true