27 Commits

Author SHA1 Message Date
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
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
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
Kim Altintop 55a6386dc2 Update indexes when updating a database (#257)
* 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.

* 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-13 07:28:39 +02:00
Kim Altintop c010bfadca test: Only update active toolchain (#223)
That is, avoid doing any more work than necessary.
2023-09-07 19:40:19 +00:00
Phoebe Goldman a1e9984840 Multiple server configurations for CLI (#214)
Alters the CLI's configuration format to support storing multiple server configurations,
and having each server configuration store an (optional) default identity.
Many CLI commands take an additional -s argument, the server on which to operate,
which defaults to the configured default_server.
Using -s consistently requires renaming the publish skip-clippy short flag to -S.

Per discussion with @jdetter , this PR does not directly associate identities with servers.
Instead, each server configuration stores the server's "fingerprint" (i.e. PEM-formatted ECDSA public key),
and the CLI uses that public key to decode tokens to determine if they apply to a given server.
This architecture allows the CLI to behave reasonably
when multiple server configurations use the same set of tokens,
e.g. if multiple distinct URLs resolve to the same SpacetimeDB instance.
For example, one could imagine a configuration with server configurations for both http://127.0.0.1:3000
and http://localhost:3000, which should use the same set of identities.
2023-09-01 17:29:20 +00:00
Kim Altintop 262d8516f3 Allow smoke tests to opt out of docker (#154)
Depending on setup, `docker logs` output is not always that useful. E.g.
on CI or when running a server outside of docker for faster turnaround.
2023-08-10 10:47:13 +02:00
Kim Altintop 5da7ad2064 Terminate background smoke tests on exit (#153)
* Terminate background smoke tests on exit
2023-08-10 10:33:59 +02:00
Mazdak Farrokhzad ed9a84641a Identity: use identity_bytes in SpacetimeType (#89)
* Identity: use identity_bytes in SpacetimeType

* Use SDK's version of Identity instead

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

* make CI happy

* make axum happy<

* make axum happy v2

* Identity Codegen Impl C# (#100)

* Changes required for identity generation in csharp

* Clippy fix

* Seems to be working

* Fixes based on Mazdak suggestions

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>

* Fix compile error that somehow got merged in from https://github.com/clockworklabs/SpacetimeDB/pull/100

* Minor changes to allow `Identity` columns and reducer args in the SDK

- `sdk::identity::Identity` must now be `Hash`,
  because declaring a `#[primarykey]` column with type `Identity`
  will cause the SDK to generate code that uses `Identity` as a `HashMap` key.
  This instance was previously not necessary because the key would be `Vec<u8>`,
  but probably should've been included anyway.
- The codegen can just refer to `Identity` without path-qualifying,
  because it already imports the `Identity` type into all files it generates.

* address pheobe's review

* pacify clippy

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2023-08-01 23:17:03 +02:00
dbrinkmanncw ccf3de833a generate types to SpacetimeDB.Types namespace (#88)
* generate types to SpacetimeDB.Types namespace

* Add Reducer partial class to csharp codegen to tag it with the ReducerClass attribute

* Changes based on feedback

* Fix SpacetimeDB tests

* One more smoketest fix

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-01 23:17:03 +02:00
Phoebe Goldman de9b3ea323 Check authorization when attempting to delete a database (#96)
In the ClientAPI /database/delete/:address endpoint, require authorization before deleting a database.
2023-08-01 23:17:03 +02:00
Phoebe Goldman 3e215322e5 [Modules] spacetimedb(index) macro now uses more consistent parens. (#97)
Prior to this comment, the `#[spacetimedb(index)]` attribute accepted its arguments like:

```rust
\#[spacetimedb(index(btree), name = "NAME", FIELD_NAMES...)]
```

Putting the `NAME` and `FIELD_NAMES` arguments outside of the
inner parens was uninutitive. With this commit, the syntax is changed to:

```rust

\#[spacetimedb(index(btree, name = "NAME", FIELD_NAMES...))]
```
2023-08-01 23:17:03 +02:00
John Detter 6381d8cf42 Increase some values for canceling reducers (#92)
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:03 +02:00
John Detter 0b0c533830 Smoketests run in parallel (#49)
* Working on improving commands that use identities

* Fix lints

* Reverted file that shouldn't have changed

* Found and fixed all other todos

* Addressed more CLI TODOs

* Fixes for formatting issues

* Set names of identities

* Set name of identities + clippy

* Small fix

* Added the start of a doc comment, switching over to another PR

* Fixed tests that needed to be updated

* Addressed more feedback and fixed several clippy issues

* Small fix

* Apply suggestions from code review

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Added more doc comments

* Addressing more feedback

* Fixed really old bug in SpacetimeDB

* Tests to verify new functionality

* Fix clippy lints

* Email during identity creation is optional

* Some work

* Getting smoketests working on mac

* All tests are passing except known failing tests

* Working on parallel smoketests

* Fixed some bugs in saving configs that was preventing this from working

* Fixes required for parallel tests

* Tests are working in parallel

* Pruned changes

* retab

* re-retab

* retab the lib file

* Cargo profile for building more quickly

* I have to rebase on another PR

* smoketest fixes

* create_project and reset_project are now the same thing, removed
create_project

* More fixes

* Removed print statement

* Small fix

* Another fix

* Tons of improvements to the smoketests

* Have to rebase on master

* Small fixes

* More progress

* Finally working correctly!

* Apparently we're missing this

* Enable command output

* Listing installed targets

* Clean before building

* What is going on

* Something super wonky going on

* Another test

* Skip building containers for now

* Small fix

* Test using cargo instead

* Changed workflow a bit

* CI is stuck

* Small fix

* Another fix

* Try cargo run instead of building spacetime CLI

* Removed workflow step

* Fixing all of the tests

* Identity test

* Tests should finally be working

* Enable debug

* Remove spacetime from path

* Another try

* Logic fix

* Another fix

* Another fix

* Working now?

* Another fix

* Finally working again

* Adding github containers back in

* CI fix

* Use SpacetimeDB Large Runner

* Updated test to get more output

* Changed 0ms to 10ms to improve parallel test stability

* Removed unused logs

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

* Removed unnecessary reset_project

* Removed reset_config where its not needed

* Reset template

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-08-01 23:17:03 +02:00
John Detter 187cc74dd4 Spacetime Server Show + Ping (#75)
* Added commands for spacetime server list and spacetime server ping

* Small fix

* Updated test

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:03 +02:00
John Detter 757719e7b4 Enable restart tests (#35)
* Fixes the restart problem (i.e. rebuilding the datastore from the message log)

* Remove logging

* Enable restart tests

* Fixed small issues with tests

* Fixed restart-repeating-reducer test probably

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
Phoebe Goldman 29b1db663b Filtering on non-unique fields uses indexes when available (#40)
With this commit, module-side `filter_by_{non-unique-field}` methods will use an index on the non-unique-field, if one exists.

This is accomplished by altering `query::filter_by_field` to call `iter_by_col_eq` (formerly `seek_eq`), and having the returned `FilterByIter` gradually deserialize the returned buffer in a `Cursor`.
2023-08-01 23:17:02 +02:00
Kim Altintop a20b75b82c Fix schema equivalence check when updating a module (#39)
`IndexDef` contains a table id, which is not yet known (i.e. zero) when
constructing `TableDef` from the module describers. But it /is/ known
for the schema obtained from the database catalog, so schemas compare
inequal even if they're structurally equivalent.

Fixed by just updating the proposed schema for known tables before
comparing. Also update the smoke test to contain an indexed column.
2023-08-01 23:17:02 +02:00
John Detter 7510b83c1a Fix Spacetime Identity Remove (#33)
* Fix bug and added a test

* Test updates

* Fix tests

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
John Detter d8c8a2e931 Smoketests work on macos (#15)
* Some work

* Getting smoketests working on mac

* All tests are passing except known failing tests

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
John Detter 8cf9ed49ef Identity command improvements (#11)
* Working on improving commands that use identities

* Fix lints

* Reverted file that shouldn't have changed

* Found and fixed all other todos

* Addressed more CLI TODOs

* Fixes for formatting issues

* Set names of identities

* Set name of identities + clippy

* Small fix

* Added the start of a doc comment, switching over to another PR

* Fixed tests that needed to be updated

* Addressed more feedback and fixed several clippy issues

* Small fix

* Apply suggestions from code review

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Added more doc comments

* Addressing more feedback

* Fixed really old bug in SpacetimeDB

* Tests to verify new functionality

* Fix clippy lints

* Email during identity creation is optional

* Fix output so testsuite passes

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-08-01 23:17:02 +02:00
John Detter 8fc09bb566 Run clippy on default module (#7)
* Clippy runs on default module

* Fix clippy issue with default module

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
Tyler Cloutier 44df6c6e7d Initial commit 2023-08-01 23:16:37 +02:00