Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wavesplatform/gowaves int…
Browse files Browse the repository at this point in the history
…o smoke_test_suite
  • Loading branch information
irina-pereiaslavskaia committed Dec 21, 2023
2 parents 18b3399 + 1421423 commit f8262f3
Show file tree
Hide file tree
Showing 42 changed files with 1,530 additions and 300 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
32 changes: 0 additions & 32 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,3 @@ jobs:
file: ./coverage.txt
flags: unittests
yml: ./codecov.yml

itest:
name: integration_tests
runs-on: self-hosted
if: github.event_name == 'pull_request' && github.repository == 'wavesplatform/gowaves'

steps:
- name: Set up Go 1.20
uses: actions/setup-go@v5.0.0
with:
go-version: 1.20.x
check-latest: true
cache: true
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Get dependencies
run: go mod vendor

- name: Tests
run: make itest

- name: Upload itest logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: itest_logs
path: build/logs/
if-no-files-found: warn
retention-days: 5
41 changes: 41 additions & 0 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "ITests"
on:
workflow_dispatch:
pull_request_review:
types: [ submitted ]
branches: [ master ]

jobs:
itest:
name: integration_tests
runs-on: self-hosted
environment:
name: ITests
if: (github.event_name == 'workflow_dispatch' || github.event.review.state == 'APPROVED') && github.repository == 'wavesplatform/gowaves'

steps:
- name: Set up Go 1.20
uses: actions/setup-go@v5.0.0
with:
go-version: 1.20.x
check-latest: true
cache: true
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Get dependencies
run: go mod vendor

- name: Tests
run: make itest

- name: Upload itest logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: itest_logs
path: build/logs/
if-no-files-found: warn
retention-days: 5
4 changes: 2 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
# with '-no-fail' we let the report trigger content trigger a failure using the GitHub Security features.
args: "-no-fail -fmt sarif -out gosec.sarif ./..."
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: gosec.sarif

Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
fi
EOF
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: semgrep.sarif

Expand Down
8 changes: 4 additions & 4 deletions cmd/statehash/statehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func run() error {
zap.S().Errorf("Failed to get remote state hash at height 1: %v", err)
return err
}
lsh, err := st.StateHashAtHeight(1)
lsh, err := st.LegacyStateHashAtHeight(1)
if err != nil {
zap.S().Errorf("Failed to get local state hash at 1: %v", err)
return err
Expand All @@ -156,7 +156,7 @@ func run() error {
}
height = h
}
lsh, err := st.StateHashAtHeight(height)
lsh, err := st.LegacyStateHashAtHeight(height)
if err != nil {
zap.S().Errorf("Failed to get state hash at %d: %v", height, err)
return err
Expand All @@ -178,7 +178,7 @@ func run() error {
return err
}
zap.S().Infof("State hashes are equal at height %d", h)
lsh, err = st.StateHashAtHeight(h + 1)
lsh, err = st.LegacyStateHashAtHeight(h + 1)
if err != nil {
zap.S().Errorf("Failed to get state hash at %d: %v", h+1, err)
return err
Expand All @@ -205,7 +205,7 @@ func findLastEqualStateHashes(c *client.Client, st state.State, stop uint64) (ui
var start uint64 = 1
for start <= stop {
middle := (start + stop) / 2
lsh, err = st.StateHashAtHeight(middle)
lsh, err = st.LegacyStateHashAtHeight(middle)
if err != nil {
return middle, err
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ require (
github.com/xenolf/lego v2.7.2+incompatible
go.uber.org/atomic v1.11.0
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.16.0
golang.org/x/crypto v0.17.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/sync v0.5.0
golang.org/x/sys v0.15.0
google.golang.org/grpc v1.60.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
moul.io/zapfilter v1.7.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down Expand Up @@ -472,8 +472,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc=
google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k=
google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/metamask/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ func (s RPCService) Eth_EstimateGas(req estimateGasRequest) (string, error) {
}
}

txKind, err := proto.GuessEthereumTransactionKind(data)
txKind, err := proto.GuessEthereumTransactionKindType(data)
if err != nil {
return "", errors.Errorf("failed to guess ethereum tx kind, %v", err)
}
switch txKind {
case proto.EthereumTransferWavesKind:
case proto.EthereumTransferWavesKindType:
return uint64ToHexString(proto.MinFee), nil
case proto.EthereumTransferAssetsKind:
case proto.EthereumTransferAssetsKindType:
fee := proto.MinFee
assetID := (*proto.AssetID)(req.To)

Expand All @@ -191,7 +191,7 @@ func (s RPCService) Eth_EstimateGas(req estimateGasRequest) (string, error) {
fee += proto.MinFeeScriptedAsset
}
return uint64ToHexString(uint64(fee)), nil
case proto.EthereumInvokeKind:
case proto.EthereumInvokeKindType:
return uint64ToHexString(proto.MinFeeInvokeScript), nil
default:
return "", errors.Errorf("unexpected ethereum tx kind")
Expand Down
25 changes: 24 additions & 1 deletion pkg/api/node_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func (a *NodeApi) nodeProcesses(w http.ResponseWriter, _ *http.Request) error {
}

func (a *NodeApi) stateHashDebug(height proto.Height) (*proto.StateHashDebug, error) {
stateHash, err := a.state.StateHashAtHeight(height)
stateHash, err := a.state.LegacyStateHashAtHeight(height)
if err != nil {
return nil, errors.Wrapf(err, "failed to get state hash at height %d", height)
}
Expand Down Expand Up @@ -805,6 +805,29 @@ func (a *NodeApi) stateHashLast(w http.ResponseWriter, _ *http.Request) error {
return nil
}

func (a *NodeApi) snapshotStateHash(w http.ResponseWriter, r *http.Request) error {
s := chi.URLParam(r, "height")
height, err := strconv.ParseUint(s, 10, 64)
if err != nil {
// TODO(nickeskov): which error it should send?
return &BadRequestError{err}
}
sh, err := a.state.SnapshotStateHashAtHeight(height)
if err != nil {
if state.IsNotFound(err) {
return apiErrs.BlockDoesNotExist
}
return errors.Wrapf(err, "failed to get snapshot state hash at height %d", height)
}
type out struct {
StateHash proto.HexBytes `json:"stateHash"`
}
if sendErr := trySendJson(w, out{StateHash: sh.Bytes()}); sendErr != nil {
return errors.Wrap(sendErr, "snapshotStateHash")
}
return nil
}

func wavesAddressInvalidCharErr(invalidChar rune, id string) *apiErrs.CustomValidationError {
return apiErrs.NewCustomValidationError(
fmt.Sprintf(
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"github.com/go-chi/chi/middleware"
"github.com/pkg/errors"
"github.com/semrush/zenrpc/v2"
"github.com/wavesplatform/gowaves/pkg/api/metamask"
"go.uber.org/zap"

"github.com/wavesplatform/gowaves/pkg/api/metamask"
)

type HandleErrorFunc func(w http.ResponseWriter, r *http.Request, err error)
Expand Down Expand Up @@ -88,6 +89,9 @@ func (a *NodeApi) routes(opts *RunOptions) (chi.Router, error) {

rAuth.Post("/load", wrapper(WalletLoadKeys(a.app)))
})
r.Route("/debug", func(r chi.Router) {
r.Get("/snapshotStateHash/{height:\\d+}", wrapper(a.snapshotStateHash))
})

r.Get("/miner/info", wrapper(a.GoMinerInfo))
r.Get("/node/processes", wrapper(a.nodeProcesses))
Expand Down
Loading

0 comments on commit f8262f3

Please sign in to comment.