Skip to content

Commit

Permalink
Merge branch 'master' into eth-invoke-expression-tx
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov authored Feb 7, 2022
2 parents db9cf6f + 3dfbf51 commit 7a86bca
Show file tree
Hide file tree
Showing 23 changed files with 527 additions and 53 deletions.
40 changes: 20 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ build-retransmitter-windows:
release-retransmitter: ver build-retransmitter-linux build-retransmitter-darwin build-retransmitter-windows

build-node-linux:
@GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/node ./cmd/node
@GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/node -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/node
build-node-linux-arm:
@GOOS=linux GOARCH=arm go build -o build/bin/linux-arm/node ./cmd/node
@GOOS=linux GOARCH=arm go build -o build/bin/linux-arm/node -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/node
build-node-linux-i386:
@GOOS=linux GOARCH=386 go build -o build/bin/linux-i386/node ./cmd/node
@GOOS=linux GOARCH=386 go build -o build/bin/linux-i386/node -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/node
build-node-darwin:
@GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/node ./cmd/node
@GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/node -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/node
build-node-windows:
@GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/node.exe ./cmd/node
@GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/node.exe -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/node

release-node: ver build-node-linux build-node-linux-arm build-node-linux-i386 build-node-darwin build-node-windows

Expand All @@ -119,11 +119,11 @@ dist-node: release-node build-node-mainnet-deb-package build-node-testnet-deb-pa
@cd ./build/bin/darwin-amd64/; tar pzcvf ../../dist/node_$(VERSION)_macOS-64bit.tar.gz ./node*

build-custom-linux:
@CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/custom ./cmd/custom
@CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/custom -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/custom
build-custom-darwin:
@CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/custom ./cmd/custom
@CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/custom -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/custom
build-custom-windows:
@CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/custom.exe ./cmd/custom
@CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/custom.exe -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/custom

build-custom: ver build-custom-linux build-custom-darwin build-custom-windows

Expand All @@ -132,11 +132,11 @@ build-docker:
date "+%Y-%m-%d %H:%M:%S"

build-importer-linux:
@CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/importer ./cmd/importer
@CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/importer -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/importer
build-importer-darwin:
@CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/importer ./cmd/importer
@CGO_ENABLE=0 GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/importer -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/importer
build-importer-windows:
@CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/importer.exe ./cmd/importer
@CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/importer.exe -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/importer

release-importer: ver build-importer-linux build-importer-darwin build-importer-windows

Expand All @@ -155,21 +155,21 @@ build-wallet-windows:

release-wallet: ver build-wallet-linux build-wallet-darwin build-wallet-windows

build-rollback-linux:
@GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/rollback ./cmd/rollback
build-rollback-darwin:
@GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/rollback ./cmd/rollback
build-rollback-windows:
@GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/rollback.exe ./cmd/rollback

release-rollback: ver build-rollback-linux build-rollback-darwin build-rollback-windows

dist-wallet: release-wallet
@mkdir -p build/dist
@cd ./build/; zip -j ./dist/wallet_$(VERSION)_Windows-64bit.zip ./bin/windows-amd64/wallet*
@cd ./build/bin/linux-amd64/; tar pzcvf ../../dist/wallet_$(VERSION)_Linux-64bit.tar.gz ./wallet*
@cd ./build/bin/darwin-amd64/; tar pzcvf ../../dist/wallet_$(VERSION)_macOS-64bit.tar.gz ./wallet*

build-rollback-linux:
@GOOS=linux GOARCH=amd64 go build -o build/bin/linux-amd64/rollback -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/rollback
build-rollback-darwin:
@GOOS=darwin GOARCH=amd64 go build -o build/bin/darwin-amd64/rollback -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/rollback
build-rollback-windows:
@GOOS=windows GOARCH=amd64 go build -o build/bin/windows-amd64/rollback.exe -ldflags="-X 'github.com/wavesplatform/gowaves/pkg/versioning.Version=$(VERSION)'" ./cmd/rollback

release-rollback: ver build-rollback-linux build-rollback-darwin build-rollback-windows

