Skip to content

Commit

Permalink
Add a lint command and integrate the Sindri Manifest JSON Schema
Browse files Browse the repository at this point in the history
This adds npm scripts to download the Sindri Manifest JSON Schema from the
backend. Currently it's stored at the root of the project. It can be updated by
running:

```bash
yarn download-sindri-manifest-schema
```

This also adds a `sindri lint` command which validates a project's
`sindri.json` file against the schema. It also checks for a `README.md` file
and logs it as a warning if it is not found. We can add more checks in the
future.

Merges #20
  • Loading branch information
sangaline authored Nov 30, 2023
1 parent 82b8ffa commit 4e00f59
Show file tree
Hide file tree
Showing 7 changed files with 522 additions and 5 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ yarn generate-api:dev
yarn denerate-api:docker
```

### Updating Sindri Manifest JSON Schema

The Sindri Manifest JSON Schema is stored in [`sindri-manifest.json`](sindri-manifest.json) and needs to be manually updated and committed when the schema changes.
The file can be updated by running:

```bash
yarn download-sindri-manifest-schema
```

To develop against an unreleased version of the schema, you can use these variants to target a local development server:

```bash
# If you're not using Docker:
yarn download-sindri-manifest-schema:dev

# Or...

# If you are using Docker:
yarn download-sindri-manifest-schema:docker
```

### Linting

To lint the project with Eslint and Prettier:
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"name": "sindri",
"version": "0.0.0",
"description": "The Sindri Labs JavaScript SDK and CLI tool.",
"files": [
"dist/",
"src/"
],
"files": ["dist/", "src/", "sindri-manifest.json"],
"main": "dist/lib/index.js",
"module": "dist/lib/index.mjs",
"bin": {
Expand All @@ -25,6 +22,9 @@
"scripts": {
"build": "NODE_ENV=production tsup --env.NODE_ENV $NODE_ENV",
"build:watch": "NODE_ENV=development tsup --watch --env.NODE_ENV $NODE_ENV",
"download-sindri-manifest-schema": "nwget https://forge.sindri.app/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"download-sindri-manifest-schema:dev": "nwget http://localhost/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"download-sindri-manifest-schema:docker": "nwget http://host.docker.internal/api/v1/sindri-manifest-schema.json -O sindri-manifest.json && prettier --write sindri-manifest.json",
"generate-api": "rm -rf src/lib/api/ && openapi --client axios --input https://forge.sindri.app/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
"generate-api:dev": "rm -rf src/lib/api/ && openapi --client axios --input http://localhost/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
"generate-api:docker": "rm -rf src/lib/api/ && openapi --client axios --input http://host.docker.internal/api/openapi.json --output src/lib/api/ && prettier --write src/lib/api/**/*",
Expand All @@ -48,6 +48,7 @@
"commander": "^11.1.0",
"env-paths": "^2.2.1",
"form-data": "^4.0.0",
"jsonschema": "^1.4.1",
"lodash": "^4.17.21",
"pino": "^8.16.2",
"pino-pretty": "^10.2.3",
Expand All @@ -68,6 +69,7 @@
"prettier": "^3.1.0",
"tsup": "^7.3.0",
"type-fest": "^4.8.2",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"wget-improved": "^3.4.0"
}
}
322 changes: 322 additions & 0 deletions sindri-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
{
"$id": "https://forge.sindri.app/api/v1/sindri-manifest-schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SindriManifest",
"description": "Discriminated union type for `sindri.json` manifest files.\n\nThis is only used for serializing the JSON Schema currently, but it would be nice to use it more\nbroadly once we improve the typing on the union types. We should be able to use\n`SindriManifest.parse_obj()` instead of `get_validate_sindri_manifest()` and other\nsimplifications.",
"anyOf": [
{
"$ref": "#/definitions/CircomSindri"
},
{
"$ref": "#/definitions/GnarkSindri"
},
{
"$ref": "#/definitions/Halo2AxiomV022Sindri"
},
{
"$ref": "#/definitions/Halo2AxiomV030Sindri"
},
{
"$ref": "#/definitions/Halo2ChiquitoSindri"
},
{
"$ref": "#/definitions/NoirSindri"
}
],
"definitions": {
"SindriCircuitTypeOptions": {
"title": "SindriCircuitTypeOptions",
"description": "circuit_type options",
"enum": ["circom", "gnark", "halo2", "noir"],
"type": "string"
},
"CircomCurveOptions": {
"title": "CircomCurveOptions",
"description": "An enumeration.",
"enum": ["bn254"],
"type": "string"
},
"CircomProvingSchemeOptions": {
"title": "CircomProvingSchemeOptions",
"description": "An enumeration.",
"enum": ["groth16"],
"type": "string"
},
"CircomWitnessCompilerOptions": {
"title": "CircomWitnessCompilerOptions",
"description": "An enumeration.",
"enum": ["c++", "wasm"],
"type": "string"
},
"CircomSindri": {
"title": "CircomSindri",
"description": "Circom Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"curve": {
"default": "bn254",
"allOf": [
{
"$ref": "#/definitions/CircomCurveOptions"
}
]
},
"provingScheme": {
"default": "groth16",
"allOf": [
{
"$ref": "#/definitions/CircomProvingSchemeOptions"
}
]
},
"witnessCompiler": {
"default": "c++",
"allOf": [
{
"$ref": "#/definitions/CircomWitnessCompilerOptions"
}
]
}
},
"required": ["circuitType", "name"],
"additionalProperties": false
},
"GnarkCurveOptions": {
"title": "GnarkCurveOptions",
"description": "An enumeration.",
"enum": [
"bls12-377",
"bls12-381",
"bls24-315",
"bn254",
"bw6-633",
"bw6-761"
],
"type": "string"
},
"GnarkVersionOptions": {
"title": "GnarkVersionOptions",
"description": "An enumeration.",
"enum": ["v0.8.1", "v0.9.0"],
"type": "string"
},
"GnarkProvingSchemeOptions": {
"title": "GnarkProvingSchemeOptions",
"description": "An enumeration.",
"enum": ["groth16"],
"type": "string"
},
"GnarkSindri": {
"title": "GnarkSindri",
"description": "Gnark Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"circuitStructName": {
"title": "Circuit Struct Name",
"type": "string"
},
"curve": {
"default": "bn254",
"allOf": [
{
"$ref": "#/definitions/GnarkCurveOptions"
}
]
},
"gnarkVersion": {
"$ref": "#/definitions/GnarkVersionOptions"
},
"packageName": {
"title": "Package Name",
"type": "string"
},
"provingScheme": {
"default": "groth16",
"allOf": [
{
"$ref": "#/definitions/GnarkProvingSchemeOptions"
}
]
}
},
"required": [
"circuitType",
"name",
"circuitStructName",
"gnarkVersion",
"packageName"
],
"additionalProperties": false
},
"Halo2VersionOptions": {
"title": "Halo2VersionOptions",
"description": "An enumeration.",
"enum": ["axiom-v0.2.2", "axiom-v0.3.0", "chiquito"],
"type": "string"
},
"Halo2AxiomV022Sindri": {
"title": "Halo2AxiomV022Sindri",
"description": "Halo2 Axiom V0.2.2 Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"className": {
"title": "Class Name",
"type": "string"
},
"degree": {
"title": "Degree",
"type": "integer"
},
"halo2Version": {
"$ref": "#/definitions/Halo2VersionOptions"
},
"packageName": {
"title": "Package Name",
"type": "string"
}
},
"required": [
"circuitType",
"name",
"className",
"degree",
"halo2Version",
"packageName"
],
"additionalProperties": false
},
"Halo2AxiomV030Sindri": {
"title": "Halo2AxiomV030Sindri",
"description": "Halo2 Axiom V0.3.0 Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"className": {
"title": "Class Name",
"type": "string"
},
"degree": {
"title": "Degree",
"type": "integer"
},
"halo2Version": {
"$ref": "#/definitions/Halo2VersionOptions"
},
"packageName": {
"title": "Package Name",
"type": "string"
},
"threadBuilder": {
"title": "Thread Builder",
"enum": ["GateThreadBuilder", "RlcThreadBuilder"],
"type": "string"
}
},
"required": [
"circuitType",
"name",
"className",
"degree",
"halo2Version",
"packageName",
"threadBuilder"
],
"additionalProperties": false
},
"Halo2ChiquitoSindri": {
"title": "Halo2ChiquitoSindri",
"description": "Halo2 Chiquito Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"className": {
"title": "Class Name",
"type": "string"
},
"degree": {
"title": "Degree",
"type": "integer"
},
"halo2Version": {
"$ref": "#/definitions/Halo2VersionOptions"
},
"packageName": {
"title": "Package Name",
"type": "string"
}
},
"required": [
"circuitType",
"name",
"className",
"degree",
"halo2Version",
"packageName"
],
"additionalProperties": false
},
"NoirProvingSchemeOptions": {
"title": "NoirProvingSchemeOptions",
"description": "An enumeration.",
"enum": ["barretenberg"],
"type": "string"
},
"NoirSindri": {
"title": "NoirSindri",
"description": "Noir Sindri Manifest",
"type": "object",
"properties": {
"circuitType": {
"$ref": "#/definitions/SindriCircuitTypeOptions"
},
"name": {
"title": "Name",
"type": "string"
},
"provingScheme": {
"default": "barretenberg",
"allOf": [
{
"$ref": "#/definitions/NoirProvingSchemeOptions"
}
]
}
},
"required": ["circuitType", "name"],
"additionalProperties": false
}
}
}
Loading

0 comments on commit 4e00f59

Please sign in to comment.