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 fix_additional_settings_for_config
  • Loading branch information
irina-pereiaslavskaia committed Nov 2, 2024
2 parents 2720523 + ee55592 commit 7aac274
Show file tree
Hide file tree
Showing 37 changed files with 708 additions and 559 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
* text eol=lf
* text=auto eol=lf

# Windows .bat files are known to have multiple bugs when run with LF
# endings, and so they are checked in with CRLF endings.
*.bat text eol=crlf
*.cmd text eol=crlf
importer.pgo -text
pkg/state/testdata/blocks-10000 -text
6 changes: 5 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
schedule:
- cron: '15 12 * * 3'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'workflow_dispatch' }}

jobs:
analyze:
name: Analyze
Expand All @@ -42,7 +46,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: build
on: [ push, pull_request, workflow_dispatch ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'workflow_dispatch' }}

jobs:
golangci:
name: lint
Expand All @@ -16,7 +20,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand All @@ -39,7 +43,7 @@ jobs:

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down Expand Up @@ -75,7 +79,7 @@ jobs:

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
types: [ submitted ]
branches: [ master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'workflow_dispatch' }}

jobs:
itest:
name: integration_tests
Expand All @@ -15,7 +19,7 @@ jobs:

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/itests_race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
schedule:
- cron: '30 12 * * 3'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && github.event_name != 'workflow_dispatch' }}

jobs:
gosec:
name: gosec check
Expand Down Expand Up @@ -65,7 +69,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5.0.2
uses: actions/setup-go@v5.1.0
with:
go-version: 1.22.x
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ build-node-windows-amd64:

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

dist-node: release-node build-node-mainnet-amd64-deb-package build-node-testnet-amd64-deb-package build-node-testnet-arm64-deb-package build-node-stagenet-amd64-deb-package build-node-stagenet-arm64-deb-package
dist-node: release-node build-node-mainnet-amd64-deb-package build-node-mainnet-arm64-deb-package build-node-testnet-amd64-deb-package build-node-testnet-arm64-deb-package build-node-stagenet-amd64-deb-package build-node-stagenet-arm64-deb-package
@mkdir -p build/dist
@cd ./build/; zip -j ./dist/node_$(VERSION)_Windows-amd64.zip ./bin/windows-amd64/node*
@cd ./build/bin/linux-amd64/; tar pzcvf ../../dist/node_$(VERSION)_Linux-amd64.tar.gz ./node*
Expand Down
18 changes: 11 additions & 7 deletions cmd/convert/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ type config struct {
toJSON bool
toBinary bool
base64 bool
validate bool
}

func (c *config) parse() error {
var (
scheme, privateKey, in, out string
)
flag.StringVar(&scheme, "scheme", "W", "Network scheme byte. Defaults to 'W' (MainNet).")
flag.StringVar(&scheme, "scheme", "W", "Specifies the network scheme byte. Defaults to 'W' (MainNet).")
flag.BoolVar(&c.toJSON, "to-json", false,
"Convert the transaction to JSON representation. Sign the transaction if a private key is provided.")
"Converts the transaction to JSON format. Signs the transaction if a private key is provided.")
flag.BoolVar(&c.toBinary, "to-binary", false,
"Convert the transaction to binary representation. Sign the transaction if a private key is provided.")
flag.BoolVar(&c.base64, "base64", false, "Use Base64 as the binary transaction encoding.")
"Converts the transaction to binary format. Signs the transaction if a private key is provided.")
flag.BoolVar(&c.base64, "base64", false, "Encodes the binary transaction in Base64.")
flag.StringVar(&privateKey, "private-key", "",
"Private key to sign the transaction. Please provide the key in Base58 string.")
flag.StringVar(&in, "in", "", "Input file path. Defaults to empty string. If empty, reads from STDIN.")
flag.StringVar(&out, "out", "", "Output file path. Defaults to empty string. If empty, writes to STDOUT.")
"Private key for signing the transaction. Provide the key as a Base58 string.")
flag.StringVar(&in, "in", "",
"Specifies the input file path. Defaults to an empty string. If empty, reads from STDIN.")
flag.StringVar(&out, "out", "",
"Specifies the output file path. Defaults to an empty string. If empty, writes to STDOUT.")
flag.BoolVar(&c.validate, "validate", false, "Validates the transaction after deserialization.")
flag.Parse()

if len(scheme) != 1 {
Expand Down
11 changes: 11 additions & 0 deletions cmd/convert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ func handleJSON(data []byte, cfg config) error {
if rErr != nil {
return rErr
}

if cfg.validate {
vp := proto.TransactionValidationParams{
Scheme: cfg.scheme,
CheckVersion: true,
}
_, err := tx.Validate(vp)
if err != nil {
return err
}
}
tx, sErr := sign(tx, cfg)
if sErr != nil {
return sErr
Expand Down
43 changes: 26 additions & 17 deletions cmd/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,26 @@ const (
)

func main() {
err := run()
os.Exit(realMain()) // for more info see https://github.com/golang/go/issues/42078
}

func realMain() int {
c := parseFlags()

logSync := c.setupLogger()
defer logSync()

if err := c.validateFlags(); err != nil {
zap.S().Error(capitalize(err.Error()))
return 1
}

err := runImporter(&c)
if err != nil {
zap.S().Error(capitalize(err.Error()))
os.Exit(1)
return 1
}
return 0
}

type cfg struct {
Expand All @@ -58,7 +73,7 @@ type cfg struct {
disableBloomFilter bool
}

func parseFlags() (cfg, error) {
func parseFlags() cfg {
const (
defaultBlocksNumber = 1000
defaultBufferSize = 16
Expand Down Expand Up @@ -92,18 +107,20 @@ func parseFlags() (cfg, error) {
flag.BoolVar(&c.disableBloomFilter, "disable-bloom", false,
"Disable bloom filter. Less memory usage, but decrease performance.")
flag.Parse()
return c
}

func (c *cfg) validateFlags() error {
if c.blockchainPath == "" {
return cfg{}, errors.New("option blockchain-path is not specified, please specify it")
return errors.New("option blockchain-path is not specified, please specify it")
}
if c.dataDirPath == "" {
return cfg{}, errors.New("option data-path is not specified, please specify it")
return errors.New("option data-path is not specified, please specify it")
}
if c.lightNodeMode && c.snapshotsPath == "" {
return cfg{}, errors.New("option snapshots-path is not specified in light mode, please specify it")
return errors.New("option snapshots-path is not specified in light mode, please specify it")
}

return c, nil
return nil
}

func (c *cfg) params(maxFDs int) state.StateParams {
Expand Down Expand Up @@ -147,15 +164,7 @@ func (c *cfg) setupCPUProfile() (func(), error) {
}, nil
}

func run() error {
c, err := parseFlags()
if err != nil {
return err
}

logSync := c.setupLogger()
defer logSync()

func runImporter(c *cfg) error {
zap.S().Infof("Gowaves Importer version: %s", versioning.Version)

fds, err := riseFDLimit()
Expand Down
Loading

0 comments on commit 7aac274

Please sign in to comment.