Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(prover): update APIs && integrate swagger docs #386

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .swaggo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replace common.Address string
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8028a49ea2dfc123b1c818afb722a029d3743e5c
098a350bac5d2f01f39c975d4c6f4d93efed943a
892 changes: 885 additions & 7 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion cmd/flags/prover.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package flags

import (
"time"

"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -115,6 +117,12 @@ var (
Usage: "Capacity of prover, required if oracleProver is false",
Category: proverCategory,
}
MaxExpiry = &cli.Uint64Flag{
Name: "prover.maxExpiry",
Usage: "maximum accepted expiry in seconds for accepting proving a block",
Value: uint64(time.Hour.Seconds()),
Category: proverCategory,
}
)

// All prover flags.
Expand All @@ -125,6 +133,7 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
ZkEvmRpcdEndpoint,
ZkEvmRpcdParamsPath,
L1ProverPrivKey,
MinProofFee,
StartingBlockID,
MaxConcurrentProvingJobs,
Dummy,
Expand All @@ -139,5 +148,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
ProveBlockTxGasLimit,
ProverHTTPServerPort,
ProverCapacity,
MinProofFee,
MaxExpiry,
})
122 changes: 122 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "https://community.taiko.xyz/",
"email": "info@taiko.xyz"
},
"license": {
"name": "MIT",
"url": "hhttps://github.com/taikoxyz/taiko-client/blob/main/LICENSE.md"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/assignment": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Try to accept a block proof assignment",
"operationId": "create-assignment",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.ProposeBlockResponse"
}
},
"422": {
"description": "prover does not have capacity",
"schema": {
"type": "string"
}
}
}
}
},
"/status": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get current prover server status",
"operationId": "get-status",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.Status"
}
}
}
}
}
},
"definitions": {
"server.ProposeBlockResponse": {
"type": "object",
"properties": {
"prover": {
"type": "string"
},
"signedPayload": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"server.Status": {
"type": "object",
"properties": {
"currentCapacity": {
"type": "integer"
},
"maxExpiry": {
"type": "integer"
},
"minProofFee": {
"type": "integer"
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "prover-api.test.taiko.xyz",
BasePath: "",
Schemes: []string{},
Title: "Taiko Prover API",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
96 changes: 96 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"swagger": "2.0",
"info": {
"title": "Taiko Prover API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "https://community.taiko.xyz/",
"email": "info@taiko.xyz"
},
"license": {
"name": "MIT",
"url": "hhttps://github.com/taikoxyz/taiko-client/blob/main/LICENSE.md"
},
"version": "1.0"
},
"host": "prover-api.test.taiko.xyz",
"paths": {
"/assignment": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Try to accept a block proof assignment",
"operationId": "create-assignment",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.ProposeBlockResponse"
}
},
"422": {
"description": "prover does not have capacity",
"schema": {
"type": "string"
}
}
}
}
},
"/status": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get current prover server status",
"operationId": "get-status",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.Status"
}
}
}
}
}
},
"definitions": {
"server.ProposeBlockResponse": {
"type": "object",
"properties": {
"prover": {
"type": "string"
},
"signedPayload": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"server.Status": {
"type": "object",
"properties": {
"currentCapacity": {
"type": "integer"
},
"maxExpiry": {
"type": "integer"
},
"minProofFee": {
"type": "integer"
}
}
}
}
}
63 changes: 63 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
definitions:
server.ProposeBlockResponse:
properties:
prover:
type: string
signedPayload:
items:
type: integer
type: array
type: object
server.Status:
properties:
currentCapacity:
type: integer
maxExpiry:
type: integer
minProofFee:
type: integer
type: object
host: prover-api.test.taiko.xyz
info:
contact:
email: info@taiko.xyz
name: API Support
url: https://community.taiko.xyz/
license:
name: MIT
url: hhttps://github.com/taikoxyz/taiko-client/blob/main/LICENSE.md
termsOfService: http://swagger.io/terms/
title: Taiko Prover API
version: "1.0"
paths:
/assignment:
post:
consumes:
- application/json
operationId: create-assignment
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/server.ProposeBlockResponse'
"422":
description: prover does not have capacity
schema:
type: string
summary: Try to accept a block proof assignment
/status:
get:
consumes:
- application/json
operationId: get-status
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/server.Status'
summary: Get current prover server status
swagger: "2.0"
21 changes: 15 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ require (
github.com/ethereum/go-ethereum v1.12.2
github.com/go-resty/resty/v2 v2.7.0
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/prysmaticlabs/prysm/v4 v4.0.1
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
github.com/swaggo/swag v1.16.2
github.com/urfave/cli/v2 v2.24.1
golang.org/x/sync v0.3.0
)

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -41,6 +42,10 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
Expand All @@ -58,11 +63,14 @@ require (
github.com/holiman/uint256 v1.2.3 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
Expand Down Expand Up @@ -96,12 +104,13 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
Expand Down
Loading