Skip to content

Commit

Permalink
Decode identity correctly (#1952)
Browse files Browse the repository at this point in the history
jsdt authored Nov 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6d712b4 commit 0b1beec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/cli/src/util.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ use base64::{
};
use reqwest::RequestBuilder;
use serde::Deserialize;
use spacetimedb::auth::identity::SpacetimeIdentityClaims2;
use spacetimedb::auth::identity::{IncomingClaims, SpacetimeIdentityClaims2};
use spacetimedb_client_api_messages::name::{DnsLookupResponse, RegisterTldResult, ReverseDNSResponse};
use spacetimedb_data_structures::map::HashMap;
use spacetimedb_lib::{AlgebraicType, Identity};
@@ -280,7 +280,8 @@ pub fn decode_identity(config: &Config) -> anyhow::Result<String> {
let decoded_bytes = BASE_64_STD_NO_PAD.decode(token_parts[1])?;
let decoded_string = String::from_utf8(decoded_bytes)?;

let claims_data: SpacetimeIdentityClaims2 = serde_json::from_str(decoded_string.as_str())?;
let claims_data: IncomingClaims = serde_json::from_str(decoded_string.as_str())?;
let claims_data: SpacetimeIdentityClaims2 = claims_data.try_into()?;

Ok(claims_data.identity.to_string())
}

2 comments on commit 0b1beec

@github-actions
Copy link

@github-actions github-actions bot commented on 0b1beec Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criterion benchmark results

Criterion benchmark report

YOU SHOULD PROBABLY IGNORE THESE RESULTS.

Criterion is a wall time based benchmarking system that is extremely noisy when run on CI. We collect these results for longitudinal analysis, but they are not reliable for comparing individual PRs.

Go look at the callgrind report instead.

empty

db on disk new latency old latency new throughput old throughput
sqlite 💿 404.1±1.61ns 411.1±6.61ns - -
sqlite 🧠 398.2±3.57ns 408.1±5.14ns - -
stdb_raw 💿 774.3±1.40ns 788.0±2.02ns - -
stdb_raw 🧠 774.4±3.08ns 786.7±2.31ns - -

insert_1

db on disk schema indices preload new latency old latency new throughput old throughput

insert_bulk

db on disk schema indices preload count new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str btree_each_column 2048 256 591.7±0.77µs 585.9±0.86µs 1690 tx/sec 1706 tx/sec
sqlite 💿 u32_u64_str unique_0 2048 256 147.5±0.62µs 148.0±0.48µs 6.6 Ktx/sec 6.6 Ktx/sec
sqlite 💿 u32_u64_u64 btree_each_column 2048 256 465.4±0.25µs 469.5±1.02µs 2.1 Ktx/sec 2.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 2048 256 135.4±0.31µs 135.8±0.37µs 7.2 Ktx/sec 7.2 Ktx/sec
sqlite 🧠 u32_u64_str btree_each_column 2048 256 447.7±0.58µs 447.9±0.40µs 2.2 Ktx/sec 2.2 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 2048 256 121.6±1.08µs 120.1±0.43µs 8.0 Ktx/sec 8.1 Ktx/sec
sqlite 🧠 u32_u64_u64 btree_each_column 2048 256 365.6±0.40µs 368.2±0.50µs 2.7 Ktx/sec 2.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 2048 256 104.6±1.42µs 105.8±0.66µs 9.3 Ktx/sec 9.2 Ktx/sec
stdb_raw 💿 u32_u64_str btree_each_column 2048 256 553.7±59.69µs 592.9±24.11µs 1806 tx/sec 1686 tx/sec
stdb_raw 💿 u32_u64_str unique_0 2048 256 481.6±21.15µs 450.2±36.20µs 2.0 Ktx/sec 2.2 Ktx/sec
stdb_raw 💿 u32_u64_u64 btree_each_column 2048 256 369.3±9.29µs 361.9±11.99µs 2.6 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 2048 256 345.7±7.02µs 348.5±10.83µs 2.8 Ktx/sec 2.8 Ktx/sec
stdb_raw 🧠 u32_u64_str btree_each_column 2048 256 298.0±0.19µs 301.1±0.21µs 3.3 Ktx/sec 3.2 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 2048 256 227.7±0.20µs 227.6±0.36µs 4.3 Ktx/sec 4.3 Ktx/sec
stdb_raw 🧠 u32_u64_u64 btree_each_column 2048 256 234.1±0.15µs 235.0±0.35µs 4.2 Ktx/sec 4.2 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 2048 256 207.2±0.20µs 208.2±0.32µs 4.7 Ktx/sec 4.7 Ktx/sec

iterate

db on disk schema indices new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str unique_0 22.4±0.41µs 22.1±0.16µs 43.5 Ktx/sec 44.3 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 20.1±0.04µs 21.0±0.05µs 48.5 Ktx/sec 46.6 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 19.5±0.11µs 19.7±0.08µs 50.1 Ktx/sec 49.5 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 17.4±0.07µs 18.4±0.10µs 56.1 Ktx/sec 53.0 Ktx/sec
stdb_raw 💿 u32_u64_str unique_0 4.0±0.00µs 4.0±0.00µs 244.2 Ktx/sec 243.6 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 3.9±0.00µs 3.9±0.00µs 252.1 Ktx/sec 251.7 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 4.0±0.00µs 4.0±0.00µs 244.5 Ktx/sec 244.2 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 3.9±0.01µs 3.9±0.00µs 252.6 Ktx/sec 252.0 Ktx/sec

find_unique

db on disk key type preload new latency old latency new throughput old throughput

filter

db on disk key type index strategy load count new latency old latency new throughput old throughput
sqlite 💿 string index 2048 256 69.8±0.16µs 70.8±0.32µs 14.0 Ktx/sec 13.8 Ktx/sec
sqlite 💿 u64 index 2048 256 65.6±0.52µs 67.0±0.08µs 14.9 Ktx/sec 14.6 Ktx/sec
sqlite 🧠 string index 2048 256 65.5±0.24µs 66.9±0.36µs 14.9 Ktx/sec 14.6 Ktx/sec
sqlite 🧠 u64 index 2048 256 59.8±0.16µs 62.2±0.19µs 16.3 Ktx/sec 15.7 Ktx/sec
stdb_raw 💿 string index 2048 256 5.0±0.00µs 5.0±0.01µs 195.5 Ktx/sec 194.9 Ktx/sec
stdb_raw 💿 u64 index 2048 256 4.9±0.00µs 4.9±0.00µs 198.6 Ktx/sec 197.8 Ktx/sec
stdb_raw 🧠 string index 2048 256 5.0±0.00µs 5.0±0.00µs 195.5 Ktx/sec 194.8 Ktx/sec
stdb_raw 🧠 u64 index 2048 256 4.9±0.00µs 4.9±0.01µs 198.7 Ktx/sec 197.9 Ktx/sec

serialize

schema format count new latency old latency new throughput old throughput
u32_u64_str bflatn_to_bsatn_fast_path 100 3.6±0.01µs 3.6±0.01µs 26.9 Mtx/sec 26.6 Mtx/sec
u32_u64_str bflatn_to_bsatn_slow_path 100 3.5±0.00µs 3.6±0.01µs 26.9 Mtx/sec 26.7 Mtx/sec
u32_u64_str bsatn 100 15.7±0.11ns 15.6±0.11ns 6.0 Gtx/sec 6.0 Gtx/sec
u32_u64_str bsatn 100 2.4±0.01µs 2.5±0.02µs 40.1 Mtx/sec 37.4 Mtx/sec
u32_u64_str json 100 4.8±0.02µs 5.1±0.06µs 19.8 Mtx/sec 18.9 Mtx/sec
u32_u64_str json 100 9.1±0.18µs 8.8±0.06µs 10.4 Mtx/sec 10.9 Mtx/sec
u32_u64_str product_value 100 1018.9±3.26ns 1016.9±0.63ns 93.6 Mtx/sec 93.8 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_fast_path 100 1007.2±37.10ns 948.6±48.11ns 94.7 Mtx/sec 100.5 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.00µs 34.2 Mtx/sec 34.0 Mtx/sec
u32_u64_u64 bsatn 100 14.8±0.02ns 14.8±0.02ns 6.3 Gtx/sec 6.3 Gtx/sec
u32_u64_u64 bsatn 100 1736.0±29.40ns 1758.7±28.03ns 54.9 Mtx/sec 54.2 Mtx/sec
u32_u64_u64 json 100 3.3±0.05µs 3.1±0.01µs 29.1 Mtx/sec 30.8 Mtx/sec
u32_u64_u64 json 100 6.0±0.13µs 6.0±0.15µs 15.9 Mtx/sec 15.9 Mtx/sec
u32_u64_u64 product_value 100 1014.6±0.57ns 1014.1±0.44ns 94.0 Mtx/sec 94.0 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_fast_path 100 726.4±1.93ns 724.0±1.94ns 131.3 Mtx/sec 131.7 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_slow_path 100 2.8±0.01µs 2.8±0.00µs 34.2 Mtx/sec 33.9 Mtx/sec
u64_u64_u32 bsatn 100 1751.3±70.04ns 1809.0±21.18ns 54.5 Mtx/sec 52.7 Mtx/sec
u64_u64_u32 bsatn 100 704.9±3.63ns 706.1±1.52ns 135.3 Mtx/sec 135.1 Mtx/sec
u64_u64_u32 json 100 3.1±0.02µs 3.3±0.03µs 30.5 Mtx/sec 28.8 Mtx/sec
u64_u64_u32 json 100 6.0±0.13µs 5.8±0.09µs 16.0 Mtx/sec 16.4 Mtx/sec
u64_u64_u32 product_value 100 1015.3±0.84ns 1014.6±0.76ns 93.9 Mtx/sec 94.0 Mtx/sec

stdb_module_large_arguments

arg size new latency old latency new throughput old throughput
64KiB 100.8±7.71µs 102.2±11.89µs - -

stdb_module_print_bulk

line count new latency old latency new throughput old throughput
1 51.2±5.00µs 57.4±4.27µs - -
100 614.3±6.29µs 598.8±8.25µs - -
1000 5.5±0.03ms 3.7±0.56ms - -

remaining

name new latency old latency new throughput old throughput
special/db_game/circles/load=10 42.0±7.15ms 53.3±2.29ms - -
special/db_game/circles/load=100 37.7±1.01ms 48.3±4.56ms - -
special/db_game/ia_loop/load=500 148.2±1.12ms 145.2±2.75ms - -
special/db_game/ia_loop/load=5000 5.2±0.03s 5.1±0.03s - -
sqlite/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 52.8±0.10µs 53.6±0.21µs 18.5 Ktx/sec 18.2 Ktx/sec
sqlite/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 45.6±0.17µs 51.1±17.03µs 21.4 Ktx/sec 19.1 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 38.7±0.05µs 38.6±0.20µs 25.2 Ktx/sec 25.3 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 35.7±0.14µs 34.5±0.06µs 27.4 Ktx/sec 28.3 Ktx/sec
stdb_module/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 1258.8±7.44µs 1251.9±10.55µs 794 tx/sec 798 tx/sec
stdb_module/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 1020.5±3.70µs 1008.2±6.85µs 979 tx/sec 991 tx/sec
stdb_raw/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 523.6±11.84µs 618.3±38.10µs 1909 tx/sec 1617 tx/sec
stdb_raw/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 478.5±8.88µs 429.7±19.69µs 2.0 Ktx/sec 2.3 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 361.4±0.50µs 365.8±0.24µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 322.6±0.96µs 323.3±0.42µs 3.0 Ktx/sec 3.0 Ktx/sec

@github-actions
Copy link

@github-actions github-actions bot commented on 0b1beec Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callgrind benchmark results

Callgrind Benchmark Report

These benchmarks were run using callgrind,
an instruction-level profiler. They allow comparisons between sqlite (sqlite), SpacetimeDB running through a module (stdb_module), and the underlying SpacetimeDB data storage engine (stdb_raw). Callgrind emulates a CPU to collect the below estimates.

Measurement changes larger than five percent are in bold.

In-memory benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 6399 6399 0.00% 6491 6491 0.00%
sqlite 5579 5579 0.00% 6051 6051 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 1 u64 76593 76593 0.00% 77045 77049 -0.01%
stdb_raw u32_u64_str no_index 64 128 2 string 120180 119091 0.91% 120968 119871 0.92%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25083 25087 -0.02% 25667 25691 -0.09%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24051 24051 0.00% 24467 24471 -0.02%
sqlite u32_u64_str no_index 64 128 2 string 144695 144695 0.00% 146215 146215 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124044 124044 0.00% 125320 125320 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131361 131361 0.00% 132817 132817 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134494 134494 0.00% 136206 136198 0.01%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 876862 877054 -0.02% 931914 932062 -0.02%
stdb_raw u32_u64_str btree_each_column 64 128 1029125 1026887 0.22% 1053805 1082143 -2.62%
sqlite u32_u64_str unique_0 64 128 398320 398320 0.00% 413308 413316 -0.00%
sqlite u32_u64_str btree_each_column 64 128 983637 983637 0.00% 1018731 1018739 -0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 153726 153726 0.00% 153800 153800 0.00%
stdb_raw u32_u64_str unique_0 64 16751 16751 0.00% 16833 16809 0.14%
sqlite u32_u64_str unique_0 1024 1067255 1067255 0.00% 1070583 1070583 0.00%
sqlite u32_u64_str unique_0 64 76201 76201 0.00% 77195 77195 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47528 47528 0.00% 50146 50146 0.00%
64 bsatn 25509 25509 0.00% 27685 27685 0.00%
16 bsatn 8200 8200 0.00% 9492 9492 0.00%
16 json 12188 12188 0.00% 14058 14058 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 20086103 20495868 -2.00% 20665167 21131262 -2.21%
stdb_raw u32_u64_str unique_0 64 128 1284124 1285277 -0.09% 1357694 1358659 -0.07%
sqlite u32_u64_str unique_0 1024 1024 1802182 1802182 0.00% 1811458 1811458 0.00%
sqlite u32_u64_str unique_0 64 128 128528 128528 0.00% 131412 131412 0.00%
On-disk benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 6404 6404 0.00% 6512 6512 0.00%
sqlite 5621 5621 0.00% 6153 6153 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 1 u64 76598 76598 0.00% 77026 77034 -0.01%
stdb_raw u32_u64_str no_index 64 128 2 string 119096 120185 -0.91% 119896 121025 -0.93%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25088 25091 -0.01% 25632 25659 -0.11%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24056 24056 0.00% 24456 24456 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125965 125965 0.00% 127633 127637 -0.00%
sqlite u32_u64_str no_index 64 128 2 string 146616 146616 0.00% 148496 148500 -0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136616 136616 0.00% 138782 138778 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133457 133457 0.00% 135263 135263 0.00%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 825964 826537 -0.07% 880078 880635 -0.06%
stdb_raw u32_u64_str btree_each_column 64 128 977328 976469 0.09% 1031134 1030103 0.10%
sqlite u32_u64_str unique_0 64 128 415857 415857 0.00% 430139 430127 0.00%
sqlite u32_u64_str btree_each_column 64 128 1021898 1021898 0.00% 1056380 1056380 0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 153731 153731 0.00% 153785 153789 -0.00%
stdb_raw u32_u64_str unique_0 64 16756 16756 0.00% 16810 16810 0.00%
sqlite u32_u64_str unique_0 1024 1070323 1070323 0.00% 1074041 1074041 0.00%
sqlite u32_u64_str unique_0 64 77973 77973 0.00% 79211 79211 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47528 47528 0.00% 50146 50146 0.00%
64 bsatn 25509 25509 0.00% 27685 27685 0.00%
16 bsatn 8200 8200 0.00% 9492 9492 0.00%
16 json 12188 12188 0.00% 14058 14058 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 19004206 19003818 0.00% 19672796 19658748 0.07%
stdb_raw u32_u64_str unique_0 64 128 1237950 1237907 0.00% 1310060 1310111 -0.00%
sqlite u32_u64_str unique_0 1024 1024 1809743 1809743 0.00% 1818387 1818387 0.00%
sqlite u32_u64_str unique_0 64 128 132654 132654 0.00% 135590 135590 0.00%

Please sign in to comment.