From e3b451c6410fc7860f0c89ec3569b0e18a6cbc3c Mon Sep 17 00:00:00 2001 From: Lawliet-Chan <1576710154@qq.com> Date: Thu, 20 Jul 2023 15:33:29 +0800 Subject: [PATCH] feat(prover-stats-api): add prover stats API (#635) Co-authored-by: xinran chen Co-authored-by: georgehao Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- .github/workflows/prover_stats_api.yml | 80 ++++++ common/version/version.go | 2 +- go.work | 1 + go.work.sum | 87 +++--- prover-stats-api/.gitignore | 1 + prover-stats-api/Makefile | 16 ++ prover-stats-api/README | 30 ++ prover-stats-api/cmd/app/app.go | 96 +++++++ prover-stats-api/cmd/app/flags.go | 15 + prover-stats-api/cmd/main.go | 24 ++ prover-stats-api/conf/config.json | 12 + prover-stats-api/docs/docs.go | 263 ++++++++++++++++++ prover-stats-api/docs/swagger.json | 238 ++++++++++++++++ prover-stats-api/docs/swagger.yaml | 157 +++++++++++ prover-stats-api/go.mod | 63 +++++ prover-stats-api/go.sum | 231 +++++++++++++++ prover-stats-api/internal/config/config.go | 36 +++ prover-stats-api/internal/controller/auth.go | 56 ++++ .../internal/controller/controller.go | 24 ++ .../internal/controller/prover_task.go | 138 +++++++++ .../internal/logic/prover_task.go | 47 ++++ .../internal/logic/prover_task_test.go | 94 +++++++ prover-stats-api/internal/middleware/jwt.go | 69 +++++ prover-stats-api/internal/orm/orm_test.go | 118 ++++++++ prover-stats-api/internal/orm/prover_task.go | 99 +++++++ prover-stats-api/internal/route/route.go | 35 +++ prover-stats-api/internal/types/auth.go | 14 + prover-stats-api/internal/types/errno.go | 12 + .../internal/types/prover_task.go | 36 +++ prover-stats-api/internal/types/response.go | 28 ++ prover-stats-api/test/prover_task_test.go | 150 ++++++++++ 31 files changed, 2230 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/prover_stats_api.yml create mode 100644 prover-stats-api/.gitignore create mode 100644 prover-stats-api/Makefile create mode 100644 prover-stats-api/README create mode 100644 prover-stats-api/cmd/app/app.go create mode 100644 prover-stats-api/cmd/app/flags.go create mode 100644 prover-stats-api/cmd/main.go create mode 100644 prover-stats-api/conf/config.json create mode 100644 prover-stats-api/docs/docs.go create mode 100644 prover-stats-api/docs/swagger.json create mode 100644 prover-stats-api/docs/swagger.yaml create mode 100644 prover-stats-api/go.mod create mode 100644 prover-stats-api/go.sum create mode 100644 prover-stats-api/internal/config/config.go create mode 100644 prover-stats-api/internal/controller/auth.go create mode 100644 prover-stats-api/internal/controller/controller.go create mode 100644 prover-stats-api/internal/controller/prover_task.go create mode 100644 prover-stats-api/internal/logic/prover_task.go create mode 100644 prover-stats-api/internal/logic/prover_task_test.go create mode 100644 prover-stats-api/internal/middleware/jwt.go create mode 100644 prover-stats-api/internal/orm/orm_test.go create mode 100644 prover-stats-api/internal/orm/prover_task.go create mode 100644 prover-stats-api/internal/route/route.go create mode 100644 prover-stats-api/internal/types/auth.go create mode 100644 prover-stats-api/internal/types/errno.go create mode 100644 prover-stats-api/internal/types/prover_task.go create mode 100644 prover-stats-api/internal/types/response.go create mode 100644 prover-stats-api/test/prover_task_test.go diff --git a/.github/workflows/prover_stats_api.yml b/.github/workflows/prover_stats_api.yml new file mode 100644 index 0000000000..a4518f4cc2 --- /dev/null +++ b/.github/workflows/prover_stats_api.yml @@ -0,0 +1,80 @@ +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/common/version/version.go b/common/version/version.go index c3711186eb..936178cfc8 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.0.23" +var tag = "v4.0.24" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/go.work b/go.work index 37c825049e..ee5bf7df71 100644 --- a/go.work +++ b/go.work @@ -8,4 +8,5 @@ use ( ./database ./roller ./tests/integration-test + ./prover-stats-api ) diff --git a/go.work.sum b/go.work.sum index 2f60f57e92..b58146e172 100644 --- a/go.work.sum +++ b/go.work.sum @@ -24,6 +24,7 @@ github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+B github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.8.0 h1:CxTzQrySOxDnKpLjFJeZAS5Qrv/qFPkgLjx5bOAi//I= github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= +github.com/Azure/go-autorest/autorest/adal v0.9.23 h1:Yepx8CvFxwNKpH6ja7RZ+sKX+DWYNldbLiALMC3BTz8= github.com/Azure/go-autorest/autorest/adal v0.9.23/go.mod h1:5pcMqFkdPhviJdlEy3kC/v1ZLnQl0MH6XA5YCcMhy4c= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM= @@ -41,6 +42,7 @@ github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VY github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/ClickHouse/clickhouse-go/v2 v2.2.0 h1:dj00TDKY+xwuTJdbpspCSmTLFyWzRJerTHwaBxut1C0= github.com/ClickHouse/clickhouse-go/v2 v2.2.0/go.mod h1:8f2XZUi7XoeU+uPIytSi1cvx8fmJxi7vIgqpvYTF1+o= @@ -153,7 +155,6 @@ github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdw github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8 h1:akOQj8IVgoeFfBTzGOEQakCYshWD6RNo1M5pivFXt70= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -196,6 +197,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c h1:CndMRAH4JIwxbW8KYq6Q+cGWcGHz0FjGR3QqcInWcW0= github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= +github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY= github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90 h1:WXb3TSNmHp2vHoCroCIB1foO/yQ36swABL8aOVeDpgg= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc= @@ -207,10 +209,7 @@ github.com/getkin/kin-openapi v0.61.0 h1:6awGqF5nG5zkVpMsAih1QH4VgzS8phTxECUWIFo github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9 h1:r5GgOLGbza2wVHRzK7aAj6lWZjfbAwiu/RDCVOKjRyM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -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 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= -github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd h1:r04MMPyLHj/QwZuMJ5+7tJcBr1AQjpiAK/rZWRrQT7o= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= @@ -228,11 +227,8 @@ github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dT github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= -github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= @@ -270,6 +266,7 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= @@ -278,6 +275,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gotestyourself/gotestyourself v1.4.0 h1:CDSlSIuRL/Fsc72Ln5lMybtrCvSRDddsHsDRG/nP7Rg= github.com/gotestyourself/gotestyourself v1.4.0/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= @@ -286,7 +284,11 @@ github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gt github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e/go.mod h1:j9cQbcqHQujT0oKJ38PylVfqohClLr3CvDC+Qcg+lhU= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM= +github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150 h1:vlNjIqmUZ9CMAWsbURYl3a6wZbw7q5RHVvlXTNS/Bs8= +github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91 h1:KyZDvZ/GGn+r+Y3DKZ7UOQ/TP4xV6HNkrwiVMB1GnNY= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6 h1:UDMh68UUwekSh5iP2OMhRRZJiiBccgV7axzUG8vi56c= github.com/iden3/go-iden3-crypto v0.0.12/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo= github.com/iden3/go-iden3-crypto v0.0.14/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= @@ -309,37 +311,36 @@ github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= -github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= -github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8= -github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jackc/puddle/v2 v2.2.0 h1:RdcDk92EJBuBS55nQMMYFXTxwstHug4jkhT5pq8VxPk= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e h1:UvSe12bq+Uj2hWd8aOlwPmoZ+CITRFrdit+sDGfAg8U= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= 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= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= -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/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jsternberg/zap-logfmt v1.0.0 h1:0Dz2s/eturmdUS34GM82JwNEdQ9hPoJgqptcEKcbpzY= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5 h1:PJr+ZMXIecYc1Ey2zucXdR73SMBtgjPgwa31099IMv0= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef h1:2jNeR4YUziVtswNP9sEFAI913cVrzH85T+8Q6LpYbT0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kataras/jwt v0.1.8 h1:u71baOsYD22HWeSOg32tCHbczPjdCk7V4MMeJqTtmGk= github.com/kataras/jwt v0.1.8/go.mod h1:Q5j2IkcIHnfwy+oNY3TVWuEBJNw0ADgCcXK9CaZwV4o= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY= github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= @@ -347,6 +348,12 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfM github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8= github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= +github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 h1:KAZ1BW2TCmT6PRihDPpocIy1QTtsAsrx6TneU/4+CMg= +github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada h1:3L+neHp83cTjegPdCiOxVOJtRIy7/8RldvMTsyPYH10= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= +github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1 h1:LF5Iq7t/jrtUuSutNuiEWtB5eiHfZ5gSe2pcu5exjQw= github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY= @@ -356,7 +363,6 @@ github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= @@ -364,6 +370,7 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq 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= +github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d h1:oNAwILwmgWKFpuU+dXvI6dl9jG2mAWAZLX3r9s0PPiw= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104 h1:d8RFOZ2IiFtFWBcKEHAFYJcPTf0wY5q0exFNJZVWa1U= github.com/mattn/goveralls v0.0.2 h1:7eJB6EqsPhRVxvwEXGnqdO2sJI0PTsrWoTMXEk9/OQc= @@ -371,7 +378,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/mmcloughlin/profile v0.1.1 h1:jhDmAqPyebOsVDOCICJoINoLb/AnLBaUw58nFzxWS2w= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY= @@ -380,6 +387,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/naoina/go-stringutil v0.1.0 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= +github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 h1:shk/vn9oCoOTmwcouEdwIeOtOGA/ELRUw/GwvxwfT+0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nats-io/jwt/v2 v2.3.0/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k= github.com/nats-io/nats-server/v2 v2.9.11/go.mod h1:b0oVuxSlkvS3ZjMkncFeACGyZohbO4XhSqW1Lt7iRRY= @@ -414,6 +422,7 @@ github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= +github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7 h1:cZC+usqsYgHtlBaGulVnZ1hfKAi8iWtujBnRLQE698c= github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7/go.mod h1:IToEjHuttnUzwZI5KBSM/LOOW3qLbbrHOEfp3SbECGY= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52 h1:RnWNS9Hlm8BIkjr6wx8li5abe0fr73jljLycdfemTp0= @@ -428,6 +437,7 @@ github.com/scroll-tech/go-ethereum v1.10.14-0.20230210093343-bb26fa3e391d/go.mod github.com/scroll-tech/go-ethereum v1.10.14-0.20230220082843-ec9254b0b1c6/go.mod h1:eW+eyNdMoO0MyuczCc9xWSnW8dPJ0kOy5xsxgOKYEaA= github.com/scroll-tech/go-ethereum v1.10.14-0.20230306131930-03b4de32b78b/go.mod h1:f9ygxrxL7WRCTzuloV+t/UlcxMq3AL+gcNU60liiNNU= github.com/scroll-tech/go-ethereum v1.10.14-0.20230321020420-127af384ed04/go.mod h1:jH8c08L9K8Hieaf0r/ur2P/cpesn4dFhmLm2Mmoi8kI= +github.com/scroll-tech/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= github.com/scroll-tech/zktrie v0.4.3/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/scroll-tech/zktrie v0.5.2/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/segmentio/kafka-go v0.2.0 h1:HtCSf6B4gN/87yc5qTl7WsxPKQIIGXLPPM1bMCPOsoY= @@ -435,13 +445,10 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.23.2 h1:PAWSuiAszn7IhPMBtXsbSCafej7PqUOvY6YywlQUExU= github.com/shirou/gopsutil/v3 v3.23.2/go.mod h1:gv0aQw33GLo3pG8SiWKiQrbDzbRY1K80RyZJ7V4Th1M= -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/shurcooL/go v0.0.0-20200502201357-93f07166e636 h1:aSISeOcal5irEhJd1M+IrApc0PdcN7e7Aj4yuEnOrfQ= github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk= github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -451,18 +458,23 @@ github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8= github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/tinylib/msgp v1.0.2 h1:DfdQrzQa7Yh2es9SuLkixqxuXS2SxsdYn0KbdrOGWD8= github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/valyala/fasthttp v1.40.0 h1:CRq/00MfruPGFLTQKY8b+8SfdK60TxNztjRMnH0t1Yc= @@ -475,7 +487,6 @@ github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6 h1:YdYsPAZ2pC6Tow/n github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow= github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.etcd.io/gofail v0.1.0 h1:XItAMIhOojXFQMgrxjnd2EIIHun/d5qL0Pf7FzVTkFg= @@ -493,9 +504,7 @@ golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20191227195350-da58074b4299 h1:zQpM52jfKHG6II1ISZY1ZcpygvuSFZpLwfluuF89XOg= golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5 h1:rxKZ2gOnYxjfmakvUUqh9Gyb6KXfrj7JWTxORTYqb0E= golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4= @@ -503,50 +512,41 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNT golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -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.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.3.0 h1:6l90koy8/LaBLmLu8jpHeHexzMwEita0zFfYlggy2F8= golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.4.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.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= gonum.org/v1/gonum v0.6.0 h1:DJy6UzXbahnGUf1ujUNkh/NEtK14qMo2nvlBPs4U5yw= @@ -561,15 +561,20 @@ google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 h1:R1r5J0u6Cx+RNl/ google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg= google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= +gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= +gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 h1:a6cXbcDDUkSBlpnkWV1bJ+vv3mOgQEltEJ2rPxroVu0= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A= -gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gotest.tools v1.4.0 h1:BjtEgfuw8Qyd+jPvQz8CfoxiO/UjFEidWinwEXZiWv0= gotest.tools v1.4.0/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.36.1/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= diff --git a/prover-stats-api/.gitignore b/prover-stats-api/.gitignore new file mode 100644 index 0000000000..14cea4e5ea --- /dev/null +++ b/prover-stats-api/.gitignore @@ -0,0 +1 @@ +/build/bin \ No newline at end of file diff --git a/prover-stats-api/Makefile b/prover-stats-api/Makefile new file mode 100644 index 0000000000..a527dc3c8b --- /dev/null +++ b/prover-stats-api/Makefile @@ -0,0 +1,16 @@ +.PHONY: clean build test + +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 diff --git a/prover-stats-api/README b/prover-stats-api/README new file mode 100644 index 0000000000..01f3aaa3ba --- /dev/null +++ b/prover-stats-api/README @@ -0,0 +1,30 @@ +# prover-stats-api + +## how to get the prover-stats-api docs + +### 1. start the prover-stats-api server + +``` +cd ./prover-stats-api +go build -o prover-stats ./cmd/ +./prover-stats --config=./conf/config.json +``` + +you will get server run log +``` +Listening and serving HTTP on :8990 +``` + +### 2. browse the documents + +open this documents in your browser +``` +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 new file mode 100644 index 0000000000..e31849abf2 --- /dev/null +++ b/prover-stats-api/cmd/app/app.go @@ -0,0 +1,96 @@ +package app + +import ( + "context" + "fmt" + "os" + "os/signal" + + "github.com/gin-gonic/gin" + "github.com/scroll-tech/go-ethereum/log" + "github.com/urfave/cli/v2" + + "scroll-tech/common/database" + "scroll-tech/common/metrics" + "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) + } + }() + + subCtx, cancel := context.WithCancel(ctx.Context) + defer func() { + cancel() + }() + + // Start metrics server. + metrics.Serve(subCtx, ctx) + + // init Prover Stats API + port := ctx.String(httpPortFlag.Name) + + router := gin.Default() + controller.InitController(db) + route.Route(router, cfg) + + 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 new file mode 100644 index 0000000000..4c6afd44c7 --- /dev/null +++ b/prover-stats-api/cmd/app/flags.go @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000000..df2934ea0b --- /dev/null +++ b/prover-stats-api/cmd/main.go @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000000..3d371ce5f7 --- /dev/null +++ b/prover-stats-api/conf/config.json @@ -0,0 +1,12 @@ +{ + "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 new file mode 100644 index 0000000000..bfe9469301 --- /dev/null +++ b/prover-stats-api/docs/docs.go @@ -0,0 +1,263 @@ +// 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 new file mode 100644 index 0000000000..fbfa1a83d2 --- /dev/null +++ b/prover-stats-api/docs/swagger.json @@ -0,0 +1,238 @@ +{ + "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 new file mode 100644 index 0000000000..0d083f5e3d --- /dev/null +++ b/prover-stats-api/docs/swagger.yaml @@ -0,0 +1,157 @@ +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 new file mode 100644 index 0000000000..ad36b003d2 --- /dev/null +++ b/prover-stats-api/go.mod @@ -0,0 +1,63 @@ +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/stretchr/testify v1.8.3 + gorm.io/gorm v1.25.2 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/golang-jwt/jwt/v4 v4.4.3 // indirect + github.com/pmezard/go-difflib v1.0.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.20230613025759-f055f50f9d56 + 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.11.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect + golang.org/x/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 new file mode 100644 index 0000000000..544a0b9c26 --- /dev/null +++ b/prover-stats-api/go.sum @@ -0,0 +1,231 @@ +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/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/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.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +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 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= +github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +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 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +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/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/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +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.20230613025759-f055f50f9d56 h1:Cqj7haxwvzI2O4n9ZZ25helShzFGCy7Z/B+FFSBFHNI= +github.com/scroll-tech/go-ethereum v1.10.14-0.20230613025759-f055f50f9d56/go.mod h1:45PZqlQCqV0dU4o4+SE8LoJLEvXkK5j45ligvbih9QY= +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.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +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.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +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.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.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.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +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.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 new file mode 100644 index 0000000000..0fdac9520e --- /dev/null +++ b/prover-stats-api/internal/config/config.go @@ -0,0 +1,36 @@ +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 new file mode 100644 index 0000000000..65be021a82 --- /dev/null +++ b/prover-stats-api/internal/controller/auth.go @@ -0,0 +1,56 @@ +package controller + +import ( + "errors" + "fmt" + "strings" + "time" + + "github.com/gin-gonic/gin" + + "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, + } + types.RenderJSON(c, code, nil, resp) +} diff --git a/prover-stats-api/internal/controller/controller.go b/prover-stats-api/internal/controller/controller.go new file mode 100644 index 0000000000..40f99270ea --- /dev/null +++ b/prover-stats-api/internal/controller/controller.go @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000000..6d79ab54e2 --- /dev/null +++ b/prover-stats-api/internal/controller/prover_task.go @@ -0,0 +1,138 @@ +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) + types.RenderJSON(ctx, types.ErrParameterInvalidNo, nerr, nil) + return + } + + tasks, err := c.logic.GetTasksByProver(ctx, pp.PublicKey, pp.Page, pp.PageSize) + if err != nil { + nerr := fmt.Errorf("controller.ProverTasks err:%w", err) + types.RenderJSON(ctx, types.ErrProverTaskFailure, nerr, nil) + 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) + } + + types.RenderJSON(ctx, types.Success, nil, 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) + types.RenderJSON(ctx, types.ErrParameterInvalidNo, nerr, nil) + return + } + + rewards, err := c.logic.GetTotalRewards(ctx, pp.PublicKey) + if err != nil { + nerr := fmt.Errorf("controller.GetTotalRewards, err:%w", err) + types.RenderJSON(ctx, types.ErrProverTotalRewardFailure, nerr, nil) + return + } + + resp := types.ProverTotalRewardsSchema{ + Rewards: rewards.String(), + } + + types.RenderJSON(ctx, types.Success, nil, 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) + types.RenderJSON(ctx, types.ErrParameterInvalidNo, nerr, nil) + return + } + + task, err := c.logic.GetTask(ctx, pp.TaskID) + if err != nil { + nerr := fmt.Errorf("controller.GetTask, err:%w", err) + types.RenderJSON(ctx, types.ErrProverTotalRewardFailure, nerr, nil) + 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, + } + + types.RenderJSON(ctx, types.Success, nil, schema) +} diff --git a/prover-stats-api/internal/logic/prover_task.go b/prover-stats-api/internal/logic/prover_task.go new file mode 100644 index 0000000000..24c5de7caf --- /dev/null +++ b/prover-stats-api/internal/logic/prover_task.go @@ -0,0 +1,47 @@ +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 new file mode 100644 index 0000000000..b5edc6a9cf --- /dev/null +++ b/prover-stats-api/internal/logic/prover_task_test.go @@ -0,0 +1,94 @@ +package logic + +import ( + "context" + "math/big" + "scroll-tech/common/database" + "scroll-tech/common/docker" + "scroll-tech/common/types" + "scroll-tech/database/migrate" + "testing" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "gorm.io/gorm" + + "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.RollerAssigned), + Reward: decimal.NewFromInt(10), + } + + task2 = orm.ProverTask{ + TaskID: "2", + ProverPublicKey: proverPubkey, + ProverName: "prover-1", + ProvingStatus: int16(types.RollerAssigned), + 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.SetProverTask(context.Background(), &task1) + assert.NoError(t, err) + + err = ptdb.SetProverTask(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 new file mode 100644 index 0000000000..979876f0db --- /dev/null +++ b/prover-stats-api/internal/middleware/jwt.go @@ -0,0 +1,69 @@ +package middleware + +import ( + "errors" + "time" + + jwt "github.com/appleboy/gin-jwt/v2" + "github.com/gin-gonic/gin" + + "github.com/scroll-tech/go-ethereum/log" + + "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) + types.RenderJSON(c, code, err, nil) +} + +// 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 new file mode 100644 index 0000000000..5d6b2316d8 --- /dev/null +++ b/prover-stats-api/internal/orm/orm_test.go @@ -0,0 +1,118 @@ +package orm + +import ( + "context" + "math/big" + "testing" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "gorm.io/gorm" + + "scroll-tech/common/database" + "scroll-tech/common/docker" + "scroll-tech/common/types" + + "scroll-tech/database/migrate" +) + +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{ + TaskID: "test-hash", + ProverName: "roller-0", + ProverPublicKey: "0", + ProvingStatus: int16(types.RollerAssigned), + Reward: decimal.NewFromBigInt(reward, 0), + } + + err = proverTaskOrm.SetProverTask(context.Background(), &proverTask) + assert.NoError(t, err) + getTask, err := proverTaskOrm.GetProverTasksByHash(context.Background(), "test-hash") + assert.NoError(t, err) + assert.Equal(t, proverTask.ProverName, getTask.ProverName) + + // test decimal reward, get reward + resultReward := getTask.Reward.BigInt() + assert.Equal(t, resultReward, reward) + assert.Equal(t, resultReward.String(), "18446744073709551616") + + proverTask.ProvingStatus = int16(types.RollerProofValid) + err = proverTaskOrm.SetProverTask(context.Background(), &proverTask) + assert.NoError(t, err) + getTask, err = proverTaskOrm.GetProverTasksByHash(context.Background(), "test-hash") + assert.NoError(t, err) + assert.Equal(t, proverTask.ProvingStatus, getTask.ProvingStatus) +} + +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{ + TaskID: "test-hash", + ProverName: "roller-0", + ProverPublicKey: "0", + ProvingStatus: int16(types.RollerAssigned), + Reward: decimal.NewFromBigInt(rewardUint256, 0), + } + + err = proverTaskOrm.SetProverTask(context.Background(), &proverTask) + assert.NoError(t, err) + proverTasksUint256, err := proverTaskOrm.GetProverTasksByHash(context.Background(), "test-hash") + assert.NoError(t, err) + resultRewardUint256 := proverTasksUint256.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 new file mode 100644 index 0000000000..22495e8613 --- /dev/null +++ b/prover-stats-api/internal/orm/prover_task.go @@ -0,0 +1,99 @@ +package orm + +import ( + "context" + "fmt" + "math/big" + "time" + + "gorm.io/gorm/clause" + + "github.com/shopspring/decimal" + "gorm.io/gorm" +) + +// ProverTask is assigned rollers info of chunk/batch proof prover task +type ProverTask struct { + db *gorm.DB `gorm:"column:-"` + + ID int64 `json:"id" gorm:"column:id"` + TaskID string `json:"task_id" gorm:"column:task_id"` + ProverPublicKey string `json:"prover_public_key" gorm:"column:prover_public_key"` + ProverName string `json:"prover_name" gorm:"column:prover_name"` + TaskType int16 `json:"task_type" gorm:"column:task_type;default:0"` + 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"` + 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 +} + +// SetProverTask updates or inserts a ProverTask record. +func (o *ProverTask) SetProverTask(ctx context.Context, proverTask *ProverTask) error { + db := o.db.WithContext(ctx) + db = db.Model(&ProverTask{}) + db = db.Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "task_type"}, {Name: "task_id"}, {Name: "prover_public_key"}}, + DoUpdates: clause.AssignmentColumns([]string{"proving_status"}), + }) + + if err := db.Create(&proverTask).Error; err != nil { + return fmt.Errorf("ProverTask.SetProverTask 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 new file mode 100644 index 0000000000..c10d442b32 --- /dev/null +++ b/prover-stats-api/internal/route/route.go @@ -0,0 +1,35 @@ +package route + +import ( + "github.com/gin-gonic/gin" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" + + "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) { + router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + + 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 new file mode 100644 index 0000000000..79a036783c --- /dev/null +++ b/prover-stats-api/internal/types/auth.go @@ -0,0 +1,14 @@ +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/errno.go b/prover-stats-api/internal/types/errno.go new file mode 100644 index 0000000000..62a0de888d --- /dev/null +++ b/prover-stats-api/internal/types/errno.go @@ -0,0 +1,12 @@ +package types + +const ( + // Success shows OK. + Success = 200 + // ErrParameterInvalidNo is invalid params + ErrParameterInvalidNo = 10001 + // ErrProverTaskFailure is getting prover task error + ErrProverTaskFailure = 10002 + // ErrProverTotalRewardFailure is getting total rewards error + ErrProverTotalRewardFailure = 10003 +) diff --git a/prover-stats-api/internal/types/prover_task.go b/prover-stats-api/internal/types/prover_task.go new file mode 100644 index 0000000000..bfa372b03c --- /dev/null +++ b/prover-stats-api/internal/types/prover_task.go @@ -0,0 +1,36 @@ +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/internal/types/response.go b/prover-stats-api/internal/types/response.go new file mode 100644 index 0000000000..61a69b1f8d --- /dev/null +++ b/prover-stats-api/internal/types/response.go @@ -0,0 +1,28 @@ +package types + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +// Response the response schema +type Response struct { + ErrCode int `json:"errcode"` + ErrMsg string `json:"errmsg"` + Data interface{} `json:"data"` +} + +// RenderJSON renders response with json +func RenderJSON(ctx *gin.Context, errCode int, err error, data interface{}) { + var errMsg string + if err != nil { + errMsg = err.Error() + } + renderData := Response{ + ErrCode: errCode, + ErrMsg: errMsg, + Data: data, + } + ctx.JSON(http.StatusOK, renderData) +} diff --git a/prover-stats-api/test/prover_task_test.go b/prover-stats-api/test/prover_task_test.go new file mode 100644 index 0000000000..e88f9c8d82 --- /dev/null +++ b/prover-stats-api/test/prover_task_test.go @@ -0,0 +1,150 @@ +package test + +import ( + "context" + "encoding/json" + "fmt" + "io" + "math/big" + "net/http" + "scroll-tech/common/database" + "scroll-tech/common/docker" + "scroll-tech/common/types" + "scroll-tech/database/migrate" + + "github.com/gin-gonic/gin" + + "testing" + + "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" + api_types "scroll-tech/prover-stats-api/internal/types" + + "github.com/shopspring/decimal" + "github.com/stretchr/testify/assert" + "gorm.io/gorm" +) + +var ( + proverPubkey = "11111" +) + +var ( + port = ":12990" + addr = fmt.Sprintf("http://localhost%s", port) + basicPath = fmt.Sprintf("%s/api/prover_task/v1", addr) + token string +) + +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 + router := gin.Default() + controller.InitController(db) + route.Route(router, cfg) + go func() { + router.Run(port) + }() + + 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(api_types.Response) + assert.NoError(t, json.Unmarshal(byt, res)) + t.Log("----byt is ", string(byt)) + assert.Equal(t, api_types.Success, res.ErrCode) + return res.Data +} + +var ( + task1 = orm.ProverTask{ + TaskID: "1", + ProverPublicKey: proverPubkey, + ProverName: "prover-0", + ProvingStatus: int16(types.RollerAssigned), + Reward: decimal.NewFromInt(10), + } + + task2 = orm.ProverTask{ + TaskID: "2", + ProverPublicKey: proverPubkey, + ProverName: "prover-1", + ProvingStatus: int16(types.RollerAssigned), + 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.SetProverTask(context.Background(), &task1) + assert.NoError(t, err) + + err = ptdb.SetProverTask(context.Background(), &task2) + assert.NoError(t, err) +}