22 Commits

Author SHA1 Message Date
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
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
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
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 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
Kim Altintop ea2bae4583 Cloud next (#173)
* Client API changes to accomodate new cloud architecture

The exact trait interfaces for `client-api` is TBD

* Ensure we're not blocking when accessing the filesystem

* Derive Clone for SendGridController

* Add YOLO error variant to InsertDomainResult

* Rebase

* fixup! Rebase

* Fix SpacetimeType for Address

* Temporarily disable message / frame size limits for SDK WS

* Remove get_database_instance_state from API trait

It's an internal (worker db) thing, which does not need to be satisfied
by impls.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Fix -S instead of -s for update-module smoke test

-s now means "server", -S "skip clippy", changed in:

a1e9984 (Multiple server configurations for CLI (#214), 2023-09-01)

* Invalidate schema cache when committing a tx

* Use long options in update-module.sh, fix unused warning

* Add test asserting schema_for_table reflects index updates
2023-09-20 07:42:37 +02:00
Ingvar Stepanyan c47e571d2d Avoid relying on global CLI in tests (#294)
This switches tests from invoking a spacetimedb CLI found on PATH to always using up-to-date version by depending on the CLI crate as a library.

---------

Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2023-09-14 09:15:32 -04:00
Ingvar Stepanyan f98694f707 Add C# integration test (#291) 2023-09-13 15:53:07 +01:00
Phoebe Goldman 32ac808804 SDK test suites (#258)
* Simple SDK test harness; SDK test module

Yet to come: actual SDK tests.

* Quiet clippy lint about "too many arguments"

* Lints are named with underscores, not dashes...

* Will this make clippy shut up?

* Go nuclear on disabling `too_many_attributes` lint. Sigh.

* WIP SDK test client, and fix bugs in Rust codegen

Compiling the module_bindings for the sdk-test module revealed two bugs:

- Enums holding structs generated incorrectly,
  unpacking the struct into the enum's payload.

- Recursive types would cause the codegen to attempt to recursively import
  the current module into itself.

* One (1) actual runnable test in the sdk crate

* Exclude test-client from CI

The sdk tests already build this crate (though they don't clippy or fmt it).

Attempting to build, test, fmt or clippy it as-is will fail
because the module_bindings are not committed.
This is intentional, as the SDK test suite wants to generate the module_bindings
during its run.

* Rustfmt ignore generated module_bindings

It turns out `cargo fmt` doesn't actually support the `--exclude` option
the way `cargo clippy` does.

Instead, just `#[rustfmt::skip]` the `mod module_bindings;` decl.

* Actually commit test file...

God, I'm so bad at remembering to commit new files.

Anyway, add a test for deleting rows with primitive unique fields.

* Make CLI tool available in tests workflow

The SDK tests need to run `spacetime start`, `spacetime generate` and `spacetime publish`.

* Test update events with primitive pk types; split test-client into files

* Tests with `Identity` fields in tables

* Tests for reducer callbacks, both successful and failing

* Tests with vecs of stuff, with structs, with enums

* Test that should fail, test that uses a large table with many columns

* Test for resubscribe functionality

* Test of reauth; fix major bug in `TestCounter`

I misread `Condvar::wait_timeout_while` as `Condvar::wait_timeout_until`,
and flipped my predicate.
This led to false negatives (i.e. tests that passed that shouldn't have).

* A fistful of doc comments

* Avoid race condition running multiple tests with same client project

This commit fixes a race condition which sometimes caused the SDK tests to fail
because multiple `spacetime generate` processes running concurrently
would clobber each others' output,
potentially deleting it while a `cargo build` or `cargo run` process was running.

Now, the test harness will only run `spacetime generate` at most once
for any given directory.

* Add env_logger to SDK test client

* RUST_LOG=trace when running test clients

* quieter logs in test client: only warn-level and higher
2023-09-12 12:50:47 -05:00
joshua-spacetime e72b8f3d1b perf(datastore): disable fsync mode by default (#221) 2023-08-23 18:22:53 -07:00
Mario Montoya 68b9536822 Separate the global location of files per OS & create a configuration trait to read them (#171)
* Install from source instructions

* Improved comment

* Separate the global location of files per OS & create a configuration trait to read them

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-22 23:51:18 +00:00
George Kulakowski 66a8f22e94 Remove the bitrotted trace replay functionality (#219)
* Remove the bitrotted trace replay functionality

* cargo fmt

* Remove unused tracelogging feature from ci actions

* Remove unneeded clone
2023-08-22 21:29:05 +00:00
John Detter 116bdee090 Version upgrade to 0.6.1 (#180)
* Version upgrade to 0.6.1

* Upgrade version used by CLI

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-12 08:56:28 -07:00
Mario Montoya 80a0a29704 Move cargo deps to the workspace (#172)
* Moving deps to workspace

* Merge
2023-08-11 15:24:31 -07:00
George Kulakowski 26c49f2571 Allow spacetimedb to run in an in-memory mode (#137)
* Allow spacetimedb to run in an in-memory mode

* cargo fmt and review comments

* Fix test code

* Ensure the db directory is always created
2023-08-04 10:56:57 -07:00
Tyler Cloutier 3e0caff415 Updated version to 0.6.0 2023-08-03 01:39:03 +02:00
John Detter 0f63e70694 spacetime start 2 (#125)
* spacetime start

README revert

Reverted stuff that shouldn't have changed

* Build fix

* Cargo fmt

* Cargo clippy

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-02 11:21:49 -05:00
Tyler Cloutier 399f1b26d2 Reimplemented the energy tracking for identities (#115)
* Refactoring some stuff for energy

* Fix an issue with i128 query params

* Infinite budget in Standalone

* Energy and crash fixes

* Hopefully fixed the test that now has energy

* Addresses Centril's comments

* Cargo fmt

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2023-08-01 23:17:03 +02:00
Mario Montoya c154e3a6df Private tables (#17)
* Initial bootstrap for private tables

* Separate Access (private, public) for kind o table (system, user)

* Validates the access to private tables

* Check auth for drop table
2023-08-01 23:17:02 +02:00
John Detter 41dc128533 Upgrade Version to 0.5.0 (#47)
* Committing version upgrade script

* Fixes to the upgrade script

* Upgrade version to 0.5.0

* Update Cargo.toml

No longer optional

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Fixed small issue in the version upgrade script

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
Tyler Cloutier 0b6cddca13 test (#1)
* test

* Fixed CI

* Fixed tests

* Fixed formatting

* Fixed test error by removing chrono default features

* Rename smoketests CI thing

* Hopefully fix the testing issue

* Fix typos

* Fixed install git-hooks

* Fixed formatting

* Fixed compile error

* fixed testing issues
2023-08-01 23:17:02 +02:00
Tyler Cloutier 44df6c6e7d Initial commit 2023-08-01 23:16:37 +02:00