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

[Feature]: New SPEC language to make It less verbose. Increase readability and maintainability #1555

Open
RuslanGlaznyov opened this issue Jul 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@RuslanGlaznyov
Copy link
Contributor

RuslanGlaznyov commented Jul 9, 2024

Summary

We have verbose API descriptions in the SPEC, which are challenging to write and review.

For example, in lava spec, this setting repeats for all endpoints:

 {
  "name": "/lavanet/lava/conflict/conflict_vote/{index}",
  "block_parsing": {
    "parser_arg": [
      "latest"
    ],
    "parser_func": "DEFAULT"
  },
  "compute_units": 10,
  "enabled": true,
  "category": {
    "deterministic": true,
    "local": false,
    "subscription": false,
    "stateful": 0
  },
  "extra_compute_units": 0
}

https://github.com/lavanet/lava/blob/main/cookbook/specs/lava.json#L36

The same thing for verifications and extensions
https://github.com/lavanet/lava/blob/main/cookbook/specs/lava.json#L1247
https://github.com/lavanet/lava/blob/main/cookbook/specs/lava.json#L2463
https://github.com/lavanet/lava/blob/main/cookbook/specs/lava.json#L2507

Problem Definition

Now spec is verbose and we have a lot of repeats for endpoints

Proposed Feature

The idea is to create a new spec lang on top of the current lang, the same way as TS for JS, but for spec.

Here is an example of a new spec language

api_collections: 
  - enabled: true
    collection_data: 
     api_interface: "rest"
     type: "GET"
    # default settings for each endpoint  
    api_default: 
     block_parsing: 
      parser_arg: ["latest"]
      purser_func: "DEFAULT"
      computute_unit: 10
      enabled: true
      category: 
       deterministic: true
       local: false
       subscription: false
       stateful: false
      extra_compute_units: 0 
    apis:
    # here is an example of endpoints with default params 
     - name: [
         '/example/example/v1beta1/params',
         '/example/example/v1beta1/params',
         '/example/example/v1beta1/params',
       ]
     # here is the example of the batch of endpoints with overridden params   
     - name: [
         "/example/example/v1beta1/params",
         "/example/example/v1beta1/params",
         "/example/example/v1beta1/params",
         ]
       cotegory: 
        deterministic: true
    # override single endpoint settings 
     - name: '/example/example/v1beta1/params'
       extra_compute_units: 5

This YAML example will be transpile to regular JSON spec.
The compiler will convert bidirectional
json -> yaml
yaml -> json

This approach will increase the readability of spec and maintainability. We don't need to modify existing spec logic on-chain, because translation will be done off-chain.

@RuslanGlaznyov RuslanGlaznyov changed the title [Feature]: New SPEC lanuage to make it less verbose [Feature]: New SPEC Language to Make It Less verbose. Increase readability and maintainability Jul 9, 2024
@RuslanGlaznyov RuslanGlaznyov changed the title [Feature]: New SPEC Language to Make It Less verbose. Increase readability and maintainability [Feature]: New SPEC language to make It less verbose. Increase readability and maintainability Jul 9, 2024
@omerlavanet omerlavanet added the enhancement New feature or request label Jul 9, 2024
@omerlavanet
Copy link
Collaborator

thanks @RuslanGlaznyov i love this initiative, improving spec stack allows more champions and easier onboarding which is one of our goals
will definitely revisit this post launch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@RuslanGlaznyov @omerlavanet and others