Skip to content

feat: support non consecutive blocks ryhope #425

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
272 commits
Select commit Hold shift + click to select a range
799a60f
Merge with main
nicholas-mainardi Sep 16, 2024
b26ea94
fix: ORDER BY is not supported
delehef Sep 16, 2024
a36fd13
Merge pull request #355 from Lagrange-Labs/feat/drop-scalar-check
nikkolasg Sep 16, 2024
dfaa7d7
WiP: keep both queries types in a single test
nicholas-mainardi Sep 16, 2024
8fc299f
Merge branch 'main' into feat/tabular-queries
nicholas-mainardi Sep 16, 2024
76a4bdd
wip
nikkolasg Sep 17, 2024
4f7aec5
compiling
nikkolasg Sep 17, 2024
c0bb9a6
Merge branch 'feat/tabular-queries' into feat/unproven-limit-offset-q…
nicholas-mainardi Sep 18, 2024
28a3383
Working intergation test for simple select queries
nicholas-mainardi Sep 18, 2024
c3c199d
fmt
nicholas-mainardi Sep 18, 2024
170ad44
Run also commented test cases
nicholas-mainardi Sep 18, 2024
676dfec
Bind matching row keys and results in a single query
nicholas-mainardi Sep 18, 2024
34d88ec
Remove dead code
nicholas-mainardi Sep 18, 2024
689b929
Add distinct to circuit and Parsil
nicholas-mainardi Sep 19, 2024
56e0dde
Support DISTINCT and SELECT * queries in integration test
nicholas-mainardi Sep 19, 2024
17cd47f
Comment out test cases
nicholas-mainardi Sep 19, 2024
84fe37a
passing test
nikkolasg Sep 19, 2024
cd59ea3
More complex test case with wildcards
nicholas-mainardi Sep 19, 2024
d8bc019
integrated test refactor #1
nikkolasg Sep 19, 2024
1fb227d
refactoring #2 compiling
nikkolasg Sep 20, 2024
735b415
correct size of circuit set
nikkolasg Sep 20, 2024
cebaf1c
full refactoring #3
nikkolasg Sep 20, 2024
a1274ae
multiplier columns
nikkolasg Sep 20, 2024
aee4872
test case for merge
nikkolasg Sep 20, 2024
2ea4e0d
add metadata from contract
nikkolasg Sep 20, 2024
99022b6
merge updates
nikkolasg Sep 21, 2024
1024dbe
default sec cell
nikkolasg Sep 21, 2024
abd9989
debug storage root
nikkolasg Sep 21, 2024
c7bea49
fixing block
nikkolasg Sep 21, 2024
12e083f
ordered cells
nikkolasg Sep 21, 2024
f6a5647
more debug
nikkolasg Sep 21, 2024
4368993
debug
nikkolasg Sep 21, 2024
1d4c10e
fixing vdb row digest
nikkolasg Sep 21, 2024
e0ad8d5
correct update depending on type
nikkolasg Sep 21, 2024
8407145
fixing update of mapping
nikkolasg Sep 21, 2024
6352db1
final test
nikkolasg Sep 21, 2024
84cd5cb
handle deletion for single
nikkolasg Sep 21, 2024
619c950
multiple rows
nikkolasg Sep 22, 2024
ab88009
Update verifiable-db/src/cells_tree/api.rs
nikkolasg Sep 23, 2024
c580c01
Update verifiable-db/src/cells_tree/api.rs
nikkolasg Sep 23, 2024
2c51871
reviews first pass
nikkolasg Sep 23, 2024
8184bd3
correct conditional scalar mul
nikkolasg Sep 23, 2024
8b30e6a
better API
nikkolasg Sep 23, 2024
3b83417
more debug
nikkolasg Sep 23, 2024
e5635d0
more debug
nikkolasg Sep 23, 2024
1d05c47
Optimize SQL queries to get Merkle-path
nicholas-mainardi Sep 23, 2024
f877735
testing split digest
nikkolasg Sep 23, 2024
90e4d42
with correct name
nikkolasg Sep 23, 2024
5e057ed
more tests
nikkolasg Sep 23, 2024
9020e54
fixes
nikkolasg Sep 23, 2024
c90e821
query adaptable
nikkolasg Sep 23, 2024
edad5fa
putting back ignoring query
nikkolasg Sep 23, 2024
71c2ce7
Merge branch 'main' into feat/merge_table
nikkolasg Sep 23, 2024
8ce5ca1
Fix non-existence proven node selection
nicholas-mainardi Sep 25, 2024
185ff79
Comment to clarify non-existence node selection logic
nicholas-mainardi Sep 25, 2024
994a115
Check query upper bounds in Parsil + add LIMIT to query if missing
nicholas-mainardi Sep 26, 2024
5fd774f
Refactor revelation APIs to avoid calling ids_for_placeholder_hash
nicholas-mainardi Sep 26, 2024
c89fc0f
Add comment for cells tree hash construction
nicholas-mainardi Sep 27, 2024
0f706cf
Fix: ensure we always use the appropriate merge flag in rows tre circ…
nicholas-mainardi Oct 1, 2024
06941a7
Implement the MPT part of generic extraction.
silathdiir Sep 30, 2024
3b368f4
Replace `32` with `MAPPING_LEAF_VALUE_LEN` in column gadget.
silathdiir Oct 6, 2024
84143e8
Replace the wrong index `7 - j` with `NUM_LAST_BITS_LOOKUP_TABLES - 1…
silathdiir Oct 6, 2024
69014f4
Re-use `length_bytes` as `real_len`.
silathdiir Oct 6, 2024
22068c4
Replace `less_than_or_equal_to` with `less_than_or_equal_to_unsafe` i…
silathdiir Oct 6, 2024
af66891
Fix to pack `extract_value`.
silathdiir Oct 6, 2024
1fbe615
Delete the wrong addition of `mpt_key` and `offset`.
silathdiir Oct 6, 2024
08f34cd
Replace `UInt256Target::new_from_be_target_limbs` with `new_from_targ…
silathdiir Oct 6, 2024
dce73a4
Delete uesless range check for slot and EVM word, since they're hashe…
silathdiir Oct 6, 2024
9c9519a
Fix to pack before digest computation as `D(key_id || pack(left_pad32…
silathdiir Oct 6, 2024
6640d85
Fix to only add values digest if EVM word is zero in leaf mapping cir…
silathdiir Oct 6, 2024
87809b8
Fix to use one field for the prefix `KEY`.
silathdiir Oct 6, 2024
94c9de8
Fix wrong byte order in `unpack_u32_to_u8_target`.
silathdiir Oct 7, 2024
691b69f
Add mapping of mappings leaf circuit.
silathdiir Oct 7, 2024
4f27919
Update storage key.
silathdiir Oct 7, 2024
08642f3
Update values extraction API.
silathdiir Oct 7, 2024
c7371b0
Add tests for column and metadata gadgets.
silathdiir Oct 8, 2024
6b8c7af
Add tests for storage key.
silathdiir Oct 9, 2024
cdc353b
Add test for leaf single circuit.
silathdiir Oct 10, 2024
7127536
Add test to leaf mapping circuit.
silathdiir Oct 10, 2024
e54449a
Add test for leaf mapping of mappings circuit.
silathdiir Oct 10, 2024
0cd9487
Merge branch 'main' into feat/merge_table
nikkolasg Oct 10, 2024
1da45a1
Delete `aggregation type` (`is_simple_aggregation`) in branch circuit.
silathdiir Oct 10, 2024
b23465d
Replace `31` with `MAPPING_LEAF_VALUE_LEN - 1`.
silathdiir Oct 11, 2024
46eeeb4
Replace wrong `curve_eq` with `connect_curve_points` in `TestMetadata…
silathdiir Oct 11, 2024
65fe5cf
Replace wrong `curve_eq` with `connect_curve_points` in `TestColumnGa…
silathdiir Oct 11, 2024
5b8ad23
Fix a bug in `ColumnGadget`.
silathdiir Oct 11, 2024
23ecf24
Move common fields to `MetadataGadget`.
silathdiir Oct 11, 2024
cd5fa5c
Fix `unpack_u32_to_u8_targets`.
silathdiir Oct 11, 2024
3407665
Fix to only set maximum as `u8::MAX + 8` for `first_bits_5` lookup ta…
silathdiir Oct 11, 2024
bc84083
Fix to generic paramters for `impl CircuitLogicWires`.
silathdiir Oct 11, 2024
380be6b
Add API tests.
silathdiir Oct 13, 2024
02290cd
Add simple struct, mapping struct and mapping of mappings to the test…
silathdiir Oct 13, 2024
ef7d07b
Update bindings.
silathdiir Oct 13, 2024
43791de
Enable single value extraction in integration test.
silathdiir Oct 13, 2024
08ebeea
Enable mapping value extraction in integration test.
silathdiir Oct 14, 2024
3bd0319
Optimize normalize_left to reduce cost of extract values
nicholas-mainardi Oct 14, 2024
7b63f6e
fmt
nicholas-mainardi Oct 14, 2024
9757f60
Fix the assigment to `evm_word`.
silathdiir Oct 14, 2024
6428a2f
Fix `MAX_COLUMNS` and `MAX_FIELD_PER_EVM` to generic parameters.
silathdiir Oct 14, 2024
b7e9ed3
Pass into the extracted column identifier to init `MetadataGadget`.
silathdiir Oct 15, 2024
ad4ddd9
Fix `outer_key_id` and `inner_key_id` to `Option` in `StorageSlotInfo…
silathdiir Oct 15, 2024
20f3933
Add test `test_values_extraction_api_serialization`.
silathdiir Oct 15, 2024
32f9837
Remove `evm_word` for generating mapping key identifier.
silathdiir Oct 15, 2024
d87b8a6
Fix encoded data.
silathdiir Oct 15, 2024
b405f04
Add common functions for metadata and values digest computation.
silathdiir Oct 15, 2024
5916860
Merge branch 'feat/merge_table' into feat/tabular-queries
nicholas-mainardi Oct 15, 2024
7b12a98
Fix to check the expected metadata digest in API test.
silathdiir Oct 15, 2024
1098ce5
Specify `NODE_LEN` to `69` as `MAX_LEAF_NODE_LEN`.
silathdiir Oct 15, 2024
39d522d
Fix build.
silathdiir Oct 15, 2024
635eb56
Clean the current useless code in integration test.
silathdiir Oct 15, 2024
63fc418
Enable rows digest check in integration test.
silathdiir Oct 15, 2024
9002398
Merge branch 'feat/tabular-queries' into feat/unproven-limit-offset-q…
nicholas-mainardi Oct 15, 2024
c87856f
Add LIMIT by default only in simple SELECT queries
nicholas-mainardi Oct 15, 2024
c7bd811
Avoid running wildcard queries on merged tables
nicholas-mainardi Oct 15, 2024
a5a6962
Fix parsil test
nicholas-mainardi Oct 15, 2024
9c325d6
Merge remote-tracking branch 'origin/feat/unproven-limit-offset-queri…
silathdiir Oct 15, 2024
e3292a6
Add a new constant `EVM_WORD_LEN` for the slot value length.
silathdiir Oct 16, 2024
0048e0d
Remove `num_actual_columns` from the arguments of `MetadataGadget::ne…
silathdiir Oct 16, 2024
ef51ed8
Add check for the parent of a Slot mapping entry, it must be type of …
silathdiir Oct 16, 2024
bc90aba
Compute the column information digest in `ColumnInfo` and called in `…
silathdiir Oct 16, 2024
de7e002
Fix the Key ID constants to size of Uint32 or Uint64.
silathdiir Oct 16, 2024
8a85e45
Fix `evm_word` to `usize`, key IDs to `u64` and `extracted_column_ide…
silathdiir Oct 16, 2024
896e85a
Fix build.
silathdiir Oct 16, 2024
765731c
Fix tests.
silathdiir Oct 16, 2024
e36d424
Fix build.
silathdiir Oct 16, 2024
75937e2
Remove `extracted_column_identifiers` and `evm_word` from metadata co…
silathdiir Oct 16, 2024
5249a29
Fix tests.
silathdiir Oct 16, 2024
83a68e3
Pass `MetadataGadget` to the API functions.
silathdiir Oct 16, 2024
ec22c05
Check `values_digest` in `prove_leaf`.
silathdiir Oct 16, 2024
ddd0e9e
Replace `key_id` with `value_id` in `value_metadata` function.
silathdiir Oct 16, 2024
96f2223
Fix to place the value column for mappings of simple variables.
silathdiir Oct 16, 2024
7671861
Support mapping of Struct and mapping of mappings for the value metad…
silathdiir Oct 16, 2024
3043229
Update the metadata hash and integration test.
silathdiir Oct 17, 2024
92c73f4
Add `extracted_column_indentifiers` function to `MetadataGadget`.
silathdiir Oct 17, 2024
e5c21d1
Fix to check MPT `location` bytes without unpacking.
silathdiir Oct 17, 2024
17680fb
Fix the merge circuit metadata to `D(md_a) + D(md_b)`.
silathdiir Oct 17, 2024
1058717
Fix test.
silathdiir Oct 17, 2024
94dca85
fix: MemoryStorage::all_keys_at should not return dead keys
delehef Oct 17, 2024
e58faee
feat: add random_key_at
delehef Oct 17, 2024
3548cc5
Do range-check for the Keccak output which will be converted for Uint…
silathdiir Oct 22, 2024
aea77c6
Refactor the assign functions for the simple and mapping slots.
silathdiir Oct 22, 2024
7f9cb61
Update the circuits of cells tree, rows tree and block tree for gener…
silathdiir Oct 18, 2024
63b3b2d
Update tests for cells tree.
silathdiir Oct 22, 2024
c7291cf
Update tests for rows tree.
silathdiir Oct 23, 2024
d9f8825
Update tests of block tree.
silathdiir Oct 23, 2024
f59c5d7
Fix test.
silathdiir Oct 23, 2024
e651ab9
Add missing `value` for hash in rows tree.
silathdiir Oct 25, 2024
85cdb54
Merge branch 'feat/merge_table' into feat/tabular-queries
nicholas-mainardi Oct 29, 2024
791ba8a
Merge branch 'feat/tabular-queries' into feat/unproven-limit-offset-q…
nicholas-mainardi Oct 29, 2024
65ff089
Merge branch 'feat/unproven-limit-offset-queries' into generic-mpt-ex…
nicholas-mainardi Oct 29, 2024
5e2df85
Simple Select Queries with Unchecked Offset (#365)
nicholas-mainardi Oct 29, 2024
2717f98
Update verifiable-db/src/row_tree/public_inputs.rs
silathdiir Oct 30, 2024
a5ae612
Fix to ensure `extraction_proof.is_merge or rows_tree_proof.multiplie…
silathdiir Oct 30, 2024
ca0a971
Fix to use `split_and_accumulate`.
silathdiir Oct 30, 2024
2c94c12
Fix the test coverage for the all cells node circuits.
silathdiir Oct 30, 2024
6b791c9
Remove merge flag in rows tree public inputs.
silathdiir Oct 30, 2024
16bea45
Rename `assign_wires` to `assign`.
silathdiir Oct 30, 2024
1f70eb4
Fix to use `PublicInputs::sample`.
silathdiir Oct 30, 2024
21bb637
Fix to `p.partial`.
silathdiir Oct 30, 2024
0ad3977
Merge remote-tracking branch 'origin/feat/tabular-queries' into gener…
silathdiir Oct 30, 2024
32f4495
Merge remote-tracking branch 'origin/generic-mpt-extraction' into gen…
silathdiir Oct 30, 2024
31f7685
Delete the `ignore` comment for test `isolution`.
silathdiir Oct 30, 2024
e37e98e
Fix to use `split_and_accumulate`.
silathdiir Oct 30, 2024
0836ee3
Replace MPT metadata with the counter.
silathdiir Oct 30, 2024
aa84a07
Remove `child_metadata_digest` in the cells tree test.
silathdiir Oct 31, 2024
3a686f9
Fix to use `F::from_bool`.
silathdiir Oct 31, 2024
d5c9e24
Replace `HashOut<F>` with `HashOutput` in the API functions.
silathdiir Oct 31, 2024
5ce5ca5
Fix test
silathdiir Oct 31, 2024
5483d50
chore: clippy
delehef Oct 31, 2024
93c80de
Update integration test for generic extraction.
silathdiir Oct 24, 2024
60d3f34
[parsil] correctly handle LIMIT/OFFSET
delehef Nov 5, 2024
35d9623
[mp2] use more explicit names
delehef Nov 5, 2024
5bb0490
fix: imports
delehef Nov 5, 2024
2e32687
Merge branch 'main' into feat/tabular-queries
nicholas-mainardi Nov 6, 2024
3644f30
Fix integration test + fmt
nicholas-mainardi Nov 6, 2024
6a27c73
use u32's for offset & limit
delehef Nov 6, 2024
ec32679
Fix test failing from time to time
nicholas-mainardi Nov 6, 2024
d6cd3ad
Merge remote-tracking branch 'origin/feat/tabular-queries' into gener…
silathdiir Nov 7, 2024
a2c4cfc
Remove `bit_offset` in API.
silathdiir Nov 7, 2024
322280b
Merge remote-tracking branch 'origin/generic-mpt-extraction' into gen…
silathdiir Nov 7, 2024
82cc17c
Merge remote-tracking branch 'origin/generic-extraction-tree-creation…
silathdiir Nov 7, 2024
d7607cf
Merge remote-tracking branch 'origin/generic-extraction-row-id-update…
silathdiir Nov 7, 2024
9c4ddb7
Rename `Row` to `SecondaryIndexCell`.
silathdiir Nov 7, 2024
4b5dc13
Merge remote-tracking branch 'origin/generic-extraction-tree-creation…
silathdiir Nov 7, 2024
51768ea
Merge remote-tracking branch 'origin/generic-extraction-row-id-update…
silathdiir Nov 7, 2024
b33cd73
Combine the single and mapping test cases, and update the merge test …
silathdiir Nov 8, 2024
911aadb
Rename to `ContractController` and update the trait function names.
silathdiir Nov 12, 2024
6b8d4bc
Add TODO to the deprecated `bit_offset`.
silathdiir Nov 12, 2024
e2b717c
Fix the wrong log.
silathdiir Nov 12, 2024
302b17e
Add back the MPT key and ptr check.
silathdiir Nov 12, 2024
6155a66
Fix `last_byte_offset` to not restrict the maximum length.
silathdiir Nov 12, 2024
051bf96
Rename `MetadataGadget` to `ColumnsMetadata`, and leave `build` and `…
silathdiir Nov 12, 2024
c21fe13
Add more common `_raw` functions for the values extraction identifier…
silathdiir Nov 12, 2024
29fd77b
Remove `TableDimension`.
silathdiir Nov 13, 2024
2d1aa8a
Fix the row unique ID always get from the key ID column.
silathdiir Nov 13, 2024
38d6d30
Fix to the value column as the secondary index column in mapping stru…
silathdiir Nov 13, 2024
be3db69
Merge the match arms for mapping update.
silathdiir Nov 14, 2024
973325d
Set to simple rest for the row key.
silathdiir Nov 14, 2024
c423611
Fix the slot checking logic in the storage trie.
silathdiir Nov 14, 2024
50a58d9
Refactor the columns metadata and APIs.
silathdiir Nov 14, 2024
f53f0ee
Fix test.
silathdiir Nov 15, 2024
45deacf
Fix test.
silathdiir Nov 15, 2024
736d790
Merge remote-tracking branch 'origin/main' into generic-mpt-extraction
silathdiir Nov 17, 2024
4a342a0
Merge remote-tracking branch 'origin/generic-mpt-extraction' into gen…
silathdiir Nov 18, 2024
93e04dc
Merge remote-tracking branch 'origin/generic-extraction-tree-creation…
silathdiir Nov 18, 2024
8e1fb40
Merge remote-tracking branch 'origin/generic-extraction-row-id-update…
silathdiir Nov 18, 2024
29b6ddf
Add mapping of mappings test cases to the integration test.
silathdiir Nov 4, 2024
2c1ee60
Merge remote-tracking branch 'origin/main' into generic-mpt-extraction
silathdiir Dec 13, 2024
a139673
Merge remote-tracking branch 'origin/generic-mpt-extraction' into gen…
silathdiir Dec 13, 2024
e13b75e
Merge remote-tracking branch 'origin/generic-extraction-tree-creation…
silathdiir Dec 13, 2024
a22e6d7
Merge remote-tracking branch 'origin/generic-extraction-row-id-update…
silathdiir Dec 13, 2024
6018cdb
Merge remote-tracking branch 'origin/generic-extraction-integration-t…
silathdiir Dec 13, 2024
8fa830e
Comment out `test_pidgy_pinguin_mapping_slot` test case, and fix clippy.
silathdiir Dec 13, 2024
5719de9
Fix `test_pidgy_pinguin_mapping_slot`.
silathdiir Dec 13, 2024
dd0348b
Fix toolchain.
silathdiir Dec 13, 2024
8bbe471
Fix lint.
silathdiir Dec 13, 2024
be0c0a1
Merge branch 'main' into generic-mpt-extraction
nicholas-mainardi Jan 24, 2025
41e798a
Merge branch 'generic-mpt-extraction' into generic-extraction-tree-cr…
nicholas-mainardi Jan 24, 2025
55a2a14
Merhe with generic-mpt-extraction
nicholas-mainardi Jan 24, 2025
de716a7
Merge branch 'generic-extraction-tree-creation' into generic-extracti…
nicholas-mainardi Jan 24, 2025
47a5784
Merge branch 'generic-extraction-row-id-update' into generic-extracti…
nicholas-mainardi Jan 24, 2025
279b340
Merge branch 'generic-extraction-integration-test' into generic-extra…
nicholas-mainardi Jan 24, 2025
d981c7a
fmt
nicholas-mainardi Jan 24, 2025
7f610bc
Support non-contiguous block numbers
nicholas-mainardi Jan 3, 2025
c59a1e1
fmt + clippy
nicholas-mainardi Jan 3, 2025
cc7fd0b
Make current_epoch in EpochStorage trait return error
nicholas-mainardi Jan 3, 2025
72c45e9
fmt
nicholas-mainardi Jan 3, 2025
2bf0658
Fix table name provided to core_index_keys
nicholas-mainardi Jan 3, 2025
cf1c60f
Avoid expenmsive JOIN in some queries
nicholas-mainardi Jan 10, 2025
cfc65ad
Optimize row cache SQL queries
nicholas-mainardi Jan 10, 2025
652e732
Optimize JOIN wide lineage rows tree + fix eth test
nicholas-mainardi Jan 10, 2025
64a30c9
Address comments
nicholas-mainardi Jan 13, 2025
2d99d5e
Optimize InMemoryEpochMapper + imporve handling of incremental user e…
nicholas-mainardi Jan 14, 2025
f5f7db2
Add untracked file
nicholas-mainardi Jan 14, 2025
91191ae
Add maximum size to epoch mapper cache
nicholas-mainardi Jan 14, 2025
869a968
fmt
nicholas-mainardi Jan 14, 2025
e548c1e
Improve fetch_many_at
nicholas-mainardi Jan 15, 2025
8b591ab
Address comments
nicholas-mainardi Jan 16, 2025
57c5c10
Add indexes + optimizes bracketer secondary index
nicholas-mainardi Jan 20, 2025
33077f4
fmt
nicholas-mainardi Jan 20, 2025
7ffb465
Fix pidgy_pinguit test
nicholas-mainardi Jan 20, 2025
8eab5b5
Split bracketer queries for performance
nicholas-mainardi Jan 21, 2025
ea59525
fmt
nicholas-mainardi Jan 21, 2025
737079d
Improve comments to bracketer secondary index
nicholas-mainardi Jan 21, 2025
1298394
Fix after rebase
nicholas-mainardi Feb 3, 2025
73540da
fmt
nicholas-mainardi Feb 3, 2025
cc8326c
Change indexing integration test to support non-consecutive blocks
nicholas-mainardi Feb 4, 2025
2f13f53
Query in integration test compatible with non-conseuctive blocks
nicholas-mainardi Feb 6, 2025
54a23a2
Fix typo in bracketer_primary_index query
nicholas-mainardi Feb 6, 2025
981a1d3
Merge branch 'feat/new_extraction_features' into feat/support_non_con…
nicholas-mainardi Mar 5, 2025
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
12 changes: 6 additions & 6 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 inspect/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::repl::PayloadFormatter;
pub(crate) type IndexDb = MerkleTreeKvDb<
BlockTree,
IndexNode<BlockPrimaryIndex>,
PgsqlStorage<BlockTree, IndexNode<BlockPrimaryIndex>>,
PgsqlStorage<BlockTree, IndexNode<BlockPrimaryIndex>, false>,
>;

struct IndexPayloadFormatterDisplay {
Expand Down
11 changes: 7 additions & 4 deletions inspect/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use repl::Repl;
use rows::{RowDb, RowPayloadFormatter};
use ryhope::{
storage::pgsql::{SqlServerConnection, SqlStorageSettings, ToFromBytea},
Epoch, InitSettings,
InitSettings, UserEpoch,
};
use serde::Serialize;

Expand All @@ -26,7 +26,7 @@ struct Args {

#[arg(short = 'E', long = "at")]
/// If set, try to view the tree at this epoch
epoch: Option<Epoch>,
epoch: Option<UserEpoch>,

#[command(subcommand)]
/// The type of tree to load from the database
Expand Down Expand Up @@ -77,6 +77,8 @@ async fn main() -> Result<()> {
SqlStorageSettings {
source: SqlServerConnection::NewConnection(args.db_uri.clone()),
table: args.db_table,
external_mapper: None, // not necessary even if there is an external epoch mapper,
// since we are initializing the tree with `InitSettings::MustExist`
},
)
.await?;
Expand All @@ -91,7 +93,7 @@ async fn main() -> Result<()> {

let mut repl = Repl::new(tree_db, payload_fmt).await?;
if let Some(epoch) = args.epoch {
repl.set_epoch(epoch)?;
repl.set_epoch(epoch).await?;
}
repl.run().await
}
Expand All @@ -101,6 +103,7 @@ async fn main() -> Result<()> {
SqlStorageSettings {
source: SqlServerConnection::NewConnection(args.db_uri.clone()),
table: args.db_table,
external_mapper: None,
},
)
.await?;
Expand All @@ -109,7 +112,7 @@ async fn main() -> Result<()> {

let mut repl = Repl::new(tree_db, payload_fmt).await?;
if let Some(epoch) = args.epoch {
repl.set_epoch(epoch)?;
repl.set_epoch(epoch).await?;
}
repl.run().await
}
Expand Down
22 changes: 11 additions & 11 deletions inspect/src/repl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, bail};
use anyhow::{anyhow, bail, Result};
use colored::Colorize;
use dialoguer::{console, theme::ColorfulTheme, FuzzySelect, Input};
use itertools::Itertools;
Expand All @@ -8,7 +8,7 @@ use ryhope::{
TreeStorage,
},
tree::{MutableTree, PrintableTree, TreeTopology},
Epoch, MerkleTreeKvDb, NodePayload,
MerkleTreeKvDb, NodePayload, UserEpoch,
};
use std::io::Write;
use tabled::{builder::Builder, settings::Style};
Expand Down Expand Up @@ -57,7 +57,7 @@ pub(crate) struct Repl<
F: PayloadFormatter<V>,
> {
current_key: T::Key,
current_epoch: Epoch,
current_epoch: UserEpoch,
db: MerkleTreeKvDb<T, V, S>,
tty: console::Term,
payload_fmt: F,
Expand All @@ -77,7 +77,7 @@ impl<
{
pub async fn new(db: MerkleTreeKvDb<T, V, S>, payload_fmt: F) -> anyhow::Result<Self> {
let current_key = db.root().await?.ok_or(anyhow!("tree is empty"))?;
let current_epoch = db.current_epoch();
let current_epoch = db.current_epoch().await?;

Ok(Self {
current_key,
Expand Down Expand Up @@ -105,19 +105,19 @@ impl<
.unwrap();
}

pub fn set_epoch(&mut self, epoch: Epoch) -> anyhow::Result<()> {
if epoch < self.db.initial_epoch() {
pub async fn set_epoch(&mut self, epoch: UserEpoch) -> Result<()> {
if epoch < self.db.initial_epoch().await {
bail!(
"epoch `{}` is older than initial epoch `{}`",
epoch,
self.db.initial_epoch()
self.db.initial_epoch().await
);
}
if epoch > self.db.current_epoch() {
if epoch > self.db.current_epoch().await? {
bail!(
"epoch `{}` is newer than latest epoch `{}`",
epoch,
self.db.current_epoch()
self.db.current_epoch().await?
);
}

Expand Down Expand Up @@ -147,9 +147,9 @@ impl<

async fn travel(&mut self) -> anyhow::Result<()> {
loop {
let epoch: Epoch = Input::new().with_prompt("target epoch:").interact_text()?;
let epoch: UserEpoch = Input::new().with_prompt("target epoch:").interact_text()?;

self.set_epoch(epoch)?;
self.set_epoch(epoch).await?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion inspect/src/rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::repl::PayloadFormatter;
pub(crate) type RowDb = MerkleTreeKvDb<
RowTree,
RowPayload<BlockPrimaryIndex>,
PgsqlStorage<RowTree, RowPayload<BlockPrimaryIndex>>,
PgsqlStorage<RowTree, RowPayload<BlockPrimaryIndex>, true>,
>;

struct RowPayloadFormatterDisplay {
Expand Down
8 changes: 4 additions & 4 deletions mp2-test/src/cells_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ use plonky2::{
use rand::{thread_rng, Rng};
use ryhope::{
storage::{memory::InMemory, updatetree::UpdateTree, EpochKvStorage, TreeTransactionalStorage},
tree::{sbbst, TreeTopology},
tree::{sbbst::IncrementalTree, TreeTopology},
InitSettings, MerkleTreeKvDb, NodePayload,
};
use serde::{Deserialize, Serialize};
use std::iter;

pub type CellTree = sbbst::Tree;
pub type CellTree = IncrementalTree;
pub type CellTreeKey = <CellTree as TreeTopology>::Key;
type CellStorage = InMemory<CellTree, TestCell>;
type CellStorage = InMemory<CellTree, TestCell, false>;
pub type MerkleCellTree = MerkleTreeKvDb<CellTree, TestCell, CellStorage>;

/// Test node of the cells tree
Expand Down Expand Up @@ -116,7 +116,7 @@ impl NodePayload for TestCell {
pub async fn build_cell_tree(
row: Vec<TestCell>,
) -> Result<(MerkleCellTree, UpdateTree<<CellTree as TreeTopology>::Key>)> {
let mut cell_tree = MerkleCellTree::new(InitSettings::Reset(sbbst::Tree::empty()), ())
let mut cell_tree = MerkleCellTree::new(InitSettings::Reset(IncrementalTree::empty()), ())
.await
.unwrap();
let update_tree = cell_tree
Expand Down
64 changes: 55 additions & 9 deletions mp2-v1/src/indexing/block.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
//! Module to handle the block number as a primary index
use ryhope::tree::{sbbst, TreeTopology};

/// The index tree when the primary index is the block number of a blockchain is a sbbst since it
/// is a highly optimized tree for monotonically increasing index. It produces very little
/// tree-manipulating operations on update, and therefore, requires the least amount of reproving
/// when adding a new index.
/// NOTE: when dealing with another type of index, i.e. a general index such as what can happen on
/// a result table, then this tree does not work anymore.
pub type BlockTree = sbbst::Tree;
use anyhow::anyhow;
use ryhope::{
storage::{pgsql::PgsqlStorage, RoEpochKvStorage},
tree::{sbbst, TreeTopology},
MerkleTreeKvDb,
};

use crate::query::planner::TreeFetcher;

use super::index::IndexNode;

/// The index tree when the primary index is an epoch in a time-series DB, like the block number for a blockchain.
/// It is a sbbst since it is a highly optimized tree for monotonically increasing index.
/// It produces very little tree-manipulating operations on update, and therefore, requires the least amount
/// of reproving when adding a new index.
/// NOTE: it is still required that monotonically increasing indexes are inserted in the tree,
/// i.e. a general index such as what can happen on a result table wouldn't work with this tree.
pub type BlockTree = sbbst::EpochTree;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change comments above which is still very much linked to sequential usecase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 23affb5

/// The key used to refer to a table where the block number is the primary index.
pub type BlockTreeKey = <BlockTree as TreeTopology>::Key;
/// Just an alias that give more meaning depending on the context
pub type BlockPrimaryIndex = BlockTreeKey;

pub type IndexStorage = PgsqlStorage<BlockTree, IndexNode<BlockPrimaryIndex>, false>;
pub type MerkleIndexTree = MerkleTreeKvDb<BlockTree, IndexNode<BlockPrimaryIndex>, IndexStorage>;

/// Get the previous epoch of `epoch` in `tree`
pub async fn get_previous_epoch(
tree: &MerkleIndexTree,
epoch: BlockPrimaryIndex,
) -> anyhow::Result<Option<BlockPrimaryIndex>> {
let current_epoch = tree.current_epoch().await?;
let epoch_ctx = tree
.node_context(&epoch)
.await?
.ok_or(anyhow!("epoch {epoch} not found in the tree"))?;

Ok(tree
.get_predecessor(&epoch_ctx, current_epoch)
.await
.map(|(ctx, _)| ctx.node_id))
}

/// Get the next epoch of `epoch` in `tree`
pub async fn get_next_epoch(
tree: &MerkleIndexTree,
epoch: BlockPrimaryIndex,
) -> anyhow::Result<Option<BlockPrimaryIndex>> {
let current_epoch = tree.current_epoch().await?;
let epoch_ctx = tree
.node_context(&epoch)
.await?
.ok_or(anyhow!("epoch {epoch} not found in the tree"))?;

Ok(tree
.get_successor(&epoch_ctx, current_epoch)
.await
.map(|(ctx, _)| ctx.node_id))
}
6 changes: 3 additions & 3 deletions mp2-v1/src/indexing/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use super::ColumnID;

/// By default the cells tree is a sbbst tree since it is fixed for a given table and this is the
/// simplest/fastest tree.
pub type CellTree = sbbst::Tree;
pub type CellTree = sbbst::IncrementalTree;
/// The key used to refer to a cell in the tree
pub type CellTreeKey = <CellTree as TreeTopology>::Key;
/// The storage of cell tree is "in memory" since it is never really saved on disk. Rather, it is
/// always reconstructed on the fly given it is very small. Moreover, storing it on disk would
/// require as many sql tables as there would be rows, making this solution highly unpracticable.
pub type CellStorage<PrimaryIndex> = InMemory<CellTree, MerkleCell<PrimaryIndex>>;
pub type CellStorage<PrimaryIndex> = InMemory<CellTree, MerkleCell<PrimaryIndex>, false>;
/// The cells tree is a Merkle tree with cryptographically secure hash function committing to its
/// content.
pub type MerkleCellTree<PrimaryIndex> =
Expand All @@ -50,7 +50,7 @@ pub async fn new_tree<
+ Serialize
+ for<'a> Deserialize<'a>,
>() -> MerkleCellTree<PrimaryIndex> {
MerkleCellTree::new(InitSettings::Reset(sbbst::Tree::empty()), ())
MerkleCellTree::new(InitSettings::Reset(sbbst::IncrementalTree::empty()), ())
.await
.unwrap()
}
Expand Down
80 changes: 80 additions & 0 deletions mp2-v1/src/indexing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use anyhow::Result;

use crate::indexing::{index::IndexNode, row::RowPayload};
use alloy::primitives::U256;
use block::MerkleIndexTree;
use mp2_common::types::HashOutput;
use row::MerkleRowTree;
use ryhope::{
storage::pgsql::{SqlServerConnection, SqlStorageSettings},
tree::scapegoat,
InitSettings, UserEpoch,
};

pub mod block;
pub mod cell;
Expand All @@ -9,6 +18,77 @@ pub mod row;

pub type ColumnID = u64;

/// Build `MerkleIndexTree` and `MerkleRowTree` trees from tables
/// `index_table_name` and `row_table_name` in the DB with URL `db_url`.
pub async fn load_trees(
db_url: &str,
index_table_name: String,
row_table_name: String,
) -> Result<(MerkleIndexTree, MerkleRowTree)> {
let index_tree = MerkleIndexTree::new(
InitSettings::MustExist,
SqlStorageSettings {
source: SqlServerConnection::NewConnection(db_url.to_string()),
table: index_table_name.clone(),
external_mapper: None,
},
)
.await?;
let row_tree = MerkleRowTree::new(
InitSettings::MustExist,
SqlStorageSettings {
table: row_table_name,
source: SqlServerConnection::NewConnection(db_url.to_string()),
external_mapper: Some(index_table_name),
},
)
.await?;

Ok((index_tree, row_tree))
}

/// Build `MerkleIndexTree` and `MerkleRowTree` trees starting from
/// `genesis_block`. The tables employed in the DB with URL `db_url`
/// to store the trees are `index_table_name` and `row_table_name`,
/// respectively. The following additional parameters are required:
/// - `alpha`: Parameter of the Scapegoat tree employed for the `MerkleRowTree`
/// - `reset_if_exist`: if true, an existing tree would be deleted
pub async fn build_trees(
db_url: &str,
index_table_name: String,
row_table_name: String,
genesis_block: UserEpoch,
alpha: scapegoat::Alpha,
reset_if_exist: bool,
) -> Result<(MerkleIndexTree, MerkleRowTree)> {
let db_settings_index = SqlStorageSettings {
source: SqlServerConnection::NewConnection(db_url.to_string()),
table: index_table_name.clone(),
external_mapper: None,
};
let db_settings_row = SqlStorageSettings {
source: SqlServerConnection::NewConnection(db_url.to_string()),
table: row_table_name,
external_mapper: Some(index_table_name),
};

let index_tree = ryhope::new_index_tree(
genesis_block as UserEpoch,
db_settings_index,
reset_if_exist,
)
.await?;
let row_tree = ryhope::new_row_tree(
genesis_block as UserEpoch,
alpha,
db_settings_row,
reset_if_exist,
)
.await?;

Ok((index_tree, row_tree))
}

// NOTE this might be good to have on public API ?
// cc/ @andrus
pub trait LagrangeNode {
Expand Down
Loading