From 0a4e1d1ef96cecb53fdc66450429bdce661a5ef9 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Fri, 27 Sep 2024 13:07:18 +0300 Subject: [PATCH] cli: add upload-bin This command is used for keeping container with blocks for blockfetcher updated. Close #3578 Signed-off-by: Ekaterina Pavlova README: add archival notice (#520) People are likely to find this repo and we better have some directions for them. Signed-off-by: Roman Khimov Signed-off-by: Ekaterina Pavlova --- cli/util/convert.go | 53 +++++ cli/util/uploader.go | 432 +++++++++++++++++++++++++++++++++++++++++ go.sum | 63 ++++++ pkg/vm/testdata/neo-vm | 2 +- 4 files changed, 549 insertions(+), 1 deletion(-) create mode 100644 cli/util/uploader.go diff --git a/cli/util/convert.go b/cli/util/convert.go index 26c520877a..23959a533b 100644 --- a/cli/util/convert.go +++ b/cli/util/convert.go @@ -6,6 +6,7 @@ import ( "fmt" "os" + "github.com/nspcc-dev/neo-go/cli/cmdargs" "github.com/nspcc-dev/neo-go/cli/flags" "github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/cli/txctx" @@ -32,6 +33,51 @@ func NewCommands() []*cli.Command { txctx.AwaitFlag, }, options.RPC...) txCancelFlags = append(txCancelFlags, options.Wallet...) + uploadBinFlags := append([]cli.Flag{ + &cli.StringSliceFlag{ + Name: "fs-rpc-endpoint", + Aliases: []string{"fsr"}, + Usage: "List of NeoFS storage node RPC addresses (comma-separated or multiple --fs-rpc-endpoint flags)", + Required: true, + Action: func(ctx *cli.Context, fsRpcEndpoints []string) error { + for _, endpoint := range fsRpcEndpoints { + if endpoint == "" { + return cli.Exit("NeoFS RPC endpoint cannot contain empty values", 1) + } + } + return nil + }, + }, + &cli.StringFlag{ + Name: "container", + Aliases: []string{"cid"}, + Usage: "NeoFS container ID to upload blocks to", + Required: true, + Action: cmdargs.EnsureNotEmpty("container"), + }, + &cli.StringFlag{ + Name: "block-attribute", + Usage: "Attribute key of the block object", + Required: true, + Action: cmdargs.EnsureNotEmpty("block-attribute"), + }, + &cli.StringFlag{ + Name: "index-attribute", + Usage: "Attribute key of the index file object", + Required: true, + Action: cmdargs.EnsureNotEmpty("index-attribute"), + }, + &flags.AddressFlag{ + Name: "address", + Usage: "Address to use for signing the uploading and searching transactions in NeoFS", + }, + &cli.UintFlag{ + Name: "index-file-size", + Usage: "Size of index file", + Value: 128000, + }, + }, options.RPC...) + uploadBinFlags = append(uploadBinFlags, options.Wallet...) return []*cli.Command{ { Name: "util", @@ -109,6 +155,13 @@ func NewCommands() []*cli.Command { }, }, }, + { + Name: "upload-bin", + Usage: "Fetch blocks from RPC node and upload them to the NeoFS container", + UsageText: "neo-go util upload-bin --fs-rpc-endpoint [,[...]] --container --block-attribute block --index-attribute index --rpc-endpoint [--timeout