Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of the where api #1199

Closed
wants to merge 184 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
e4303a8
reenabled index and added interface with keys
Sep 9, 2023
940cae8
getting by key
Sep 9, 2023
4743f5e
bidirectional reference for keys and debug
Sep 9, 2023
5e5b4ce
commented out test
Sep 9, 2023
79060f8
a placeholder for key deletion
Sep 11, 2023
1e71ae1
using index in database
Sep 11, 2023
6e00168
using new api in world
Sep 11, 2023
c0da825
simple test entities in world
Sep 11, 2023
8f384fa
add .vscode to .gitignore
neotheprogramist Sep 11, 2023
e2ba615
disable indexing by default
neotheprogramist Sep 11, 2023
eea4f68
fix tests
neotheprogramist Sep 11, 2023
029728a
doc comments
matzayonc Sep 11, 2023
aa7f753
added new test cases
verzotokumpel Sep 13, 2023
d33c498
improved some tests
verzotokumpel Sep 13, 2023
9fccc08
updating indexer to use layouts
matzayonc Sep 25, 2023
ca3dd24
run with CAIRO_FIX_TESTS=1
neotheprogramist Sep 25, 2023
07210d6
clippy
neotheprogramist Sep 25, 2023
34f3318
updated test_entities for new api
matzayonc Sep 25, 2023
8472d89
rebase and comments
matzayonc Sep 28, 2023
a280cfe
ci trigger
matzayonc Sep 28, 2023
b725a64
Remove partitions
tarrencev Sep 28, 2023
4a96d90
Propose api
tarrencev Sep 28, 2023
975e3fb
made future interface compile
Oct 2, 2023
0515480
update after rebase
Oct 3, 2023
2a6eb79
stripping unneeded
Oct 3, 2023
b592ee3
test fixes
Oct 3, 2023
bdf8438
removed keys_layout
Oct 3, 2023
a58686d
moved index over values to separate file
Oct 3, 2023
dfd8f18
working index with values
Oct 3, 2023
496e71d
entry deletion
Oct 3, 2023
dce8712
cleaned up indexes
Oct 3, 2023
ad399b5
universal index
Oct 4, 2023
0343f80
where condition from entities method
Oct 4, 2023
636dcb1
creating indexes with values
Oct 4, 2023
883c660
tests and a fix
Oct 6, 2023
14191e4
added pagination capabilities
Oct 6, 2023
817e9c4
added key storage and deletion
Oct 6, 2023
7f130a5
simplified key deletion
Oct 6, 2023
50dfc53
deletion test
Oct 6, 2023
04f1c2b
fix after rebase
Oct 6, 2023
9d28ba0
CAIRO_TEST_FIX=1
Oct 6, 2023
2b391ff
fixed out of gas errors
Oct 9, 2023
43c59e7
fix after rebase
Oct 9, 2023
d0ce033
removed rebase leftover
Oct 9, 2023
f0c4150
added clause type
Oct 12, 2023
a9924e5
test fix after pull
Oct 12, 2023
9efdda8
fix entity_ids
neotheprogramist Oct 16, 2023
aa26a7b
CAIRO_FIX_TESTS=1
neotheprogramist Oct 16, 2023
479de11
array instead of serialization
Oct 21, 2023
36a7761
fixes
Oct 21, 2023
4255c8f
simple test entities in world
Sep 11, 2023
ae3fcd9
updating indexer to use layouts
matzayonc Sep 25, 2023
9aae93b
tests and a fix
Oct 6, 2023
8047e5f
added clause type
Oct 12, 2023
886dd8a
fixes after rebase
Oct 21, 2023
cb8db04
fixes after rebase
Oct 21, 2023
5373a7f
CAIRO_FIX_TESTS=1
Oct 21, 2023
f765774
CAIRO_FIX_TESTS=1
neotheprogramist Oct 27, 2023
4afaacb
fix gas
neotheprogramist Oct 30, 2023
16d4b2a
remove old test
neotheprogramist Nov 3, 2023
0c4e239
fixes after merge
Nov 6, 2023
59c54aa
just hardcoded new value
matzayonc Nov 12, 2023
921809a
hardcoded value comment
matzayonc Nov 12, 2023
be6773c
Merge main
tarrencev Nov 21, 2023
d9f4ea8
Update clause api to match grpc
tarrencev Nov 21, 2023
520a765
Refactor indexing
tarrencev Nov 22, 2023
49f5504
Merge remote-tracking branch 'origin/main' into 9-implementation-of-t…
tarrencev Nov 22, 2023
b9fa2bf
Fix cargo tests
tarrencev Nov 22, 2023
c45c5a9
Hardcode plugin version (#1208)
tarrencev Nov 27, 2023
7b72792
Graphql `where` input type check (#1209)
broody Nov 27, 2023
cb91c21
Cleanup release.yml
tarrencev Nov 27, 2023
a253b0c
Prepare v0.3.13
tarrencev Nov 27, 2023
bbb932f
make world upgradeable (#1210)
notV4l Nov 27, 2023
84fbcb7
Rename grpc attribute clause to member (#1211)
broody Nov 27, 2023
8c2f0d9
refactor(spawn-and-move): up to date readme (#1212)
Larkooo Nov 27, 2023
09115ef
Refactor torii core add entity_model table (#1213)
broody Nov 28, 2023
4b3041a
reenabled index and added interface with keys
Sep 9, 2023
3cf0fbc
getting by key
Sep 9, 2023
9d6e8e2
bidirectional reference for keys and debug
Sep 9, 2023
0d4863d
commented out test
Sep 9, 2023
751e0e4
a placeholder for key deletion
Sep 11, 2023
ba545f1
using index in database
Sep 11, 2023
4a7fe8f
using new api in world
Sep 11, 2023
e39bbc9
simple test entities in world
Sep 11, 2023
2bedfea
add .vscode to .gitignore
neotheprogramist Sep 11, 2023
107aabc
disable indexing by default
neotheprogramist Sep 11, 2023
29ec18d
fix tests
neotheprogramist Sep 11, 2023
d0814a3
doc comments
matzayonc Sep 11, 2023
ff2a850
added new test cases
verzotokumpel Sep 13, 2023
0a583f3
improved some tests
verzotokumpel Sep 13, 2023
c25a0eb
updating indexer to use layouts
matzayonc Sep 25, 2023
b135bff
run with CAIRO_FIX_TESTS=1
neotheprogramist Sep 25, 2023
7558656
clippy
neotheprogramist Sep 25, 2023
623a2e5
updated test_entities for new api
matzayonc Sep 25, 2023
3af9991
rebase and comments
matzayonc Sep 28, 2023
d17e49f
ci trigger
matzayonc Sep 28, 2023
345a278
Remove partitions
tarrencev Sep 28, 2023
ad304ba
Propose api
tarrencev Sep 28, 2023
d317078
made future interface compile
Oct 2, 2023
098a8fc
update after rebase
Oct 3, 2023
ebcb6ff
stripping unneeded
Oct 3, 2023
ec77d8c
test fixes
Oct 3, 2023
cfc9d1d
removed keys_layout
Oct 3, 2023
ace6e3c
moved index over values to separate file
Oct 3, 2023
5748f74
working index with values
Oct 3, 2023
1a74a56
entry deletion
Oct 3, 2023
a3ab682
cleaned up indexes
Oct 3, 2023
153c235
universal index
Oct 4, 2023
ee05d90
where condition from entities method
Oct 4, 2023
3af0395
creating indexes with values
Oct 4, 2023
73cc0d5
tests and a fix
Oct 6, 2023
2b01276
added pagination capabilities
Oct 6, 2023
6554234
added key storage and deletion
Oct 6, 2023
ded3051
simplified key deletion
Oct 6, 2023
66252c1
deletion test
Oct 6, 2023
51f6c82
fix after rebase
Oct 6, 2023
66fb813
CAIRO_TEST_FIX=1
Oct 6, 2023
11f0efc
fix after rebase
Oct 9, 2023
3f6c95b
added clause type
Oct 12, 2023
a82678a
test fix after pull
Oct 12, 2023
9e88a04
fix entity_ids
neotheprogramist Oct 16, 2023
a76787f
CAIRO_FIX_TESTS=1
neotheprogramist Oct 16, 2023
f355413
array instead of serialization
Oct 21, 2023
39d26d5
fixes
Oct 21, 2023
ed52836
simple test entities in world
Sep 11, 2023
a703a5a
updating indexer to use layouts
matzayonc Sep 25, 2023
674fb3e
tests and a fix
Oct 6, 2023
90ba900
added clause type
Oct 12, 2023
f3b56ef
fixes after rebase
Oct 21, 2023
6e9f58f
fixes after rebase
Oct 21, 2023
e12a0d2
CAIRO_FIX_TESTS=1
Oct 21, 2023
ec35a03
remove old test
neotheprogramist Nov 3, 2023
382e935
fixes after merge
Nov 6, 2023
e3ad86a
hardcoded value comment
matzayonc Nov 12, 2023
4563cfb
Update clause api to match grpc
tarrencev Nov 21, 2023
78f23b2
Refactor indexing
tarrencev Nov 22, 2023
6069d35
assert to check for empty index
matzayonc Nov 23, 2023
1c651e7
member position in model in clause
matzayonc Nov 28, 2023
7e6083e
fix after rebase
matzayonc Nov 28, 2023
061874e
reenabled index and added interface with keys
Sep 9, 2023
288c628
commented out test
Sep 9, 2023
bac96a8
using index in database
Sep 11, 2023
ded67b3
using new api in world
Sep 11, 2023
b7dcef4
simple test entities in world
Sep 11, 2023
a948101
add .vscode to .gitignore
neotheprogramist Sep 11, 2023
6ece1da
doc comments
matzayonc Sep 11, 2023
ef5829e
updating indexer to use layouts
matzayonc Sep 25, 2023
1ad2f5d
run with CAIRO_FIX_TESTS=1
neotheprogramist Sep 25, 2023
6ce13ea
clippy
neotheprogramist Sep 25, 2023
b9cd247
updated test_entities for new api
matzayonc Sep 25, 2023
8268a49
rebase and comments
matzayonc Sep 28, 2023
2479119
ci trigger
matzayonc Sep 28, 2023
11e393b
Remove partitions
tarrencev Sep 28, 2023
173e825
Propose api
tarrencev Sep 28, 2023
c575c97
made future interface compile
Oct 2, 2023
1530099
update after rebase
Oct 3, 2023
6ba8180
stripping unneeded
Oct 3, 2023
30efe55
test fixes
Oct 3, 2023
d1ac8cf
removed keys_layout
Oct 3, 2023
371003e
moved index over values to separate file
Oct 3, 2023
36dd57f
working index with values
Oct 3, 2023
e0f0bc9
entry deletion
Oct 3, 2023
3124e40
cleaned up indexes
Oct 3, 2023
1741c73
universal index
Oct 4, 2023
c5c891d
where condition from entities method
Oct 4, 2023
8d105ce
creating indexes with values
Oct 4, 2023
5879263
tests and a fix
Oct 6, 2023
a26fbb9
added pagination capabilities
Oct 6, 2023
8e7751b
added key storage and deletion
Oct 6, 2023
de5cd81
simplified key deletion
Oct 6, 2023
b83d5ac
deletion test
Oct 6, 2023
7bc4223
added clause type
Oct 12, 2023
886c0d2
simple test entities in world
Sep 11, 2023
0c0fba7
updating indexer to use layouts
matzayonc Sep 25, 2023
82328f6
fixes after rebase
Oct 21, 2023
0190b69
remove old test
neotheprogramist Nov 3, 2023
7daa23f
fixes after merge
Nov 6, 2023
5e9c657
Update clause api to match grpc
tarrencev Nov 21, 2023
f41216e
Refactor indexing
tarrencev Nov 22, 2023
e9bb56f
Fix cargo tests
tarrencev Nov 22, 2023
901c6d6
updated hardcoded class as fixed on other branch
matzayonc Nov 29, 2023
6069856
Merge branch '9-implementation-of-the-where-api' of github.com:dojoen…
matzayonc Nov 30, 2023
2460339
updated contract address
matzayonc Nov 30, 2023
d8a11fa
Merge branch '9-implementation-of-the-where-api' of https://github.co…
matzayonc Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ jobs:
target: arm64
build-contexts: |
artifacts=artifacts
# cache-from: type=gha
# cache-to: type=gha,mode=max

docker-build-and-push-linux-amd64:
name: Build and push linux-amd64 docker image
Expand Down Expand Up @@ -305,5 +303,3 @@ jobs:
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: linux/amd64
target: amd64
# cache-from: type=gha
# cache-to: type=gha,mode=max
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition = "2021"
license = "Apache-2.0"
license-file = "LICENSE"
repository = "https://github.com/dojoengine/dojo/"
version = "0.3.12"
version = "0.3.13"

[profile.performance]
codegen-units = 1
Expand Down
6 changes: 3 additions & 3 deletions crates/dojo-core/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ version = 1

[[package]]
name = "dojo"
version = "0.3.12"
version = "0.3.13"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_plugin"
version = "0.3.12"
source = "git+https://github.com/dojoengine/dojo?tag=v0.3.12#12d58f29ec53454317f1f6d265007a053d279288"
version = "0.3.11"
source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7d8aa29a92062fcb9e6659"
4 changes: 2 additions & 2 deletions crates/dojo-core/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
cairo-version = "2.3.1"
description = "The Dojo Core library for autonomous worlds."
name = "dojo"
version = "0.3.12"
version = "0.3.13"

[dependencies]
dojo_plugin = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.12" }
dojo_plugin = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.11" }
starknet = "2.3.1"
67 changes: 28 additions & 39 deletions crates/dojo-core/src/benchmarks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use starknet::SyscallResultTrait;
use starknet::{contract_address_const, ContractAddress, ClassHash, get_caller_address};

use dojo::database;
use dojo::database::{storage, index};
use dojo::database::{storage, index, Clause};
use dojo::packing::{shl, shr};
use dojo::model::Model;
use dojo::world_test::Foo;
use dojo::test_utils::end;
Expand Down Expand Up @@ -113,30 +114,30 @@ fn bench_native_storage_offset() {
fn bench_index() {
let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let no_query = index::query(0, 69, Option::None(()));
let no_query = index::get(0, 69, 0);
end(gas, 'idx empty');
assert(no_query.len() == 0, 'entity indexed');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
index::create(0, 69, 420);
index::create(0, 69, 420, 0);
end(gas, 'idx create 1st');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let query = index::query(0, 69, Option::None(()));
let query = index::get(0, 69, 0);
end(gas, 'idx query one');
assert(query.len() == 1, 'entity not indexed');
assert(*query.at(0) == 420, 'entity value incorrect');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
index::create(0, 69, 1337);
index::create(0, 69, 1337, 0);
end(gas, 'idx query 2nd');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let two_query = index::query(0, 69, Option::None(()));
let two_query = index::get(0, 69, 0);
end(gas, 'idx query two');
assert(two_query.len() == 2, 'index should have two query');
assert(*two_query.at(1) == 1337, 'entity value incorrect');
Expand Down Expand Up @@ -171,18 +172,18 @@ fn bench_big_index() {
if i == 1000 {
break;
}
index::create(0, 69, i);
index::create(0, 69, i, 0);
i += 1;
};
end(gas, 'idx create 1000');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let query = index::query(0, 69, Option::None(()));
let query = index::get(0, 69, 0);
end(gas, 'idx query 1000');
assert(query.len() == 1000, 'entity not indexed');
assert(*query.at(420) == 420, 'entity value incorrect');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
index::exists(0, 69, 999);
Expand Down Expand Up @@ -249,27 +250,25 @@ fn bench_indexed_database_array() {

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
database::set_with_index('table', 'even', 0, even, layout);
database::set_with_index('table', 'even', array![].span(), 0, even, layout);
end(gas, 'dbi set arr 1st');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let (keys, values) = database::scan('table', Option::None(()), 2, layout);
let values = database::scan(Clause::All('table'), 2, layout);
end(gas, 'dbi scan arr 1');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
database::set_with_index('table', 'odd', 0, odd, layout);
database::set_with_index('table', 'odd', array![].span(), 0, odd, layout);
end(gas, 'dbi set arr 2nd');

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let (keys, values) = database::scan('table', Option::None(()), 2, layout);
let values = database::scan(Clause::All('table'), 2, layout);
end(gas, 'dbi scan arr 2');

assert(keys.len() == 2, 'Wrong number of keys!');
assert(values.len() == 2, 'Wrong number of values!');
assert(*keys.at(0) == 'even', 'Wrong key at index 0!');
assert(*(*values.at(0)).at(0) == 2, 'Wrong value at index 0!');
assert(*(*values.at(0)).at(1) == 4, 'Wrong value at index 1!');
}
Expand All @@ -282,11 +281,7 @@ fn bench_simple_struct() {

let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let mut foo = Foo {
caller,
a: 0x123456789abcdef,
b: 0x123456789abcdef,
};
let mut foo = Foo { caller, a: 0x123456789abcdef, b: 0x123456789abcdef, };
end(gas, 'foo init');

let gas = testing::get_available_gas();
Expand Down Expand Up @@ -402,18 +397,12 @@ fn bench_nested_struct() {
gas::withdraw_gas().unwrap();

let mut case = Case {
owner: caller,
sword: Sword {
swordsmith: caller,
damage: 0x12345678,
},
material: 'wooden',
owner: caller, sword: Sword { swordsmith: caller, damage: 0x12345678, }, material: 'wooden',
};
end(gas, 'case init');
let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();


let gas = testing::get_available_gas();
gas::withdraw_gas().unwrap();
let mut serialized = ArrayTrait::new();
Expand Down Expand Up @@ -516,16 +505,16 @@ fn bench_complex_struct() {
finished: true,
romances: 0x1234,
},
weapon: Weapon::DualWield((
Sword {
swordsmith: starknet::contract_address_const::<0x69>(),
damage: 0x12345678,
},
Sword {
swordsmith: starknet::contract_address_const::<0x69>(),
damage: 0x12345678,
}
)),
weapon: Weapon::DualWield(
(
Sword {
swordsmith: starknet::contract_address_const::<0x69>(), damage: 0x12345678,
},
Sword {
swordsmith: starknet::contract_address_const::<0x69>(), damage: 0x12345678,
}
)
),
gold: 0x12345678,
};
end(gas, 'chars init');
Expand Down Expand Up @@ -566,4 +555,4 @@ fn bench_complex_struct() {
gas::withdraw_gas().unwrap();
database::get('chars', '42', 0, char.packed_size(), char.layout());
end(gas, 'chars db get');
}
}
Loading
Loading