Commit Graph

3186 Commits

Author SHA1 Message Date
Piotr Sarnacki eb621fde21 Build spacetimedb-standalone on arm runner too (#377) v0.7.0-beta 2023-10-05 23:49:16 -05:00
Mario Montoya 05956d6817 Bench for SQL scan / where (#370)
* Bench for sql scan

* Add SQL..WHERE bench

* Factour out the request for table schema, and remove some duplicate logic
2023-10-05 20:06:41 -05:00
Piotr Sarnacki 45818096a5 Build ARM64 client on dedicated runner (#376) 2023-10-06 00:03:18 +00:00
Piotr Sarnacki 93c593b716 Build linux binary on bare metal (#375) 2023-10-05 22:35:27 +00:00
Piotr Sarnacki c7f7164329 Run docker builds on bare-metal (#372) 2023-10-05 22:03:56 +00:00
Piotr Sarnacki b7d5d83cda Run benchmarks on a dedicated runner (#373) 2023-10-05 21:48:00 +00:00
John Detter e635024cc7 Disable tracing (#371)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-05 15:51:23 -05:00
Noa 90207251a0 Fix deadlock (#369) 2023-10-05 15:33:49 -05:00
John Detter 1518baab6a C# SDK - Fix Genererated FilterByX for Option Columns (#367)
* Fixes - still working on this

* filter on option is now working properly

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-05 01:45:43 -05:00
Kurtis Mullins 6dba36c7f3 Fix AMD64 dependency error in CLI Docker Build (#362)
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Kurtis Mullins <hello@kurtismullins.com>
rm
2023-10-03 21:11:58 -05:00
Kurtis Mullins 5bd53a9462 Fix arm64 builds on Linux (#361)
Signed-off-by: Kurtis Mullins <github@kurtismullins.com>
2023-10-03 17:56:11 -07:00
Ingvar Stepanyan ba535f24d1 Move connection events to reducers (#309)
* Move connection events to reducers

* More rebase fixups

* Avoid double-reference

* Filter out special reducers in generate cli

This updates filtering of `__init__` to exclude all special reducers, as well as moves the filtering to centralised place before calling language-specific generate command.

* Incrememted ABI version number

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2023-10-03 23:19:49 +00:00
John Detter de43e96b11 Version Upgrade to 0.7.0 (#355)
* Saving because I'm testing writing files

* New upgrade program working quite well

* Update license file as well

* Tool seems good to go

* Cargo check is passing, new upgrade-version is ready, old version
removed

* Updating lock file is required for CI to pass

* main.rs clippy lints

* More sensible default

* Version upgrade to 0.7.0 via new version-upgrade util

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-10-03 22:27:11 +00:00
Kim Altintop e8aed85c1c core: Provide read access to commit/message log and odb (#265)
* core: Provide read access to commit/message log and odb

This is a first approximation to provide data access for Kafka-style
replication. It punts on notifications of segment rotation (which
could also be solved via filesystem events).

ObjectDB access is fairly crude, and will likely require it's own
replication subsystem.

* fixup! Merge remote-tracking branch 'origin/master' into kim/log-access

* Add some tests

Also make max segment size configurable, so tests don't have to write
>= 1GiB worth of data.

* Abide to the Rust naming conventions

* Add test for commit iter

* Remove `MessageLogIter`, use `commit_log::Iter` instead (#272)
2023-10-03 22:09:29 +00:00
John Detter 3f5f97fb1f New Upgrade Version Util (#354)
* Saving because I'm testing writing files

* New upgrade program working quite well

* Update license file as well

* Tool seems good to go

* Cargo check is passing, new upgrade-version is ready, old version
removed

* Updating lock file is required for CI to pass

* main.rs clippy lints

* More sensible default

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-10-03 14:38:52 -07:00
Mazdak Farrokhzad 2daf06cdce Bindings: improve docs precision (#146)
* bindings: improve docs precision

* Fix some 32 vs 64 bit comments

---------

Co-authored-by: George Kulakowski <george@clockworklabs.io>
2023-10-03 17:29:33 +00:00
joshua-spacetime 8f9ff271ee chore: Add tracing to all datastore iterators (#349)
Fixes #347.
2023-10-03 07:47:20 -07:00
Ikko Eltociear Ashimine ba3e21dfc1 Fix typo in README.md (#193)
propogated -> propagated

refs https://github.com/clockworklabs/SpacetimeDB/pull/183

Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
2023-10-02 17:59:26 -07:00
Mario Montoya d456ce4a2e Print the elapsed time & # of returned rows in the interactive repl (#344)
* Print the elapsed time & # of returned rows in the interactive repl

* Fixed clippy warning

* Change formatting of timings to be like psql & remove it from direct sql calls

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2023-10-02 17:43:45 -07:00
Phoebe Goldman f0e4b004da Commit test clients' module_bindings (#346)
* Commit test clients' module_bindings

Having discussed with the team, I've come around to it being correct
to commit the `module_bindings` for the SDK tests' two test clients.

This way, people not working on codegen can run `cargo test --workspace` &c,
and open the test clients with rust-analyzer without any additional rigamarole.

The downside is that any time codegen changes,
we'll see very large commits touching all of these files,
but consensus is we don't really care.

An additional upside is that now we can run clippy against the bindings in CI,
which will incentivize ensuring that the bindings generate lint-free code.

* Add linguist-generated=true for generated module bindings

* Top-level .gitattributes sets `module_bindings` as generated
2023-10-02 16:56:52 -07:00
Phoebe Goldman 7f6d90fb9e Preliminary module-side interface for timing execution (#351)
* Preliminary module-side interface for timing execution

* placate rustfmt, hopefully
2023-10-02 22:24:41 +00:00
Phoebe Goldman a379874a91 SDK tests use a tempdir as STDB_PATH, rather than ~/.spacetime (#348)
We've had continual issues with test isolation when developing breaking changes.
This commit doesn't fully address those, but is a step in the right direction:
the SDK tests now create a tempdir as their `STDB_PATH`,
rather than using `~/.spacetime`.
2023-10-02 13:18:57 -04:00
Piotr Sarnacki a0c5fa49bc Bump package version to 0.6.2 2023-10-02 18:43:46 +02:00
dbrinkmanncw 09806591d7 Add LICENSE.txt (#22)
* Add license.text

* Fix case on file name

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>
2023-10-02 18:43:17 +02:00
Phoebe Goldman b910b45dd1 Add simple READMEs for SDK test clients (#350) 2023-10-02 15:57:01 +00:00
Ingvar Stepanyan 6325f754a5 Move ABI check to instantiation (#233)
* Move ABI check to instantiation

This is a follow-up to #197.

This fixes an extra case I was worried about even with that fix but didn't hit it in my initial examples so hoped it's not worth the complexity.

Now I've hit it in a different module: because ABI can have zeroes - e.g. 3.0 is encoded as `\00\00\03\00` in the data segment - linker might place it in the beginning of a data segment, in which case `wasm-opt` will trim those prefix \00 bytes and there won't be any single data segment containing the entire version, and the ABI check will still fail.

It's possible to make the `determine_spacetime_abi` account for this case and merge chunks from different data segments when they overlap with version, but I feel it's growing to the point where it doesn't justify the complexity.

Instead, I'm moving the check into Wasmer's instantiation, since we construct a Wasm instance right away anyway, and it takes care of zero-filling and loading all the data segments into memory.

This makes the check more reliable and simpler, as well as avoids double-parsing of Wasm, but it does mean that we'll need to copy it to other hosts in the unlikely event we want to support 2 Wasm hosts simultaneously in the future.

IMO in this case the tradeoff is worth it.

* Add comment explanation

* Fixup conflict resolution

Signed-off-by: Ingvar Stepanyan <me@rreverser.com>

---------

Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2023-10-02 12:59:26 +00:00
dbrinkmanncw 4349370f68 Add filter_by autogen functions for option types in csharp and python SDKs (#275)
* Add filterby autogen functions for option types in csharp and python sdks

* Clippy

* Fixed lint

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2023-09-30 07:12:45 +00:00
Phoebe Goldman 59159dbb3d Add address: Address to ReducerContext (#299)
* Add `address: Address` to `ReducerContext`

Initial support for identifying connections via an `Address`,
passed as the caller address in `ReducerContext`.

Notable design choices:

- The same type `Address` is used for clients and dbs,
  as opposed to having distinct `DbAddress` and `ClientAddress` types.
- For automatic reducers (init, scheduled, &c), the passed `Address`
  is the database's address, not the address of the client which called `publish`.
- Clients may specify an `Address` as a query parameter
  to the `subscribe` and `call` endpoints.
  If they do not, an `Address` will be randomly generated for them.

Still to do:

- Send the client's `Address` alongside their `Identity` and token
  upon WebSocket init in `IdentityToken`,
  so the client can save its `Address` for re-connection.
- SDK support.
- C# module support.
- Documentation.
- Refuse new connections if an existing connection
  with the same `(Identity, Address)` pair exists.
- Ensure we can store `Address` in tables,
  so modules can track connected clients,
  and ser/de `Address`, so those tables can be synced to clients.

* Use `None` in `ReducerContext` for HTTP calls without client address

* Fix typo in trait argument name

* `Address` representation amenable to SDK usage

Similar to `Identity`, make `Address` a product type with a double-underscored field name.

This will allow SDKs to distinguish `Address` from `Vec<u8>`,
but does necessitate some ugly `AddressForUrl` hackery
to get ser/de working correctly in different contexts.

This commit does not yet include SDK support for `Address`,
only the server-side machinery necessary for it.

* Add client_address parameter to /publish; pass to init and update reducers

Per discussion with Kim, it's useful for SpacetimeDB-cloud
for the client_address passed to the init reducer
to be that of the caller of /database/publish,
rather than the database's address.

This commit implements that behavior. Now:
- `init` and `update` take the client_address passed to publish, if any,
  or `None` if no client_address was supplied.
- Scheduled reducers never receive a client_address.
- Reducers invoked by HTTP /call take the client_address passed to /call, if any,
  or `None` if no client_address was supplied.
- Reducers invoked by WebSocket always receive the address of the WebSocket connection.

* `Address` support in Rust client SDK

* Add test that addresses are stable within a client process

* Run rustfmt against merge changes

* Not sure why my local `cargo fmt` didn't get this...

* Add caller_address argument to reducer arguments in Rust SDK

* rustfmt again...

* Add caller address to `EventJson` message

* Python codegen for client addresses

* C# module support for client addresses

* Fix scoping error

* Add `Address`-related stuff to C# codegen

- Emit `SpacetimeDB.Address` for address types
- Add `callerAddress` field to `ReducerEvent`

* TypeScript codegen changes

* Fix merge conflict with new test

* Run rustfmt

---------

Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2023-09-29 23:39:34 -07:00
Noa d8395fe138 Fix derive(Deserialize) on void enum (#330)
* Fix derive(Deserialize) on void enum

* Also fix derive(Serialize) for empty enums; remove empty reducers from tests

---------

Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2023-09-29 23:27:37 -07:00
John Detter 905da73dd0 Added Git Commit Hash to Version Command (#340)
* Added git commit hash to version command

* Fixed clippy warning

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2023-09-30 06:25:20 +00:00
Mario Montoya 3d1d98c137 Fix the printing of ascii codes on tracy and improve some tracing (#341)
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2023-09-30 06:23:31 +00:00
Phoebe Goldman 97ed85efc5 Benchmarks: report tx/s as elements/s (#345)
Based on my limited understanding of Criterion,
I think we can get add transactions per second reporting to benchmarks
using Criterion's Throughput::Elements tracking,
by treating transactions as elements.

This is not ideal, as the output says e.g.
`thrpt:  [38.763 Kelem/s 38.781 Kelem/s 38.799 Kelem/s]`,
where we'd like `Ktx/s`,
but it's not clear whether Criterion allows us that much customization.

Each of the benchmarks currently does one tx per iteration,
so pass `Throughput::Elements(1)` for each of them.
Do this as close to the test as possible, despite redundancy,
in case we ever add benchmarks to the same group
which do multiple transactions per iteration.
2023-09-29 21:39:23 -07:00
james gilles 010c7e3c1e Wrangle benchmarks (#289)
Refactor benchmarks framework to allow direct comparison of spacetime modules, the spacetime datastore not through a module, and sqlite.
2023-09-29 23:12:12 +00:00
Kim Altintop e927741634 Fix bootstrapping of ST_MODULE (#342) 2023-09-29 18:52:33 -04:00
John Detter cb42225d0a connect/disconnect reducers called when executing reducer from from CLI (#334)
* SpacetimeDB is hanging, might be because of my changes

* Fixed issue - put connect/disconnect in right spot

* Tested, working

* Reverted changes that are irrelevant

* Added test for detecting connect/disconnect when calling from the CLI

* Smoketest fix

* Fix compilation issue with test

* Addressing some feedback

* Updated test for a better test case

* Addressing review

* connect is a substring of disconnect which was causing a failure

* Fixing another test bug, should be correct now 👍

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-09-29 12:55:30 -05:00
Phoebe Goldman b51e5516cf [SDK] generate struct Module to hold dispatch functions (#239)
Prior to this commit, the Rust SDK passed autogenerated dispatch functions around as
function pointers (i.e. values of `fn` types).
This was brittle and inextensible; adding a new dispatch function
or changing the type of a dispatch function
required threading a new argument through `BackgroundDbConnection::connect`,
and a new field to whatever struct was supposed to invoke the dispatch function.

This commit adds a new trait `SpacetimeModule`,
which has a method for each autogenerated function.
`BackgroundDbConnection::connect` accepts an `Arc<dyn SpacetimeModule>`,
which it passes to various components which need access to the autogenerated methods.
The CLI's `generate` with `--lang rust` generates a unit struct `Module`,
which implements the trait.
The generated `connect` function passes `Arc::new(Module)` to the internal connect method.

This greatly reduces the maintenance burden of adding new dispatch functions.
Now, we only need to alter:
- The definition of `trait SpacetimeModule`.
- The generation of the instance.
- Whatever internals call the method.
2023-09-29 09:54:38 -04:00
Phoebe Goldman 0a3a9d63b5 Return the formatted error from log_and_500, so the CLI can report it (#338)
In the client API's log_and_500,
return an ErrorResponse with a body derived from the error,
rather than a bare 500 code.

Note that this exposes previously-internal error messages to users.
2023-09-28 21:06:13 +00:00
Piotr Sarnacki 205ad6b2d7 Client binaries builds (#337)
This PR adds builds for client binaries for all of the platforms that we support. The binaries are uploaded to a DO Spaces bucket.
2023-09-28 19:16:43 +00:00
joshua-spacetime 4a84211fb7 feat(332): Support incremental evaluation for index joins (#336)
Fixes #332.

If an index semijoin is to be incrementally evaluated,
it is first converted to an inner join which supports MemTables.

As part of this change, I had to abstract the projection part of the
inner join spec to be able to express semijoins.
2023-09-28 09:47:33 -07:00
Nathaniel Richards 3651aedf6c Changed part 1 of unity tut 2023-09-28 11:18:03 -04:00
Nathaniel Richards 7051be0fb8 Removed excess 2023-09-28 08:57:08 -04:00
Kim Altintop 00050967a9 Store the current module hash in a system table (#290)
* Store the current module hash in a system table

* Add more user logs

Fill the user-retrievable database log with more info about what is
going on while a database is being initialized or updated.

* Silence unused warning

* sats: Add `field_as_u64` to `ProductValue`

* db: Add `epoch` to st_module

Add a u64 field `epoch` to the st_module table, used to store a fencing
token.

* core: Add a way to obtain a keyed lock to `ControlDB`

* host: Thread through the fencing token

* standalone: Implement module lifecycle using the new locking facilities

* test: Fix update-module

Need another line of logs, as there is now more output.

* Refine API

Make getting and setting the program hash trait methods. Also widen the
epoch / fencing token to fit stdb sequences.

* db: Hand out opaque index / sequence ids instead of numbers

This allows to actually use relational db methods taking those types as
arguments outside the core crate.

Also make `next_sequence` and `create_sequence` not take `&mut self`
unnecessarily.

* Fix type error

* Fix test
2023-09-28 09:46:32 +02:00
Noa c71d24c1f9 Remove Table::{update,delete} (#328)
* Remove Table::{update,delete}

* Fix failing test

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-09-27 13:01:57 -05:00
John Detter 5cf76927a9 Positional Arguments (#322)
* Working on this but found another bug

* Fixing describe

* Working on this but found another bug

* Tested working, have to update tests

* Updated tests, hopefully I caught everything

* Clippy fix

* Addressing more clippy issues

* Cargo fmt

* Implementing Phoebe's feedback

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-09-27 12:44:24 -05:00
John Detter befbc5c64a Fixing describe (#323)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-09-27 12:43:49 -05:00
Kim Altintop 9364c93a2f Add smoke test for private tables (#331) 2023-09-27 18:55:39 +02:00
Phoebe Goldman 5f8615a367 Add SDK test that verifies connect/disconnect callbacks happen (#326)
* Add SDK test that verifies connect/disconnect callbacks happen

* Add C# connect/disconnect test

---------

Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2023-09-27 11:29:09 -04:00
joshua-spacetime 6061e236c3 feat(298): Index nested loop semijoin (#316)
Fixes #298.

Adds a join implementation that probes an index
and returns rows from said index.
2023-09-27 08:18:53 -07:00
joshua-spacetime d2b995d638 feat(318): Push selections below joins in the general case (#319)
Fixes #318.

Push selections below joins even when selection is not sargable.
2023-09-26 12:01:25 -07:00
joshua-spacetime 8a80600c83 fix(320): Incremental evaluation of index scan plans (#321)
Fixes #320.
2023-09-26 10:19:25 -07:00