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

Introduce project manifest version 0.2.0 #495

Merged
merged 19 commits into from
Oct 4, 2021
Merged

Conversation

stwiname
Copy link
Collaborator

@stwiname stwiname commented Sep 24, 2021

Addresses #463

Overview of changes:

  • Define new project manifest schema
  • Update validator for new schema, validate chain types
  • Update CLI for new schema
    • Update init to create a v0.0.2 project
    • Update validate to validate all supported versions
  • Update Node for new schema
    • Rely on genesis hash for network identification
    • Add --network-registry flag to provide mapping from genesis hash to endpoint
    • Support new chain types in external file
    • Support new entry point for indexer sandbox

Todo:

  • Merge Update manifest to v0.0.2 subql-starter#30 and update init command once merged Not merging so CLI releases before these changes are not broken
  • Setup and write tests for IndexerManager
  • Expand upon default values for --network-registry flag
  • Update docs (might be out of scope)

project.endpoint = await cli.prompt('RPC endpoint', {
default: 'wss://polkadot.api.onfinality.io/public-ws',
project.network = await cli.prompt('Netork genesis hash', {
default: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might be worth adding more human readable options here. Like a list of network names and the ability to add a custom genesis

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can ask user for an endpoint and retrieve genesishash from that endpoint and ask confirm.

@ianhe8x
Copy link
Collaborator

ianhe8x commented Sep 27, 2021

Probably need to reconsider the version, for this scale of change, i think we can use 0.2.0

specVersion: string;
description: string;
repository: string;
dataSources: SubqlDataSource[];
schema: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can still have schema in IProjectManifest

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have removed it here because the type has changed from string to { file: string; }. Each of the versioned interfaces include the specific type.

I'm happy to add it back in as a union type or ensure that its mapped to { file: string; }

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can even make the type of schema GraphQLDocument or something alike.

packages/node/src/indexer/api.service.ts Outdated Show resolved Hide resolved
packages/node/src/indexer/indexer.manager.ts Outdated Show resolved Hide resolved
@ianhe8x ianhe8x requested a review from zhex September 27, 2021 10:16
@ianhe8x
Copy link
Collaborator

ianhe8x commented Sep 27, 2021

@seandotau @zhex This is a quite large change for the project manifest. Your inputs are so important and welcomed.

@@ -42,6 +46,14 @@ const DEFAULT_CONFIG = {
indexCountLimit: 10,
timestampField: true,
proofOfIndex: false,
networkRegistry: {
/* TODO provide a default list */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is probably the largest change on the hosted service side. If the project is using the new manifest spec then it only provides a genesis hash, so there needs to be a mapping to the endpoints.

@ianhe8x
Copy link
Collaborator

ianhe8x commented Sep 29, 2021

If there are still uncertainty in networkRegistry, we can leave it in the future PR. Currently we allow user provides overrides for endpoint, which should be enough.

@stwiname
Copy link
Collaborator Author

If there are still uncertainty in networkRegistry, we can leave it in the future PR. Currently we allow user provides overrides for endpoint, which should be enough.

I've removed the networkRegistry flag. networkEndpoint is required for v0.2.0 projects now and will throw an error if its not provided

@@ -35,6 +35,10 @@ Options:
--timestamp-field Enable/disable created_at and updated_at in schema
[boolean] [default: true]
-d, --network-dictionary Specify the dictionary api for this network [string]
--proof-of-index Enable/disable proof of index
[boolean] [default: false]
--network-registry JSON object mapping genesisHash of each network to
Copy link
Collaborator

Choose a reason for hiding this comment

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

update here since it has been removed


if (flags.specVersion === '0.2.0') {
(project as ProjectSpecV0_2_0).genesisHash = await cli.prompt('Network genesis hash', {
default: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3', // Polkadot
Copy link
Collaborator

Choose a reason for hiding this comment

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

for v0.2.0 we can still ask user for the endpoint first. with the endpoint we can

  1. retrieve genesis hash and ask user to confirm it or they input another one
  2. store endpoint in runtime config (is it included in v0.2.0?)

@ianhe8x
Copy link
Collaborator

ianhe8x commented Sep 29, 2021

If there are still uncertainty in networkRegistry, we can leave it in the future PR. Currently we allow user provides overrides for endpoint, which should be enough.

I've removed the networkRegistry flag. networkEndpoint is required for v0.2.0 projects now and will throw an error if its not provided

Sorry I change the idea and forget to update the issue. it says runtimeConfig.yaml only provided via cli flags. But after second though I think we can have it in the project.yaml (or have its reference), and remove it when we convert project.yaml to deployment..

We can have this change in a separate PR.

- Define new project manifest schema
- Update validator for new schema, validate chain types
- Update CLI for new schema
  - Update `init` to create a v0.0.2 project
  - Update validate to validate all supported versions
- Update Node for new schema
  - Rely on genesis hash for network identification
  - Add `--network-registry` flag to provide mapping from genesis hash to endpoint
  - Support new chain types in external file
  - Support new entry point for indexer sandbox
@stwiname
Copy link
Collaborator Author

stwiname commented Oct 3, 2021

I can't seem to figure out why these tests cause other tests to fail https://github.com/subquery/subql/pull/495/files#diff-07519fb2dbc5155256ed036d08aece637848c043d153094ca7dab73099e6f34dR168-R180

My only thought could be because of something due to the sandbox vm or the process being overworked trying to index even though the fetch service gets stopped.

@ianhe8x any ideas on this? At this stage I'm happy just to disable these tests

@ianhe8x ianhe8x merged commit d74daad into main Oct 4, 2021
@ianhe8x ianhe8x deleted the project-manifest-0.0.2 branch October 4, 2021 03:35
@ianhe8x ianhe8x changed the title Introduce project manifest version 0.0.2 Introduce project manifest version 0.2.0 Oct 22, 2021
bz888 pushed a commit that referenced this pull request Jun 3, 2022
* Introduce project manifest version 0.0.2

- Define new project manifest schema
- Update validator for new schema, validate chain types
- Update CLI for new schema
  - Update `init` to create a v0.0.2 project
  - Update validate to validate all supported versions
- Update Node for new schema
  - Rely on genesis hash for network identification
  - Add `--network-registry` flag to provide mapping from genesis hash to endpoint
  - Support new chain types in external file
  - Support new entry point for indexer sandbox

* Fix up tests

* Fix up prettier

* Fix lint issue

* Enable noImplicitAny ts setting for cli, common and validator

* Update new manifest version from 0.0.2 to 0.2.0, address other minor comments

* Add tests for index manager, reuse sandbox VM for same entry point

* Revert CLI init changes

* Update docs

* Update init command to allow specifying spec version

* Remove networkDictionary option and require networkEndpoint to be provided for v0.2.0 projects

* Remove logging

* Add validator tests to jest scrope, fix valitation when project.yaml is missing

* Fix failing test

* Allow specifying an optional endpoint in network config, update CLI to resolve genesis hash from url

* Fix commit hook issue with prettier and partially staged files

* Fix tests failing

* Disable breaking tests

* Remove name from datasource in v0.2.0 manifest spec
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.

2 participants