diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2adeac8215..552295b347 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -132,24 +132,3 @@ jobs: tags: scrolltech/coordinator:${{github.ref_name}} # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} - prover-stats-api: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push prover-stats-api docker - uses: docker/build-push-action@v2 - with: - context: . - file: ./build/dockerfiles/prover-stats-api.Dockerfile - push: true - tags: scrolltech/prover-stats-api:${{github.ref_name}} - # cache-from: type=gha,scope=${{ github.workflow }} - # cache-to: type=gha,scope=${{ github.workflow }} diff --git a/.github/workflows/prover_stats_api.yml b/.github/workflows/prover_stats_api.yml deleted file mode 100644 index a4518f4cc2..0000000000 --- a/.github/workflows/prover_stats_api.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: ProverStatsAPI - -on: - push: - branches: - - main - - staging - - develop - - alpha - paths: - - 'prover-stats-api/**' - - '.github/workflows/prover_stats_api.yml' - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - paths: - - 'prover-stats-api/**' - - '.github/workflows/prover_stats_api.yml' - -defaults: - run: - working-directory: 'prover-stats-api' - -jobs: - check: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.19.x - - name: Checkout code - uses: actions/checkout@v2 - - name: Lint - run: | - rm -rf $HOME/.cache/golangci-lint - make lint - test: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.19.x - - name: Checkout code - uses: actions/checkout@v2 - - name: Test - run: | - make test - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - with: - flags: prover-stats-api - goimports-lint: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.19.x - - name: Checkout code - uses: actions/checkout@v2 - - name: Install goimports - run: go install golang.org/x/tools/cmd/goimports - - run: goimports -local scroll-tech/prover-stats-api/ -w . - - run: go mod tidy - # If there are any diffs from goimports or go mod tidy, fail. - - name: Verify no changes from goimports and go mod tidy - run: | - if [ -n "$(git status --porcelain)" ]; then - exit 1 - fi diff --git a/README.md b/README.md index 71317702c4..ffb1c30de8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ ├── database: Database client and schema definition ├── l2geth: Scroll execution node ├── prover: Prover client that runs proof generation for zkEVM circuit and aggregation circuit -├── prover-stats-api: Collect and show prover statistics ├── rollup: Rollup-related services ├── rpc-gateway: RPC gateway external repo └── tests: Integration tests diff --git a/build/dockerfiles/coordinator.Dockerfile b/build/dockerfiles/coordinator.Dockerfile index 4dfc259369..0f501f771c 100644 --- a/build/dockerfiles/coordinator.Dockerfile +++ b/build/dockerfiles/coordinator.Dockerfile @@ -24,7 +24,6 @@ COPY ./rollup/go.* ./rollup/ COPY ./common/go.* ./common/ COPY ./coordinator/go.* ./coordinator/ COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ COPY ./prover/go.* ./prover/ COPY ./tests/integration-test/go.* ./tests/integration-test/ COPY ./bridge-history-api/go.* ./bridge-history-api/ diff --git a/build/dockerfiles/db_cli.Dockerfile b/build/dockerfiles/db_cli.Dockerfile index e7c2bf22d0..bc86e93601 100644 --- a/build/dockerfiles/db_cli.Dockerfile +++ b/build/dockerfiles/db_cli.Dockerfile @@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/ COPY ./common/go.* ./common/ COPY ./coordinator/go.* ./coordinator/ COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ COPY ./prover/go.* ./prover/ COPY ./tests/integration-test/go.* ./tests/integration-test/ COPY ./bridge-history-api/go.* ./bridge-history-api/ diff --git a/build/dockerfiles/event_watcher.Dockerfile b/build/dockerfiles/event_watcher.Dockerfile index 8db495076a..26b11d9dd8 100644 --- a/build/dockerfiles/event_watcher.Dockerfile +++ b/build/dockerfiles/event_watcher.Dockerfile @@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/ COPY ./common/go.* ./common/ COPY ./coordinator/go.* ./coordinator/ COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ COPY ./prover/go.* ./prover/ COPY ./tests/integration-test/go.* ./tests/integration-test/ COPY ./bridge-history-api/go.* ./bridge-history-api/ diff --git a/build/dockerfiles/gas_oracle.Dockerfile b/build/dockerfiles/gas_oracle.Dockerfile index 0011b95d98..1ca9ff1dba 100644 --- a/build/dockerfiles/gas_oracle.Dockerfile +++ b/build/dockerfiles/gas_oracle.Dockerfile @@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/ COPY ./common/go.* ./common/ COPY ./coordinator/go.* ./coordinator/ COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ COPY ./prover/go.* ./prover/ COPY ./tests/integration-test/go.* ./tests/integration-test/ COPY ./bridge-history-api/go.* ./bridge-history-api/ diff --git a/build/dockerfiles/prover-stats-api.Dockerfile b/build/dockerfiles/prover-stats-api.Dockerfile deleted file mode 100644 index 53020c399d..0000000000 --- a/build/dockerfiles/prover-stats-api.Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# Download Go dependencies -FROM scrolltech/go-alpine-builder:1.19 as base - -WORKDIR /src -COPY go.work* ./ -COPY ./rollup/go.* ./rollup/ -COPY ./common/go.* ./common/ -COPY ./coordinator/go.* ./coordinator/ -COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ -COPY ./prover/go.* ./prover/ -COPY ./tests/integration-test/go.* ./tests/integration-test/ -COPY ./bridge-history-api/go.* ./bridge-history-api/ -# Support mainland environment. -#ENV GOPROXY="https://goproxy.cn,direct" -RUN go mod download -x - - -# Build prover-stats-api -FROM base as builder - -RUN --mount=target=. \ - --mount=type=cache,target=/root/.cache/go-build \ - cd /src/prover-stats-api/cmd/ && go build -v -p 4 -o /bin/prover-stats-api - -# Pull prover-stats-api into a second stage deploy alpine container \ -FROM alpine:latest - -COPY --from=builder /bin/prover-stats-api /bin/ - -ENTRYPOINT ["prover-stats-api"] \ No newline at end of file diff --git a/build/dockerfiles/rollup_relayer.Dockerfile b/build/dockerfiles/rollup_relayer.Dockerfile index 1a51f23669..952f45f674 100644 --- a/build/dockerfiles/rollup_relayer.Dockerfile +++ b/build/dockerfiles/rollup_relayer.Dockerfile @@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/ COPY ./common/go.* ./common/ COPY ./coordinator/go.* ./coordinator/ COPY ./database/go.* ./database/ -COPY ./prover-stats-api/go.* ./prover-stats-api/ COPY ./prover/go.* ./prover/ COPY ./tests/integration-test/go.* ./tests/integration-test/ COPY ./bridge-history-api/go.* ./bridge-history-api/ diff --git a/coordinator/internal/config/config.go b/coordinator/internal/config/config.go index 0848b62a23..273869c988 100644 --- a/coordinator/internal/config/config.go +++ b/coordinator/internal/config/config.go @@ -31,7 +31,7 @@ type L2 struct { ChainID uint64 `json:"chain_id"` } -// Auth provides the auth of prover-stats-api +// Auth provides the auth coordinator type Auth struct { Secret string `json:"secret"` ChallengeExpireDurationSec int `json:"challenge_expire_duration_sec"` diff --git a/go.work b/go.work index f1875b8b3a..564923fca0 100644 --- a/go.work +++ b/go.work @@ -6,7 +6,6 @@ use ( ./coordinator ./database ./prover - ./prover-stats-api ./rollup ./tests/integration-test ) diff --git a/go.work.sum b/go.work.sum index 147f8822a8..f0b658d87c 100644 --- a/go.work.sum +++ b/go.work.sum @@ -462,6 +462,8 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= @@ -530,6 +532,8 @@ github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDe github.com/mailgun/raymond/v2 v2.0.46 h1:aOYHhvTpF5USySJ0o7cpPno/Uh2I5qg2115K25A+Ft4= github.com/mailgun/raymond/v2 v2.0.46/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd h1:HvFwW+cm9bCbZ/+vuGNq7CRWXql8c0y8nGeYpqmpvmk= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8B5ajsLIjeuEHLi8xE4fk997o= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= diff --git a/prover-stats-api/.gitignore b/prover-stats-api/.gitignore deleted file mode 100644 index 14cea4e5ea..0000000000 --- a/prover-stats-api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build/bin \ No newline at end of file diff --git a/prover-stats-api/Makefile b/prover-stats-api/Makefile deleted file mode 100644 index 458e7154b2..0000000000 --- a/prover-stats-api/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -.PHONY: clean build test docker - -IMAGE_NAME=prover-stats-api -IMAGE_VERSION=latest -REPO_ROOT_DIR=./.. - -all: build - -build: - GOBIN=$(PWD)/build/bin go build -o $(PWD)/build/bin/prover-stats-api ./cmd - -clean: ## Empty out the bin folder - @rm -rf build/bin - -swag: - swag init -g ./cmd/main.go - -test: - go test -v $(PWD)/... - -lint: ## Lint the files - used for CI - GOBIN=$(PWD)/build/bin go run ../build/lint.go - -docker: - DOCKER_BUILDKIT=1 docker build -t scrolltech/${IMAGE_NAME}:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/prover-stats-api.Dockerfile - -.PHONY: all diff --git a/prover-stats-api/README.md b/prover-stats-api/README.md deleted file mode 100644 index 185dd2fe5c..0000000000 --- a/prover-stats-api/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# prover-stats-api - -This directory contains the `prover-stats-api` service that provides REST APIs to query the status of proving tasks assigned to the prover. - -## Instructions - -1. Build and start the `prover-stats-api` service. - - ``` - cd ./prover-stats-api - make build - ./build/bin/prover-stats --config=./conf/config.json - ``` - -2. Open this URL in your browser to view the API documents. - ``` - http://localhost:8990/swagger/index.html - ``` - -## How to update the prover-stats-api docs - -``` -cd ./prover-stats-api -make swag -``` diff --git a/prover-stats-api/cmd/app/app.go b/prover-stats-api/cmd/app/app.go deleted file mode 100644 index beb82514ac..0000000000 --- a/prover-stats-api/cmd/app/app.go +++ /dev/null @@ -1,91 +0,0 @@ -package app - -import ( - "fmt" - "os" - "os/signal" - - "github.com/gin-gonic/gin" - "github.com/prometheus/client_golang/prometheus" - "github.com/scroll-tech/go-ethereum/log" - "github.com/urfave/cli/v2" - - "scroll-tech/common/database" - "scroll-tech/common/observability" - "scroll-tech/common/utils" - "scroll-tech/common/version" - - "scroll-tech/prover-stats-api/internal/config" - "scroll-tech/prover-stats-api/internal/controller" - "scroll-tech/prover-stats-api/internal/route" -) - -var app *cli.App - -func init() { - // Set up prover-stats-api info. - app = cli.NewApp() - app.Action = action - app.Name = "Prover Stats API" - app.Usage = "The Scroll L2 ZK Prover Stats API" - app.Version = version.Version - app.Flags = append(app.Flags, utils.CommonFlags...) - app.Flags = append(app.Flags, apiFlags...) - app.Before = func(ctx *cli.Context) error { - return utils.LogSetup(ctx) - } -} - -func action(ctx *cli.Context) error { - // Load config file. - cfgFile := ctx.String(utils.ConfigFileFlag.Name) - cfg, err := config.NewConfig(cfgFile) - if err != nil { - log.Crit("failed to load config file", "config file", cfgFile, "error", err) - } - - // init db handler - db, err := database.InitDB(cfg.DBConfig) - if err != nil { - log.Crit("failed to init db connection", "err", err) - } - defer func() { - if err = database.CloseDB(db); err != nil { - log.Error("can not close ormFactory", "error", err) - } - }() - - registry := prometheus.DefaultRegisterer - observability.Server(ctx, db) - - // init Prover Stats API - port := ctx.String(httpPortFlag.Name) - - router := gin.Default() - controller.InitController(db) - route.Route(router, cfg, registry) - - go func() { - if runServerErr := router.Run(fmt.Sprintf(":%s", port)); runServerErr != nil { - log.Crit("run http server failure", "error", runServerErr) - } - }() - - // Catch CTRL-C to ensure a graceful shutdown. - interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt) - - // Wait until the interrupt signal is received from an OS signal. - <-interrupt - - return nil -} - -// Run run prover-stats-api. -func Run() { - // RunApp the prover-stats-api. - if err := app.Run(os.Args); err != nil { - _, _ = fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} diff --git a/prover-stats-api/cmd/app/flags.go b/prover-stats-api/cmd/app/flags.go deleted file mode 100644 index 4c6afd44c7..0000000000 --- a/prover-stats-api/cmd/app/flags.go +++ /dev/null @@ -1,15 +0,0 @@ -package app - -import "github.com/urfave/cli/v2" - -var ( - apiFlags = []cli.Flag{ - &httpPortFlag, - } - // httpPortFlag set http.port. - httpPortFlag = cli.IntFlag{ - Name: "http.port", - Usage: "HTTP server listening port", - Value: 8990, - } -) diff --git a/prover-stats-api/cmd/main.go b/prover-stats-api/cmd/main.go deleted file mode 100644 index df2934ea0b..0000000000 --- a/prover-stats-api/cmd/main.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "scroll-tech/prover-stats-api/cmd/app" - _ "scroll-tech/prover-stats-api/docs" -) - -// @title Scroll Prover Stats API -// @version 1.0 -// @description This is an API server for Provers. - -// @contact.name Prover Stats API Support -// @contact.email Be Pending - -// @license.name Apache 2.0 -// @license.url http://www.apache.org/licenses/LICENSE-2.0.html - -// @host localhost:8990 -// @BasePath /api/v1 - -// @securityDefinitions.basic BasicAuth -func main() { - app.Run() -} diff --git a/prover-stats-api/conf/config.json b/prover-stats-api/conf/config.json deleted file mode 100644 index 3d371ce5f7..0000000000 --- a/prover-stats-api/conf/config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_config": { - "driver_name": "postgres", - "dsn": "postgres://localhost/scroll?sslmode=disable", - "maxOpenNum": 200, - "maxIdleNum": 20 - }, - "auth": { - "secret": "prover secret key", - "token_expire_duration": 3600 - } -} diff --git a/prover-stats-api/docs/docs.go b/prover-stats-api/docs/docs.go deleted file mode 100644 index bfe9469301..0000000000 --- a/prover-stats-api/docs/docs.go +++ /dev/null @@ -1,263 +0,0 @@ -// 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}}", - "contact": { - "name": "Prover Stats API Support", - "email": "Be Pending" - }, - "license": { - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/api/prover_task/v1/request_token": { - "get": { - "description": "login with prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "login with prover public key", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.LoginSchema" - } - } - } - } - } - }, - "/api/prover_task/v1/task": { - "get": { - "description": "get prover task by task id", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "give the specific prover task", - "parameters": [ - { - "type": "string", - "description": "prover task hash", - "name": "task_id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.ProverTaskSchema" - } - } - } - } - }, - "/api/prover_task/v1/tasks": { - "get": { - "description": "get all the prover task by prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "get all the prover task by prover public key", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page_size", - "name": "page_size", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.ProverTaskSchema" - } - } - } - } - } - }, - "/api/prover_task/v1/total_rewards": { - "get": { - "description": "get uint64 by prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "give the total rewards of a prover", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.ProverTotalRewardsSchema" - } - } - } - } - } - }, - "definitions": { - "types.LoginSchema": { - "type": "object", - "properties": { - "time": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "types.ProverTaskSchema": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "failure_type": { - "type": "string" - }, - "prover_name": { - "type": "string" - }, - "proving_status": { - "type": "string" - }, - "reward": { - "type": "string" - }, - "task_id": { - "type": "string" - }, - "task_type": { - "type": "string" - } - } - }, - "types.ProverTotalRewardsSchema": { - "type": "object", - "properties": { - "rewards": { - "type": "string" - } - } - } - }, - "securityDefinitions": { - "BasicAuth": { - "type": "basic" - } - } -}` - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = &swag.Spec{ - Version: "1.0", - Host: "localhost:8990", - BasePath: "/api/v1", - Schemes: []string{}, - Title: "Zero-knowledge Prover Stats API", - Description: "This is an API server for Provers.", - InfoInstanceName: "swagger", - SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", -} - -func init() { - swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) -} diff --git a/prover-stats-api/docs/swagger.json b/prover-stats-api/docs/swagger.json deleted file mode 100644 index fbfa1a83d2..0000000000 --- a/prover-stats-api/docs/swagger.json +++ /dev/null @@ -1,238 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "description": "This is an API server for Provers.", - "title": "Zero-knowledge Prover Stats API", - "contact": { - "name": "Prover Stats API Support", - "email": "Be Pending" - }, - "license": { - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - }, - "version": "1.0" - }, - "host": "localhost:8990", - "basePath": "/api/v1", - "paths": { - "/api/prover_task/v1/request_token": { - "get": { - "description": "login with prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "login with prover public key", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.LoginSchema" - } - } - } - } - } - }, - "/api/prover_task/v1/task": { - "get": { - "description": "get prover task by task id", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "give the specific prover task", - "parameters": [ - { - "type": "string", - "description": "prover task hash", - "name": "task_id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.ProverTaskSchema" - } - } - } - } - }, - "/api/prover_task/v1/tasks": { - "get": { - "description": "get all the prover task by prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "get all the prover task by prover public key", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "page_size", - "name": "page_size", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/types.ProverTaskSchema" - } - } - } - } - } - }, - "/api/prover_task/v1/total_rewards": { - "get": { - "description": "get uint64 by prover public key", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "prover_task" - ], - "summary": "give the total rewards of a prover", - "parameters": [ - { - "type": "string", - "description": "prover public key", - "name": "pubkey", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Bearer license", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/types.ProverTotalRewardsSchema" - } - } - } - } - } - }, - "definitions": { - "types.LoginSchema": { - "type": "object", - "properties": { - "time": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "types.ProverTaskSchema": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "failure_type": { - "type": "string" - }, - "prover_name": { - "type": "string" - }, - "proving_status": { - "type": "string" - }, - "reward": { - "type": "string" - }, - "task_id": { - "type": "string" - }, - "task_type": { - "type": "string" - } - } - }, - "types.ProverTotalRewardsSchema": { - "type": "object", - "properties": { - "rewards": { - "type": "string" - } - } - } - }, - "securityDefinitions": { - "BasicAuth": { - "type": "basic" - } - } -} \ No newline at end of file diff --git a/prover-stats-api/docs/swagger.yaml b/prover-stats-api/docs/swagger.yaml deleted file mode 100644 index 0d083f5e3d..0000000000 --- a/prover-stats-api/docs/swagger.yaml +++ /dev/null @@ -1,157 +0,0 @@ -basePath: /api/v1 -definitions: - types.LoginSchema: - properties: - time: - type: string - token: - type: string - type: object - types.ProverTaskSchema: - properties: - created_at: - type: string - failure_type: - type: string - prover_name: - type: string - proving_status: - type: string - reward: - type: string - task_id: - type: string - task_type: - type: string - type: object - types.ProverTotalRewardsSchema: - properties: - rewards: - type: string - type: object -host: localhost:8990 -info: - contact: - email: Be Pending - name: Prover Stats API Support - description: This is an API server for Provers. - license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - title: Zero-knowledge Prover Stats API - version: "1.0" -paths: - /api/prover_task/v1/request_token: - get: - consumes: - - text/plain - description: login with prover public key - parameters: - - description: prover public key - in: query - name: pubkey - required: true - type: string - produces: - - text/plain - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/types.LoginSchema' - type: array - summary: login with prover public key - tags: - - prover_task - /api/prover_task/v1/task: - get: - consumes: - - text/plain - description: get prover task by task id - parameters: - - description: prover task hash - in: path - name: task_id - required: true - type: string - - description: Bearer license - in: header - name: Authorization - type: string - produces: - - text/plain - responses: - "200": - description: OK - schema: - $ref: '#/definitions/types.ProverTaskSchema' - summary: give the specific prover task - tags: - - prover_task - /api/prover_task/v1/tasks: - get: - consumes: - - text/plain - description: get all the prover task by prover public key - parameters: - - description: prover public key - in: query - name: pubkey - required: true - type: string - - description: page - in: query - name: page - required: true - type: integer - - description: page_size - in: query - name: page_size - required: true - type: integer - - description: Bearer license - in: header - name: Authorization - type: string - produces: - - text/plain - responses: - "200": - description: OK - schema: - items: - $ref: '#/definitions/types.ProverTaskSchema' - type: array - summary: get all the prover task by prover public key - tags: - - prover_task - /api/prover_task/v1/total_rewards: - get: - consumes: - - text/plain - description: get uint64 by prover public key - parameters: - - description: prover public key - in: path - name: pubkey - required: true - type: string - - description: Bearer license - in: header - name: Authorization - type: string - produces: - - text/plain - responses: - "200": - description: OK - schema: - $ref: '#/definitions/types.ProverTotalRewardsSchema' - summary: give the total rewards of a prover - tags: - - prover_task -securityDefinitions: - BasicAuth: - type: basic -swagger: "2.0" diff --git a/prover-stats-api/go.mod b/prover-stats-api/go.mod deleted file mode 100644 index fa11229dec..0000000000 --- a/prover-stats-api/go.mod +++ /dev/null @@ -1,74 +0,0 @@ -module scroll-tech/prover-stats-api - -go 1.19 - -require ( - github.com/appleboy/gin-jwt/v2 v2.9.1 - github.com/gin-gonic/gin v1.9.1 - github.com/google/uuid v1.3.0 - github.com/prometheus/client_golang v1.14.0 - github.com/stretchr/testify v1.8.3 - gorm.io/gorm v1.25.2 -) - -require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-stack/stack v1.8.1 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect -) - -require ( - github.com/KyleBanks/depth v1.2.1 // indirect - github.com/bytedance/sonic v1.9.2 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // 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.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.1 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.5 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/scroll-tech/go-ethereum v1.10.14-0.20230829000527-f883dcdc21fc - github.com/shopspring/decimal v1.3.1 - github.com/swaggo/files v1.0.1 - github.com/swaggo/gin-swagger v1.6.0 - github.com/swaggo/swag v1.16.1 - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - github.com/urfave/cli/v2 v2.25.7 - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/arch v0.4.0 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.11.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/prover-stats-api/go.sum b/prover-stats-api/go.sum deleted file mode 100644 index 5785bad49c..0000000000 --- a/prover-stats-api/go.sum +++ /dev/null @@ -1,256 +0,0 @@ -github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= -github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/appleboy/gin-jwt/v2 v2.9.1 h1:l29et8iLW6omcHltsOP6LLk4s3v4g2FbFs0koxGWVZs= -github.com/appleboy/gin-jwt/v2 v2.9.1/go.mod h1:jwcPZJ92uoC9nOUTOKWoN/f6JZOgMSKlFSHw5/FrRUk= -github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4= -github.com/appleboy/gofight/v2 v2.1.2/go.mod h1:frW+U1QZEdDgixycTj4CygQ48yLTUhplt43+Wczp3rw= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.2 h1:GDaNjuWSGu09guE9Oql0MSTNhNCLlWwO8y/xM5BzcbM= -github.com/bytedance/sonic v1.9.2/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8= -github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= -github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= -github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= -github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= -github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scroll-tech/go-ethereum v1.10.14-0.20230829000527-f883dcdc21fc h1:eK3NOpjgm/b2TQ6rYqWx92Zri0kBuxf6gKjjsVxWKr8= -github.com/scroll-tech/go-ethereum v1.10.14-0.20230829000527-f883dcdc21fc/go.mod h1:DiN3p2inoXOxGffxSswDKqWjQ7bU+Mp0c9v0XQXKmaA= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= -github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= -github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M= -github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= -github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= -github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= -golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= -golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho= -gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/prover-stats-api/internal/config/config.go b/prover-stats-api/internal/config/config.go deleted file mode 100644 index e8562a4047..0000000000 --- a/prover-stats-api/internal/config/config.go +++ /dev/null @@ -1,37 +0,0 @@ -package config - -import ( - "encoding/json" - "os" - "path/filepath" - - "scroll-tech/common/database" -) - -// Config provides the config of prover-stats-api -type Config struct { - DBConfig *database.Config `json:"db_config"` - Auth Auth `json:"auth"` -} - -// Auth provides the auth of prover-stats-api -type Auth struct { - Secret string `json:"secret"` - TokenExpireDuration int `json:"token_expire_duration"` // unit: seconds -} - -// NewConfig returns a new instance of Config. -func NewConfig(file string) (*Config, error) { - buf, err := os.ReadFile(filepath.Clean(file)) - if err != nil { - return nil, err - } - - cfg := &Config{} - err = json.Unmarshal(buf, cfg) - if err != nil { - return nil, err - } - - return cfg, nil -} diff --git a/prover-stats-api/internal/controller/auth.go b/prover-stats-api/internal/controller/auth.go deleted file mode 100644 index 2618217fac..0000000000 --- a/prover-stats-api/internal/controller/auth.go +++ /dev/null @@ -1,58 +0,0 @@ -package controller - -import ( - "errors" - "fmt" - "strings" - "time" - - "github.com/gin-gonic/gin" - - ctype "scroll-tech/common/types" - - "scroll-tech/prover-stats-api/internal/types" -) - -// AuthController is auth API -type AuthController struct { -} - -// NewAuthController returns an AuthController instance -func NewAuthController() *AuthController { - return &AuthController{} -} - -// Login godoc -// @Summary login with prover public key -// @Description login with prover public key -// @Tags prover_task -// @Accept plain -// @Produce plain -// @Param pubkey query string true "prover public key" -// @Success 200 {array} types.LoginSchema -// @Router /api/prover_task/v1/request_token [get] -func (a *AuthController) Login(c *gin.Context) (interface{}, error) { - var login types.LoginParameter - if err := c.ShouldBindQuery(&login); err != nil { - return "", fmt.Errorf("missing the public_key, err:%w", err) - } - - if a.checkValidPublicKey(login.PublicKey) { - return types.LoginParameter{PublicKey: login.PublicKey}, nil - } - - return nil, errors.New("incorrect public_key") -} - -func (a *AuthController) checkValidPublicKey(pubkey string) bool { - return strings.TrimSpace(pubkey) != "" -} - -// LoginResponse response login api -func (a *AuthController) LoginResponse(c *gin.Context, code int, message string, time time.Time) { - resp := types.LoginSchema{ - Time: time, - Token: message, - } - ctype.RenderSuccess(c, resp) -} diff --git a/prover-stats-api/internal/controller/controller.go b/prover-stats-api/internal/controller/controller.go deleted file mode 100644 index 40f99270ea..0000000000 --- a/prover-stats-api/internal/controller/controller.go +++ /dev/null @@ -1,24 +0,0 @@ -package controller - -import ( - "sync" - - "gorm.io/gorm" -) - -var ( - // ProverTask is controller instance - ProverTask *ProverTaskController - // Auth is controller instance - Auth *AuthController - - initControllerOnce sync.Once -) - -// InitController inits Controller with database -func InitController(db *gorm.DB) { - initControllerOnce.Do(func() { - ProverTask = NewProverTaskController(db) - Auth = NewAuthController() - }) -} diff --git a/prover-stats-api/internal/controller/prover_task.go b/prover-stats-api/internal/controller/prover_task.go deleted file mode 100644 index 16709890ec..0000000000 --- a/prover-stats-api/internal/controller/prover_task.go +++ /dev/null @@ -1,138 +0,0 @@ -package controller - -import ( - "fmt" - - "github.com/gin-gonic/gin" - "gorm.io/gorm" - - ctype "scroll-tech/common/types" - "scroll-tech/common/types/message" - - "scroll-tech/prover-stats-api/internal/logic" - "scroll-tech/prover-stats-api/internal/types" -) - -// ProverTaskController provides API controller. -type ProverTaskController struct { - logic *logic.ProverTaskLogic -} - -// NewProverTaskController provides a ProverTask instance. -func NewProverTaskController(db *gorm.DB) *ProverTaskController { - return &ProverTaskController{ - logic: logic.NewProverTaskLogic(db), - } -} - -// ProverTasks godoc -// @Summary get all the prover task by prover public key -// @Description get all the prover task by prover public key -// @Tags prover_task -// @Accept plain -// @Produce plain -// @Param pubkey query string true "prover public key" -// @Param page query int true "page" -// @Param page_size query int true "page_size" -// @Param Authorization header string false "Bearer license" -// @Success 200 {array} types.ProverTaskSchema -// @Router /api/prover_task/v1/tasks [get] -func (c *ProverTaskController) ProverTasks(ctx *gin.Context) { - var pp types.ProverTasksPaginationParameter - if err := ctx.ShouldBind(&pp); err != nil { - nerr := fmt.Errorf("parameter invalid, err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIParameterInvalidNo, nerr) - return - } - - tasks, err := c.logic.GetTasksByProver(ctx, pp.PublicKey, pp.Page, pp.PageSize) - if err != nil { - nerr := fmt.Errorf("controller.ProverTasks err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIProverTaskFailure, nerr) - return - } - - var proverTaskSchemas []types.ProverTaskSchema - for _, task := range tasks { - proverTaskSchema := types.ProverTaskSchema{ - TaskID: task.TaskID, - ProverName: task.ProverName, - TaskType: message.ProofType(task.TaskType).String(), - ProvingStatus: ctype.ProvingStatus(task.ProvingStatus).String(), - Reward: task.Reward.String(), - CreatedAt: task.CreatedAt, - } - proverTaskSchemas = append(proverTaskSchemas, proverTaskSchema) - } - - ctype.RenderSuccess(ctx, proverTaskSchemas) -} - -// GetTotalRewards godoc -// @Summary give the total rewards of a prover -// @Description get uint64 by prover public key -// @Tags prover_task -// @Accept plain -// @Produce plain -// @Param pubkey path string true "prover public key" -// @Param Authorization header string false "Bearer license" -// @Success 200 {object} types.ProverTotalRewardsSchema -// @Router /api/prover_task/v1/total_rewards [get] -func (c *ProverTaskController) GetTotalRewards(ctx *gin.Context) { - var pp types.ProverTotalRewardsParameter - if err := ctx.ShouldBind(&pp); err != nil { - nerr := fmt.Errorf("parameter invalid, err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIParameterInvalidNo, nerr) - return - } - - rewards, err := c.logic.GetTotalRewards(ctx, pp.PublicKey) - if err != nil { - nerr := fmt.Errorf("controller.GetTotalRewards, err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIProverTotalRewardFailure, nerr) - return - } - - resp := types.ProverTotalRewardsSchema{ - Rewards: rewards.String(), - } - - ctype.RenderSuccess(ctx, resp) -} - -// GetTask godoc -// @Summary give the specific prover task -// @Description get prover task by task id -// @Tags prover_task -// @Accept plain -// @Produce plain -// @Param task_id path string true "prover task hash" -// @Param Authorization header string false "Bearer license" -// @Success 200 {object} types.ProverTaskSchema -// @Router /api/prover_task/v1/task [get] -func (c *ProverTaskController) GetTask(ctx *gin.Context) { - var pp types.ProverTaskParameter - if err := ctx.ShouldBind(&pp); err != nil { - nerr := fmt.Errorf("parameter invalid, err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIParameterInvalidNo, nerr) - return - } - - task, err := c.logic.GetTask(ctx, pp.TaskID) - if err != nil { - nerr := fmt.Errorf("controller.GetTask, err:%w", err) - ctype.RenderFailure(ctx, ctype.ErrProverStatsAPIProverTotalRewardFailure, nerr) - return - } - - schema := types.ProverTaskSchema{ - TaskID: task.TaskID, - ProverName: task.ProverName, - TaskType: message.ProofType(task.TaskType).String(), - ProvingStatus: ctype.ProvingStatus(task.ProvingStatus).String(), - Reward: task.Reward.String(), - CreatedAt: task.CreatedAt, - } - - ctype.RenderSuccess(ctx, schema) -} diff --git a/prover-stats-api/internal/logic/prover_task.go b/prover-stats-api/internal/logic/prover_task.go deleted file mode 100644 index 24c5de7caf..0000000000 --- a/prover-stats-api/internal/logic/prover_task.go +++ /dev/null @@ -1,47 +0,0 @@ -package logic - -import ( - "context" - "math/big" - - "gorm.io/gorm" - - "scroll-tech/prover-stats-api/internal/orm" -) - -// ProverTaskLogic deals the prover task logic with orm. -type ProverTaskLogic struct { - proverTaskOrm *orm.ProverTask -} - -// NewProverTaskLogic provides a ProverTaskLogic with database instance. -func NewProverTaskLogic(db *gorm.DB) *ProverTaskLogic { - return &ProverTaskLogic{ - proverTaskOrm: orm.NewProverTask(db), - } -} - -// GetTasksByProver returns tasks by given prover's public key and page, page size. -func (p *ProverTaskLogic) GetTasksByProver(ctx context.Context, pubkey string, page, pageSize int) ([]*orm.ProverTask, error) { - offset := (page - 1) * pageSize - limit := pageSize - return p.proverTaskOrm.GetProverTasksByProver(ctx, pubkey, offset, limit) -} - -// GetTotalRewards returns prover's total rewards by given public key. -func (p *ProverTaskLogic) GetTotalRewards(ctx context.Context, pubkey string) (*big.Int, error) { - totalReward, err := p.proverTaskOrm.GetProverTotalReward(ctx, pubkey) - if err != nil { - return nil, err - } - return totalReward, nil -} - -// GetTask returns ProverTask by given task id. -func (p *ProverTaskLogic) GetTask(ctx context.Context, taskID string) (*orm.ProverTask, error) { - task, err := p.proverTaskOrm.GetProverTasksByHash(ctx, taskID) - if err != nil { - return nil, err - } - return task, nil -} diff --git a/prover-stats-api/internal/logic/prover_task_test.go b/prover-stats-api/internal/logic/prover_task_test.go deleted file mode 100644 index 66aaf02712..0000000000 --- a/prover-stats-api/internal/logic/prover_task_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package logic - -import ( - "context" - "math/big" - "testing" - - "github.com/shopspring/decimal" - "github.com/stretchr/testify/assert" - "gorm.io/gorm" - - "scroll-tech/database/migrate" - - "scroll-tech/common/database" - "scroll-tech/common/docker" - "scroll-tech/common/types" - - "scroll-tech/prover-stats-api/internal/config" - "scroll-tech/prover-stats-api/internal/orm" -) - -var ( - proverPubkey = "key" - - task1 = orm.ProverTask{ - TaskID: "1", - ProverPublicKey: proverPubkey, - ProverName: "prover-0", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromInt(10), - } - - task2 = orm.ProverTask{ - TaskID: "2", - ProverPublicKey: proverPubkey, - ProverName: "prover-1", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromInt(12), - } - - service *ProverTaskLogic -) - -func insertSomeProverTasks(t *testing.T, db *gorm.DB) { - sqlDB, err := db.DB() - assert.NoError(t, err) - assert.NoError(t, migrate.ResetDB(sqlDB)) - - ptdb := orm.NewProverTask(db) - err = ptdb.InsertProverTask(context.Background(), &task1) - assert.NoError(t, err) - - err = ptdb.InsertProverTask(context.Background(), &task2) - assert.NoError(t, err) -} - -func TestProverTaskService(t *testing.T) { - // start database image - base := docker.NewDockerApp() - defer base.Free() - cfg, err := config.NewConfig("../../conf/config.json") - assert.NoError(t, err) - cfg.DBConfig.DSN = base.DBImg.Endpoint() - base.RunDBImage(t) - - db, err := database.InitDB(cfg.DBConfig) - assert.NoError(t, err) - - // insert some tasks - insertSomeProverTasks(t, db) - - service = NewProverTaskLogic(db) - - t.Run("testGetTasksByProver", testGetTasksByProver) - t.Run("testGetTotalRewards", testGetTotalRewards) - t.Run("testGetTask", testGetTask) -} - -func testGetTasksByProver(t *testing.T) { - tasks, err := service.GetTasksByProver(context.Background(), proverPubkey, 1, 2) - assert.NoError(t, err) - assert.Equal(t, task2.TaskID, tasks[0].TaskID) - assert.Equal(t, task1.TaskID, tasks[1].TaskID) -} - -func testGetTotalRewards(t *testing.T) { - rewards, err := service.GetTotalRewards(context.Background(), proverPubkey) - assert.NoError(t, err) - assert.Equal(t, big.NewInt(22), rewards) -} - -func testGetTask(t *testing.T) { - task, err := service.GetTask(context.Background(), "2") - assert.NoError(t, err) - assert.Equal(t, task2.TaskID, task.TaskID) -} diff --git a/prover-stats-api/internal/middleware/jwt.go b/prover-stats-api/internal/middleware/jwt.go deleted file mode 100644 index 735e53bb54..0000000000 --- a/prover-stats-api/internal/middleware/jwt.go +++ /dev/null @@ -1,71 +0,0 @@ -package middleware - -import ( - "errors" - "time" - - jwt "github.com/appleboy/gin-jwt/v2" - "github.com/gin-gonic/gin" - - "github.com/scroll-tech/go-ethereum/log" - - ctype "scroll-tech/common/types" - - "scroll-tech/prover-stats-api/internal/config" - "scroll-tech/prover-stats-api/internal/controller" - "scroll-tech/prover-stats-api/internal/types" -) - -// IdentityKey is auth key -const IdentityKey = "public_key" - -// AuthMiddleware jwt auth middleware -func AuthMiddleware(conf *config.Config) *jwt.GinJWTMiddleware { - jwtMiddleware, err := jwt.New(&jwt.GinJWTMiddleware{ - PayloadFunc: PayloadFunc, - IdentityHandler: IdentityHandler, - IdentityKey: IdentityKey, - Key: []byte(conf.Auth.Secret), - Timeout: time.Second * time.Duration(conf.Auth.TokenExpireDuration), - Authenticator: controller.Auth.Login, - Unauthorized: Unauthorized, - TokenLookup: "header: Authorization, query: token, cookie: jwt", - TokenHeadName: "Bearer", - TimeFunc: time.Now, - LoginResponse: controller.Auth.LoginResponse, - }) - - if err != nil { - log.Crit("new jwt middleware panic", "error", err) - } - - if errInit := jwtMiddleware.MiddlewareInit(); errInit != nil { - log.Crit("init jwt middleware panic", "error", errInit) - } - - return jwtMiddleware -} - -// Unauthorized response Unauthorized error message to client -func Unauthorized(c *gin.Context, code int, message string) { - err := errors.New(message) - ctype.RenderFailure(c, code, err) -} - -// PayloadFunc returns jwt.MapClaims with public key. -func PayloadFunc(data interface{}) jwt.MapClaims { - if v, ok := data.(types.LoginParameter); ok { - return jwt.MapClaims{ - IdentityKey: v.PublicKey, - } - } - return jwt.MapClaims{} -} - -// IdentityHandler replies to client for /login -func IdentityHandler(c *gin.Context) interface{} { - claims := jwt.ExtractClaims(c) - return &types.LoginParameter{ - PublicKey: claims[IdentityKey].(string), - } -} diff --git a/prover-stats-api/internal/orm/orm_test.go b/prover-stats-api/internal/orm/orm_test.go deleted file mode 100644 index ed9ae29c3f..0000000000 --- a/prover-stats-api/internal/orm/orm_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package orm - -import ( - "context" - "math/big" - "testing" - - "github.com/shopspring/decimal" - "github.com/stretchr/testify/assert" - "gorm.io/gorm" - - "scroll-tech/database/migrate" - - "scroll-tech/common/database" - "scroll-tech/common/docker" - "scroll-tech/common/types" - "scroll-tech/common/types/message" - "scroll-tech/common/utils" -) - -var ( - base *docker.App - - db *gorm.DB - proverTaskOrm *ProverTask -) - -func TestMain(m *testing.M) { - t := &testing.T{} - setupEnv(t) - defer tearDownEnv(t) - m.Run() -} - -func setupEnv(t *testing.T) { - base = docker.NewDockerApp() - base.RunDBImage(t) - var err error - db, err = database.InitDB( - &database.Config{ - DSN: base.DBConfig.DSN, - DriverName: base.DBConfig.DriverName, - MaxOpenNum: base.DBConfig.MaxOpenNum, - MaxIdleNum: base.DBConfig.MaxIdleNum, - }, - ) - assert.NoError(t, err) - sqlDB, err := db.DB() - assert.NoError(t, err) - assert.NoError(t, migrate.ResetDB(sqlDB)) - - proverTaskOrm = NewProverTask(db) -} - -func tearDownEnv(t *testing.T) { - sqlDB, err := db.DB() - assert.NoError(t, err) - sqlDB.Close() - base.Free() -} - -func TestProverTaskOrm(t *testing.T) { - sqlDB, err := db.DB() - assert.NoError(t, err) - assert.NoError(t, migrate.ResetDB(sqlDB)) - - reward := big.NewInt(0) - reward.SetString("18446744073709551616", 10) // 1 << 64, uint64 maximum 1<<64 -1 - - proverTask := ProverTask{ - TaskType: int16(message.ProofTypeChunk), - TaskID: "test-hash", - ProverName: "prover-0", - ProverPublicKey: "0", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromBigInt(reward, 0), - AssignedAt: utils.NowUTC(), - } - - err = proverTaskOrm.InsertProverTask(context.Background(), &proverTask) - assert.NoError(t, err) - proverTasks, err := proverTaskOrm.GetProverTasksByHashes(context.Background(), message.ProofTypeChunk, []string{"test-hash"}) - assert.NoError(t, err) - assert.Equal(t, 1, len(proverTasks)) - assert.Equal(t, proverTask.ProverName, proverTasks[0].ProverName) - assert.NotEqual(t, proverTask.UUID.String(), "00000000-0000-0000-0000-000000000000") - - // test decimal reward, get reward - resultReward := proverTasks[0].Reward.BigInt() - assert.Equal(t, resultReward, reward) - assert.Equal(t, resultReward.String(), "18446744073709551616") - - proverTask.ProvingStatus = int16(types.ProverProofValid) - proverTask.AssignedAt = utils.NowUTC() - err = proverTaskOrm.InsertProverTask(context.Background(), &proverTask) - assert.Error(t, err) -} - -func TestProverTaskOrmUint256(t *testing.T) { - sqlDB, err := db.DB() - assert.NoError(t, err) - assert.NoError(t, migrate.ResetDB(sqlDB)) - - // test reward for uint256 maximum 1 << 256 -1 :115792089237316195423570985008687907853269984665640564039457584007913129639935 - rewardUint256 := big.NewInt(0) - rewardUint256.SetString("115792089237316195423570985008687907853269984665640564039457584007913129639935", 10) - proverTask := ProverTask{ - TaskType: int16(message.ProofTypeChunk), - TaskID: "test-hash", - ProverName: "prover-0", - ProverPublicKey: "0", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromBigInt(rewardUint256, 0), - AssignedAt: utils.NowUTC(), - } - - err = proverTaskOrm.InsertProverTask(context.Background(), &proverTask) - assert.NoError(t, err) - assert.NotEqual(t, proverTask.UUID.String(), "00000000-0000-0000-0000-000000000000") - proverTasksUint256, err := proverTaskOrm.GetProverTasksByHashes(context.Background(), message.ProofTypeChunk, []string{"test-hash"}) - assert.NoError(t, err) - assert.Equal(t, 1, len(proverTasksUint256)) - resultRewardUint256 := proverTasksUint256[0].Reward.BigInt() - assert.Equal(t, resultRewardUint256, rewardUint256) - assert.Equal(t, resultRewardUint256.String(), "115792089237316195423570985008687907853269984665640564039457584007913129639935") -} diff --git a/prover-stats-api/internal/orm/prover_task.go b/prover-stats-api/internal/orm/prover_task.go deleted file mode 100644 index 811d73c93d..0000000000 --- a/prover-stats-api/internal/orm/prover_task.go +++ /dev/null @@ -1,131 +0,0 @@ -package orm - -import ( - "context" - "fmt" - "math/big" - "time" - - "github.com/google/uuid" - "github.com/shopspring/decimal" - "gorm.io/gorm" - "gorm.io/gorm/clause" - - "scroll-tech/common/types/message" -) - -// ProverTask is assigned provers info of chunk/batch proof prover task -type ProverTask struct { - db *gorm.DB `gorm:"column:-"` - - ID int64 `json:"id" gorm:"column:id"` - UUID uuid.UUID `json:"uuid" gorm:"column:uuid;type:uuid;default:gen_random_uuid()"` - - // prover - ProverPublicKey string `json:"prover_public_key" gorm:"column:prover_public_key"` - ProverName string `json:"prover_name" gorm:"column:prover_name"` - ProverVersion string `json:"prover_version" gorm:"column:prover_version"` - - // task - TaskID string `json:"task_id" gorm:"column:task_id"` - TaskType int16 `json:"task_type" gorm:"column:task_type;default:0"` - - // status - ProvingStatus int16 `json:"proving_status" gorm:"column:proving_status;default:0"` - FailureType int16 `json:"failure_type" gorm:"column:failure_type;default:0"` - Reward decimal.Decimal `json:"reward" gorm:"column:reward;default:0;type:decimal(78)"` - Proof []byte `json:"proof" gorm:"column:proof;default:NULL"` - AssignedAt time.Time `json:"assigned_at" gorm:"assigned_at"` - - // metadata - CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` - UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"column:deleted_at"` -} - -// NewProverTask creates a new ProverTask instance. -func NewProverTask(db *gorm.DB) *ProverTask { - return &ProverTask{db: db} -} - -// TableName returns the name of the "prover_task" table. -func (*ProverTask) TableName() string { - return "prover_task" -} - -// GetProverTasksByProver get all prover tasks by the given prover's public key. -func (o *ProverTask) GetProverTasksByProver(ctx context.Context, pubkey string, offset, limit int) ([]*ProverTask, error) { - var proverTasks []*ProverTask - db := o.db.WithContext(ctx) - db = db.Model(&ProverTask{}) - db = db.Where("prover_public_key", pubkey) - db = db.Order("id desc") - db = db.Offset(offset) - db = db.Limit(limit) - if err := db.Find(&proverTasks).Error; err != nil { - return nil, fmt.Errorf("ProverTask.GetProverTasksByProver error: %w, prover %s", err, pubkey) - } - return proverTasks, nil -} - -// GetProverTotalReward get prover all reward by the given prover's public key. -func (o *ProverTask) GetProverTotalReward(ctx context.Context, pubkey string) (*big.Int, error) { - var totalReward decimal.Decimal - db := o.db.WithContext(ctx) - db = db.Model(&ProverTask{}) - db = db.Select("sum(reward)") - db = db.Where("prover_public_key", pubkey) - if err := db.Scan(&totalReward).Error; err != nil { - return nil, fmt.Errorf("ProverTask.GetProverTotalReward error:%w, prover:%s", err, pubkey) - } - return totalReward.BigInt(), nil -} - -// GetProverTasksByHash retrieves the ProverTask records associated with the specified hashes. -// The returned prover task objects are sorted in ascending order by their ids. -func (o *ProverTask) GetProverTasksByHash(ctx context.Context, hash string) (*ProverTask, error) { - db := o.db.WithContext(ctx) - db = db.Model(&ProverTask{}) - db = db.Where("task_id", hash) - db = db.Order("id asc") - - var proverTask *ProverTask - if err := db.Find(&proverTask).Error; err != nil { - return nil, fmt.Errorf("ProverTask.GetProverTasksByHash error: %w, hash: %v", err, hash) - } - return proverTask, nil -} - -// GetProverTasksByHashes retrieves the ProverTask records associated with the specified hashes. -// The returned prover task objects are sorted in ascending order by their ids. -func (o *ProverTask) GetProverTasksByHashes(ctx context.Context, taskType message.ProofType, hashes []string) ([]*ProverTask, error) { - if len(hashes) == 0 { - return nil, nil - } - - db := o.db.WithContext(ctx) - db = db.Model(&ProverTask{}) - db = db.Where("task_type", int(taskType)) - db = db.Where("task_id IN ?", hashes) - db = db.Order("id asc") - - var proverTasks []*ProverTask - if err := db.Find(&proverTasks).Error; err != nil { - return nil, fmt.Errorf("ProverTask.GetProverTasksByHashes error: %w, hashes: %v", err, hashes) - } - return proverTasks, nil -} - -// InsertProverTask insert a prover Task record -func (o *ProverTask) InsertProverTask(ctx context.Context, proverTask *ProverTask, dbTX ...*gorm.DB) error { - db := o.db.WithContext(ctx) - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } - db = db.Clauses(clause.Returning{}) - db = db.Model(&ProverTask{}) - if err := db.Create(proverTask).Error; err != nil { - return fmt.Errorf("ProverTask.InsertProverTask error: %w, prover task: %v", err, proverTask) - } - return nil -} diff --git a/prover-stats-api/internal/route/route.go b/prover-stats-api/internal/route/route.go deleted file mode 100644 index a36cab0338..0000000000 --- a/prover-stats-api/internal/route/route.go +++ /dev/null @@ -1,40 +0,0 @@ -package route - -import ( - "github.com/gin-gonic/gin" - "github.com/prometheus/client_golang/prometheus" - swaggerFiles "github.com/swaggo/files" - ginSwagger "github.com/swaggo/gin-swagger" - - "scroll-tech/common/observability" - - "scroll-tech/prover-stats-api/internal/config" - "scroll-tech/prover-stats-api/internal/controller" - "scroll-tech/prover-stats-api/internal/middleware" -) - -// Route routes the APIs -func Route(router *gin.Engine, conf *config.Config, reg prometheus.Registerer) { - router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - - observability.Use(router, "prover_stats_api", reg) - - r := router.Group("api/prover_task") - - v1(r, conf) -} - -func v1(router *gin.RouterGroup, conf *config.Config) { - r := router.Group("/v1") - - authMiddleware := middleware.AuthMiddleware(conf) - r.GET("/request_token", authMiddleware.LoginHandler) - - // need jwt token api - r.Use(authMiddleware.MiddlewareFunc()) - { - r.GET("/tasks", controller.ProverTask.ProverTasks) - r.GET("/total_rewards", controller.ProverTask.GetTotalRewards) - r.GET("/task", controller.ProverTask.GetTask) - } -} diff --git a/prover-stats-api/internal/types/auth.go b/prover-stats-api/internal/types/auth.go deleted file mode 100644 index 79a036783c..0000000000 --- a/prover-stats-api/internal/types/auth.go +++ /dev/null @@ -1,14 +0,0 @@ -package types - -import "time" - -// LoginParameter for /login api -type LoginParameter struct { - PublicKey string `form:"public_key" json:"public_key" binding:"required"` -} - -// LoginSchema for /login response -type LoginSchema struct { - Time time.Time `json:"time"` - Token string `json:"token"` -} diff --git a/prover-stats-api/internal/types/prover_task.go b/prover-stats-api/internal/types/prover_task.go deleted file mode 100644 index bfa372b03c..0000000000 --- a/prover-stats-api/internal/types/prover_task.go +++ /dev/null @@ -1,36 +0,0 @@ -package types - -import "time" - -// ProverTasksPaginationParameter for GetTasksByProver request -type ProverTasksPaginationParameter struct { - PublicKey string `form:"public_key" json:"public_key" binding:"required"` - Page int `form:"page" json:"page" binding:"required"` - PageSize int `form:"page_size" json:"page_size" binding:"required"` -} - -// ProverTaskSchema is response for ProverTask -type ProverTaskSchema struct { - TaskID string `json:"task_id"` - ProverName string `json:"prover_name"` - TaskType string `json:"task_type"` - ProvingStatus string `json:"proving_status"` - FailureType string `json:"failure_type"` - Reward string `json:"reward"` - CreatedAt time.Time `json:"created_at"` -} - -// ProverTotalRewardsParameter for GetTotalRewards request -type ProverTotalRewardsParameter struct { - PublicKey string `form:"public_key" json:"public_key" binding:"required"` -} - -// ProverTotalRewardsSchema is response for GetTotalRewards -type ProverTotalRewardsSchema struct { - Rewards string `json:"rewards"` -} - -// ProverTaskParameter for GetTask request -type ProverTaskParameter struct { - TaskID string `form:"task_id" json:"task_id" binding:"required"` -} diff --git a/prover-stats-api/test/prover_task_test.go b/prover-stats-api/test/prover_task_test.go deleted file mode 100644 index efc6e3f7bc..0000000000 --- a/prover-stats-api/test/prover_task_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package test - -import ( - "context" - "encoding/json" - "fmt" - "io" - "math/big" - "net/http" - "testing" - - "github.com/gin-gonic/gin" - "github.com/prometheus/client_golang/prometheus" - "github.com/shopspring/decimal" - "github.com/stretchr/testify/assert" - "gorm.io/gorm" - - "scroll-tech/database/migrate" - - "scroll-tech/common/database" - "scroll-tech/common/docker" - "scroll-tech/common/types" - "scroll-tech/common/utils" - - "scroll-tech/prover-stats-api/internal/config" - "scroll-tech/prover-stats-api/internal/controller" - "scroll-tech/prover-stats-api/internal/orm" - "scroll-tech/prover-stats-api/internal/route" -) - -var ( - proverPubkey = "11111" -) - -var ( - addr = utils.RandomURL() - basicPath = fmt.Sprintf("http://%s/api/prover_task/v1", addr) - token string -) - -func mockHTTPServer(cfg *config.Config, db *gorm.DB) (*http.Server, error) { - // run Prover Stats APIs - router := gin.Default() - controller.InitController(db) - route.Route(router, cfg, prometheus.DefaultRegisterer) - return utils.StartHTTPServer(addr, router) -} - -func TestProverTaskAPIs(t *testing.T) { - // start database image - base := docker.NewDockerApp() - defer base.Free() - cfg, err := config.NewConfig("../conf/config.json") - assert.NoError(t, err) - cfg.DBConfig.DSN = base.DBImg.Endpoint() - base.RunDBImage(t) - - db, err := database.InitDB(cfg.DBConfig) - assert.NoError(t, err) - - // insert some tasks - insertSomeProverTasks(t, db) - - // run Prover Stats APIs - srv, err := mockHTTPServer(cfg, db) - assert.NoError(t, err) - defer srv.Close() - - t.Run("testRequestToken", testRequestToken) - t.Run("testGetProverTasksByProver", testGetProverTasksByProver) - t.Run("testGetTotalRewards", testGetTotalRewards) - t.Run("testGetProverTask", testGetProverTask) -} - -func testRequestToken(t *testing.T) { - data := getResp(t, fmt.Sprintf("%s/request_token?public_key=%s", basicPath, proverPubkey)) - token = fmt.Sprintf("Bearer %s", data.(map[string]interface{})["token"].(string)) - t.Log("token: ", token) -} - -func testGetProverTasksByProver(t *testing.T) { - datas := getResp(t, fmt.Sprintf("%s/tasks?public_key=%s&page=%d&page_size=%d", basicPath, proverPubkey, 1, 10)) - anys := datas.([]interface{}) - var tasks []map[string]interface{} - for _, data := range anys { - task := data.(map[string]interface{}) - tasks = append(tasks, task) - } - - assert.Equal(t, task2.TaskID, tasks[0]["task_id"]) - assert.Equal(t, task1.TaskID, tasks[1]["task_id"]) -} - -func testGetTotalRewards(t *testing.T) { - data := getResp(t, fmt.Sprintf("%s/total_rewards?public_key=%s", basicPath, proverPubkey)) - schema := data.(map[string]interface{}) - assert.Equal(t, big.NewInt(22).String(), schema["rewards"]) -} - -func testGetProverTask(t *testing.T) { - data := getResp(t, fmt.Sprintf("%s/task?task_id=1", basicPath)) - task := data.(map[string]interface{}) - assert.Equal(t, task1.TaskID, task["task_id"]) -} - -func getResp(t *testing.T, url string) interface{} { - req, err := http.NewRequest(http.MethodGet, url, nil) - assert.NoError(t, err) - req.Header.Add("Authorization", token) - - resp, err := http.DefaultClient.Do(req) - assert.NoError(t, err) - defer resp.Body.Close() - assert.Equal(t, resp.StatusCode, http.StatusOK) - - byt, err := io.ReadAll(resp.Body) - assert.NoError(t, err) - - res := new(types.Response) - assert.NoError(t, json.Unmarshal(byt, res)) - assert.Equal(t, types.Success, res.ErrCode) - return res.Data -} - -var ( - task1 = orm.ProverTask{ - TaskID: "1", - ProverPublicKey: proverPubkey, - ProverName: "prover-0", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromInt(10), - } - - task2 = orm.ProverTask{ - TaskID: "2", - ProverPublicKey: proverPubkey, - ProverName: "prover-1", - ProvingStatus: int16(types.ProverAssigned), - Reward: decimal.NewFromInt(12), - } -) - -func insertSomeProverTasks(t *testing.T, db *gorm.DB) { - sqlDB, err := db.DB() - assert.NoError(t, err) - assert.NoError(t, migrate.ResetDB(sqlDB)) - - ptdb := orm.NewProverTask(db) - err = ptdb.InsertProverTask(context.Background(), &task1) - assert.NoError(t, err) - - err = ptdb.InsertProverTask(context.Background(), &task2) - assert.NoError(t, err) -}