dist: clean dist-chaincmp dist-wmd dist-importer dist-node dist-wallet


Expand Down
6 changes: 4 additions & 2 deletions cmd/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/wavesplatform/gowaves/pkg/state"
"github.com/wavesplatform/gowaves/pkg/util/common"
"github.com/wavesplatform/gowaves/pkg/util/fdlimit"
"github.com/wavesplatform/gowaves/pkg/versioning"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -42,6 +43,9 @@ var (
func main() {
flag.Parse()

common.SetupLogger(*logLevel)
zap.S().Infof("Gowaves Importer version: %s", versioning.Version)

maxFDs, err := fdlimit.MaxFDs()
if err != nil {
zap.S().Fatalf("Initialization error: %v", err)
Expand All @@ -51,8 +55,6 @@ func main() {
zap.S().Fatalf("Initialization error: %v", err)
}

common.SetupLogger(*logLevel)

if *blockchainPath == "" {
zap.S().Fatalf("You must specify blockchain-path option.")
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ import (
"github.com/wavesplatform/gowaves/pkg/types"
"github.com/wavesplatform/gowaves/pkg/util/common"
"github.com/wavesplatform/gowaves/pkg/util/fdlimit"
"github.com/wavesplatform/gowaves/pkg/versioning"
"github.com/wavesplatform/gowaves/pkg/wallet"
"go.uber.org/zap"
)

var version = proto.Version{Major: 1, Minor: 3, Patch: 0}
var protocolVersion = proto.Version{Major: 1, Minor: 3, Patch: 0}

const (
maxTransactionTimeForwardOffset = 300 // seconds
Expand Down Expand Up @@ -142,6 +143,8 @@ func main() {
flag.Parse()
common.SetupLogger(*logLevel)

zap.S().Infof("Gowaves Node version: %s", versioning.Version)

maxFDs, err := fdlimit.MaxFDs()
if err != nil {
zap.S().Fatalf("Initialization failure: %v", err)
Expand Down Expand Up @@ -318,7 +321,7 @@ func main() {
cancel()
return
}
peerSpawnerImpl := peer_manager.NewPeerSpawner(parent, conf.WavesNetwork, declAddr, *nodeName, nodeNonce.Uint64(), version)
peerSpawnerImpl := peer_manager.NewPeerSpawner(parent, conf.WavesNetwork, declAddr, *nodeName, nodeNonce.Uint64(), protocolVersion)
peerStorage, err := peersPersistentStorage.NewCBORStorage(*statePath, time.Now())
if err != nil {
zap.S().Errorf("Failed to open or create peers storage: %v", err)
Expand All @@ -341,7 +344,7 @@ func main() {
peerSpawnerImpl,
peerStorage,
int(*limitAllConnections/2),
version,
protocolVersion,
conf.WavesNetwork,
!*disableOutgoingConnections,
*newConnectionsLimit,
Expand Down
6 changes: 4 additions & 2 deletions cmd/rollback/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/wavesplatform/gowaves/pkg/state"
"github.com/wavesplatform/gowaves/pkg/util/common"
"github.com/wavesplatform/gowaves/pkg/util/fdlimit"
"github.com/wavesplatform/gowaves/pkg/versioning"
"go.uber.org/zap"
)

Expand All @@ -22,6 +23,9 @@ var (
func main() {
flag.Parse()

common.SetupLogger(*logLevel)
zap.S().Infof("Gowaves Rollback version: %s", versioning.Version)

maxFDs, err := fdlimit.MaxFDs()
if err != nil {
zap.S().Fatalf("Initialization error: %v", err)
Expand All @@ -31,8 +35,6 @@ func main() {
zap.S().Fatalf("Initialization error: %v", err)
}

common.SetupLogger(*logLevel)

cfg, err := settings.BlockchainSettingsByTypeName(*blockchainType)
if err != nil {
zap.S().Error(err)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ require (
github.com/mr-tron/base58 v1.2.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.0
github.com/prometheus/client_golang v1.12.1
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c
github.com/semrush/zenrpc/v2 v2.1.1
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.8.0
github.com/spf13/afero v1.8.1
github.com/spf13/pflag v1.0.5
github.com/starius/emsort v0.0.0-20191221202443-6f2fbdee4781
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg=
github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -387,8 +387,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.8.0 h1:5MmtuhAgYeU6qpa7w7bP0dv6MBYuup0vekhSpSkoq60=
github.com/spf13/afero v1.8.0/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/afero v1.8.1 h1:izYHOT71f9iZ7iq37Uqjael60/vYC6vMtzedudZ0zEk=
github.com/spf13/afero v1.8.1/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/starius/emsort v0.0.0-20191221202443-6f2fbdee4781 h1:RH1x1ojC87qoqoYDf+LT+gqlATL1ULIcLN7ldhHq3U0=
Expand Down
14 changes: 14 additions & 0 deletions pkg/api/app_node.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
package api

import (
"fmt"

"github.com/wavesplatform/gowaves/pkg/versioning"
)

type nodeVersion struct {
Version string `json:"version"`
}

func (a *App) version() nodeVersion {
return nodeVersion{Version: fmt.Sprintf("Gowaves %s", versioning.Version)}
}

func (a *App) NodeProcesses() map[string]int {
return a.services.LoggableRunner.Running()
}
8 changes: 8 additions & 0 deletions pkg/api/node_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ func (a *NodeApi) EthereumDAppABI(w http.ResponseWriter, r *http.Request) error
return nil
}

func (a *NodeApi) version(w http.ResponseWriter, _ *http.Request) error {
rs := a.app.version()
if err := trySendJson(w, rs); err != nil {
return errors.Wrap(err, "Version")
}
return nil
}

// tryParseJson receives reader and out params. out MUST be a pointer
func tryParseJson(r io.Reader, out interface{}) error {
// TODO(nickeskov): check empty reader
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func (a *NodeApi) routes(opts *RunOptions) (chi.Router, error) {
r.Route("/debug", func(r chi.Router) {
r.Get("/stateHash/{height:\\d+}", wrapper(a.stateHash))
})
r.Route("/node", func(r chi.Router) {
r.Get("/version", wrapper(a.version))
})
r.Route("/eth", func(r chi.Router) {
r.Get("/abi/{address}", wrapper(a.EthereumDAppABI))
})
Expand Down
37 changes: 28 additions & 9 deletions pkg/crypto/groth16.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ type Bn256 struct{}

type Dummy struct{}

const (
sizeUint64 = 8
lenOneFrElement = 4
frReprSize = sizeUint64 * lenOneFrElement
)

func ReadInputs(inputs []byte) ([]*big.Int, error) {
var result []*big.Int
const sizeUint64 = 8
const lenOneFrElement = 4

if len(inputs)%32 != 0 {
if len(inputs)%frReprSize != 0 {
return nil, errors.New("inputs should be % 32 = 0")
}

lenFrElements := len(inputs) / 32
frReprSize := sizeUint64 * lenOneFrElement

var currentOffset int
var oldOffSet int

var (
currentOffset int
oldOffSet int
lenFrElements = len(inputs) / frReprSize
)
// Appending every 32 bytes [0..32], [32..64], ...
for i := 0; i < lenFrElements; i++ {
currentOffset += frReprSize
Expand All @@ -42,6 +45,22 @@ func ReadInputs(inputs []byte) ([]*big.Int, error) {
return result, nil
}

func SerializeInputs(inputs []*big.Int) []byte {
if len(inputs) == 0 {
return nil
}

out := make([]byte, frReprSize*len(inputs))

outInput := out[:0]
for _, input := range inputs {
outInput = outInput[:frReprSize]
input.FillBytes(outInput)
outInput = outInput[frReprSize:]
}
return out
}

func (Bls12381) Groth16Verify(vk []byte, proof []byte, inputs []byte) (bool, error) {
if len(vk)%48 != 0 {
return false, errors.New("invalid vk length, should be multiple of 48")
Expand Down
Loading

0 comments on commit 7a86bca

Please sign in to comment.