Skip to content

Splitting Store implementation into separate crates #498

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

Merged
merged 51 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e928d02
Move indexeddb out into a separate crate
gnunicorn Feb 14, 2022
5cae4e0
making tests pass again
gnunicorn Feb 14, 2022
393cfb1
move indexeddb cryptostore into new crate
gnunicorn Feb 15, 2022
ea92bc6
Merge remote-tracking branch 'origin/main' into ben-splitting-out-sto…
gnunicorn Feb 17, 2022
0ca6ec1
moving sled state store into separate crate
gnunicorn Feb 17, 2022
00ea5d9
moving sled cryptostore, too
gnunicorn Feb 18, 2022
95384f0
make encryption in new crates optional
gnunicorn Feb 18, 2022
87cd9a3
clean up base
gnunicorn Feb 18, 2022
6aeb382
move state inspector for sled store into corresponding crate
gnunicorn Feb 21, 2022
f6a3c76
Merge remote-tracking branch 'origin/main' into ben-splitting-out-sto…
gnunicorn Feb 23, 2022
eeea757
clippy and formatting
gnunicorn Feb 23, 2022
7322762
one more fmt
gnunicorn Feb 23, 2022
2188787
chore(CI): limit CI runs to non-draft PRs and manual dispatching
gnunicorn Feb 23, 2022
692f9d8
chore(CI): also skip docs making on draft PRs
gnunicorn Feb 23, 2022
ed0974e
re-integrate sled and indexeddb stores into base
gnunicorn Feb 23, 2022
12cf187
indexeddb store and passphrase opening
gnunicorn Feb 23, 2022
e20bdfa
cleaning up more cryptocrate
gnunicorn Feb 23, 2022
d7f3016
moving safe encode, making regular build work again
gnunicorn Feb 24, 2022
9c5cb08
fixing crypto testing problems
gnunicorn Feb 24, 2022
259ba3b
refactor CI tests
gnunicorn Feb 24, 2022
cccad61
fixing formatting
gnunicorn Feb 24, 2022
4d6d13b
fixing some clippies and wrong package naming
gnunicorn Feb 24, 2022
4c1e3ac
fix missing import
gnunicorn Feb 24, 2022
418fac8
fixing missing import for tests
gnunicorn Feb 24, 2022
9386e9d
fixing name path
gnunicorn Feb 24, 2022
8706ab6
fixing formatting
gnunicorn Feb 24, 2022
6c90af1
fixing indexeddb test
gnunicorn Feb 24, 2022
75953d6
fixing machine doc builds
gnunicorn Feb 24, 2022
e1f898e
fixing clippy and docs for base and crypto
gnunicorn Feb 25, 2022
c97f7e9
clippy
gnunicorn Feb 25, 2022
06c9b1a
fixing proepr cargo build call
gnunicorn Feb 25, 2022
2e9ca56
more clippy for indexeddb
gnunicorn Feb 25, 2022
a6514b0
indexeddb formatting
gnunicorn Feb 25, 2022
5e05411
fixing typos
gnunicorn Feb 25, 2022
13c39db
fixing crypto bench
gnunicorn Feb 25, 2022
56b3b2c
minor fix in ci
gnunicorn Feb 25, 2022
e414c88
fixing integration test example
gnunicorn Feb 25, 2022
fce78ea
fixing style
gnunicorn Feb 25, 2022
25e98db
missing .to_string
gnunicorn Feb 25, 2022
c2bb1b9
remove unneded braces in ci
gnunicorn Mar 1, 2022
33be17d
review requests
gnunicorn Mar 1, 2022
ca18fca
make Sled store benchmarks use SledStore again
gnunicorn Mar 1, 2022
8aed72a
Update crates/matrix-sdk-crypto/src/olm/account.rs
gnunicorn Mar 3, 2022
fd6f438
Merge remote-tracking branch 'origin/main' into ben-splitting-out-sto…
gnunicorn Mar 3, 2022
ab57fb3
Addressing review remark
gnunicorn Mar 3, 2022
e7fb512
adding another encryption wasm tests
gnunicorn Mar 3, 2022
4e6b80d
fix docs
gnunicorn Mar 3, 2022
193a5ed
fixing if syntax
gnunicorn Mar 3, 2022
6435ea6
fix testing function wrongly exposed
gnunicorn Mar 3, 2022
ba1b3e0
fix the indexeddb tests, that clippy tried to fix
gnunicorn Mar 3, 2022
44fe3a6
remove unneeded helper function
gnunicorn Mar 3, 2022
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
6 changes: 6 additions & 0 deletions .github/workflows/appservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ on:
branches: [main]
pull_request:
branches: [main]
types:
- opened
- reopened
- synchronize
- ready_for_review

