Commit Graph

3186 Commits

Author SHA1 Message Date
Mazdak Farrokhzad e258262556 perf(JoinInner): use AVs for keys instead of PVs (#1194)
* perf(JoinInner): use AVs for keys instead of PVs

* Remove stale comment.

Co-authored-by: james gilles <jameshgilles@gmail.com>
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>

---------

Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: james gilles <jameshgilles@gmail.com>
2024-05-02 21:00:34 +00:00
Piotr Sarnacki 51509aa96d Bump to 0.9.0 2024-05-02 20:24:59 +02:00
Mazdak Farrokhzad 7c52ef555a clarify cost of dropping the updates in eval_incr (#1192) 2024-05-02 16:47:34 +00:00
Puru Vijay 35640c113f fix: Unity tutorial slugs (#51) 2024-05-02 08:21:12 -07:00
Tyler Cloutier 6a071583f5 Revert "fix: Docs build, pnpm, vm evaluate (#46) (#50)" (#52)
This reverts commit 6c11566a23.
2024-05-02 10:11:54 -04:00
Piotr Sarnacki 3a1dd4c58a Drogus/big int to bigint (#37) 2024-05-02 16:08:34 +02:00
Tyler Cloutier 6c11566a23 fix: Docs build, pnpm, vm evaluate (#46) (#50)
* Push

* prettierrc

* Use cjs cuz current api require's it

* Prettier override for md

* fix 2b-c-sharp

Hopefully fixed the break introduced by pnpm

Fix to nav.js generation

Now just using tsc to build the file

type = commonjs

Co-authored-by: Puru Vijay <47742487+PuruVJ@users.noreply.github.com>
2024-05-02 10:02:46 -04:00
Tyler Cloutier 30f628dcfd Revert "fix: Docs build, pnpm, vm evaluate (#46)" (#48)
This reverts commit a92dbc08c4.
2024-05-01 23:57:58 -04:00
Zeke Foppa 6810821cbb Add PR status check that fails unless based on master (#1180)
* [bfops/block-pr-chain]: empty

* [bfops/block-pr-chain]: workflow

* [bfops/block-pr-chain]: fix

* [bfops/block-pr-chain]: update

* [bfops/block-pr-chain]: update

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-01 17:38:20 +00:00
Puru Vijay a92dbc08c4 fix: Docs build, pnpm, vm evaluate (#46)
* Push

* prettierrc

* Use cjs cuz current api require's it

* Prettier override for md

* fix 2b-c-sharp
2024-05-01 22:20:11 +05:30
Mazdak Farrokhzad e526c8c113 Fix soundness hole in Table::delete + don't make & immedately drop PVs in the method (#1162)
* impl Eq + Hash for RelValue

* Use Hash for RelValue in incr-eval

* naming: spell out pv, rv, and tro

* fix soundness hole in Table::delete + don't make + drop PVs

* Clarify `Table::delete`'s callback `before`

Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>

---------

Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2024-04-30 22:30:50 +00:00
Mazdak Farrokhzad 0142e14de5 Implement RelValue: Eq + Hash (#1107)
* impl Eq + Hash for RelValue

* Use Hash for RelValue in incr-eval

* naming: spell out pv, rv, and tro
2024-04-30 22:13:50 +00:00
Mazdak Farrokhzad b55121cc83 use a custom FixedBitSet + optimize Page::iter_fixed_len (#1160) 2024-04-30 21:57:28 +00:00
Mazdak Farrokhzad 2c07b3bd69 impl PartialEq<ProductValue> for RowRef (#1164)
* impl PartialEq<ProductValue> for RowRef

* Apply Phoebe's suggestions

Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>

---------

Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2024-04-30 21:20:32 +00:00
Mazdak Farrokhzad e144c400c5 Redefine FieldName as (TableId, ColId) (#1165)
* redefine FieldName as (TableId, ColId)

* fix & refactor tests + move MemTable/Header test helpers test code
2024-04-30 20:59:20 +00:00
Ingvar Stepanyan 27a7b67608 NFC: reuse common parts of C# generation (#1187)
Reuse the `indented_block` helper more and add new `CsharpAutogen` helper structure for consistent header / footer structure and reduced boilerplate.
2024-04-30 18:31:36 +00:00
Mazdak Farrokhzad fd44242e99 1. Add Hash for RowRef + make it consistent with PV. (#1163)
2. Make `RowRef::row_hash` use the above.
3. Make `Table::insert` return a `RowRef`.
4. Use less unsafe because of 1-3.
5. Use `second-stack` to reuse temporary allocations in hashing and serialization.
2024-04-30 17:59:58 +00:00
Ingvar Stepanyan 5cc05b173b NFC: few more C# shorthand syntax conversions (#1176)
* NFC: few more C# shorthand conversions

For some reason these automated refactoring conversions didn't get included in #1149.

* Also remove unused usings

* Restore a using that was erroneously marked as unused
2024-04-30 00:39:45 +00:00
joshua-spacetime ac647a0371 fix(1173): Record wait time for all reducers (#1174)
Fixes #1173.

Previously we were only recording this metric for scheduled reducers.
We were also recording it before we acquired access to the module instance.
Now we record it for all reducers after we acquire access to the module instance.

This patch also removes max wait time since the histogram should suffice.
2024-04-29 21:15:05 +00:00
joshua-spacetime fc3ff30c34 fix(1170): Use scope guard to decrement reducer queue length (#1172)
Fixes #1170.

Also updates the bucket values for the queue length histogram.
Also removes the max queue length metric, since the histogram should suffice.
2024-04-29 20:31:02 +00:00
joshua-spacetime 0fa8312657 chore: Remove unused server metrics (#1171) 2024-04-29 20:30:19 +00:00
Noa 0c7530ffc6 Disallow calling random lifecycle reducers (#1114)
* Disallow calling random lifecycle reducers

* Add lifecycle reducer smoketest
2024-04-29 19:11:05 +00:00
Ingvar Stepanyan 48c0b4d646 Ignore const members in C# types (#1175)
Const members shouldn't count as table or type fields in `[SpacetimeDB.Type]`.
2024-04-29 18:06:34 +00:00
Ingvar Stepanyan 84a7f83086 Simplify C# source generator csproj (#1143)
* Simplify source generator csproj

Apparently custom scripts are no longer necessary, so removing to make maintenance simpler (noticed this while working on yet another source generator).

* Add smoketest based on Ingvar's comment, + run smoketests on Windows

* Whoops, don't mkdtemp outside of debugging

* Make smoketest sillier

* Finish up a print statement

* Revert "Make smoketest sillier"

This reverts commit 135b05b380.

* Resolve versioning issue in a non-silly, professional way.

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
2024-04-29 17:20:22 +00:00
Dylan Hunt d2b98e0b19 doc: Link directly to cargo install on missing (#1102) 2024-04-29 12:22:35 -05:00
Ingvar Stepanyan 175ca25504 NFC: inline format args in generate code (#1153)
CLI `generate` code is a particularly heavy user of format-based macros, and so it benefits most from inlining format args where possible.

This is done by adding `#![warn(clippy::uninlined_format_args)]` + running `cargo clippy --fix` followed by `cargo fmt`, so shouldn't require manual review.

This is a follow-up to #1142 and, like that PR, is mainly done to make generate's code a bit cleaner and diffs simpler.
2024-04-25 23:03:41 +00:00
Dylan Hunt d6d31b594c Unity tutorial - C# parity (#31)
* doc: Onboarding impr, fixes, consistency, cleanup

refactor: Whats next cleanup, +unity, -bloat

Removed redundant text while there

refactor: Unity quickstart fixes, impr, prettify

refactor: Unity pt1 fixes, impr, prettify

fix(README): Rm "see test edits below" ref

* !exists

refactor(minor): General onboarding cleanup

* Shorter, prettier, consistent

fix(sdks/c#): Broken unitypackage url

feat(sdks/c#): Add OneTimeQuery api ref

* doc: Onboarding impr, fixes, consistency, cleanup

* fix: Rm redundant 'module_bindings' mention

* fix: Floating period, "arbitrary", "important":

- PR review change requests
- Additionally: hasUpdatedRecently fix and reformatting

* fix: Mentioned FilterBy, used FindBy

- Used FindBy since that was what the tutorial used, and also looking for a single Identity.
- Note: There may be a similar rust discrepancy in the Unity pt1 tutorial. It'll work with Filter, but just simply less consistent. Holding off on that since my Rust syntax knowledge !exists.

* fix(Unity-pt1): Rm copy+paste redundant comments

* Duplicate comments found both above and within funcs

* fix(unity): Rm unused using statement +merged info

* Removed `System.Runtime.CompilerServices`
* SpacetimeDB.Module seems to already include this (merged the info)

* refactor(minor): Code spacing for grouping/clarity

* feat: 'Standalone mode runs in foreground' memo

* At general quickstart for `spacetime start`

* refactor(unity-pt1): Standalone mode foreground memo

* Also, removed the "speed" loss mention of C#

* fix(syntaxErr): Fix err, keep FilterBy, handle null

- After a verbose discussion, we will eventually swap to FindBy for single-result queries, but not in this PR.
- For now, the syntax err is fixed by making the var nullable and suffixing a LINQ FirstOrDefault(). Approved by Tyler in Discord.
- We never *actually* created a player in the tutorial. This creates the player. Approved by Tyler in Discord.

* doc!(unity-tutorial): Add C# module parity + split

- Why?
  - Despite being a Unity tutorial (we 100% know the user knows C#), the server example used Rust.
  - This creates friction when the user is already learning multiple new things: The SpacetimeDB architecture, the CLI, the client SDK and server SDK. If they previously did not know Rust, this could add some weight to the onboarding friction.
  - The Unity tutorial could use an overview since it's quite lengthy and progressive.
  - Part1 should be split, anyway - it covers way too much for a single section to handle (especially since it jumps between client and server). Splitting between basic multiplayer + advanced makes things more-manageable and less intimidating.

- Before:
  - UNITY TUTORIAL
    - Part1 (Client + Rust Server)
    - Part2 (Resources and Scheduling)
    - Part3 (BitCraft Mini)

- After:
  - UNITY TUTORIAL - BASIC MULTIPLAYER
    - Overview
    - Part1 (Setup)
    - Part2a (Rust Server)
    - Part2b (C# Server)
    - Part3 (Client)
  - UNITY TUTORIAL - ADVANCED
    - Part4 (Resources and Scheduling)
    - Part5 (BitCraft Mini)

* Update docs/unity/part-2b-c-sharp.md

Rust -> C#

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

* Update docs/unity/part-2b-c-sharp.md

- `--lang=rust` to `=csharp`

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

* Update docs/unity/part-2b-c-sharp.md

- Rm RustRover mention

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

* Update docs/unity/part-2b-c-sharp.md

- Rust -> C#

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

* fix: "Next tutorial" mixups

* fix: Bad troubleshooting links

- Server issues shouldn't link to Client troubleshooting that has no answer

* Update docs/unity/part-2b-c-sharp.md

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

* Update docs/unity/part-2a-rust.md

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>

---------

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2024-04-25 12:51:37 -07:00
Noa 44c9e89879 Fail CI on smoketest failures (#1155)
* Fail CI on smoketest failures

* Fix smoketests
2024-04-25 17:49:58 +00:00
Ingvar Stepanyan 2fd9eb48ea Fix nullability warnings in WebSocket class (#82)
There is a bunch of nullability issues in the project; this PR fixes just the ones in WebSocket + some drive-by fixups and/or syntax simplifications.
2024-04-25 15:43:04 +01:00
Dylan Hunt 20856910ba CLI - Set default server to testnet (#1078)
* refactor!: Change DEFAULT_HOST_NICKNAME to "testnet"

- from "local"
- Suggested by Tyler

* refactor!: Change more const to default testnet srv

* [bfops/tests-use-explicit-server]: fix?

* [bfops/tests-use-explicit-server]: empty

* [dylan/refactor/set-default-server-to-testnet]: fix?

* [bfops/default-server-inline]: do thing

* [bfops/default-server-inline]: fix

* [dylan/refactor/set-default-server-to-testnet]: fix

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-04-25 05:12:54 +00:00
Zeke Foppa a6d81dc0ac CLI - Small refactor to default server configs (#1151)
* [bfops/tests-use-explicit-server]: fix?

* [bfops/tests-use-explicit-server]: empty

* [bfops/default-server-inline]: do thing

* [bfops/default-server-inline]: fix

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-04-25 03:00:10 +00:00
Zeke Foppa fbaa5ae9df Tests use explicit --server local (#1150)
* [bfops/tests-use-explicit-server]: fix?

* [bfops/tests-use-explicit-server]: empty

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-04-25 02:41:49 +00:00
Mazdak Farrokhzad 516dfe376c impl Eq for RowRef (#1135) 2024-04-25 01:09:26 +00:00
Ingvar Stepanyan cdf46202f2 NFC: format C# module SDK code (#1149)
While looking through the large diffs while splitting out small PRs out of my refactor branch, I noticed that quite a lot of noise is from me working on a formatted code and using primary constructors while the one in master is not.

As such, I'm splitting out just those automated / non-functional changes into a separate PR to make subsequent functional diffs easier to read.
2024-04-25 00:03:22 +00:00
Mazdak Farrokhzad cb0c09bab0 Define Hash + Eq for BSATN (#1112)
* add hash_bsatn + move proptest generators to sats crate

* add eq_bsatn
2024-04-24 23:06:22 +00:00
Ingvar Stepanyan 383ba27324 Make logger a separate SDK setting from client instance (#79)
This allows to:

1. Have a preset logger that is already correctly matching the environment (console vs Unity).
2. Removes the need for explicit `SpacetimeDBClient.CreateInstance(...)` which is particularly awkward to use and easy to forget with singleton as it doesn't return a result as a factory method name could suggest. Instead, `SpacetimeDBClient.instance` is available on first use.
3. Slightly simplifies dependencies between classes, e.g. `ClientCache` doesn't need a circular dependency on `SpacetimeDBClient`, making future maintenance and changes a bit easier.
2024-04-24 17:51:53 +01:00
Ingvar Stepanyan f6aa76c733 Set language version to 9 (#80)
This is the last C# version supported by Unity.

While this PR doesn't require almost any C# code changes, I found that limiting the version is helpful for ensuring that I don't accidentally introduce Unity-incompatible code in larger PRs.
2024-04-24 15:34:17 +01:00
Ingvar Stepanyan 45f6cd6f0c Fix codegen tests (#1146)
While working on the new C# codegen, I accidentally noticed that those tests were passing even when they clearly should've been failing due to changed output.

After running with `--nocapture`, I found out it's because the tests are silently skipped and reported as successful when `rust_wasm_test.wasm` isn't built.

This further led to finding that `rust_wasm_test.wasm` is never built - the relevant module results in `rust_wasm_test_module.wasm` instead - so these tests have been incorrectly passing for ages.

This PR changes them to actually build the module as part of testing and updates the snapshots to latest master.
2024-04-24 14:03:03 +00:00
Ingvar Stepanyan d3db4a12ef Reduce unwrap noise in CLI generate code (#1142)
This adds a non-fallible `write_fmt` method to `CodeIndenter<String>` (since we know it should never fail), which allows to use `write!` and `writeln!` without `.unwrap()` everywhere, making code a lot less noisy.
2024-04-24 14:03:01 +00:00
Mazdak Farrokhzad 8b12d3fa26 - Ignore discriminants in Hash for AlgebraicValue (#1057)
- Nix len-prefixing in `Hash for ProductValue`
- Ignore discriminants in `Hash for ArrayValue`
2024-04-24 11:34:31 +00:00
Ingvar Stepanyan 0ca2a5453d Nit: remove unused inserts field (#77) 2024-04-23 13:10:18 +01:00
Mazdak Farrokhzad e1064eef29 Remove Column.col_id field (#1136)
* Remove redundant field Column.col_id

* remove redundant fn Header::ty

* - move extract_table_field to only use (#1137)

- remove unused get_index_by_field
2024-04-22 21:23:06 +00:00
John Detter 2712844484 Fixes an inconsistency issue with spacetime server fingerprint -s <server> (#1131)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 16:04:15 +00:00
John Detter 06f766fd70 Use -s to specify server for spacetime identity list -s <server> (#1130)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 16:04:03 +00:00
John Detter 64fe230b69 Build uses -S for skip clippy (#1129)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 15:57:22 +00:00
Mazdak Farrokhzad db6f1561c6 document RelValue variants (#1134) 2024-04-22 11:46:56 +00:00
Kim Altintop 3c6b60a9d0 core: AnyBytes from boxed slice (#1133)
Avoids an unnecessary roundtrip through `Vec<u8>` in private#731.
2024-04-22 10:58:35 +00:00
Mazdak Farrokhzad 9797695ef6 multimap: don't sort values, use push & swap_remove (#1029) 2024-04-22 10:01:17 +00:00
Mazdak Farrokhzad 8f85da598c Remove #[spacetimedb(reducer, repeat = _)] support (#1095) 2024-04-22 09:58:39 +00:00
John Detter c9381af714 Default commitlog to info logs (#1123)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-19 18:44:16 +00:00