diff --git a/packages/taiko-client/.swaggo b/packages/taiko-client/.swaggo index 8cc34d878a..e69de29bb2 100644 --- a/packages/taiko-client/.swaggo +++ b/packages/taiko-client/.swaggo @@ -1,2 +0,0 @@ -replace common.Address string -replace encoding.TierFee uint64 \ No newline at end of file diff --git a/packages/taiko-client/docs/docs.go b/packages/taiko-client/docs/docs.go new file mode 100644 index 0000000000..2b8c139d16 --- /dev/null +++ b/packages/taiko-client/docs/docs.go @@ -0,0 +1,353 @@ +// 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": "https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/healthz": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get current server health status", + "operationId": "health-check", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, + "/tentativeBlocks": { + "post": { + "description": "Insert a group of transactions into a tentative block for preconfirmation. If the group is the\nfirst for a block, a new tentative block will be created. Otherwise, the transactions will\nbe appended to the existing tentative block. The API will fail if:\n1) the block is not tentative, 2) any transaction in the group is invalid or a duplicate, 3)\nblock-level parameters are invalid or do not match the current tentative block’s parameters,\n4) the group ID is not exactly 1 greater than the previous one, or 5) the last group of\nthe block indicates no further transactions are allowed.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "description": "preconf blocks creation request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/preconfserver.BuildTentativeBlocksRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/preconfserver.BuildTentativeBlocksResponseBody" + } + } + } + }, + "delete": { + "description": "Remove all tentative blocks from the blockchain beyond the specified block height,\nensuring the latest block ID does not exceed the given height. This method will fail if\nthe block with an ID one greater than the specified height is not a tentative block. If the\nspecified block height is greater than the latest tentative block ID, the method will succeed\nwithout modifying the blockchain.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "description": "preconf blocks creation request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/preconfserver.RemoveTentativeBlocksRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/preconfserver.RemoveTentativeBlocksResponseBody" + } + } + } + } + } + }, + "definitions": { + "big.Int": { + "type": "object" + }, + "preconfserver.BuildTentativeBlocksRequestBody": { + "type": "object", + "properties": { + "transactionsGroups": { + "type": "array", + "items": { + "$ref": "#/definitions/preconfserver.PreconfTransactionsGroup" + } + } + } + }, + "preconfserver.BuildTentativeBlocksResponseBody": { + "type": "object", + "properties": { + "tentativeHeaders": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Header" + } + } + } + }, + "preconfserver.PreconfTransactionsGroup": { + "type": "object", + "properties": { + "anchorBlockID": { + "description": "AnchorV2 parameters", + "type": "integer" + }, + "anchorStateRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "baseFeePerGas": { + "type": "integer" + }, + "blockId": { + "type": "integer" + }, + "groupId": { + "type": "integer" + }, + "groupStatus": { + "$ref": "#/definitions/preconfserver.PreconfTxsGroupStatus" + }, + "parentGasUsed": { + "type": "integer" + }, + "prevRandao": { + "type": "array", + "items": { + "type": "integer" + } + }, + "signature": { + "type": "string" + }, + "suggestedFeeRecipient": { + "type": "array", + "items": { + "type": "integer" + } + }, + "timestamp": { + "description": "Block parameters", + "type": "integer" + }, + "transactions": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Transaction" + } + } + } + }, + "preconfserver.PreconfTxsGroupStatus": { + "type": "string", + "enum": [ + "finalBlockGroup", + "finalPreconfGroup" + ], + "x-enum-varnames": [ + "StatusFinalBlockGroup", + "StatusFinalPreconfGroup" + ] + }, + "preconfserver.RemoveTentativeBlocksRequestBody": { + "type": "object", + "properties": { + "newHead": { + "type": "integer" + } + } + }, + "preconfserver.RemoveTentativeBlocksResponseBody": { + "type": "object", + "properties": { + "currentHead": { + "$ref": "#/definitions/types.Header" + } + } + }, + "types.Header": { + "type": "object", + "properties": { + "baseFeePerGas": { + "description": "BaseFee was added by EIP-1559 and is ignored in legacy headers.", + "allOf": [ + { + "$ref": "#/definitions/big.Int" + } + ] + }, + "blobGasUsed": { + "description": "BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.", + "type": "integer" + }, + "difficulty": { + "$ref": "#/definitions/big.Int" + }, + "excessBlobGas": { + "description": "ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.", + "type": "integer" + }, + "extraData": { + "type": "array", + "items": { + "type": "integer" + } + }, + "gasLimit": { + "type": "integer" + }, + "gasUsed": { + "type": "integer" + }, + "logsBloom": { + "type": "array", + "items": { + "type": "integer" + } + }, + "miner": { + "type": "array", + "items": { + "type": "integer" + } + }, + "mixHash": { + "type": "array", + "items": { + "type": "integer" + } + }, + "nonce": { + "type": "array", + "items": { + "type": "integer" + } + }, + "number": { + "$ref": "#/definitions/big.Int" + }, + "parentBeaconBlockRoot": { + "description": "ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + }, + "parentHash": { + "type": "array", + "items": { + "type": "integer" + } + }, + "receiptsRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "requestsRoot": { + "description": "RequestsHash was added by EIP-7685 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + }, + "sha3Uncles": { + "type": "array", + "items": { + "type": "integer" + } + }, + "stateRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "timestamp": { + "type": "integer" + }, + "transactionsRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "withdrawalsRoot": { + "description": "WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "types.Transaction": { + "type": "object" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "Taiko Preconfirmation Server API", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/packages/taiko-client/docs/swagger.json b/packages/taiko-client/docs/swagger.json new file mode 100644 index 0000000000..61c81a0fc0 --- /dev/null +++ b/packages/taiko-client/docs/swagger.json @@ -0,0 +1,308 @@ +{ + "swagger": "2.0", + "info": { + "title": "Taiko Preconfirmation Server API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "https://community.taiko.xyz/", + "email": "info@taiko.xyz" + }, + "license": { + "name": "MIT", + "url": "https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md" + }, + "version": "1.0" + }, + "paths": { + "/healthz": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get current server health status", + "operationId": "health-check", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, + "/tentativeBlocks": { + "post": { + "description": "Insert a group of transactions into a tentative block for preconfirmation. If the group is the\nfirst for a block, a new tentative block will be created. Otherwise, the transactions will\nbe appended to the existing tentative block. The API will fail if:\n1) the block is not tentative, 2) any transaction in the group is invalid or a duplicate, 3)\nblock-level parameters are invalid or do not match the current tentative block’s parameters,\n4) the group ID is not exactly 1 greater than the previous one, or 5) the last group of\nthe block indicates no further transactions are allowed.", + "consumes": ["application/json"], + "produces": ["application/json"], + "parameters": [ + { + "description": "preconf blocks creation request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/preconfserver.BuildTentativeBlocksRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/preconfserver.BuildTentativeBlocksResponseBody" + } + } + } + }, + "delete": { + "description": "Remove all tentative blocks from the blockchain beyond the specified block height,\nensuring the latest block ID does not exceed the given height. This method will fail if\nthe block with an ID one greater than the specified height is not a tentative block. If the\nspecified block height is greater than the latest tentative block ID, the method will succeed\nwithout modifying the blockchain.", + "consumes": ["application/json"], + "produces": ["application/json"], + "parameters": [ + { + "description": "preconf blocks creation request body", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/preconfserver.RemoveTentativeBlocksRequestBody" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/preconfserver.RemoveTentativeBlocksResponseBody" + } + } + } + } + } + }, + "definitions": { + "big.Int": { + "type": "object" + }, + "preconfserver.BuildTentativeBlocksRequestBody": { + "type": "object", + "properties": { + "transactionsGroups": { + "type": "array", + "items": { + "$ref": "#/definitions/preconfserver.PreconfTransactionsGroup" + } + } + } + }, + "preconfserver.BuildTentativeBlocksResponseBody": { + "type": "object", + "properties": { + "tentativeHeaders": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Header" + } + } + } + }, + "preconfserver.PreconfTransactionsGroup": { + "type": "object", + "properties": { + "anchorBlockID": { + "description": "AnchorV2 parameters", + "type": "integer" + }, + "anchorStateRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "baseFeePerGas": { + "type": "integer" + }, + "blockId": { + "type": "integer" + }, + "groupId": { + "type": "integer" + }, + "groupStatus": { + "$ref": "#/definitions/preconfserver.PreconfTxsGroupStatus" + }, + "parentGasUsed": { + "type": "integer" + }, + "prevRandao": { + "type": "array", + "items": { + "type": "integer" + } + }, + "signature": { + "type": "string" + }, + "suggestedFeeRecipient": { + "type": "array", + "items": { + "type": "integer" + } + }, + "timestamp": { + "description": "Block parameters", + "type": "integer" + }, + "transactions": { + "type": "array", + "items": { + "$ref": "#/definitions/types.Transaction" + } + } + } + }, + "preconfserver.PreconfTxsGroupStatus": { + "type": "string", + "enum": ["finalBlockGroup", "finalPreconfGroup"], + "x-enum-varnames": ["StatusFinalBlockGroup", "StatusFinalPreconfGroup"] + }, + "preconfserver.RemoveTentativeBlocksRequestBody": { + "type": "object", + "properties": { + "newHead": { + "type": "integer" + } + } + }, + "preconfserver.RemoveTentativeBlocksResponseBody": { + "type": "object", + "properties": { + "currentHead": { + "$ref": "#/definitions/types.Header" + } + } + }, + "types.Header": { + "type": "object", + "properties": { + "baseFeePerGas": { + "description": "BaseFee was added by EIP-1559 and is ignored in legacy headers.", + "allOf": [ + { + "$ref": "#/definitions/big.Int" + } + ] + }, + "blobGasUsed": { + "description": "BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.", + "type": "integer" + }, + "difficulty": { + "$ref": "#/definitions/big.Int" + }, + "excessBlobGas": { + "description": "ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.", + "type": "integer" + }, + "extraData": { + "type": "array", + "items": { + "type": "integer" + } + }, + "gasLimit": { + "type": "integer" + }, + "gasUsed": { + "type": "integer" + }, + "logsBloom": { + "type": "array", + "items": { + "type": "integer" + } + }, + "miner": { + "type": "array", + "items": { + "type": "integer" + } + }, + "mixHash": { + "type": "array", + "items": { + "type": "integer" + } + }, + "nonce": { + "type": "array", + "items": { + "type": "integer" + } + }, + "number": { + "$ref": "#/definitions/big.Int" + }, + "parentBeaconBlockRoot": { + "description": "ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + }, + "parentHash": { + "type": "array", + "items": { + "type": "integer" + } + }, + "receiptsRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "requestsRoot": { + "description": "RequestsHash was added by EIP-7685 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + }, + "sha3Uncles": { + "type": "array", + "items": { + "type": "integer" + } + }, + "stateRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "timestamp": { + "type": "integer" + }, + "transactionsRoot": { + "type": "array", + "items": { + "type": "integer" + } + }, + "withdrawalsRoot": { + "description": "WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "types.Transaction": { + "type": "object" + } + } +} diff --git a/packages/taiko-client/docs/swagger.yaml b/packages/taiko-client/docs/swagger.yaml new file mode 100644 index 0000000000..fe3da6b5fd --- /dev/null +++ b/packages/taiko-client/docs/swagger.yaml @@ -0,0 +1,233 @@ +definitions: + big.Int: + type: object + preconfserver.BuildTentativeBlocksRequestBody: + properties: + transactionsGroups: + items: + $ref: "#/definitions/preconfserver.PreconfTransactionsGroup" + type: array + type: object + preconfserver.BuildTentativeBlocksResponseBody: + properties: + tentativeHeaders: + items: + $ref: "#/definitions/types.Header" + type: array + type: object + preconfserver.PreconfTransactionsGroup: + properties: + anchorBlockID: + description: AnchorV2 parameters + type: integer + anchorStateRoot: + items: + type: integer + type: array + baseFeePerGas: + type: integer + blockId: + type: integer + groupId: + type: integer + groupStatus: + $ref: "#/definitions/preconfserver.PreconfTxsGroupStatus" + parentGasUsed: + type: integer + prevRandao: + items: + type: integer + type: array + signature: + type: string + suggestedFeeRecipient: + items: + type: integer + type: array + timestamp: + description: Block parameters + type: integer + transactions: + items: + $ref: "#/definitions/types.Transaction" + type: array + type: object + preconfserver.PreconfTxsGroupStatus: + enum: + - finalBlockGroup + - finalPreconfGroup + type: string + x-enum-varnames: + - StatusFinalBlockGroup + - StatusFinalPreconfGroup + preconfserver.RemoveTentativeBlocksRequestBody: + properties: + newHead: + type: integer + type: object + preconfserver.RemoveTentativeBlocksResponseBody: + properties: + currentHead: + $ref: "#/definitions/types.Header" + type: object + types.Header: + properties: + baseFeePerGas: + allOf: + - $ref: "#/definitions/big.Int" + description: BaseFee was added by EIP-1559 and is ignored in legacy headers. + blobGasUsed: + description: BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. + type: integer + difficulty: + $ref: "#/definitions/big.Int" + excessBlobGas: + description: + ExcessBlobGas was added by EIP-4844 and is ignored in legacy + headers. + type: integer + extraData: + items: + type: integer + type: array + gasLimit: + type: integer + gasUsed: + type: integer + logsBloom: + items: + type: integer + type: array + miner: + items: + type: integer + type: array + mixHash: + items: + type: integer + type: array + nonce: + items: + type: integer + type: array + number: + $ref: "#/definitions/big.Int" + parentBeaconBlockRoot: + description: + ParentBeaconRoot was added by EIP-4788 and is ignored in legacy + headers. + items: + type: integer + type: array + parentHash: + items: + type: integer + type: array + receiptsRoot: + items: + type: integer + type: array + requestsRoot: + description: RequestsHash was added by EIP-7685 and is ignored in legacy headers. + items: + type: integer + type: array + sha3Uncles: + items: + type: integer + type: array + stateRoot: + items: + type: integer + type: array + timestamp: + type: integer + transactionsRoot: + items: + type: integer + type: array + withdrawalsRoot: + description: + WithdrawalsHash was added by EIP-4895 and is ignored in legacy + headers. + items: + type: integer + type: array + type: object + types.Transaction: + type: object +info: + contact: + email: info@taiko.xyz + name: API Support + url: https://community.taiko.xyz/ + license: + name: MIT + url: https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md + termsOfService: http://swagger.io/terms/ + title: Taiko Preconfirmation Server API + version: "1.0" +paths: + /healthz: + get: + consumes: + - application/json + operationId: health-check + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + summary: Get current server health status + /tentativeBlocks: + delete: + consumes: + - application/json + description: |- + Remove all tentative blocks from the blockchain beyond the specified block height, + ensuring the latest block ID does not exceed the given height. This method will fail if + the block with an ID one greater than the specified height is not a tentative block. If the + specified block height is greater than the latest tentative block ID, the method will succeed + without modifying the blockchain. + parameters: + - description: preconf blocks creation request body + in: body + name: body + required: true + schema: + $ref: "#/definitions/preconfserver.RemoveTentativeBlocksRequestBody" + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/preconfserver.RemoveTentativeBlocksResponseBody" + post: + consumes: + - application/json + description: |- + Insert a group of transactions into a tentative block for preconfirmation. If the group is the + first for a block, a new tentative block will be created. Otherwise, the transactions will + be appended to the existing tentative block. The API will fail if: + 1) the block is not tentative, 2) any transaction in the group is invalid or a duplicate, 3) + block-level parameters are invalid or do not match the current tentative block’s parameters, + 4) the group ID is not exactly 1 greater than the previous one, or 5) the last group of + the block indicates no further transactions are allowed. + parameters: + - description: preconf blocks creation request body + in: body + name: body + required: true + schema: + $ref: "#/definitions/preconfserver.BuildTentativeBlocksRequestBody" + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/preconfserver.BuildTentativeBlocksResponseBody" +swagger: "2.0" diff --git a/packages/taiko-client/driver/preconf_server/api.go b/packages/taiko-client/driver/preconf_server/api.go index adbcafa1ff..e8dd557c9f 100644 --- a/packages/taiko-client/driver/preconf_server/api.go +++ b/packages/taiko-client/driver/preconf_server/api.go @@ -1,4 +1,4 @@ -package preconf_server +package preconfserver import ( "net/http" @@ -32,60 +32,68 @@ type PreconfTransactionsGroup struct { BaseFeePerGas uint64 `json:"baseFeePerGas"` // AnchorV2 parameters - AnchorBlockId uint64 `json:"anchorBlockId"` + AnchorBlockID uint64 `json:"anchorBlockID"` AnchorStateRoot common.Hash `json:"anchorStateRoot"` ParentGasUsed uint32 `json:"parentGasUsed"` } -// CreateOrUpdateBlocksFromBatchResponseBodyRequestBody represents a request body when handling +// buildTentativeBlocksRequestBody represents a request body when handling // preconfirmation blocks creation requests. -type CreateOrUpdateBlocksFromBatchResponseBodyRequestBody struct { +type BuildTentativeBlocksRequestBody struct { TransactionsGroups []PreconfTransactionsGroup `json:"transactionsGroups"` } // CreateOrUpdateBlocksFromBatchResponseBody represents a response body when handling preconfirmation // blocks creation requests. -type CreateOrUpdateBlocksFromBatchResponseBody struct { - PreconfHeaders []types.Header `json:"preconfHeaders"` +type BuildTentativeBlocksResponseBody struct { + PreconfHeaders []types.Header `json:"tentativeHeaders"` } -// CreateOrUpdateBlocksFromBatch handles a preconfirmation blocks creation request, +// BuildTentativeBlocks handles a preconfirmation blocks creation request, // if the preconfirmation block groups in request are valid, it will insert the correspoinding new preconfirmation // blocks to the backend L2 execution engine and return a success response. // -// @Summary Insert preconfirmation blocks by the given groups to the backend L2 execution engine, please note that -// the AVS service should sort the groups and make sure all the groups are valid at first. -// @Param body body CreateOrUpdateBlocksFromBatchResponseBodyRequestBody true "preconf blocks creation request body" -// @Accept json -// @Produce json -// @Success 200 {object} CreateOrUpdateBlocksFromBatchResponseBody -// @Router /perconfBlocks [post] -func (s *PreconfAPIServer) CreateOrUpdateBlocksFromBatch(c echo.Context) error { +// @Description Insert a group of transactions into a tentative block for preconfirmation. If the group is the +// @Description first for a block, a new tentative block will be created. Otherwise, the transactions will +// @Description be appended to the existing tentative block. The API will fail if: +// @Description 1) the block is not tentative, 2) any transaction in the group is invalid or a duplicate, 3) +// @Description block-level parameters are invalid or do not match the current tentative block’s parameters, +// @Description 4) the group ID is not exactly 1 greater than the previous one, or 5) the last group of +// @Description the block indicates no further transactions are allowed. +// @Param body body BuildTentativeBlocksRequestBody true "preconf blocks creation request body" +// @Accept json +// @Produce json +// @Success 200 {object} BuildTentativeBlocksResponseBody +// @Router /tentativeBlocks [post] +func (s *PreconfAPIServer) BuildTentativeBlocks(c echo.Context) error { return c.NoContent(http.StatusOK) } -// ResetPreconfHeadRequestBody represents a request body when resetting the backend +// RemoveTentativeBlocksRequestBody represents a request body when resetting the backend // L2 execution engine preconfirmation head. -type ResetPreconfHeadRequestBody struct { +type RemoveTentativeBlocksRequestBody struct { NewHead uint64 `json:"newHead"` } -// ResetPreconfHeadResponseBody represents a response body when resetting the backend +// RemoveTentativeBlocksResponseBody represents a response body when resetting the backend // L2 execution engine preconfirmation head. -type ResetPreconfHeadResponseBody struct { +type RemoveTentativeBlocksResponseBody struct { CurrentHead types.Header `json:"currentHead"` } -// ResetPreconfHead resets the backend L2 execution engine preconfirmation head. +// RemoveTentativeBlocks removes the backend L2 execution engine preconfirmation head. // -// @Summary Resets the backend L2 execution engine preconfirmation head, please note that -// the AVS service should make sure the new head height is from a valid preconfirmation head. -// @Param body body ResetPreconfHeadRequestBody true "preconf blocks creation request body" -// @Accept json -// @Produce json -// @Success 200 {object} ResetPreconfHeadResponseBody -// @Router /preconfHead [put] -func (s *PreconfAPIServer) ResetPreconfHead(c echo.Context) error { +// @Description Remove all tentative blocks from the blockchain beyond the specified block height, +// @Description ensuring the latest block ID does not exceed the given height. This method will fail if +// @Description the block with an ID one greater than the specified height is not a tentative block. If the +// @Description specified block height is greater than the latest tentative block ID, the method will succeed +// @Description without modifying the blockchain. +// @Param body body RemoveTentativeBlocksRequestBody true "preconf blocks creation request body" +// @Accept json +// @Produce json +// @Success 200 {object} RemoveTentativeBlocksResponseBody +// @Router /tentativeBlocks [delete] +func (s *PreconfAPIServer) RemoveTentativeBlocks(c echo.Context) error { return c.NoContent(http.StatusOK) } @@ -95,7 +103,7 @@ func (s *PreconfAPIServer) ResetPreconfHead(c echo.Context) error { // @ID health-check // @Accept json // @Produce json -// @Success 200 {object} Status +// @Success 200 {object} string // @Router /healthz [get] func (s *PreconfAPIServer) HealthCheck(c echo.Context) error { return c.NoContent(http.StatusOK) diff --git a/packages/taiko-client/driver/preconf_server/server.go b/packages/taiko-client/driver/preconf_server/server.go index 3eb28fbba8..90f2a1cc6f 100644 --- a/packages/taiko-client/driver/preconf_server/server.go +++ b/packages/taiko-client/driver/preconf_server/server.go @@ -1,4 +1,4 @@ -package preconf_server +package preconfserver import ( "os" @@ -75,6 +75,6 @@ func (s *PreconfAPIServer) configureMiddleware(corsOrigins []string) { func (s *PreconfAPIServer) configureRoutes() { s.echo.GET("/", s.HealthCheck) s.echo.GET("/healthz", s.HealthCheck) - s.echo.POST("/perconfTransactions", s.CreateOrUpdateBlocksFromBatch) - s.echo.PUT("/preconfHead", s.ResetPreconfHead) + s.echo.POST("/tentativeBlocks", s.BuildTentativeBlocks) + s.echo.DELETE("/tentativeBlocks", s.RemoveTentativeBlocks) } diff --git a/packages/taiko-client/scripts/gen_swagger_json.sh b/packages/taiko-client/scripts/gen_swagger_json.sh index 59dce311db..ac8f7a9184 100755 --- a/packages/taiko-client/scripts/gen_swagger_json.sh +++ b/packages/taiko-client/scripts/gen_swagger_json.sh @@ -1,3 +1,3 @@ #/bin/sh -swag init -g api.go -d prover/server --pd +swag init -g server.go -d driver/preconf_server --pd