env:
CARGO_TERM_COLOR: always

jobs:
test-appservice:
if: github.event_name == 'push' || !github.event.pull_request.draft
name: ${{ matrix.name }}

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: CI

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
types:
- opened
- reopened
- synchronize
- ready_for_review

env:
CARGO_TERM_COLOR: always
Expand All @@ -13,6 +19,7 @@ jobs:
style:
name: Check style
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

steps:
- name: Checkout the repo
Expand All @@ -36,6 +43,7 @@ jobs:
name: Spell Check with Typos
needs: [style]
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

steps:
- name: Checkout Actions Repository
Expand All @@ -48,6 +56,7 @@ jobs:
name: Run clippy
needs: [style]
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

steps:
- name: Checkout the repo
Expand All @@ -72,6 +81,7 @@ jobs:

test-features:
name: ${{ matrix.name }}
if: github.event_name == 'push' || !github.event.pull_request.draft

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
Expand Down Expand Up @@ -141,6 +151,7 @@ jobs:

test:
name: ${{ matrix.name }}
if: github.event_name == 'push' || !github.event.pull_request.draft

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
docs:
name: Docs
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

steps:
- name: Checkout repository
Expand Down
54 changes: 25 additions & 29 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches: [main]
pull_request:
branches: [main]
types:
- opened
- reopened
- synchronize
- ready_for_review

env:
CARGO_TERM_COLOR: always
Expand All @@ -13,25 +18,24 @@ jobs:
check-wasm:
name: Build test
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft

strategy:
# fail-fast: true

fail-fast: true
matrix:
name:
- matrix-qrcode
- matrix-sdk (no-default, wasm-flags)
- matrix-sdk-base
- matrix-sdk-common
- matrix-sdk-crypto
- matrix-sdk-base / indexeddb_state_store
- matrix-sdk-crypto / indexeddb_cryptostore
- matrix-sdk / indexeddb_stores

include:
- name: matrix-qrcode
cargo_args: --package matrix-qrcode
- name: matrix-sdk (no-default, wasm-flags)
cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk
cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk --lib
- name: matrix-sdk-base
cargo_args: --package matrix-sdk-base
- name: matrix-sdk-common
Expand All @@ -40,10 +44,8 @@ jobs:
cargo_args: --package matrix-sdk-crypto

# special check for specific features
- name: matrix-sdk-base / indexeddb_state_store
cargo_args: --package matrix-sdk-base --features indexeddb_state_store
- name: matrix-sdk-crypto / indexeddb_cryptostore
cargo_args: --package matrix-sdk-crypto --features indexeddb_cryptostore
- name: matrix-sdk / indexeddb_stores
cargo_args: --package matrix-sdk --no-default-features --features indexeddb_stores,encryption,rustls-tls --lib

steps:
- name: Checkout the repo
Expand All @@ -59,7 +61,6 @@ jobs:

- name: Load cache
uses: Swatinem/rust-cache@v1

# needed for libolm-sys compilation
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v11
Expand All @@ -76,26 +77,26 @@ jobs:
# building wasm is not enough, we've seen runtime errors before,
# hence the tests
name: ${{ matrix.name }} test
if: github.event_name == 'push' || !github.event.pull_request.draft
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}

strategy:
matrix:
include:
- name: "matrix-sdk-crypto @Node14 emcc2.0"
experimental: false
emcc_version: 2.0.27
base_dir: matrix-sdk-crypto
cargo_args: --features indexeddb_cryptostore
- name: matrix-sdk-base
experimental: false
base_dir: matrix-sdk-base
cargo_args: --features indexeddb_state_store,indexeddb_cryptostore
- name: matrix-sdk
experimental: false
base_dir: matrix-sdk
# FIXME: we have to skip all examples b/c of https://github.com/rustwasm/wasm-pack/issues/666
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib
- name: matrix-sdk-encryption
experimental: false
emcc_version: 2.0.27
node_version: '14'
base_dir: matrix-sdk
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls,encryption --lib
- name: "matrix-sdk-indexeddb"
base_dir: matrix-sdk-indexeddb
experimental: false
- name: "matrix-sdk-example-wasm_command_bot @Node14"
experimental: false
emcc_version: 2.0.27
Expand All @@ -106,11 +107,6 @@ jobs:
npm install
npm test
wasm-pack test --firefox --headless

