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

Implement Batch Query Commitements RFC #816

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

sergiimk
Copy link
Member

@sergiimk sergiimk commented Sep 7, 2024

Description

Closes: kamu-data/kamu-node#125
Closes: kamu-data/kamu-node#126

Implements response signing and a new commitment scheme according to the RFC.

Note that the old response format is preserved for compatibility via V1 / V2 enum trick. If user request in the new format (e.g. by including ?include=proof) only then they will get a response in the new format. This will allow us to transition to the new format progressively, without breaking the oracles for example.

Also introduces a new {dataset}/metadata endpoint that allows getting dataset schema, license, info etc.

Checklist before requesting a review

  • Unit and integration tests added
  • Compatibility:
    • Network APIs: ✅
      Extra steps taken to preserve the compatibility
    • Workspace layout and metadata: ✅
      New config options added, but they have defaults
    • Configuration: ✅
    • Container images: ✅
  • Documentation:
  • Downstream effects:
    • kamu-node: ❌
      DI update is needed and new configuration needs to be exposed - will be preparing a PR

@@ -24,54 +25,59 @@ use url::Url;
#[derive(Debug, Clone, Merge, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct CLIConfig {
/// Database connection configuration
pub database: Option<DatabaseConfig>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the diff - sorted fields alphabetically

@@ -276,6 +285,208 @@ async fn test_data_query_handler_full() {

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#[test_group::group(engine, datafusion)]
#[test_log::test(tokio::test)]
async fn test_data_query_handler_v2() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test explains it all

Comment on lines +164 to +171
let mut visitors: [&mut dyn MetadataChainVisitor<Error = vis::Infallible>; 6] = [
&mut attachments_visitor,
&mut info_visitor,
&mut license_visitor,
&mut schema_visitor,
&mut seed_visitor,
&mut vocab_visitor,
];
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI @s373r I'm super happy about this trick:

  • Notice that all response elements are optional - so if user did not request seed or schema we ideally don't want to search for this event
  • So I made all visitors above optional
  • I then implemented MetadataChainVisitor for Option<T> where T: MetadataChainVisitor
  • If the Option is None - the visitor will immediately Stop
  • If Some - it delegates the calls to inner visitor

This is about as concise as it gets :)

Copy link
Member

Choose a reason for hiding this comment

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

@sergiimk , 💯

Awesome idea with the optional visitors -- looking at the changes in the other PR noticed this, very cool!

@sergiimk sergiimk force-pushed the feature/batch-query-commitments branch from c2ebb5e to c324c3e Compare September 8, 2024 00:51
@sergiimk sergiimk force-pushed the feature/batch-query-commitments branch from 50a28aa to 427e73e Compare September 8, 2024 23:19
@sergiimk sergiimk merged commit 427e73e into master Sep 9, 2024
6 checks passed
@sergiimk sergiimk deleted the feature/batch-query-commitments branch September 9, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REST API: Add /metadata endpoint REST API: Batch query commitments
2 participants