From 5b3152829e6f3d4d45d332de20c6e3385d1263f3 Mon Sep 17 00:00:00 2001 From: Arvid Lunnemark Date: Tue, 21 Jun 2022 11:58:50 -0700 Subject: [PATCH] Use SQLite for persistence (and Rust for handling the SQL) (#12) * rust * make diesel build * make diesel build * install cxx * rust calls cpp!!! * add cxx.path to allow Queryable in the ffi * add db schema * build outside client * some fixes * add cxx.patch * upd cxx.patch * more fixes * IT COMPILES * add diesel-cli * implements friend address and random friends * implement more daemon rpc methods!! * implement getmessages * compiles again!! * updated deps. Add clap to rust for CLI * everything is done!!!! * updated deps. remove clap * TEST 1 WORKED * remove dev lock Co-authored-by: Sualeh Asif --- .bazelrc | 5 + Cargo.Bazel.lock | 1586 ++++++++++++++++++++++++++++++ WORKSPACE | 12 + asphr.bzl | 4 + asphr_load.bzl | 23 + asphr_load2.bzl | 12 + asphr_load3.bzl | 14 + asphr_load4.bzl | 13 + asphr_load5.bzl | 47 + cxx.patch | 60 ++ pir/fast_pir/fast_pir_client.hpp | 19 +- schema/daemon.proto | 33 +- schema/message.proto | 8 +- 13 files changed, 1814 insertions(+), 22 deletions(-) create mode 100644 Cargo.Bazel.lock create mode 100644 asphr_load3.bzl create mode 100644 asphr_load4.bzl create mode 100644 asphr_load5.bzl create mode 100644 cxx.patch diff --git a/.bazelrc b/.bazelrc index f21ea24..c76b7ee 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,6 +1,11 @@ # REMINDER: WHEN CHANGING THIS FILE, PLEASE CHANGE ALL .BAZELRC FILES IN ALL THREE REPOS!!!! # (unfortunately, we cannot have a single source of truth...) +build --incompatible_enable_cc_toolchain_resolution + +# this is for rules_rust +build --repo_env=RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS=true + # note: each bazelrc that try-imports this one needs to try-import the buildbuddy bazelrc but using the correct relative path try-import %workspace%/../.buildbuddy.bazelrc diff --git a/Cargo.Bazel.lock b/Cargo.Bazel.lock new file mode 100644 index 0000000..b35012a --- /dev/null +++ b/Cargo.Bazel.lock @@ -0,0 +1,1586 @@ +{ + "checksum": "2baaade5e42cd2759e106e809dfbc207c4fdc3010e67328bbf58f77486c07117", + "crates": { + "cc 1.0.73": { + "name": "cc", + "version": "1.0.73", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/cc/1.0.73/download", + "sha256": "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + } + }, + "targets": [ + { + "Library": { + "crate_name": "cc", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "Binary": { + "crate_name": "gcc-shim", + "crate_root": "src/bin/gcc-shim.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "cc", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "1.0.73" + }, + "license": "MIT/Apache-2.0" + }, + "cfg-if 1.0.0": { + "name": "cfg-if", + "version": "1.0.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/cfg-if/1.0.0/download", + "sha256": "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + } + }, + "targets": [ + { + "Library": { + "crate_name": "cfg_if", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "cfg_if", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "1.0.0" + }, + "license": "MIT/Apache-2.0" + }, + "diesel 2.0.0-rc.0": { + "name": "diesel", + "version": "2.0.0-rc.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/diesel/2.0.0-rc.0/download", + "sha256": "e531d0abf8147036383c88ce3785d9cda6fe1b8b1183021ffa01cf49c5819d24" + } + }, + "targets": [ + { + "Library": { + "crate_name": "diesel", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "diesel", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "32-column-tables", + "default", + "libsqlite3-sys", + "returning_clauses_for_sqlite_3_35", + "sqlite", + "with-deprecated" + ], + "deps": { + "common": [ + { + "id": "libsqlite3-sys 0.24.2", + "target": "libsqlite3_sys" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "diesel_derives 2.0.0-rc.0", + "target": "diesel_derives" + } + ], + "selects": {} + }, + "version": "2.0.0-rc.0" + }, + "license": "MIT OR Apache-2.0" + }, + "diesel_derives 2.0.0-rc.0": { + "name": "diesel_derives", + "version": "2.0.0-rc.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/diesel_derives/2.0.0-rc.0/download", + "sha256": "212ba0cdc611523c37f26c7b3b4aedb4af7cbfe9239c4e7736a8a7c82284d77b" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "diesel_derives", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "diesel_derives", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "32-column-tables", + "default", + "sqlite", + "with-deprecated" + ], + "deps": { + "common": [ + { + "id": "proc-macro-error 1.0.4", + "target": "proc_macro_error" + }, + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + }, + { + "id": "syn 1.0.98", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "2.0.0-rc.0" + }, + "license": "MIT OR Apache-2.0" + }, + "diesel_migrations 2.0.0-rc.0": { + "name": "diesel_migrations", + "version": "2.0.0-rc.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/diesel_migrations/2.0.0-rc.0/download", + "sha256": "e2edcb7e9cff76af48e7fa33cc4680acc7df19e58a4a4aaed3e2b67fb83bc06d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "diesel_migrations", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "diesel_migrations", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "sqlite" + ], + "deps": { + "common": [ + { + "id": "diesel 2.0.0-rc.0", + "target": "diesel" + }, + { + "id": "migrations_internals 2.0.0-rc.0", + "target": "migrations_internals" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "migrations_macros 2.0.0-rc.0", + "target": "migrations_macros" + } + ], + "selects": {} + }, + "version": "2.0.0-rc.0" + }, + "license": "MIT OR Apache-2.0" + }, + "direct-cargo-bazel-deps 0.0.1": { + "name": "direct-cargo-bazel-deps", + "version": "0.0.1", + "repository": null, + "targets": [ + { + "Library": { + "crate_name": "direct_cargo_bazel_deps", + "crate_root": ".direct_cargo_bazel_deps.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "direct_cargo_bazel_deps", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "diesel 2.0.0-rc.0", + "target": "diesel" + }, + { + "id": "diesel_migrations 2.0.0-rc.0", + "target": "diesel_migrations" + }, + { + "id": "libsqlite3-sys 0.24.2", + "target": "libsqlite3_sys" + }, + { + "id": "rand 0.8.5", + "target": "rand" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.0.1" + }, + "license": null + }, + "getrandom 0.2.7": { + "name": "getrandom", + "version": "0.2.7", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/getrandom/0.2.7/download", + "sha256": "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" + } + }, + "targets": [ + { + "Library": { + "crate_name": "getrandom", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "getrandom", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "std" + ], + "deps": { + "common": [ + { + "id": "cfg-if 1.0.0", + "target": "cfg_if" + } + ], + "selects": { + "cfg(target_os = \"wasi\")": [ + { + "id": "wasi 0.11.0+wasi-snapshot-preview1", + "target": "wasi" + } + ], + "cfg(unix)": [ + { + "id": "libc 0.2.126", + "target": "libc" + } + ] + } + }, + "edition": "2018", + "version": "0.2.7" + }, + "license": "MIT OR Apache-2.0" + }, + "libc 0.2.126": { + "name": "libc", + "version": "0.2.126", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/libc/0.2.126/download", + "sha256": "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + } + }, + "targets": [ + { + "Library": { + "crate_name": "libc", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "libc", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "libc 0.2.126", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "0.2.126" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "libsqlite3-sys 0.24.2": { + "name": "libsqlite3-sys", + "version": "0.24.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/libsqlite3-sys/0.24.2/download", + "sha256": "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" + } + }, + "targets": [ + { + "Library": { + "crate_name": "libsqlite3_sys", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "libsqlite3_sys", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "bundled", + "bundled_bindings", + "cc", + "default", + "min_sqlite_version_3_6_8", + "pkg-config", + "vcpkg" + ], + "deps": { + "common": [ + { + "id": "libsqlite3-sys 0.24.2", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.24.2" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "cc 1.0.73", + "target": "cc" + }, + { + "id": "pkg-config 0.3.25", + "target": "pkg_config" + }, + { + "id": "vcpkg 0.2.15", + "target": "vcpkg" + } + ], + "selects": {} + }, + "links": "sqlite3" + }, + "license": "MIT" + }, + "migrations_internals 2.0.0-rc.0": { + "name": "migrations_internals", + "version": "2.0.0-rc.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/migrations_internals/2.0.0-rc.0/download", + "sha256": "61e2226081f9176165a49b006a0729de8cafa749615b349e15c444dbd39e4d9d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "migrations_internals", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "migrations_internals", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "serde 1.0.137", + "target": "serde" + }, + { + "id": "toml 0.5.9", + "target": "toml" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "2.0.0-rc.0" + }, + "license": "MIT OR Apache-2.0" + }, + "migrations_macros 2.0.0-rc.0": { + "name": "migrations_macros", + "version": "2.0.0-rc.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/migrations_macros/2.0.0-rc.0/download", + "sha256": "37dbadac6f186c134552cd9a0ec14b157cf4f04eacacebd5e6c1bfc6aeb158b3" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "migrations_macros", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "migrations_macros", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default" + ], + "deps": { + "common": [ + { + "id": "migrations_internals 2.0.0-rc.0", + "target": "migrations_internals" + }, + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "2.0.0-rc.0" + }, + "license": "MIT OR Apache-2.0" + }, + "pkg-config 0.3.25": { + "name": "pkg-config", + "version": "0.3.25", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/pkg-config/0.3.25/download", + "sha256": "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + } + }, + "targets": [ + { + "Library": { + "crate_name": "pkg_config", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "pkg_config", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.3.25" + }, + "license": "MIT OR Apache-2.0" + }, + "ppv-lite86 0.2.16": { + "name": "ppv-lite86", + "version": "0.2.16", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/ppv-lite86/0.2.16/download", + "sha256": "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + } + }, + "targets": [ + { + "Library": { + "crate_name": "ppv_lite86", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "ppv_lite86", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "simd", + "std" + ], + "edition": "2018", + "version": "0.2.16" + }, + "license": "MIT/Apache-2.0" + }, + "proc-macro-error 1.0.4": { + "name": "proc-macro-error", + "version": "1.0.4", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/proc-macro-error/1.0.4/download", + "sha256": "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "proc_macro_error", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "proc_macro_error", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "syn", + "syn-error" + ], + "deps": { + "common": [ + { + "id": "proc-macro-error 1.0.4", + "target": "build_script_build" + }, + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + }, + { + "id": "syn 1.0.98", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "proc-macro-error-attr 1.0.4", + "target": "proc_macro_error_attr" + } + ], + "selects": {} + }, + "version": "1.0.4" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "version_check 0.9.4", + "target": "version_check" + } + ], + "selects": {} + } + }, + "license": "MIT OR Apache-2.0" + }, + "proc-macro-error-attr 1.0.4": { + "name": "proc-macro-error-attr", + "version": "1.0.4", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/proc-macro-error-attr/1.0.4/download", + "sha256": "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "proc_macro_error_attr", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "proc_macro_error_attr", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "proc-macro-error-attr 1.0.4", + "target": "build_script_build" + }, + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.0.4" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "version_check 0.9.4", + "target": "version_check" + } + ], + "selects": {} + } + }, + "license": "MIT OR Apache-2.0" + }, + "proc-macro2 1.0.40": { + "name": "proc-macro2", + "version": "1.0.40", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/proc-macro2/1.0.40/download", + "sha256": "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" + } + }, + "targets": [ + { + "Library": { + "crate_name": "proc_macro2", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "proc_macro2", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "proc-macro" + ], + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.40", + "target": "build_script_build" + }, + { + "id": "unicode-ident 1.0.1", + "target": "unicode_ident" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.0.40" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "quote 1.0.20": { + "name": "quote", + "version": "1.0.20", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/quote/1.0.20/download", + "sha256": "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" + } + }, + "targets": [ + { + "Library": { + "crate_name": "quote", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "quote", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "proc-macro" + ], + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.0.20" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "rand 0.8.5": { + "name": "rand", + "version": "0.8.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand/0.8.5/download", + "sha256": "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "alloc", + "default", + "getrandom", + "libc", + "rand_chacha", + "std", + "std_rng" + ], + "deps": { + "common": [ + { + "id": "rand_chacha 0.3.1", + "target": "rand_chacha" + }, + { + "id": "rand_core 0.6.3", + "target": "rand_core" + } + ], + "selects": { + "cfg(unix)": [ + { + "id": "libc 0.2.126", + "target": "libc" + } + ] + } + }, + "edition": "2018", + "version": "0.8.5" + }, + "license": "MIT OR Apache-2.0" + }, + "rand_chacha 0.3.1": { + "name": "rand_chacha", + "version": "0.3.1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand_chacha/0.3.1/download", + "sha256": "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand_chacha", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand_chacha", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "std" + ], + "deps": { + "common": [ + { + "id": "ppv-lite86 0.2.16", + "target": "ppv_lite86" + }, + { + "id": "rand_core 0.6.3", + "target": "rand_core" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.3.1" + }, + "license": "MIT OR Apache-2.0" + }, + "rand_core 0.6.3": { + "name": "rand_core", + "version": "0.6.3", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/rand_core/0.6.3/download", + "sha256": "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" + } + }, + "targets": [ + { + "Library": { + "crate_name": "rand_core", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "rand_core", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "alloc", + "getrandom", + "std" + ], + "deps": { + "common": [ + { + "id": "getrandom 0.2.7", + "target": "getrandom" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.6.3" + }, + "license": "MIT OR Apache-2.0" + }, + "serde 1.0.137": { + "name": "serde", + "version": "1.0.137", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/serde/1.0.137/download", + "sha256": "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" + } + }, + "targets": [ + { + "Library": { + "crate_name": "serde", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "serde", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "derive", + "serde_derive", + "std" + ], + "deps": { + "common": [ + { + "id": "serde 1.0.137", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2015", + "proc_macro_deps": { + "common": [ + { + "id": "serde_derive 1.0.137", + "target": "serde_derive" + } + ], + "selects": {} + }, + "version": "1.0.137" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "serde_derive 1.0.137": { + "name": "serde_derive", + "version": "1.0.137", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/serde_derive/1.0.137/download", + "sha256": "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "serde_derive", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "serde_derive", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default" + ], + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + }, + { + "id": "serde_derive 1.0.137", + "target": "build_script_build" + }, + { + "id": "syn 1.0.98", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "1.0.137" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "syn 1.0.98": { + "name": "syn", + "version": "1.0.98", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/syn/1.0.98/download", + "sha256": "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" + } + }, + "targets": [ + { + "Library": { + "crate_name": "syn", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "syn", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "clone-impls", + "default", + "derive", + "fold", + "parsing", + "printing", + "proc-macro", + "quote" + ], + "deps": { + "common": [ + { + "id": "proc-macro2 1.0.40", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.20", + "target": "quote" + }, + { + "id": "syn 1.0.98", + "target": "build_script_build" + }, + { + "id": "unicode-ident 1.0.1", + "target": "unicode_ident" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.0.98" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT OR Apache-2.0" + }, + "toml 0.5.9": { + "name": "toml", + "version": "0.5.9", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/toml/0.5.9/download", + "sha256": "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" + } + }, + "targets": [ + { + "Library": { + "crate_name": "toml", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "toml", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default" + ], + "deps": { + "common": [ + { + "id": "serde 1.0.137", + "target": "serde" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.5.9" + }, + "license": "MIT/Apache-2.0" + }, + "unicode-ident 1.0.1": { + "name": "unicode-ident", + "version": "1.0.1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/unicode-ident/1.0.1/download", + "sha256": "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "unicode_ident", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "unicode_ident", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "1.0.1" + }, + "license": "MIT OR Apache-2.0" + }, + "vcpkg 0.2.15": { + "name": "vcpkg", + "version": "0.2.15", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/vcpkg/0.2.15/download", + "sha256": "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + } + }, + "targets": [ + { + "Library": { + "crate_name": "vcpkg", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "vcpkg", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.2.15" + }, + "license": "MIT/Apache-2.0" + }, + "version_check 0.9.4": { + "name": "version_check", + "version": "0.9.4", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/version_check/0.9.4/download", + "sha256": "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + } + }, + "targets": [ + { + "Library": { + "crate_name": "version_check", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "version_check", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.9.4" + }, + "license": "MIT/Apache-2.0" + }, + "wasi 0.11.0+wasi-snapshot-preview1": { + "name": "wasi", + "version": "0.11.0+wasi-snapshot-preview1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/wasi/0.11.0+wasi-snapshot-preview1/download", + "sha256": "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + } + }, + "targets": [ + { + "Library": { + "crate_name": "wasi", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "wasi", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "default", + "std" + ], + "edition": "2018", + "version": "0.11.0+wasi-snapshot-preview1" + }, + "license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT" + } + }, + "binary_crates": [ + "cc 1.0.73" + ], + "workspace_members": { + "direct-cargo-bazel-deps 0.0.1": "" + }, + "conditions": { + "cfg(target_os = \"wasi\")": [ + "wasm32-wasi" + ], + "cfg(unix)": [ + "aarch64-apple-darwin", + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "aarch64-linux-android", + "aarch64-unknown-linux-gnu", + "arm-unknown-linux-gnueabi", + "armv7-linux-androideabi", + "armv7-unknown-linux-gnueabi", + "i686-apple-darwin", + "i686-linux-android", + "i686-unknown-freebsd", + "i686-unknown-linux-gnu", + "powerpc-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-apple-ios", + "x86_64-linux-android", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-gnu" + ] + } +} diff --git a/WORKSPACE b/WORKSPACE index e1e7e3f..7308aa8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -11,6 +11,18 @@ load("//:asphr_load2.bzl", "load_asphr_repos2") load_asphr_repos2() +load("//:asphr_load3.bzl", "load_asphr_repos3") + +load_asphr_repos3() + +load("//:asphr_load4.bzl", "load_asphr_repos4") + +load_asphr_repos4() + +load("//:asphr_load5.bzl", "load_asphr_repos5") + +load_asphr_repos5("") + load("//:asphr.bzl", "setup_asphr") setup_asphr("") diff --git a/asphr.bzl b/asphr.bzl index 3c06697..c4d7581 100644 --- a/asphr.bzl +++ b/asphr.bzl @@ -10,6 +10,7 @@ load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains") load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") +load("@crate_index//:defs.bzl", "crate_repositories") def setup_asphr(asphr_path): """Setup the asphr repository @@ -38,3 +39,6 @@ def setup_asphr(asphr_path): package_json = asphr_path + "//schema:package.json", yarn_lock = asphr_path + "//schema:yarn.lock", ) + + crate_repositories() + diff --git a/asphr_load.bzl b/asphr_load.bzl index 19bc552..23f1268 100644 --- a/asphr_load.bzl +++ b/asphr_load.bzl @@ -7,6 +7,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +RUST_VERSION = "1.61.0" + def load_asphr_repos(asphr_path): """Loads the repositories for the asphr project. @@ -92,4 +94,25 @@ def load_asphr_repos(asphr_path): patches = [asphr_path + "//:rules_boost.patch"], # issue: https://github.com/nelhage/rules_boost/issues/160 (on certain linux distros, clang cannot find backtrace.h. see https://www.boost.org/doc/libs/1_71_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3) ) + # To find additional information on this release or newer ones visit: + # https://github.com/bazelbuild/rules_rust/releases + http_archive( + name = "rules_rust", + sha256 = "872b04538ca20dad94791c348623f079ba93daf274c1d57ae6bfe0930ec77f0d", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_rust/releases/download/0.6.0/rules_rust-v0.6.0.tar.gz", + "https://github.com/bazelbuild/rules_rust/releases/download/0.6.0/rules_rust-v0.6.0.tar.gz", + ], + ) + + http_archive( + name = "cxx.rs", + sha256 = "6fed9ef1c64a37c343727368b38c27fa4e15b27ca9924c6672a6a5496080c832", + strip_prefix = "cxx-1.0.68", + urls = ["https://github.com/dtolnay/cxx/archive/refs/tags/1.0.68.tar.gz"], + patch_args = ["-p1"], + patches = [asphr_path + "//:cxx.patch"], # issue: we want to derive custom traits in Rust that C++ doesn't necessarily need to know about! + ) + + diff --git a/asphr_load2.bzl b/asphr_load2.bzl index 1665e91..f86bf3f 100644 --- a/asphr_load2.bzl +++ b/asphr_load2.bzl @@ -12,6 +12,10 @@ load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies") load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") +load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains") +load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_deps") +load(":asphr_load.bzl", "RUST_VERSION") + def load_asphr_repos2(): """Loads the remaining repositories for the asphr project (those that depend on load_asphr_repos()).""" @@ -33,3 +37,11 @@ def load_asphr_repos2(): grpc_deps() boost_deps() + + rules_rust_dependencies() + + rust_register_toolchains(version = RUST_VERSION, edition="2021") + + rust_analyzer_deps() + + diff --git a/asphr_load3.bzl b/asphr_load3.bzl new file mode 100644 index 0000000..5c4a6a5 --- /dev/null +++ b/asphr_load3.bzl @@ -0,0 +1,14 @@ +# +# Copyright 2022 Anysphere, Inc. +# SPDX-License-Identifier: GPL-3.0-only +# + +"""Load asphr repos (part 3).""" + +load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") + +def load_asphr_repos3(): + """Loads the remaining repositories for the asphr project (those that depend on load_asphr_repos2()).""" + + crate_universe_dependencies() + diff --git a/asphr_load4.bzl b/asphr_load4.bzl new file mode 100644 index 0000000..674af7f --- /dev/null +++ b/asphr_load4.bzl @@ -0,0 +1,13 @@ +# +# Copyright 2022 Anysphere, Inc. +# SPDX-License-Identifier: GPL-3.0-only +# + +"""Load asphr repos (part 4).""" + +load("@rules_rust//crate_universe:crates_deps.bzl", "crate_repositories") + +def load_asphr_repos4(): + """Loads the remaining repositories for the asphr project (those that depend on load_asphr_repos3()).""" + + crate_repositories() diff --git a/asphr_load5.bzl b/asphr_load5.bzl new file mode 100644 index 0000000..ccf91e7 --- /dev/null +++ b/asphr_load5.bzl @@ -0,0 +1,47 @@ +# +# Copyright 2022 Anysphere, Inc. +# SPDX-License-Identifier: GPL-3.0-only +# + +"""Load asphr repos (part 5).""" + +load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "render_config") +load("@cxx.rs//tools/bazel:vendor.bzl", rust_cxx_vendor = "vendor") +load(":asphr_load.bzl", "RUST_VERSION") + +def load_asphr_repos5(asphr_path): + """Loads the remaining repositories for the asphr project (those that depend on load_asphr_repos4()).""" + + crates_repository( + name = "crate_index", + lockfile = asphr_path + "//:Cargo.Bazel.lock", + packages = { + "diesel": crate.spec( + version = "2.0.0-rc.0", + features = ["sqlite", "returning_clauses_for_sqlite_3_35"], + ), + "diesel_migrations": crate.spec( + version = "2.0.0-rc.0", + features = ["sqlite"], + ), + "rand": crate.spec( + version = "0.8.5", + ), + "libsqlite3-sys": crate.spec( + version = "0.24.2", + features = ["bundled"], + ), + }, + # Setting the default package name to `""` forces the use of the macros defined in this repository + # to always use the root package when looking for dependencies or aliases. This should be considered + # optional as the repository also exposes aliases for easy access to all dependencies. + render_config = render_config( + default_package_name = "", + ), + ) + + rust_cxx_vendor( + name = "third-party", + cargo_version = RUST_VERSION, + lockfile = "@cxx.rs//third-party:Cargo.lock", + ) diff --git a/cxx.patch b/cxx.patch new file mode 100644 index 0000000..d0166f9 --- /dev/null +++ b/cxx.patch @@ -0,0 +1,60 @@ +diff --git a/syntax/attrs.rs b/syntax/attrs.rs +index cb40295b..1690535c 100644 +--- a/syntax/attrs.rs ++++ b/syntax/attrs.rs +@@ -65,9 +65,17 @@ pub fn parse(cx: &mut Errors, attrs: Vec, mut parser: Parser) -> Othe + } + } else if attr.path.is_ident("derive") { + match attr.parse_args_with(|attr: ParseStream| parse_derive_attribute(cx, attr)) { +- Ok(attr) => { +- if let Some(derives) = &mut parser.derives { +- derives.extend(attr); ++ Ok((attr_if_ok, ok)) => { ++ if ok { ++ if let Some(derives) = &mut parser.derives { ++ derives.extend(attr_if_ok); ++ continue; ++ } ++ } else { ++ // If the derive attribute is not valid, we pass it through. Then, it will be available ++ // in Rust but not in C++. This is often fine. ++ // For the traits that you do want to derive in C++, provide them in a separate #[derive(...)] ++ passthrough_attrs.push(attr); + continue; + } + } +@@ -76,6 +84,9 @@ pub fn parse(cx: &mut Errors, attrs: Vec, mut parser: Parser) -> Othe + break; + } + } ++ } else if attr.path.is_ident("diesel") { ++ passthrough_attrs.push(attr); ++ continue; + } else if attr.path.is_ident("repr") { + match attr.parse_args_with(parse_repr_attribute) { + Ok(attr) => { +@@ -208,10 +219,11 @@ fn parse_doc_attribute(input: ParseStream) -> Result { + } + } + +-fn parse_derive_attribute(cx: &mut Errors, input: ParseStream) -> Result> { ++fn parse_derive_attribute(_cx: &mut Errors, input: ParseStream) -> Result<(Vec, bool)> { + let paths = input.parse_terminated::(Path::parse_mod_style)?; + + let mut derives = Vec::new(); ++ let mut ok = true; + for path in paths { + if let Some(ident) = path.get_ident() { + if let Some(derive) = Derive::from(ident) { +@@ -219,9 +231,9 @@ fn parse_derive_attribute(cx: &mut Errors, input: ParseStream) -> Result Result { \ No newline at end of file diff --git a/pir/fast_pir/fast_pir_client.hpp b/pir/fast_pir/fast_pir_client.hpp index 62050d6..8e1cb47 100644 --- a/pir/fast_pir/fast_pir_client.hpp +++ b/pir/fast_pir/fast_pir_client.hpp @@ -35,21 +35,32 @@ class FastPIRClient { // TODO: fix this absolute mess of initializers??? - FastPIRClient() : FastPIRClient(create_context_params()) {} + FastPIRClient() : FastPIRClient(create_context_params()) { + ASPHR_LOG_INFO("Creating FastPIRClient.", from, "base"); + } FastPIRClient(seal::SEALContext sc) - : FastPIRClient(sc, seal::KeyGenerator(sc)) {} + : FastPIRClient(sc, seal::KeyGenerator(sc)) { + ASPHR_LOG_INFO("Creating FastPIRClient.", from, "context params"); + } FastPIRClient(seal::SEALContext sc, seal::KeyGenerator keygen) : FastPIRClient(sc, keygen.secret_key(), - gen_galois_keys(keygen.create_galois_keys())) {} + gen_galois_keys(keygen.create_galois_keys())) { + ASPHR_LOG_INFO("Creating FastPIRClient.", from, "context params, keygen"); + } FastPIRClient(string secret_key, string galois_keys) : FastPIRClient(seal::SEALContext(create_context_params()), secret_key, - galois_keys) {} + galois_keys) { + ASPHR_LOG_INFO("Creating FastPIRClient.", from, "secret key, galois keys"); + } FastPIRClient(seal::SEALContext sc, string secret_key, string galois_keys) : FastPIRClient(sc, deserialize_secret_key(sc, secret_key), galois_keys) { + ASPHR_LOG_INFO("Creating FastPIRClient.", from, + "context params, " + "secret key, galois keys"); } FastPIRClient(seal::SecretKey secret_key, string galois_keys) diff --git a/schema/daemon.proto b/schema/daemon.proto index 510b540..efc7420 100644 --- a/schema/daemon.proto +++ b/schema/daemon.proto @@ -55,8 +55,9 @@ message RegisterUserResponse {} message GetFriendListRequest {} message FriendInfo { - string name = 1; - bool enabled = 2; + string unique_name = 1; + string display_name = 2; + bool enabled = 3; } message GetFriendListResponse { @@ -64,7 +65,8 @@ message GetFriendListResponse { } message GenerateFriendKeyRequest { - string name = 1; + string unique_name = 1; + string display_name = 2; } message GenerateFriendKeyResponse { @@ -72,20 +74,20 @@ message GenerateFriendKeyResponse { } message AddFriendRequest { - string name = 1; + string unique_name = 1; string key = 2; } message AddFriendResponse {} message RemoveFriendRequest { - string name = 1; + string unique_name = 1; } message RemoveFriendResponse {} message SendMessageRequest { - string name = 1; + string unique_name = 1; string message = 2; } @@ -96,22 +98,24 @@ message BaseMessage { // in particular, this ID is guaranteed to be unique among ALL messages (on a given device), whereas the ID in message.proto // is only unique for each pair. // the format of this ID is something like (to|from):sender:sequence_number - string id = 1; + int32 id = 1; string message = 2; + string unique_name = 3; + string display_name = 4; } message IncomingMessage { BaseMessage m = 1; - string from = 2; - google.protobuf.Timestamp received_timestamp = 3; - bool seen = 4; + google.protobuf.Timestamp delivered_at = 2; + bool seen = 3; + bool delivered = 4; } message OutgoingMessage { BaseMessage m = 1; - string to = 2; - google.protobuf.Timestamp written_timestamp = 3; - bool delivered = 4; + google.protobuf.Timestamp sent_at = 2; + bool delivered = 3; + google.protobuf.Timestamp delivered_at = 4; } message GetMessagesRequest { @@ -139,7 +143,7 @@ message GetSentMessagesResponse { } message MessageSeenRequest { - string id = 1; + int32 id = 1; } message MessageSeenResponse {} @@ -150,6 +154,7 @@ message GetStatusResponse { bool registered = 1; string release_hash = 2; int32 latency_seconds = 3; + string server_address = 4; } message GetLatencyRequest {} diff --git a/schema/message.proto b/schema/message.proto index 10b4dec..24a1dd8 100644 --- a/schema/message.proto +++ b/schema/message.proto @@ -21,11 +21,11 @@ package asphrclient; // // update GUARANTEED_MESSAGE_SIZE in client_lib.hpp whenever this is updated. message Message { - // id is a unique id for the message. it is unique for a ordered pair. + // sequence_number is a unique id for the message. it is unique for a ordered pair. // if the id is 0, then the message is a dummy message, with no actual msg to display to the user. // TODO: to optimize space usage, we should merge the id here and the nonce used for encryption. // this requires some careful thought with dummy messages. - uint32 id = 1; + uint32 sequence_number = 1; // msg contains the actual UTF-8 message, if such a message exists string msg = 2; // acks contains the ids of messages that the sender has received and has not acked before. @@ -35,7 +35,7 @@ message Message { // this field is not set if the message isn't long. uint32 num_chunks = 4; // if the message is a long message, this field contains the start id of the long message. - // the index in this message in the long message is (id - parts_start_id) + // the index in this message in the long message is (sequence_number - chunks_start_sequence_number) // this field is not set if the message isn't long. - uint32 chunks_start_id = 5; + uint32 chunks_start_sequence_number = 5; } \ No newline at end of file