# these are _known_ broken on latest node
# - name: matrix-sdk-crypto
# experimental: true
# base_dir: matrix-sdk-crypto
- name: matrix-sdk-example-wasm_command_bot
base_dir: matrix-sdk/examples/wasm_command_bot
# this might fail
Expand Down Expand Up @@ -160,14 +156,14 @@ jobs:
emcc -v

- name: Default wasm-pack tests
if: ${{!matrix.cmd}}
if: ${{ !matrix.cmd }}
run: |
cd crates/${{matrix.base_dir}}
wasm-pack test --node -- ${{ matrix.cargo_args }}
wasm-pack test --firefox --headless -- --features ${{ matrix.cargo_args }}
wasm-pack test --firefox --headless -- ${{ matrix.cargo_args }}

- name: Testing with custom command
if: ${{matrix.cmd}}
if: ${{ matrix.cmd }}
run: |
cd crates/${{matrix.base_dir}}
${{matrix.cmd}}
39 changes: 8 additions & 31 deletions crates/matrix-sdk-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = []
encryption = ["matrix-sdk-crypto"]
encryption = ["matrix-sdk-crypto", "store_key"]
qrcode = ["matrix-sdk-crypto/qrcode"]
sled_state_store = [
"sled",
"tokio",

# Store Key is a helper feature for state store implementations
store_key = [
"pbkdf2",
"hmac",
"sha2",
"rand",
"chacha20poly1305",
]
sled_cryptostore = ["matrix-sdk-crypto/sled_cryptostore"]

indexeddb_state_store = ["indexed_db_futures", "wasm-bindgen", "pbkdf2", "hmac", "sha2", "rand", "chacha20poly1305"]
indexeddb_cryptostore = ["matrix-sdk-crypto/indexeddb_cryptostore"]
# helpers for testing features build upon this
testing = [ "http" ]

[dependencies]
async-stream = "0.3.2"
Expand All @@ -50,38 +48,17 @@ ruma = { version = "0.5.0", features = ["client-api-c", "signatures", "unstable-
serde = { version = "1.0.126", features = ["rc"] }
serde_json = "1.0.64"
sha2 = { version = "0.10.1", optional = true }
sled = { version = "0.34.6", optional = true }
thiserror = "1.0.25"
tracing = "0.1.26"
zeroize = { version = "1.3.0", features = ["zeroize_derive"] }

## Feature sled_state_store
tokio = { version = "1.7.1", optional = true, default-features = false, features = ["sync", "fs"] }

## Feature indexeddb-state-store
indexed_db_futures = { version = "0.2.0", optional = true }
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
anyhow = "1"
http = { version = "0.2.4", optional = true }

[dev-dependencies]
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
http = "0.2.4"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
atty = "0.2.14"
clap = "3.1.0"
rustyline = "9.0.0"
rustyline-derive = "0.6.0"
syntect = "4.5.0"
tokio = { version = "1.7.1", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
tempfile = "3.2.0"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.24"

[[example]]
name = "state_inspector"
required-features = ["sled_state_store"]
9 changes: 3 additions & 6 deletions crates/matrix-sdk-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ library.
The following crate feature flags are available:

* `encryption`: Enables end-to-end encryption support in the library.
* `sled_cryptostore`: Enables a Sled based store for the encryption
keys. If this is disabled and `encryption` support is enabled the keys will
by default be stored only in memory and thus lost after the client is
destroyed.
* `sled_state_store`: Enables a Sled based store for the storage of the local
client state.
* `qrcode`: Enbles QRcode generation and reading code
* `store_key`: Provides extra facilities for StateStores to manage store keys
* `testing`: provides facilities and functions for tests, in particular for integration testing store implementations. ATTENTION: do not ever use outside of tests, we do not provide any stability warantees on these, these are merely helpers. If you find you _need_ any function provided here outside of tests, please open a Github Issue and inform us about your use case for us to consider.
Loading