From a3721d08567106559addc281bb485e4c5f73353a Mon Sep 17 00:00:00 2001 From: RogerLamTd Date: Wed, 18 Oct 2023 23:17:20 -0700 Subject: [PATCH 1/3] add body to req --- docs/docs.go | 48 ++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 48 ++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 31 ++++++++++++++++++++++++++++ prover/server/api.go | 25 ++++++++++++----------- 4 files changed, 140 insertions(+), 12 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 4278f7146..cd322bd2f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -34,6 +34,17 @@ const docTemplate = `{ ], "summary": "Try to accept a block proof assignment", "operationId": "create-assignment", + "parameters": [ + { + "description": "assignment request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/prover_server.CreateAssignmentRequestBody" + } + } + ], "responses": { "200": { "description": "OK", @@ -72,6 +83,43 @@ const docTemplate = `{ } }, "definitions": { + "big.Int": { + "type": "object" + }, + "github_com_taikoxyz_taiko-client_bindings_encoding.TierFee": { + "type": "object", + "properties": { + "fee": { + "$ref": "#/definitions/big.Int" + }, + "tier": { + "type": "integer" + } + } + }, + "prover_server.CreateAssignmentRequestBody": { + "type": "object", + "properties": { + "expiry": { + "type": "integer" + }, + "feeToken": { + "type": "string" + }, + "tierFees": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee" + } + }, + "txListHash": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "prover_server.ProposeBlockResponse": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 762125c07..e0db39db9 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -25,6 +25,17 @@ ], "summary": "Try to accept a block proof assignment", "operationId": "create-assignment", + "parameters": [ + { + "description": "assignment request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/prover_server.CreateAssignmentRequestBody" + } + } + ], "responses": { "200": { "description": "OK", @@ -63,6 +74,43 @@ } }, "definitions": { + "big.Int": { + "type": "object" + }, + "github_com_taikoxyz_taiko-client_bindings_encoding.TierFee": { + "type": "object", + "properties": { + "fee": { + "$ref": "#/definitions/big.Int" + }, + "tier": { + "type": "integer" + } + } + }, + "prover_server.CreateAssignmentRequestBody": { + "type": "object", + "properties": { + "expiry": { + "type": "integer" + }, + "feeToken": { + "type": "string" + }, + "tierFees": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee" + } + }, + "txListHash": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "prover_server.ProposeBlockResponse": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 3664a3f93..348f3bf08 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,28 @@ definitions: + big.Int: + type: object + github_com_taikoxyz_taiko-client_bindings_encoding.TierFee: + properties: + fee: + $ref: '#/definitions/big.Int' + tier: + type: integer + type: object + prover_server.CreateAssignmentRequestBody: + properties: + expiry: + type: integer + feeToken: + type: string + tierFees: + items: + $ref: '#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee' + type: array + txListHash: + items: + type: integer + type: array + type: object prover_server.ProposeBlockResponse: properties: prover: @@ -38,6 +62,13 @@ paths: consumes: - application/json operationId: create-assignment + parameters: + - description: assignment request body + in: body + name: body + required: true + schema: + $ref: '#/definitions/prover_server.CreateAssignmentRequestBody' produces: - application/json responses: diff --git a/prover/server/api.go b/prover/server/api.go index 48243238f..321e379d5 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -70,18 +70,19 @@ type ProposeBlockResponse struct { // handle this block, and if so, returns a signed payload the proposer // can submit onchain. // -// @Summary Try to accept a block proof assignment -// @ID create-assignment -// @Accept json -// @Produce json -// @Success 200 {object} ProposeBlockResponse -// @Failure 422 {string} string "invalid txList hash" -// @Failure 422 {string} string "only receive ETH" -// @Failure 422 {string} string "insufficient prover balance" -// @Failure 422 {string} string "proof fee too low" -// @Failure 422 {string} string "expiry too long" -// @Failure 422 {string} string "prover does not have capacity" -// @Router /assignment [post] +// @Summary Try to accept a block proof assignment +// @ID create-assignment +// @Param body body CreateAssignmentRequestBody true "assignment request body" +// @Accept json +// @Produce json +// @Success 200 {object} ProposeBlockResponse +// @Failure 422 {string} string "invalid txList hash" +// @Failure 422 {string} string "only receive ETH" +// @Failure 422 {string} string "insufficient prover balance" +// @Failure 422 {string} string "proof fee too low" +// @Failure 422 {string} string "expiry too long" +// @Failure 422 {string} string "prover does not have capacity" +// @Router /assignment [post] func (srv *ProverServer) CreateAssignment(c echo.Context) error { req := new(CreateAssignmentRequestBody) if err := c.Bind(req); err != nil { From f82f495bc4be5d4256fe60d63bfbecf46b4d8b87 Mon Sep 17 00:00:00 2001 From: Roger <50648015+RogerLamTd@users.noreply.github.com> Date: Thu, 19 Oct 2023 01:20:48 -0700 Subject: [PATCH 2/3] Update prover/server/api.go --- prover/server/api.go | 1 - 1 file changed, 1 deletion(-) diff --git a/prover/server/api.go b/prover/server/api.go index 321e379d5..04bf068fd 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -71,7 +71,6 @@ type ProposeBlockResponse struct { // can submit onchain. // // @Summary Try to accept a block proof assignment -// @ID create-assignment // @Param body body CreateAssignmentRequestBody true "assignment request body" // @Accept json // @Produce json From 4925e8ccb8c85ed15b5acb5101eaeb74fb95bd6b Mon Sep 17 00:00:00 2001 From: RogerLamTd Date: Thu, 19 Oct 2023 01:22:31 -0700 Subject: [PATCH 3/3] align --- prover/server/api.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/prover/server/api.go b/prover/server/api.go index 04bf068fd..aaacd72fb 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -70,18 +70,18 @@ type ProposeBlockResponse struct { // handle this block, and if so, returns a signed payload the proposer // can submit onchain. // -// @Summary Try to accept a block proof assignment -// @Param body body CreateAssignmentRequestBody true "assignment request body" -// @Accept json -// @Produce json -// @Success 200 {object} ProposeBlockResponse -// @Failure 422 {string} string "invalid txList hash" -// @Failure 422 {string} string "only receive ETH" -// @Failure 422 {string} string "insufficient prover balance" -// @Failure 422 {string} string "proof fee too low" -// @Failure 422 {string} string "expiry too long" -// @Failure 422 {string} string "prover does not have capacity" -// @Router /assignment [post] +// @Summary Try to accept a block proof assignment +// @Param body body CreateAssignmentRequestBody true "assignment request body" +// @Accept json +// @Produce json +// @Success 200 {object} ProposeBlockResponse +// @Failure 422 {string} string "invalid txList hash" +// @Failure 422 {string} string "only receive ETH" +// @Failure 422 {string} string "insufficient prover balance" +// @Failure 422 {string} string "proof fee too low" +// @Failure 422 {string} string "expiry too long" +// @Failure 422 {string} string "prover does not have capacity" +// @Router /assignment [post] func (srv *ProverServer) CreateAssignment(c echo.Context) error { req := new(CreateAssignmentRequestBody) if err := c.Bind(req); err != nil {