diff --git a/CHANGELOG.md b/CHANGELOG.md index 149197963c..7f0ab12dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ attribute, which is used for container domain name in NNS contracts (#2954) - EACL is no longer considered for system role (#2972) - Deprecate peapod substorage (#3013) - Node does not stop trying to PUT an object if there are more PUT tasks than configured (#3027) +- `morph` configuration section renamed to `fschain` both in IR and SN (#3028) ### Removed - Support for node.key configuration (#2959) @@ -75,6 +76,10 @@ introduced in version 0.22.3 and support for binary keys was removed from other components in 0.33.0 and 0.37.0. Please migrate to wallets (see 0.37.0 notes) if you've not done it previously. +The section `morph` in the config has been renamed to `fschain`. This version +still supports the old section name, but this compatibility code will be removed +in the next release. Please rename `morph` to `fschain` in your configuration files. + To migrate data from Peapods to FSTree: ```shell $ peapod-to-fstree -config diff --git a/cmd/neofs-adm/internal/modules/morph/balance.go b/cmd/neofs-adm/internal/modules/fschain/balance.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/balance.go rename to cmd/neofs-adm/internal/modules/fschain/balance.go index 2eb876b52a..563d297053 100644 --- a/cmd/neofs-adm/internal/modules/morph/balance.go +++ b/cmd/neofs-adm/internal/modules/fschain/balance.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "crypto/elliptic" diff --git a/cmd/neofs-adm/internal/modules/morph/config.go b/cmd/neofs-adm/internal/modules/fschain/config.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/config.go rename to cmd/neofs-adm/internal/modules/fschain/config.go index 5f2105dfeb..d759e6bc5c 100644 --- a/cmd/neofs-adm/internal/modules/morph/config.go +++ b/cmd/neofs-adm/internal/modules/fschain/config.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "bytes" diff --git a/cmd/neofs-adm/internal/modules/morph/container.go b/cmd/neofs-adm/internal/modules/fschain/container.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/container.go rename to cmd/neofs-adm/internal/modules/fschain/container.go index 7c0437aa41..210eba495c 100644 --- a/cmd/neofs-adm/internal/modules/morph/container.go +++ b/cmd/neofs-adm/internal/modules/fschain/container.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "encoding/json" diff --git a/cmd/neofs-adm/internal/modules/morph/deploy.go b/cmd/neofs-adm/internal/modules/fschain/deploy.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/deploy.go rename to cmd/neofs-adm/internal/modules/fschain/deploy.go index 3b0af78761..cf36b419db 100644 --- a/cmd/neofs-adm/internal/modules/morph/deploy.go +++ b/cmd/neofs-adm/internal/modules/fschain/deploy.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "encoding/json" diff --git a/cmd/neofs-adm/internal/modules/morph/download.go b/cmd/neofs-adm/internal/modules/fschain/download.go similarity index 98% rename from cmd/neofs-adm/internal/modules/morph/download.go rename to cmd/neofs-adm/internal/modules/fschain/download.go index 25e04fe142..ce5632592f 100644 --- a/cmd/neofs-adm/internal/modules/morph/download.go +++ b/cmd/neofs-adm/internal/modules/fschain/download.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "context" diff --git a/cmd/neofs-adm/internal/modules/morph/dump_hashes.go b/cmd/neofs-adm/internal/modules/fschain/dump_hashes.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/dump_hashes.go rename to cmd/neofs-adm/internal/modules/fschain/dump_hashes.go index ebc5e31267..e72f1aa125 100644 --- a/cmd/neofs-adm/internal/modules/morph/dump_hashes.go +++ b/cmd/neofs-adm/internal/modules/fschain/dump_hashes.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "bytes" diff --git a/cmd/neofs-adm/internal/modules/morph/dump_names.go b/cmd/neofs-adm/internal/modules/fschain/dump_names.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/dump_names.go rename to cmd/neofs-adm/internal/modules/fschain/dump_names.go index eb3d110704..dc876515b5 100644 --- a/cmd/neofs-adm/internal/modules/morph/dump_names.go +++ b/cmd/neofs-adm/internal/modules/fschain/dump_names.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "bytes" diff --git a/cmd/neofs-adm/internal/modules/morph/epoch.go b/cmd/neofs-adm/internal/modules/fschain/epoch.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/epoch.go rename to cmd/neofs-adm/internal/modules/fschain/epoch.go index a10d011e20..7e27b09373 100644 --- a/cmd/neofs-adm/internal/modules/morph/epoch.go +++ b/cmd/neofs-adm/internal/modules/fschain/epoch.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/morph/estimation.go b/cmd/neofs-adm/internal/modules/fschain/estimation.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/estimation.go rename to cmd/neofs-adm/internal/modules/fschain/estimation.go index a75dad27c3..1c81696a08 100644 --- a/cmd/neofs-adm/internal/modules/morph/estimation.go +++ b/cmd/neofs-adm/internal/modules/fschain/estimation.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/generate.go b/cmd/neofs-adm/internal/modules/fschain/generate.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/generate.go rename to cmd/neofs-adm/internal/modules/fschain/generate.go index 1c421b6fe9..ed34422fac 100644 --- a/cmd/neofs-adm/internal/modules/morph/generate.go +++ b/cmd/neofs-adm/internal/modules/fschain/generate.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/morph/generate_test.go b/cmd/neofs-adm/internal/modules/fschain/generate_test.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/generate_test.go rename to cmd/neofs-adm/internal/modules/fschain/generate_test.go index 357f8b71ba..916e163348 100644 --- a/cmd/neofs-adm/internal/modules/morph/generate_test.go +++ b/cmd/neofs-adm/internal/modules/fschain/generate_test.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "bytes" diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/fschain/initialize.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/initialize.go rename to cmd/neofs-adm/internal/modules/fschain/initialize.go index ccc4704eda..aa9194d253 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" @@ -43,7 +43,7 @@ type initializeContext struct { ContractPath string } -func initializeSideChainCmd(cmd *cobra.Command, _ []string) error { +func initializeFSChainCmd(cmd *cobra.Command, _ []string) error { initCtx, err := newInitializeContext(cmd, viper.GetViper()) if err != nil { return fmt.Errorf("initialization error: %w", err) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/initialize_deploy.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go index b11b8a5e5d..a06080aefb 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_deploy.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "archive/tar" @@ -33,8 +33,8 @@ import ( const ( nnsContract = "nns" - neofsContract = "neofs" // not deployed in side-chain. - processingContract = "processing" // not deployed in side-chain. + neofsContract = "neofs" // not deployed in FS chain. + processingContract = "processing" // not deployed in FS chain. alphabetContract = "alphabet" auditContract = "audit" balanceContract = "balance" diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/fschain/initialize_nns.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/initialize_nns.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_nns.go index 0b8fb35fa2..734bff2a37 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_nns.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_register.go b/cmd/neofs-adm/internal/modules/fschain/initialize_register.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/initialize_register.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_register.go index 9b3f451c5b..b7ddca0ad7 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_register.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_register.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_roles.go b/cmd/neofs-adm/internal/modules/fschain/initialize_roles.go similarity index 98% rename from cmd/neofs-adm/internal/modules/morph/initialize_roles.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_roles.go index 112fb7f8ae..addfb75d3b 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_roles.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_roles.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "github.com/nspcc-dev/neo-go/pkg/core/native/noderoles" diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_test.go b/cmd/neofs-adm/internal/modules/fschain/initialize_test.go similarity index 97% rename from cmd/neofs-adm/internal/modules/morph/initialize_test.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_test.go index 1235ca3066..719ebfa48d 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_test.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "encoding/hex" @@ -51,7 +51,7 @@ func testInitialize(t *testing.T, committeeSize int) { v.Set(maxObjectSizeInitFlag, 1024) setTestCredentials(v, committeeSize) - require.NoError(t, initializeSideChainCmd(initCmd, nil)) + require.NoError(t, initializeFSChainCmd(initCmd, nil)) t.Run("force-new-epoch", func(t *testing.T) { require.NoError(t, forceNewEpochCmd(forceNewEpoch, nil)) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go b/cmd/neofs-adm/internal/modules/fschain/initialize_transfer.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/initialize_transfer.go rename to cmd/neofs-adm/internal/modules/fschain/initialize_transfer.go index 0b5e8462b0..ebabd74420 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go +++ b/cmd/neofs-adm/internal/modules/fschain/initialize_transfer.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/local_client.go b/cmd/neofs-adm/internal/modules/fschain/local_client.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/local_client.go rename to cmd/neofs-adm/internal/modules/fschain/local_client.go index 6fca7dee89..4b0819feb7 100644 --- a/cmd/neofs-adm/internal/modules/morph/local_client.go +++ b/cmd/neofs-adm/internal/modules/fschain/local_client.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "crypto/elliptic" diff --git a/cmd/neofs-adm/internal/modules/morph/n3client.go b/cmd/neofs-adm/internal/modules/fschain/n3client.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/n3client.go rename to cmd/neofs-adm/internal/modules/fschain/n3client.go index cdf2c50268..8827d425e8 100644 --- a/cmd/neofs-adm/internal/modules/morph/n3client.go +++ b/cmd/neofs-adm/internal/modules/fschain/n3client.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "context" diff --git a/cmd/neofs-adm/internal/modules/morph/netmap_candidates.go b/cmd/neofs-adm/internal/modules/fschain/netmap_candidates.go similarity index 98% rename from cmd/neofs-adm/internal/modules/morph/netmap_candidates.go rename to cmd/neofs-adm/internal/modules/fschain/netmap_candidates.go index c25c2dbe0e..b45e7050de 100644 --- a/cmd/neofs-adm/internal/modules/morph/netmap_candidates.go +++ b/cmd/neofs-adm/internal/modules/fschain/netmap_candidates.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/notary.go b/cmd/neofs-adm/internal/modules/fschain/notary.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/notary.go rename to cmd/neofs-adm/internal/modules/fschain/notary.go index 181edfaab6..095b74600e 100644 --- a/cmd/neofs-adm/internal/modules/morph/notary.go +++ b/cmd/neofs-adm/internal/modules/fschain/notary.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/policy.go b/cmd/neofs-adm/internal/modules/fschain/policy.go similarity index 98% rename from cmd/neofs-adm/internal/modules/morph/policy.go rename to cmd/neofs-adm/internal/modules/fschain/policy.go index 82a6d61616..77fd6a5b69 100644 --- a/cmd/neofs-adm/internal/modules/morph/policy.go +++ b/cmd/neofs-adm/internal/modules/fschain/policy.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/remove_node.go b/cmd/neofs-adm/internal/modules/fschain/remove_node.go similarity index 98% rename from cmd/neofs-adm/internal/modules/morph/remove_node.go rename to cmd/neofs-adm/internal/modules/fschain/remove_node.go index 9ffa756667..23e32f460f 100644 --- a/cmd/neofs-adm/internal/modules/morph/remove_node.go +++ b/cmd/neofs-adm/internal/modules/fschain/remove_node.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/morph/renew_domain.go b/cmd/neofs-adm/internal/modules/fschain/renew_domain.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/renew_domain.go rename to cmd/neofs-adm/internal/modules/fschain/renew_domain.go index fe2f3e3fb1..ebad5d1cb6 100644 --- a/cmd/neofs-adm/internal/modules/morph/renew_domain.go +++ b/cmd/neofs-adm/internal/modules/fschain/renew_domain.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/morph/root.go b/cmd/neofs-adm/internal/modules/fschain/root.go similarity index 96% rename from cmd/neofs-adm/internal/modules/morph/root.go rename to cmd/neofs-adm/internal/modules/fschain/root.go index e9f8849ebf..132e157b89 100644 --- a/cmd/neofs-adm/internal/modules/morph/root.go +++ b/cmd/neofs-adm/internal/modules/fschain/root.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" @@ -63,13 +63,14 @@ const ( var ( // RootCmd is a root command of config section. RootCmd = &cobra.Command{ - Use: "morph", - Short: "Section for morph network configuration commands", + Use: "fschain", + Short: "Section FS chain network configuration commands", + Aliases: []string{"morph"}, } generateAlphabetCmd = &cobra.Command{ Use: "generate-alphabet", - Short: "Generate alphabet wallets for consensus nodes of the morph network", + Short: "Generate alphabet wallets for consensus nodes of FS chain network", PreRun: func(cmd *cobra.Command, _ []string) { // PreRun fixes https://github.com/spf13/viper/issues/233 _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) @@ -79,7 +80,7 @@ var ( initCmd = &cobra.Command{ Use: "init", - Short: "Initialize side chain network with smart-contracts and network settings", + Short: "Initialize FS chain network with smart-contracts and network settings", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) _ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag)) @@ -95,12 +96,12 @@ var ( _ = viper.BindPFlag(protoConfigPath, cmd.Flags().Lookup(protoConfigPath)) _ = viper.BindPFlag(localDumpFlag, cmd.Flags().Lookup(localDumpFlag)) }, - RunE: initializeSideChainCmd, + RunE: initializeFSChainCmd, } generateStorageCmd = &cobra.Command{ Use: "generate-storage-wallet", - Short: "Generate storage node wallet for the morph network", + Short: "Generate storage node wallet for FS chain network", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) _ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag)) @@ -111,7 +112,7 @@ var ( refillGasCmd = &cobra.Command{ Use: "refill-gas", - Short: "Refill GAS of storage node's wallet in the morph network", + Short: "Refill GAS of storage node's wallet in FS chain network", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) _ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag)) @@ -152,7 +153,7 @@ var ( mintBalanceCmd = &cobra.Command{ Use: "mint-balance", - Short: "Mint new NEOFS tokens in the morph network", + Short: "Mint new NEOFS tokens in FS chain network", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) _ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag)) @@ -182,7 +183,7 @@ var ( forceNewEpoch = &cobra.Command{ Use: "force-new-epoch", - Short: "Create new NeoFS epoch event in the side chain", + Short: "Create new NeoFS epoch event in FS chain", PreRun: func(cmd *cobra.Command, _ []string) { _ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag)) _ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag)) @@ -375,7 +376,7 @@ func init() { initCmd.Flags().String(alphabetWalletsFlag, "", "Path to alphabet wallets dir") initCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint") initCmd.Flags().String(contractsInitFlag, "", "Path to archive with compiled NeoFS contracts (default fetched from latest github release)") - initCmd.Flags().Uint(epochDurationCLIFlag, 240, "Amount of side chain blocks in one NeoFS epoch") + initCmd.Flags().Uint(epochDurationCLIFlag, 240, "Amount of FS chain blocks in one NeoFS epoch") initCmd.Flags().Uint(maxObjectSizeCLIFlag, 67108864, "Max single object size in bytes") initCmd.Flags().Bool(homomorphicHashDisabledCLIFlag, false, "Disable object homomorphic hashing") // Defaults are taken from neo-preodolenie. @@ -497,7 +498,7 @@ func init() { cmd := verifiedNodesDomainAccessListCmd fs := cmd.Flags() - fs.StringP(endpointFlag, "r", "", "NeoFS Sidechain RPC endpoint") + fs.StringP(endpointFlag, "r", "", "FS chain RPC endpoint") _ = cmd.MarkFlagRequired(endpointFlag) fs.StringP(domainFlag, "d", "", "Verified domain of the storage nodes. Must be a valid NeoFS NNS domain (e.g. 'nodes.some-org.neofs')") _ = cmd.MarkFlagRequired(domainFlag) @@ -510,7 +511,7 @@ func init() { _ = cmd.MarkFlagRequired(walletFlag) fs.StringP(walletAccountFlag, "a", "", "Optional Neo address of the wallet account for signing transactions. "+ "If omitted, default change address from the wallet is used") - fs.StringP(endpointFlag, "r", "", "NeoFS Sidechain RPC endpoint") + fs.StringP(endpointFlag, "r", "", "FS chain RPC endpoint") _ = cmd.MarkFlagRequired(endpointFlag) fs.StringP(domainFlag, "d", "", "Verified domain of the storage nodes. Must be a valid NeoFS NNS domain (e.g. 'nodes.some-org.neofs')") _ = cmd.MarkFlagRequired(domainFlag) diff --git a/cmd/neofs-adm/internal/modules/morph/update.go b/cmd/neofs-adm/internal/modules/fschain/update.go similarity index 95% rename from cmd/neofs-adm/internal/modules/morph/update.go rename to cmd/neofs-adm/internal/modules/fschain/update.go index 90b6d6558a..51abe5d3be 100644 --- a/cmd/neofs-adm/internal/modules/morph/update.go +++ b/cmd/neofs-adm/internal/modules/fschain/update.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "fmt" diff --git a/cmd/neofs-adm/internal/modules/morph/verified_domains.go b/cmd/neofs-adm/internal/modules/fschain/verified_domains.go similarity index 99% rename from cmd/neofs-adm/internal/modules/morph/verified_domains.go rename to cmd/neofs-adm/internal/modules/fschain/verified_domains.go index caf4e89a0e..ed009880ce 100644 --- a/cmd/neofs-adm/internal/modules/morph/verified_domains.go +++ b/cmd/neofs-adm/internal/modules/fschain/verified_domains.go @@ -1,4 +1,4 @@ -package morph +package fschain import ( "errors" diff --git a/cmd/neofs-adm/internal/modules/root.go b/cmd/neofs-adm/internal/modules/root.go index d52e74804e..281fc3b714 100644 --- a/cmd/neofs-adm/internal/modules/root.go +++ b/cmd/neofs-adm/internal/modules/root.go @@ -2,9 +2,10 @@ package modules import ( "os" + "slices" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config" - "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph" + "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/fschain" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/storagecfg" "github.com/nspcc-dev/neofs-node/misc" "github.com/nspcc-dev/neofs-node/pkg/util/autocomplete" @@ -39,11 +40,15 @@ func init() { rootCmd.Flags().Bool("version", false, "Application version") rootCmd.AddCommand(config.RootCmd) - rootCmd.AddCommand(morph.RootCmd) + rootCmd.AddCommand(fschain.RootCmd) rootCmd.AddCommand(storagecfg.RootCmd) rootCmd.AddCommand(autocomplete.Command("neofs-adm")) rootCmd.AddCommand(gendoc.Command(rootCmd)) + + if slices.Contains(os.Args, "morph") { + rootCmd.Println("Warning: 'morph' is deprecated, use 'fschain' instead") + } } func Execute() error { diff --git a/cmd/neofs-adm/internal/modules/storagecfg/config.go b/cmd/neofs-adm/internal/modules/storagecfg/config.go index 9fba3a390f..e6c9b59cad 100644 --- a/cmd/neofs-adm/internal/modules/storagecfg/config.go +++ b/cmd/neofs-adm/internal/modules/storagecfg/config.go @@ -32,10 +32,10 @@ control: grpc: endpoint: {{.ControlEndpoint}} # endpoint that is listened by the Control Service -morph: - dial_timeout: 20s # timeout for side chain NEO RPC client connection - cache_ttl: 15s # use TTL cache for side chain GET operations - endpoints: # side chain N3 RPC endpoints +fschain: + dial_timeout: 20s # timeout for FS chain NEO RPC client connection + cache_ttl: 15s # use TTL cache for FS chain GET operations + endpoints: # FS chain N3 RPC endpoints {{- range .MorphRPC }} - wss://{{.}}/ws{{end}} {{if not .Relay }} diff --git a/cmd/neofs-adm/internal/modules/storagecfg/root.go b/cmd/neofs-adm/internal/modules/storagecfg/root.go index 745ea856b8..a4dbf57af6 100644 --- a/cmd/neofs-adm/internal/modules/storagecfg/root.go +++ b/cmd/neofs-adm/internal/modules/storagecfg/root.go @@ -378,23 +378,23 @@ func applyTemplate(c config) ([]byte, error) { } func depositGas(cmd *cobra.Command, acc *wallet.Account, network string) error { - sideClient, err := initClient(n3config[network].MorphRPC) + fsClient, err := initClient(n3config[network].MorphRPC) if err != nil { return err } balanceHash, _ := util.Uint160DecodeStringLE(n3config[network].BalanceContract) - sideActor, err := actor.NewSimple(sideClient, acc) + fsActor, err := actor.NewSimple(fsClient, acc) if err != nil { - return fmt.Errorf("creating actor over side chain client: %w", err) + return fmt.Errorf("creating actor over FS chain client: %w", err) } - sideGas := nep17.NewReader(sideActor, balanceHash) + fsGas := nep17.NewReader(fsActor, balanceHash) accSH := acc.Contract.ScriptHash() - balance, err := sideGas.BalanceOf(accSH) + balance, err := fsGas.BalanceOf(accSH) if err != nil { - return fmt.Errorf("side chain balance: %w", err) + return fmt.Errorf("FS chain balance: %w", err) } ok, err := getConfirmation(false, fmt.Sprintf("Current NeoFS balance is %s, make a deposit? y/[n]: ", diff --git a/cmd/neofs-cli/modules/container/create.go b/cmd/neofs-cli/modules/container/create.go index 1ee6c80d1e..763bb4c1ec 100644 --- a/cmd/neofs-cli/modules/container/create.go +++ b/cmd/neofs-cli/modules/container/create.go @@ -34,7 +34,7 @@ var createContainerCmd = &cobra.Command{ Use: "create", Short: "Create new container", Long: `Create new container and register it in the NeoFS. -It will be stored in sidechain when inner ring will accepts it.`, +It will be stored in FS chain when inner ring will accepts it.`, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) error { if containerName == "" && containerGlobalName { @@ -163,7 +163,7 @@ It will be stored in sidechain when inner ring will accepts it.`, _, err := internalclient.GetContainer(ctx, getPrm) if err == nil { - cmd.Println("container has been persisted on sidechain") + cmd.Println("container has been persisted on FS chain") return nil } } diff --git a/cmd/neofs-cli/modules/container/set_eacl.go b/cmd/neofs-cli/modules/container/set_eacl.go index b9687196ca..c6f3556991 100644 --- a/cmd/neofs-cli/modules/container/set_eacl.go +++ b/cmd/neofs-cli/modules/container/set_eacl.go @@ -147,7 +147,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`, got := table.Marshal() if bytes.Equal(exp, got) { - cmd.Println("EACL has been persisted on sidechain") + cmd.Println("EACL has been persisted on FS chain") return nil } } diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index 3d6692f814..7aec4fac50 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -61,6 +61,10 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("morph.reconnections_number", 5) cfg.SetDefault("morph.reconnections_delay", 5*time.Second) cfg.SetDefault("morph.validators", []string{}) + cfg.SetDefault("fschain.dial_timeout", time.Minute) + cfg.SetDefault("fschain.reconnections_number", 5) + cfg.SetDefault("fschain.reconnections_delay", 5*time.Second) + cfg.SetDefault("fschain.validators", []string{}) cfg.SetDefault("mainnet.dial_timeout", time.Minute) cfg.SetDefault("mainnet.reconnections_number", 5) @@ -109,9 +113,7 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("indexer.cache_timeout", 15*time.Second) // extra fee values for working mode without notary contract - cfg.SetDefault("fee.main_chain", 5000_0000) // 0.5 Fixed8 - cfg.SetDefault("fee.side_chain", 2_0000_0000) // 2.0 Fixed8 - cfg.SetDefault("fee.named_container_register", 25_0000_0000) // 25.0 Fixed8 + cfg.SetDefault("fee.main_chain", 5000_0000) // 0.5 Fixed8 cfg.SetDefault("control.authorized_keys", []string{}) cfg.SetDefault("control.grpc.endpoint", "") diff --git a/cmd/neofs-ir/internal/validate/config.go b/cmd/neofs-ir/internal/validate/config.go index ae40d905bf..77438dd729 100644 --- a/cmd/neofs-ir/internal/validate/config.go +++ b/cmd/neofs-ir/internal/validate/config.go @@ -71,6 +71,61 @@ type validConfig struct { } `mapstructure:"consensus"` } `mapstructure:"morph"` + FSChain struct { + DialTimeout time.Duration `mapstructure:"dial_timeout"` + ReconnectionsNumber int `mapstructure:"reconnections_number"` + ReconnectionsDelay time.Duration `mapstructure:"reconnections_delay"` + Endpoints []string `mapstructure:"endpoints"` + Validators []string `mapstructure:"validators"` + Consensus struct { + Magic uint32 `mapstructure:"magic"` + Committee []string `mapstructure:"committee"` + + Storage struct { + Type string `mapstructure:"type"` + Path string `mapstructure:"path"` + } `mapstructure:"storage"` + + TimePerBlock time.Duration `mapstructure:"time_per_block"` + MaxTraceableBlocks uint32 `mapstructure:"max_traceable_blocks"` + SeedNodes []string `mapstructure:"seed_nodes"` + + Hardforks struct { + Name map[string]uint32 `mapstructure:",remain" prefix:""` + } `mapstructure:"hardforks"` + + ValidatorsHistory struct { + Height map[string]int `mapstructure:",remain" prefix:""` + } `mapstructure:"validators_history"` + + RPC struct { + Listen []string `mapstructure:"listen"` + TLS struct { + Enabled bool `mapstructure:"enabled"` + Listen []string `mapstructure:"listen"` + CertFile string `mapstructure:"cert_file"` + KeyFile string `mapstructure:"key_file"` + } `mapstructure:"tls"` + } `mapstructure:"rpc"` + + P2P struct { + DialTimeout time.Duration `mapstructure:"dial_timeout"` + ProtoTickInterval time.Duration `mapstructure:"proto_tick_interval"` + Listen []string `mapstructure:"listen"` + Peers struct { + Min int `mapstructure:"min"` + Max int `mapstructure:"max"` + Attempts int `mapstructure:"attempts"` + } `mapstructure:"peers"` + Ping struct { + Interval time.Duration `mapstructure:"interval"` + Timeout time.Duration `mapstructure:"timeout"` + } `mapstructure:"ping"` + } `mapstructure:"p2p"` + SetRolesInGenesis bool `mapstructure:"set_roles_in_genesis"` + } `mapstructure:"consensus"` + } `mapstructure:"fschain"` + FSChainAutodeploy bool `mapstructure:"fschain_autodeploy"` NNS struct { @@ -102,9 +157,7 @@ type validConfig struct { } `mapstructure:"node"` Fee struct { - MainChain int64 `mapstructure:"main_chain"` - SideChain int64 `mapstructure:"side_chain"` - NamedContainerRegister int64 `mapstructure:"named_container_register"` + MainChain int64 `mapstructure:"main_chain"` } `mapstructure:"fee"` Timers struct { diff --git a/cmd/neofs-ir/internal/validate/validate_test.go b/cmd/neofs-ir/internal/validate/validate_test.go index cfada1fc0a..84e29958af 100644 --- a/cmd/neofs-ir/internal/validate/validate_test.go +++ b/cmd/neofs-ir/internal/validate/validate_test.go @@ -19,13 +19,13 @@ func TestCheckForUnknownFields(t *testing.T) { { name: "with all right fields", config: ` -morph: +fschain: dial_timeout: 1m reconnections_number: 5 reconnections_delay: 5s endpoints: - - wss://sidechain1.fs.neo.org:30333/ws - - wss://sidechain2.fs.neo.org:30333/ws + - wss://fschain1.fs.neo.org:30333/ws + - wss://fschain2.fs.neo.org:30333/ws validators: - 0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170 consensus: @@ -37,7 +37,7 @@ morph: - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 storage: type: boltdb - path: ./db/morph.bolt + path: ./db/fschain.bolt time_per_block: 1s max_traceable_blocks: 11520 seed_nodes: @@ -78,9 +78,9 @@ morph: wantErr: false, }, { - name: "unknown morph.consensus.timeout", + name: "unknown fschain.consensus.timeout", config: ` -morph: +fschain: consensus: p2p: ping: @@ -91,20 +91,20 @@ morph: wantErr: true, }, { - name: "morph.consensus.storage.type expected type string", + name: "fschain.consensus.storage.type expected type string", config: ` -morph: +fschain: consensus: storage: type: - path: ./db/morph.bolt + path: ./db/fschain.bolt `, wantErr: true, }, { - name: "unknown field morph.attr", + name: "unknown field fschain.attr", config: ` -morph: +fschain: dial_timeout: 1m reconnections_number: 5 attr: 123 diff --git a/cmd/neofs-node/cache.go b/cmd/neofs-node/cache.go index 1b5cf6a24f..1a2440da4c 100644 --- a/cmd/neofs-node/cache.go +++ b/cmd/neofs-node/cache.go @@ -199,7 +199,7 @@ func (s *ttlContainerStorage) handleRemoval(cnr cid.ID) { } // Get returns container value from the cache. If value is missing in the cache -// or expired, then it returns value from side chain and updates the cache. +// or expired, then it returns value from FS chain and updates the cache. func (s *ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) { val, err := s.tc.get(cnr) if err != nil { @@ -228,7 +228,7 @@ func newCachedEACLStorage(v container.EACLSource, ttl time.Duration) *ttlEACLSto } // GetEACL returns eACL value from the cache. If value is missing in the cache -// or expired, then it returns value from side chain and updates cache. +// or expired, then it returns value from FS chain and updates cache. func (s *ttlEACLStorage) GetEACL(cnr cid.ID) (*container.EACL, error) { val, err := s.tc.get(cnr) if err != nil { @@ -333,7 +333,7 @@ func newCachedContainerLister(c *cntClient.Client, ttl time.Duration) *ttlContai } // List returns list of container IDs from the cache. If list is missing in the -// cache or expired, then it returns container IDs from side chain and updates +// cache or expired, then it returns container IDs from FS chain and updates // the cache. func (s *ttlContainerLister) List(id *user.ID) ([]cid.ID, error) { if id == nil { @@ -365,7 +365,7 @@ func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) { vt, ok := s.inner.cache.Peek(strOwner) if !ok { // we could cache the single cnr but in this case we will disperse - // with the Sidechain a lot + // with FS chain a lot return } @@ -385,7 +385,7 @@ func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) { item.list = append(item.list[:i], item.list[i+1:]...) // if list became empty we don't remove the value from the cache // since empty list is a correct value, and we don't want to insta - // re-request it from the Sidechain + // re-request it from FS chain } break @@ -415,7 +415,7 @@ func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) *cache // requests (neofs-node #1278), so limiting the request rate solves the issue. // // Exact request rate doesn't really matter because Inner Ring list update - // happens extremely rare, but there is no side chain events for that as + // happens extremely rare, but there is no FS chain events for that as // for now (neofs-contract v0.15.0 notary disabled env) to monitor it. irFetcherCacheTTL = 30 * time.Second ) @@ -430,7 +430,7 @@ func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) *cache } // InnerRingKeys returns cached list of Inner Ring keys. If keys are missing in -// the cache or expired, then it returns keys from side chain and updates +// the cache or expired, then it returns keys from FS chain and updates // the cache. func (f *cachedIRFetcher) InnerRingKeys() ([][]byte, error) { val, err := f.tc.get(struct{}{}) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 9e819895a6..0fb9430410 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -23,8 +23,8 @@ import ( engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine" shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard" fstreeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/fstree" + fschainconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/fschain" loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger" - morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph" nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node" objectconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/object" policerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/policer" @@ -110,7 +110,7 @@ type applicationConfiguration struct { objectBatchSize uint32 } - morph struct { + fsChain struct { endpoints []string dialTimeout time.Duration cacheTTL time.Duration @@ -166,13 +166,13 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error { a.engine.isIgnoreUninitedShards = engineconfig.IgnoreUninitedShards(c) a.engine.objectPutRetryDeadline = engineconfig.ObjectPutRetryDeadline(c) - // Morph + // FS chain - a.morph.endpoints = morphconfig.Endpoints(c) - a.morph.dialTimeout = morphconfig.DialTimeout(c) - a.morph.cacheTTL = morphconfig.CacheTTL(c) - a.morph.reconnectionRetriesNumber = morphconfig.ReconnectionRetriesNumber(c) - a.morph.reconnectionRetriesDelay = morphconfig.ReconnectionRetriesDelay(c) + a.fsChain.endpoints = fschainconfig.Endpoints(c) + a.fsChain.dialTimeout = fschainconfig.DialTimeout(c) + a.fsChain.cacheTTL = fschainconfig.CacheTTL(c) + a.fsChain.reconnectionRetriesNumber = fschainconfig.ReconnectionRetriesNumber(c) + a.fsChain.reconnectionRetriesDelay = fschainconfig.ReconnectionRetriesDelay(c) // Contracts @@ -522,7 +522,10 @@ type cfgReputation struct { localTrustCtrl *trustcontroller.Controller } -var persistateSideChainLastBlockKey = []byte("side_chain_last_processed_block") +var ( + persistateFSChainLastBlockKey = []byte("fs_chain_last_processed_block") + persistateDeprecatedSidechainLastBlockKey = []byte("side_chain_last_processed_block") +) func initCfg(appCfg *config.Config) *cfg { c := &cfg{} @@ -649,6 +652,12 @@ func initCfg(appCfg *config.Config) *cfg { c.veryLastClosers = make(map[string]func()) + // warning if there is morph section + + if c.cfgReader.Value("morph") != nil { + c.log.Warn("config section 'morph' is deprecated, use 'fschain'") + } + c.onShutdown(c.clientCache.CloseAll) // clean up connections c.onShutdown(c.bgClientCache.CloseAll) // clean up connections c.onShutdown(c.putClientCache.CloseAll) // clean up connections @@ -660,29 +669,49 @@ func initCfg(appCfg *config.Config) *cfg { func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStorage) basics { b := basics{} - addresses := c.applicationConfiguration.morph.endpoints + addresses := c.applicationConfiguration.fsChain.endpoints - fromSideChainBlock, err := stateStorage.UInt32(persistateSideChainLastBlockKey) + fromDeprectedSidechanBlock, err := stateStorage.UInt32(persistateDeprecatedSidechainLastBlockKey) if err != nil { - fromSideChainBlock = 0 - c.log.Warn("can't get last processed side chain block number", zap.Error(err)) + fromDeprectedSidechanBlock = 0 + } + fromFSChainBlock, err := stateStorage.UInt32(persistateFSChainLastBlockKey) + if err != nil { + fromFSChainBlock = 0 + c.log.Warn("can't get last processed FS chain block number", zap.Error(err)) + } + + // migration for deprecated DB key + if fromFSChainBlock == 0 && fromDeprectedSidechanBlock != fromFSChainBlock { + fromFSChainBlock = fromDeprectedSidechanBlock + err = stateStorage.SetUInt32(persistateFSChainLastBlockKey, fromFSChainBlock) + if err != nil { + c.log.Warn("can't update persistent state", + zap.String("chain", "FS"), + zap.Uint32("block_index", fromFSChainBlock)) + } + + err = stateStorage.Delete(persistateDeprecatedSidechainLastBlockKey) + if err != nil { + c.log.Warn("can't delete deprecated persistent state", zap.Error(err)) + } } cli, err := client.New(key, client.WithContext(c.internals.ctx), - client.WithDialTimeout(c.applicationConfiguration.morph.dialTimeout), + client.WithDialTimeout(c.applicationConfiguration.fsChain.dialTimeout), client.WithLogger(c.log), - client.WithAutoSidechainScope(), + client.WithAutoFSChainScope(), client.WithEndpoints(addresses), - client.WithReconnectionRetries(c.applicationConfiguration.morph.reconnectionRetriesNumber), - client.WithReconnectionsDelay(c.applicationConfiguration.morph.reconnectionRetriesDelay), + client.WithReconnectionRetries(c.applicationConfiguration.fsChain.reconnectionRetriesNumber), + client.WithReconnectionsDelay(c.applicationConfiguration.fsChain.reconnectionRetriesDelay), client.WithConnSwitchCallback(func() { err = c.restartMorph() if err != nil { c.internalErr <- fmt.Errorf("restarting after morph connection was lost: %w", err) } }), - client.WithMinRequiredBlockHeight(fromSideChainBlock), + client.WithMinRequiredBlockHeight(fromFSChainBlock), ) if err != nil { c.log.Info("failed to create neo RPC client", @@ -709,12 +738,12 @@ func initBasics(c *cfg, key *keys.PrivateKey, stateStorage *state.PersistentStor nmWrap, err := nmClient.NewFromMorph(cli, b.netmapSH, 0) fatalOnErr(err) - ttl := c.applicationConfiguration.morph.cacheTTL + ttl := c.applicationConfiguration.fsChain.cacheTTL if ttl == 0 { msPerBlock, err := cli.MsPerBlock() fatalOnErr(err) ttl = time.Duration(msPerBlock) * time.Millisecond - c.log.Debug("morph.cache_ttl fetched from network", zap.Duration("value", ttl)) + c.log.Debug("fschain.cache_ttl fetched from network", zap.Duration("value", ttl)) } var netmapSource netmapCore.Source @@ -813,7 +842,7 @@ func (c *cfg) handleLocalNodeInfoFromNetwork(ni *netmap.NodeInfo) { c.localNodeInNetmap.Store(ni != nil) } -// bootstrapWithState calls "addPeer" method of the Sidechain Netmap contract +// bootstrapWithState calls "addPeer" method of FS chain Netmap contract // with the binary-encoded information from the current node's configuration. // The state is set using the provided setter which MUST NOT be nil. func (c *cfg) bootstrapWithState(stateSetter func(*netmap.NodeInfo)) error { @@ -918,7 +947,7 @@ func (c *cfg) configWatcher(ctx context.Context) { // Morph - c.cli.Reload(client.WithEndpoints(c.morph.endpoints)) + c.cli.Reload(client.WithEndpoints(c.fsChain.endpoints)) // Node diff --git a/cmd/neofs-node/config/morph/config.go b/cmd/neofs-node/config/fschain/config.go similarity index 61% rename from cmd/neofs-node/config/morph/config.go rename to cmd/neofs-node/config/fschain/config.go index 8d7699fbfa..b2bf90e9d5 100644 --- a/cmd/neofs-node/config/morph/config.go +++ b/cmd/neofs-node/config/fschain/config.go @@ -1,4 +1,4 @@ -package morphconfig +package fschainconfig import ( "fmt" @@ -8,9 +8,10 @@ import ( ) const ( - subsection = "morph" + subsection = "fschain" + deprecatedMorphSubsection = "morph" - // DialTimeoutDefault is a default dial timeout of morph chain client connection. + // DialTimeoutDefault is a default dial timeout of FS chain client connection. DialTimeoutDefault = time.Minute // CacheTTLDefault is a default value for cached values TTL. @@ -24,65 +25,90 @@ const ( ) // Endpoints returns list of the values of "endpoints" config parameter -// from "morph" section. +// from "fschain" section (primary) or from "morph" section. // // Throws panic if list is empty. func Endpoints(c *config.Config) []string { endpoints := config.StringSliceSafe(c.Sub(subsection), "endpoints") - if len(endpoints) == 0 { - panic(fmt.Errorf("no morph chain RPC endpoints, see `morph.endpoints` section")) + morphEndpoints := config.StringSliceSafe(c.Sub(deprecatedMorphSubsection), "endpoints") + + if len(endpoints) == 0 && len(morphEndpoints) == 0 { + panic(fmt.Errorf("no FS chain RPC endpoints, see `fschain.endpoints` section")) + } + if len(endpoints) > 0 { + return endpoints } - return endpoints + return morphEndpoints } // DialTimeout returns the value of "dial_timeout" config parameter -// from "morph" section. +// from "fschain" section (primary) or from "morph" section. // // Returns DialTimeoutDefault if the value is not positive duration. func DialTimeout(c *config.Config) time.Duration { v := config.DurationSafe(c.Sub(subsection), "dial_timeout") + morphV := config.DurationSafe(c.Sub(deprecatedMorphSubsection), "dial_timeout") + if v > 0 { return v } + if morphV > 0 { + return morphV + } return DialTimeoutDefault } // CacheTTL returns the value of "cache_ttl" config parameter -// from "morph" section. +// from "fschain" section (primary) or from "morph" section. // // Returns CacheTTLDefault if value is zero or invalid. Supports negative durations. func CacheTTL(c *config.Config) time.Duration { res := config.DurationSafe(c.Sub(subsection), "cache_ttl") + morphRes := config.DurationSafe(c.Sub(deprecatedMorphSubsection), "cache_ttl") + if res != 0 { return res } + if morphRes != 0 { + return morphRes + } return CacheTTLDefault } // ReconnectionRetriesNumber returns the value of "reconnections_number" config -// parameter from "morph" section. +// parameter from "fschain" section (primary) or from "morph" section. // // Returns 0 if value is not specified. func ReconnectionRetriesNumber(c *config.Config) int { res := config.Int(c.Sub(subsection), "reconnections_number") + morphRes := config.Int(c.Sub(deprecatedMorphSubsection), "reconnections_number") + if res != 0 { return int(res) } + if morphRes != 0 { + return int(morphRes) + } return ReconnectionRetriesNumberDefault } // ReconnectionRetriesDelay returns the value of "reconnections_delay" config -// parameter from "morph" section. +// parameter from "fschain" section (primary) or from "morph" section. // // Returns 0 if value is not specified. func ReconnectionRetriesDelay(c *config.Config) time.Duration { res := config.DurationSafe(c.Sub(subsection), "reconnections_delay") + morphRes := config.DurationSafe(c.Sub(deprecatedMorphSubsection), "reconnections_delay") + if res != 0 { return res } + if morphRes != 0 { + return morphRes + } return ReconnectionRetriesDelayDefault } diff --git a/cmd/neofs-node/config/fschain/config_test.go b/cmd/neofs-node/config/fschain/config_test.go new file mode 100644 index 0000000000..95b1ad7463 --- /dev/null +++ b/cmd/neofs-node/config/fschain/config_test.go @@ -0,0 +1,70 @@ +package fschainconfig_test + +import ( + "os" + "path/filepath" + "testing" + "time" + + "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + fschainconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/fschain" + configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test" + "github.com/stretchr/testify/require" +) + +func TestFSChainSection(t *testing.T) { + t.Run("defaults", func(t *testing.T) { + empty := configtest.EmptyConfig() + + require.Panics(t, func() { fschainconfig.Endpoints(empty) }) + require.Equal(t, fschainconfig.DialTimeoutDefault, fschainconfig.DialTimeout(empty)) + require.Equal(t, fschainconfig.CacheTTLDefault, fschainconfig.CacheTTL(empty)) + require.Equal(t, 5, fschainconfig.ReconnectionRetriesNumber(empty)) + require.Equal(t, 5*time.Second, fschainconfig.ReconnectionRetriesDelay(empty)) + }) + + const path = "../../../../config/example/node" + + rpcs := []string{"wss://rpc1.morph.fs.neo.org:40341/ws", "wss://rpc2.morph.fs.neo.org:40341/ws"} + + var fileConfigTest = func(c *config.Config) { + require.Equal(t, rpcs, fschainconfig.Endpoints(c)) + require.Equal(t, 30*time.Second, fschainconfig.DialTimeout(c)) + require.Equal(t, 15*time.Second, fschainconfig.CacheTTL(c)) + require.Equal(t, 6, fschainconfig.ReconnectionRetriesNumber(c)) + require.Equal(t, 6*time.Second, fschainconfig.ReconnectionRetriesDelay(c)) + } + + configtest.ForEachFileType(path, fileConfigTest) + + t.Run("ENV", func(t *testing.T) { + configtest.ForEnvFileType(path, fileConfigTest) + }) + + t.Run("compatibility with morph section", func(t *testing.T) { + data := []byte(` +morph: + dial_timeout: 30s + cache_ttl: 15s + reconnections_number: 6 + reconnections_delay: 6s + endpoints: + - wss://rpc1.morph.fs.neo.org:40341/ws + - wss://rpc2.morph.fs.neo.org:40341/ws +`) + + morphPath := filepath.Join(t.TempDir(), "morph.yaml") + require.NoError(t, os.WriteFile(morphPath, data, 0o640)) + + var p config.Prm + + os.Clearenv() + + c := config.New(p, + config.WithConfigFile(morphPath), + config.WithValidate(false), + ) + + fileConfigTest(c) + }) +} diff --git a/cmd/neofs-node/config/internal/validate/config.go b/cmd/neofs-node/config/internal/validate/config.go index 0181a3efeb..6bb7781969 100644 --- a/cmd/neofs-node/config/internal/validate/config.go +++ b/cmd/neofs-node/config/internal/validate/config.go @@ -87,6 +87,14 @@ type valideConfig struct { Endpoints []string `mapstructure:"endpoints"` } `mapstructure:"morph"` + FSChain struct { + DialTimeout time.Duration `mapstructure:"dial_timeout"` + CacheTTL time.Duration `mapstructure:"cache_ttl"` + ReconnectionsNumber int `mapstructure:"reconnections_number"` + ReconnectionsDelay time.Duration `mapstructure:"reconnections_delay"` + Endpoints []string `mapstructure:"endpoints"` + } `mapstructure:"fschain"` + APIClient struct { DialTimeout time.Duration `mapstructure:"dial_timeout"` StreamTimeout time.Duration `mapstructure:"stream_timeout"` diff --git a/cmd/neofs-node/config/morph/config_test.go b/cmd/neofs-node/config/morph/config_test.go deleted file mode 100644 index bbfedded4e..0000000000 --- a/cmd/neofs-node/config/morph/config_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package morphconfig_test - -import ( - "testing" - "time" - - "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" - morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph" - configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test" - "github.com/stretchr/testify/require" -) - -func TestMorphSection(t *testing.T) { - t.Run("defaults", func(t *testing.T) { - empty := configtest.EmptyConfig() - - require.Panics(t, func() { morphconfig.Endpoints(empty) }) - require.Equal(t, morphconfig.DialTimeoutDefault, morphconfig.DialTimeout(empty)) - require.Equal(t, morphconfig.CacheTTLDefault, morphconfig.CacheTTL(empty)) - require.Equal(t, 5, morphconfig.ReconnectionRetriesNumber(empty)) - require.Equal(t, 5*time.Second, morphconfig.ReconnectionRetriesDelay(empty)) - }) - - const path = "../../../../config/example/node" - - rpcs := []string{"wss://rpc1.morph.fs.neo.org:40341/ws", "wss://rpc2.morph.fs.neo.org:40341/ws"} - - var fileConfigTest = func(c *config.Config) { - require.Equal(t, rpcs, morphconfig.Endpoints(c)) - require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c)) - require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c)) - require.Equal(t, 6, morphconfig.ReconnectionRetriesNumber(c)) - require.Equal(t, 6*time.Second, morphconfig.ReconnectionRetriesDelay(c)) - } - - configtest.ForEachFileType(path, fileConfigTest) - - t.Run("ENV", func(t *testing.T) { - configtest.ForEnvFileType(path, fileConfigTest) - }) -} diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index 99ef59f922..b03f57955d 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -84,7 +84,7 @@ func listenMorphNotifications(c *cfg) { setNetmapNotificationParser(c, newEpochNotification, func(src *state.ContainedNotificationEvent) (event.Event, error) { res, err := netmapEvent.ParseNewEpoch(src) if err == nil { - c.log.Info("new epoch event from sidechain", + c.log.Info("new epoch event from FS chain", zap.Uint64("number", res.(netmapEvent.NewEpoch).EpochNumber()), ) } @@ -97,10 +97,10 @@ func listenMorphNotifications(c *cfg) { registerBlockHandler(lis, func(block *block.Block) { c.log.Debug("new block", zap.Uint32("index", block.Index)) - err = c.persistate.SetUInt32(persistateSideChainLastBlockKey, block.Index) + err = c.persistate.SetUInt32(persistateFSChainLastBlockKey, block.Index) if err != nil { c.log.Warn("can't update persistent state", - zap.String("chain", "side"), + zap.String("chain", "FS"), zap.Uint32("block_index", block.Index)) } diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 48845eb791..21d8e10b2e 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -116,11 +116,11 @@ func (i *delNetInfo) LocalNodeID() user.ID { } type innerRingFetcherWithNotary struct { - sidechain *morphClient.Client + fschain *morphClient.Client } func (fn *innerRingFetcherWithNotary) InnerRingKeys() ([][]byte, error) { - keys, err := fn.sidechain.NeoFSAlphabetList() + keys, err := fn.fschain.NeoFSAlphabetList() if err != nil { return nil, fmt.Errorf("can't get inner ring keys from alphabet role: %w", err) } @@ -179,7 +179,7 @@ func initObjectService(c *cfg) { } irFetcher := &innerRingFetcherWithNotary{ - sidechain: c.cfgMorph.client, + fschain: c.cfgMorph.client, } c.shared.replicator = replicator.New( diff --git a/config/example/ir.env b/config/example/ir.env index 422a2dc05a..28b754362c 100644 --- a/config/example/ir.env +++ b/config/example/ir.env @@ -7,11 +7,11 @@ NEOFS_IR_WALLET_PASSWORD=secret NEOFS_IR_WITHOUT_MAINNET=false -NEOFS_IR_MORPH_DIAL_TIMEOUT=1m -NEOFS_IR_MORPH_RECONNECTIONS_NUMBER=5 -NEOFS_IR_MORPH_RECONNECTIONS_DELAY=5s -NEOFS_IR_MORPH_ENDPOINTS="wss://sidechain1.fs.neo.org:30333/ws wss://sidechain2.fs.neo.org:30333/ws" -NEOFS_IR_MORPH_VALIDATORS="0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170" +NEOFS_IR_FSCHAIN_DIAL_TIMEOUT=1m +NEOFS_IR_FSCHAIN_RECONNECTIONS_NUMBER=5 +NEOFS_IR_FSCHAIN_RECONNECTIONS_DELAY=5s +NEOFS_IR_FSCHAIN_ENDPOINTS="wss://sidechain1.fs.neo.org:30333/ws wss://sidechain2.fs.neo.org:30333/ws" +NEOFS_IR_FSCHAIN_VALIDATORS="0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170" NEOFS_IR_MAINNET_DIAL_TIMEOUT=1m NEOFS_IR_MAINNET_RECONNECTIONS_NUMBER=5 diff --git a/config/example/ir.yaml b/config/example/ir.yaml index b729859203..2810970326 100644 --- a/config/example/ir.yaml +++ b/config/example/ir.yaml @@ -11,7 +11,7 @@ wallet: without_mainnet: false # Run application in single chain environment without mainchain -morph: +fschain: dial_timeout: 1m # Timeout for RPC client connection to sidechain reconnections_number: 5 # number of reconnection attempts reconnections_delay: 5s # time delay b/w reconnection attempts diff --git a/config/example/node.env b/config/example/node.env index ad421124eb..0926395612 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -58,12 +58,12 @@ NEOFS_CONTRACTS_NETMAP=0cce9e948dca43a6b592efe59ddb4ecb89bdd9ca NEOFS_CONTRACTS_REPUTATION=441995f631c1da2b133462b71859494a5cd45e90 NEOFS_CONTRACTS_PROXY=ad7c6b55b737b696e5c82c85445040964a03e97f -# Morph chain section -NEOFS_MORPH_DIAL_TIMEOUT=30s -NEOFS_MORPH_CACHE_TTL=15s -NEOFS_MORPH_RECONNECTIONS_NUMBER=6 -NEOFS_MORPH_RECONNECTIONS_DELAY=6s -NEOFS_MORPH_ENDPOINTS="wss://rpc1.morph.fs.neo.org:40341/ws wss://rpc2.morph.fs.neo.org:40341/ws" +# FS chain section +NEOFS_FSCHAIN_DIAL_TIMEOUT=30s +NEOFS_FSCHAIN_CACHE_TTL=15s +NEOFS_FSCHAIN_RECONNECTIONS_NUMBER=6 +NEOFS_FSCHAIN_RECONNECTIONS_DELAY=6s +NEOFS_FSCHAIN_ENDPOINTS="wss://rpc1.morph.fs.neo.org:40341/ws wss://rpc2.morph.fs.neo.org:40341/ws" # API Client section NEOFS_APICLIENT_DIAL_TIMEOUT=15s diff --git a/config/example/node.json b/config/example/node.json index 72fe34fcc2..437bab4907 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -81,7 +81,7 @@ "reputation": "441995f631c1da2b133462b71859494a5cd45e90", "proxy": "ad7c6b55b737b696e5c82c85445040964a03e97f" }, - "morph": { + "fschain": { "dial_timeout": "30s", "cache_ttl": "15s", "reconnections_number": "6", diff --git a/config/example/node.yaml b/config/example/node.yaml index 23a0df716a..a0a4c77822 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -63,21 +63,21 @@ control: grpc: endpoint: localhost:8090 # endpoint that is listened by the Control Service -contracts: # side chain NEOFS contract script hashes; optional, override values retrieved from NNS contract +contracts: # FS chain NEOFS contract script hashes; optional, override values retrieved from NNS contract balance: 5263abba1abedbf79bb57f3e40b50b4425d2d6cd container: 5d084790d7aa36cea7b53fe897380dab11d2cd3c netmap: 0cce9e948dca43a6b592efe59ddb4ecb89bdd9ca reputation: 441995f631c1da2b133462b71859494a5cd45e90 proxy: ad7c6b55b737b696e5c82c85445040964a03e97f -morph: - dial_timeout: 30s # timeout for side chain NEO RPC client connection (default: 1m) - cache_ttl: 15s # Sidechain cache TTL value (min interval between similar calls). Negative value disables caching. +fschain: # previously there was a 'morph', now use this section name + dial_timeout: 30s # timeout for FS chain NEO RPC client connection (default: 1m) + cache_ttl: 15s # FS chain cache TTL value (min interval between similar calls). Negative value disables caching. # Default value: block time. It is recommended to have this value less or equal to block time. # Cached entities: containers, container lists, eACL tables. reconnections_number: 6 # number of reconnection attempts reconnections_delay: 6s # time delay b/w reconnection attempts - endpoints: # side chain NEO RPC endpoints; are shuffled and used one by one until the first success + endpoints: # FS chain NEO RPC endpoints; are shuffled and used one by one until the first success - wss://rpc1.morph.fs.neo.org:40341/ws - wss://rpc2.morph.fs.neo.org:40341/ws diff --git a/config/mainnet/config.yml b/config/mainnet/config.yml index c8c2ee20e9..9510a5dc5a 100644 --- a/config/mainnet/config.yml +++ b/config/mainnet/config.yml @@ -46,7 +46,7 @@ object: put: pool_size_remote: 100 -morph: +fschain: endpoints: - wss://rpc1.morph.fs.neo.org:40341/ws - wss://rpc2.morph.fs.neo.org:40341/ws diff --git a/config/testnet/config.yml b/config/testnet/config.yml index 70e18a7a76..282367a1c9 100644 --- a/config/testnet/config.yml +++ b/config/testnet/config.yml @@ -1,7 +1,7 @@ logger: level: info -morph: +fschain: endpoints: - wss://rpc01.morph.testnet.fs.neo.org:51331/ws - wss://rpc02.morph.testnet.fs.neo.org:51331/ws diff --git a/docs/cli-commands/neofs-cli_container_create.md b/docs/cli-commands/neofs-cli_container_create.md index 117460cc6f..c42cf4106b 100644 --- a/docs/cli-commands/neofs-cli_container_create.md +++ b/docs/cli-commands/neofs-cli_container_create.md @@ -5,7 +5,7 @@ Create new container ### Synopsis Create new container and register it in the NeoFS. -It will be stored in sidechain when inner ring will accepts it. +It will be stored in FS chain when inner ring will accepts it. ``` neofs-cli container create [flags] diff --git a/pkg/innerring/config.go b/pkg/innerring/config.go index c84be83fd0..0d4b7ba3c5 100644 --- a/pkg/innerring/config.go +++ b/pkg/innerring/config.go @@ -20,8 +20,8 @@ import ( ) // Various configuration paths. -const ( - cfgPathFSChain = "morph" +var ( + cfgPathFSChain = "fschain" cfgPathFSChainRPCEndpoints = cfgPathFSChain + ".endpoints" cfgPathFSChainLocalConsensus = cfgPathFSChain + ".consensus" cfgPathFSChainValidators = cfgPathFSChain + ".validators" @@ -33,8 +33,8 @@ const ( rpcDefaultListenPort = "30333" ) -// checks whether Inner Ring app is configured to initialize underlying NeoFS -// Sidechain or await for a background deployment. Returns an error if +// checks whether Inner Ring app is configured to initialize underlying FS chain +// or await for a background deployment. Returns an error if // the configuration format is violated. func isAutoDeploymentMode(cfg *viper.Viper) (bool, error) { res, err := parseConfigBool(cfg, "fschain_autodeploy", "flag to auto-deploy the FS chain") @@ -69,15 +69,15 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } c.NetworkMagic = netmode.Magic(_uint) - const storageSection = cfgPathFSChainLocalConsensus + ".storage" + var storageSection = cfgPathFSChainLocalConsensus + ".storage" if !v.IsSet(storageSection) { return c, fmt.Errorf("missing storage section '%s'", storageSection) } - const storageTypeKey = storageSection + ".type" + var storageTypeKey = storageSection + ".type" if !v.IsSet(storageTypeKey) { return c, fmt.Errorf("missing storage type '%s'", storageTypeKey) } - const storagePathKey = storageSection + ".path" + var storagePathKey = storageSection + ".path" switch typ := v.GetString(storageTypeKey); typ { default: return c, fmt.Errorf("unsupported storage type '%s': '%s'", storageTypeKey, typ) @@ -95,7 +95,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co c.Storage = blockchain.InMemory() } - const committeeKey = cfgPathFSChainLocalConsensus + ".committee" + var committeeKey = cfgPathFSChainLocalConsensus + ".committee" c.Committee, err = parseConfigPublicKeys(v, committeeKey, "committee members") if err != nil { return c, err @@ -119,7 +119,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co return c, err } - const hardForksKey = cfgPathFSChainLocalConsensus + ".hardforks" + var hardForksKey = cfgPathFSChainLocalConsensus + ".hardforks" if v.IsSet(hardForksKey) { c.HardForks, err = parseConfigMapUint32(v, hardForksKey, "hard forks", math.MaxUint32) if err != nil { @@ -127,7 +127,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } } - const validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history" + var validatorsHistoryKey = cfgPathFSChainLocalConsensus + ".validators_history" if v.IsSet(validatorsHistoryKey) { c.ValidatorsHistory = make(map[uint32]uint32) committeeSize := uint64(c.Committee.Len()) @@ -157,14 +157,14 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } } - const rpcSection = cfgPathFSChainLocalConsensus + ".rpc" + var rpcSection = cfgPathFSChainLocalConsensus + ".rpc" if v.IsSet(rpcSection) { c.RPC.Addresses, err = parseConfigAddressesTCP(v, rpcSection+".listen", "network addresses to listen insecure Neo RPC on", rpcDefaultListenPort) if err != nil && !errors.Is(err, errMissingConfig) { return c, err } - const rpcTLSSection = rpcSection + ".tls" + var rpcTLSSection = rpcSection + ".tls" if v.GetBool(rpcTLSSection + ".enabled") { c.RPC.TLSConfig.Enabled = true @@ -173,13 +173,13 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co return c, err } - const certCfgKey = rpcTLSSection + ".cert_file" + var certCfgKey = rpcTLSSection + ".cert_file" c.RPC.TLSConfig.CertFile = v.GetString(certCfgKey) if strings.TrimSpace(c.RPC.TLSConfig.CertFile) == "" { return c, fmt.Errorf("RPC TLS setup is enabled but no certificate ('%s') is provided", certCfgKey) } - const keyCfgKey = rpcTLSSection + ".key_file" + var keyCfgKey = rpcTLSSection + ".key_file" c.RPC.TLSConfig.KeyFile = v.GetString(keyCfgKey) if strings.TrimSpace(c.RPC.TLSConfig.KeyFile) == "" { return c, fmt.Errorf("RPC TLS setup is enabled but no key ('%s') is provided", keyCfgKey) @@ -188,7 +188,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } minPeersConfigured := false - const p2pSection = cfgPathFSChainLocalConsensus + ".p2p" + var p2pSection = cfgPathFSChainLocalConsensus + ".p2p" if v.IsSet(p2pSection) { c.P2P.DialTimeout, err = parseConfigDurationPositive(v, p2pSection+".dial_timeout", "P2P dial timeout") if err != nil && !errors.Is(err, errMissingConfig) { @@ -202,7 +202,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co if err != nil && !errors.Is(err, errMissingConfig) { return c, err } - const p2pPeersSection = p2pSection + ".peers" + var p2pPeersSection = p2pSection + ".peers" if v.IsSet(p2pPeersSection) { minPeers, err := parseConfigUint64Max(v, p2pPeersSection+".min", "minimum number of P2P peers", math.MaxInt32) if err != nil { @@ -226,7 +226,7 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co } c.P2P.AttemptConnPeers = uint(attemptConnPeers) } - const pingSection = p2pSection + ".ping" + var pingSection = p2pSection + ".ping" if v.IsSet(pingSection) { c.P2P.Ping.Interval, err = parseConfigDurationPositive(v, pingSection+".interval", "P2P ping interval") if err != nil { @@ -253,11 +253,11 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co return c, nil } -// sets NeoFS network settings to be used for the NeoFS Sidechain +// sets NeoFS network settings to be used for FS chain // auto-deployment. func setNetworkSettingsDefaults(netCfg *deploy.NetworkConfiguration) { netCfg.MaxObjectSize = 64 << 20 // in bytes of object payload - netCfg.EpochDuration = 240 // in NeoFS Sidechain blocks (e.g. ~1h for 15s block interval) + netCfg.EpochDuration = 240 // in FS chain blocks (e.g. ~1h for 15s block interval) netCfg.StoragePrice = 0 // in GAS per 1GB (NeoFS Balance contract's decimals) netCfg.AuditFee = 0 // in GAS per audit (NeoFS Balance contract's decimals) netCfg.ContainerFee = 1000 // in GAS per container (NeoFS Balance contract's decimals) diff --git a/pkg/innerring/config/fee.go b/pkg/innerring/config/fee.go index 600d758e2c..b278c23ee2 100644 --- a/pkg/innerring/config/fee.go +++ b/pkg/innerring/config/fee.go @@ -12,8 +12,6 @@ type FeeConfig struct { } // NewFeeConfig constructs FeeConfig from viper.Viper instance. Latter must not be nil. -// -// Fee for named container registration is taken from "fee.named_container_register" value. func NewFeeConfig(v *viper.Viper) *FeeConfig { return &FeeConfig{ mainchain: fixedn.Fixed8(v.GetInt64("fee.main_chain")), diff --git a/pkg/innerring/config_test.go b/pkg/innerring/config_test.go index cc494ceb59..d22272176f 100644 --- a/pkg/innerring/config_test.go +++ b/pkg/innerring/config_test.go @@ -17,7 +17,7 @@ import ( // YAML configuration of the IR consensus with all required fields. const validBlockchainConfigMinimal = ` -morph: +fschain: consensus: magic: 15405 committee: @@ -231,7 +231,7 @@ func TestParseBlockchainConfig(t *testing.T) { "storage.type", } { v := newValidBlockchainConfig(t, !fullConfig) - resetConfig(t, v, "morph.consensus."+requiredKey) + resetConfig(t, v, "fschain.consensus."+requiredKey) _, err := parseBlockchainConfig(v, _logger) require.Error(t, err, requiredKey) } @@ -239,7 +239,7 @@ func TestParseBlockchainConfig(t *testing.T) { t.Run("invalid", func(t *testing.T) { v := newValidBlockchainConfig(t, fullConfig) - resetConfig(t, v, "morph.consensus") + resetConfig(t, v, "fschain.consensus") _, err := parseBlockchainConfig(v, _logger) require.Error(t, err) @@ -311,7 +311,7 @@ func TestParseBlockchainConfig(t *testing.T) { key := kvPair.key val := kvPair.val - v.Set("morph.consensus."+key, val) + v.Set("fschain.consensus."+key, val) reportMsg = append(reportMsg, fmt.Sprintf("%s=%v", key, val)) } @@ -325,28 +325,28 @@ func TestParseBlockchainConfig(t *testing.T) { v := newValidBlockchainConfig(t, fullConfig) const path = "path/to/db" - v.Set("morph.consensus.storage.path", path) - v.Set("morph.consensus.storage.type", "boltdb") + v.Set("fschain.consensus.storage.path", path) + v.Set("fschain.consensus.storage.type", "boltdb") c, err := parseBlockchainConfig(v, _logger) require.NoError(t, err) require.Equal(t, blockchain.BoltDB(path), c.Storage) - resetConfig(t, v, "morph.consensus.storage.path") + resetConfig(t, v, "fschain.consensus.storage.path") _, err = parseBlockchainConfig(v, _logger) require.Error(t, err) - v.Set("morph.consensus.storage.path", path) - v.Set("morph.consensus.storage.type", "leveldb") + v.Set("fschain.consensus.storage.path", path) + v.Set("fschain.consensus.storage.type", "leveldb") c, err = parseBlockchainConfig(v, _logger) require.NoError(t, err) require.Equal(t, blockchain.LevelDB(path), c.Storage) - resetConfig(t, v, "morph.consensus.storage.path") + resetConfig(t, v, "fschain.consensus.storage.path") _, err = parseBlockchainConfig(v, _logger) require.Error(t, err) // no path needed - v.Set("morph.consensus.storage.type", "inmemory") + v.Set("fschain.consensus.storage.type", "inmemory") c, err = parseBlockchainConfig(v, _logger) require.NoError(t, err) require.Equal(t, blockchain.InMemory(), c.Storage) @@ -361,8 +361,8 @@ func TestIsLocalConsensusMode(t *testing.T) { v.SetEnvPrefix("neofs_ir") v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) - const envKeyEndpoints = "NEOFS_IR_MORPH_ENDPOINTS" - const envKeyConsensus = "NEOFS_IR_MORPH_CONSENSUS" + const envKeyEndpoints = "NEOFS_IR_FSCHAIN_ENDPOINTS" + const envKeyConsensus = "NEOFS_IR_FSCHAIN_CONSENSUS" var err error for _, tc := range []struct { @@ -425,9 +425,9 @@ func TestIsLocalConsensusMode(t *testing.T) { v := viper.New() v.SetConfigType("yaml") err := v.ReadConfig(strings.NewReader(` -morph: +fschain: endpoints: - - ws://morph-chain:30333/ws + - ws://fs-chain:30333/ws `)) require.NoError(t, err) @@ -435,12 +435,12 @@ morph: require.NoError(t, err) require.False(t, res) - resetConfig(t, v, "morph.endpoints") + resetConfig(t, v, "fschain.endpoints") _, err = isLocalConsensusMode(v) require.Error(t, err) - v.Set("morph.consensus", "any") + v.Set("fschain.consensus", "any") res, err = isLocalConsensusMode(v) require.NoError(t, err) @@ -596,19 +596,19 @@ func TestP2PMinPeers(t *testing.T) { } v := newValidBlockchainConfig(t, true) - v.Set("morph.consensus.p2p.peers.min", 123) + v.Set("fschain.consensus.p2p.peers.min", 123) assert(t, v, 123) t.Run("explicit zero", func(t *testing.T) { v := newValidBlockchainConfig(t, false) - v.Set("morph.consensus.p2p.peers.min", 0) + v.Set("fschain.consensus.p2p.peers.min", 0) assert(t, v, 0) }) t.Run("default", func(t *testing.T) { assertDefault := func(t testing.TB, v *viper.Viper) { setCommitteeN := func(n int) { - v.Set("morph.consensus.committee", commiteeN(t, n)) - resetConfig(t, v, "morph.consensus.validators_history") // checked against committee size + v.Set("fschain.consensus.committee", commiteeN(t, n)) + resetConfig(t, v, "fschain.consensus.validators_history") // checked against committee size } setCommitteeN(4) assert(t, v, 2) @@ -619,19 +619,19 @@ func TestP2PMinPeers(t *testing.T) { } t.Run("missing P2P section", func(t *testing.T) { v := newValidBlockchainConfig(t, true) - resetConfig(t, v, "morph.consensus.p2p") + resetConfig(t, v, "fschain.consensus.p2p") assertDefault(t, v) }) t.Run("missing peers section", func(t *testing.T) { v := newValidBlockchainConfig(t, true) - resetConfig(t, v, "morph.consensus.p2p.peers") - require.True(t, v.IsSet("morph.consensus.p2p")) + resetConfig(t, v, "fschain.consensus.p2p.peers") + require.True(t, v.IsSet("fschain.consensus.p2p")) assertDefault(t, v) }) t.Run("missing config itself", func(t *testing.T) { v := newValidBlockchainConfig(t, true) - resetConfig(t, v, "morph.consensus.p2p.peers.min") - require.True(t, v.IsSet("morph.consensus.p2p.peers")) + resetConfig(t, v, "fschain.consensus.p2p.peers.min") + require.True(t, v.IsSet("fschain.consensus.p2p.peers")) assertDefault(t, v) }) }) diff --git a/pkg/innerring/contracts.go b/pkg/innerring/contracts.go index 55020d2c6a..18e29538fa 100644 --- a/pkg/innerring/contracts.go +++ b/pkg/innerring/contracts.go @@ -92,7 +92,7 @@ func initContracts(ctx context.Context, _logger *zap.Logger, cfg *viper.Viper, m func parseAlphabetContracts(ctx *nnsContext, _logger *zap.Logger, cfg *viper.Viper, morph *client.Client) (alphabetContracts, error) { committee, err := morph.Committee() if err != nil { - return nil, fmt.Errorf("get Sidechain committee: %w", err) + return nil, fmt.Errorf("get FS chain committee: %w", err) } num := len(committee) diff --git a/pkg/innerring/deploy.go b/pkg/innerring/deploy.go index c37379e2b7..3681d26139 100644 --- a/pkg/innerring/deploy.go +++ b/pkg/innerring/deploy.go @@ -16,15 +16,15 @@ import ( // [deploy.Blockchain] methods provided from both [client.Client] and // [rpcclient.WSClient]. -type neoFSSidechainCommonRPC interface { +type fsChainCommonRPC interface { notary.RPCActor GetCommittee() (keys.PublicKeys, error) GetContractStateByID(id int32) (*state.Contract, error) GetContractStateByHash(util.Uint160) (*state.Contract, error) } -type neoFSSidechain struct { - neoFSSidechainCommonRPC +type fsChain struct { + fsChainCommonRPC client *client.Client @@ -36,7 +36,7 @@ type neoFSSidechain struct { // cancels all active subscriptions. Must not be called concurrently with // subscribe methods. -func (x *neoFSSidechain) cancelSubs() { +func (x *fsChain) cancelSubs() { if x.wsClient != nil { for i := range x.subs { _ = x.wsClient.Unsubscribe(x.subs[i]) @@ -46,7 +46,7 @@ func (x *neoFSSidechain) cancelSubs() { } // SubscribeToNewBlocks implements [deploy.Blockchain] interface. -func (x *neoFSSidechain) SubscribeToNewBlocks() (<-chan *block.Block, error) { +func (x *fsChain) SubscribeToNewBlocks() (<-chan *block.Block, error) { if x.wsClient != nil { ch := make(chan *block.Block) @@ -72,7 +72,7 @@ func (x *neoFSSidechain) SubscribeToNewBlocks() (<-chan *block.Block, error) { } // SubscribeToNotaryRequests implements [deploy.Blockchain] interface. -func (x *neoFSSidechain) SubscribeToNotaryRequests() (<-chan *result.NotaryRequestEvent, error) { +func (x *fsChain) SubscribeToNotaryRequests() (<-chan *result.NotaryRequestEvent, error) { if x.wsClient != nil { ch := make(chan *result.NotaryRequestEvent) @@ -98,16 +98,16 @@ func (x *neoFSSidechain) SubscribeToNotaryRequests() (<-chan *result.NotaryReque } // second parameter is optional and affects subscription methods. -func newNeoFSSidechain(sidechainClient *client.Client, sidechainWSClient *rpcclient.WSClient) *neoFSSidechain { - res := &neoFSSidechain{ - client: sidechainClient, - wsClient: sidechainWSClient, +func newFSChain(fsChainClient *client.Client, fsChainWSClient *rpcclient.WSClient) *fsChain { + res := &fsChain{ + client: fsChainClient, + wsClient: fsChainWSClient, } - if sidechainWSClient != nil { - res.neoFSSidechainCommonRPC = sidechainWSClient + if fsChainWSClient != nil { + res.fsChainCommonRPC = fsChainWSClient } else { - res.neoFSSidechainCommonRPC = sidechainClient + res.fsChainCommonRPC = fsChainClient } return res diff --git a/pkg/innerring/fetcher.go b/pkg/innerring/fetcher.go index 480225dc3d..fef99edb77 100644 --- a/pkg/innerring/fetcher.go +++ b/pkg/innerring/fetcher.go @@ -46,13 +46,13 @@ type IrFetcherWithoutNotary struct { } // InnerRingKeys fetches list of innerring keys from NeoFSAlphabet -// role in the sidechain. +// role in FS chain. func (fN IrFetcherWithNotary) InnerRingKeys() (keys.PublicKeys, error) { return fN.cli.NeoFSAlphabetList() } // InnerRingKeys fetches list of innerring keys from netmap contract -// in the sidechain. +// in FS chain. func (f IrFetcherWithoutNotary) InnerRingKeys() (keys.PublicKeys, error) { return f.nm.GetInnerRingList() } diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 9ee12cc349..51a7e014b5 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -141,13 +141,14 @@ type ( name string from uint32 // block height - withAutoSidechainScope bool + withAutoFSChainScope bool } ) const ( - morphPrefix = "morph" - mainnetPrefix = "mainnet" + deprecatedMorphPrefix = "morph" + fsChainPrefix = "fschain" + mainnetPrefix = "mainnet" // extra blocks to overlap two deposits, we do that to make sure that // there won't be any blocks without deposited assets in notary contract; @@ -184,15 +185,15 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) (err error) { s.log.Info("made main chain notary deposit successfully") } - err = s.depositSideNotary() + err = s.depositFSNotary() if err != nil { return fmt.Errorf("fs chain notary deposit: %w", err) } s.log.Info("made fs chain notary deposit successfully") - // vote for sidechain validator if it is prepared in config - err = s.voteForSidechainValidator(s.predefinedValidators, nil) + // vote for FS chain validator if it is prepared in config + err = s.voteForFSChainValidator(s.predefinedValidators, nil) if err != nil { // we don't stop inner ring execution on this error s.log.Warn("can't vote for prepared validators", @@ -218,7 +219,7 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) (err error) { case <-ctx.Done(): return case err := <-morphErr: - intError <- fmt.Errorf("sidechain: %w", err) + intError <- fmt.Errorf("FS chain: %w", err) case err := <-mainnnetErr: intError <- fmt.Errorf("mainnet: %w", err) } @@ -229,10 +230,10 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) (err error) { zap.Uint32("index", b.Index), ) - err = s.persistate.SetUInt32(persistateSideChainLastBlockKey, b.Index) + err = s.persistate.SetUInt32(persistateFSChainLastBlockKey, b.Index) if err != nil { s.log.Warn("can't update persistent state", - zap.String("chain", "side"), + zap.String("chain", "FS"), zap.Uint32("block_index", b.Index)) } @@ -321,17 +322,47 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- } server.registerCloser(server.persistate.Close) - fromSideChainBlock, err := server.persistate.UInt32(persistateSideChainLastBlockKey) + fromDeprectedSidechanBlock, err := server.persistate.UInt32(persistateDeprecatedSidechainLastBlockKey) if err != nil { - fromSideChainBlock = 0 - log.Warn("can't get last processed side chain block number", zap.Error(err)) + fromDeprectedSidechanBlock = 0 } + fromFSChainBlock, err := server.persistate.UInt32(persistateFSChainLastBlockKey) + if err != nil { + fromFSChainBlock = 0 + log.Warn("can't get last processed FS chain block number", zap.Error(err)) + } + + // migration for deprecated DB key + if fromFSChainBlock == 0 && fromDeprectedSidechanBlock != fromFSChainBlock { + fromFSChainBlock = fromDeprectedSidechanBlock + err = server.persistate.SetUInt32(persistateFSChainLastBlockKey, fromFSChainBlock) + if err != nil { + log.Warn("can't update persistent state", + zap.String("chain", "FS"), + zap.Uint32("block_index", fromFSChainBlock)) + } - morphChain := chainParams{ + err = server.persistate.Delete(persistateDeprecatedSidechainLastBlockKey) + if err != nil { + log.Warn("can't delete deprecated persistent state", zap.Error(err)) + } + } + + if cfg.IsSet(deprecatedMorphPrefix+".endpoints") || cfg.IsSet(deprecatedMorphPrefix+".consensus") { + log.Warn("config section 'morph' is deprecated, use 'fschain'") + cfgPathFSChain = deprecatedMorphPrefix + } + if cfg.IsSet(fsChainPrefix+".endpoints") || cfg.IsSet(fsChainPrefix+".consensus") { + cfgPathFSChain = fsChainPrefix + } + cfgPathFSChainRPCEndpoints = cfgPathFSChain + ".endpoints" + cfgPathFSChainLocalConsensus = cfgPathFSChain + ".consensus" + cfgPathFSChainValidators = cfgPathFSChain + ".validators" + fsChainParams := chainParams{ log: log, cfg: cfg, - name: morphPrefix, - from: fromSideChainBlock, + name: cfgPathFSChain, + from: fromFSChainBlock, } const walletPathKey = "wallet.path" @@ -458,17 +489,17 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- return nil, fmt.Errorf("build WS client on internal blockchain: %w", err) } - morphChain.key = server.key - sidechainOpts := make([]client.Option, 3, 4) - sidechainOpts[0] = client.WithContext(ctx) - sidechainOpts[1] = client.WithLogger(log) - sidechainOpts[2] = client.WithSingleClient(localWSClient) + fsChainParams.key = server.key + fsChainOpts := make([]client.Option, 3, 4) + fsChainOpts[0] = client.WithContext(ctx) + fsChainOpts[1] = client.WithLogger(log) + fsChainOpts[2] = client.WithSingleClient(localWSClient) if !isAutoDeploy { - sidechainOpts = append(sidechainOpts, client.WithAutoSidechainScope()) + fsChainOpts = append(fsChainOpts, client.WithAutoFSChainScope()) } - server.morphClient, err = client.New(server.key, sidechainOpts...) + server.morphClient, err = client.New(server.key, fsChainOpts...) if err != nil { return nil, fmt.Errorf("init internal morph client: %w", err) } @@ -479,22 +510,22 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- // fallback to the pure RPC architecture - morphChain.key = server.key - morphChain.withAutoSidechainScope = !isAutoDeploy + fsChainParams.key = server.key + fsChainParams.withAutoFSChainScope = !isAutoDeploy - server.morphClient, err = server.createClient(ctx, morphChain, errChan) + server.morphClient, err = server.createClient(ctx, fsChainParams, errChan) if err != nil { return nil, err } } if isAutoDeploy { - log.Info("auto-deployment configured, initializing Sidechain...") + log.Info("auto-deployment configured, initializing FS chain...") - var sidechain *neoFSSidechain + var fschain *fsChain var clnt *client.Client // set if not isLocalConsensus only if isLocalConsensus { - sidechain = newNeoFSSidechain(server.morphClient, localWSClient) + fschain = newFSChain(server.morphClient, localWSClient) } else { // create new client for deployment procedure only. This is done because event // subscriptions can be created only once, but we must cancel them to prevent @@ -510,22 +541,22 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- clnt, err = client.New(server.key, client.WithContext(ctx), client.WithLogger(log), - client.WithDialTimeout(cfg.GetDuration(morphChain.name+".dial_timeout")), + client.WithDialTimeout(cfg.GetDuration(fsChainParams.name+".dial_timeout")), client.WithEndpoints(endpoints), - client.WithReconnectionRetries(cfg.GetInt(morphChain.name+".reconnections_number")), - client.WithReconnectionsDelay(cfg.GetDuration(morphChain.name+".reconnections_delay")), - client.WithMinRequiredBlockHeight(morphChain.from), + client.WithReconnectionRetries(cfg.GetInt(fsChainParams.name+".reconnections_number")), + client.WithReconnectionsDelay(cfg.GetDuration(fsChainParams.name+".reconnections_delay")), + client.WithMinRequiredBlockHeight(fsChainParams.from), ) if err != nil { - return nil, fmt.Errorf("create multi-endpoint client for Sidechain deployment: %w", err) + return nil, fmt.Errorf("create multi-endpoint client for FS chain deployment: %w", err) } - sidechain = newNeoFSSidechain(clnt, nil) + fschain = newFSChain(clnt, nil) } var deployPrm deploy.Prm deployPrm.Logger = server.log - deployPrm.Blockchain = sidechain + deployPrm.Blockchain = fschain deployPrm.LocalAccount = singleAcc deployPrm.ValidatorMultiSigAccount = consensusAcc deployPrm.Glagolitsa = &glagolitsa.Glagolitsa{} @@ -550,24 +581,24 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- server.setHealthStatus(control.HealthStatus_INITIALIZING_NETWORK) err = deploy.Deploy(ctx, deployPrm) if err != nil { - return nil, fmt.Errorf("deploy Sidechain: %w", err) + return nil, fmt.Errorf("deploy FS chain: %w", err) } - sidechain.cancelSubs() + fschain.cancelSubs() if !isLocalConsensus { clnt.Close() } - err = server.morphClient.InitSidechainScope() + err = server.morphClient.InitFSChainScope() if err != nil { - return nil, fmt.Errorf("init Sidechain witness scope: %w", err) + return nil, fmt.Errorf("init FS chain witness scope: %w", err) } server.log.Info("autodeploy completed") } // create morph listener - server.morphListener, err = createListener(server.morphClient, morphChain) + server.morphListener, err = createListener(server.morphClient, fsChainParams) if err != nil { return nil, err } @@ -581,8 +612,8 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- server.mainnetListener = server.morphListener server.mainnetClient = server.morphClient } else { - mainnetChain := morphChain - mainnetChain.withAutoSidechainScope = false + mainnetChain := fsChainParams + mainnetChain.withAutoFSChainScope = false mainnetChain.name = mainnetPrefix fromMainChainBlock, err := server.persistate.UInt32(persistateMainChainLastBlockKey) @@ -623,12 +654,12 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- return nil, err } - // enable notary support in the side client + // enable notary support in the FS client err = server.morphClient.EnableNotarySupport( client.WithProxyContract(server.contracts.proxy), ) if err != nil { - return nil, fmt.Errorf("could not enable side chain notary support: %w", err) + return nil, fmt.Errorf("could not enable FS chain notary support: %w", err) } server.morphListener.EnableNotarySupport(server.contracts.proxy, server.key.PublicKey().GetScriptHash(), @@ -1065,7 +1096,7 @@ func (s *Server) createClient(ctx context.Context, p chainParams, errChan chan<- client.WithConnSwitchCallback(func() { var err error - if p.name == morphPrefix { + if p.name == fsChainPrefix || p.name == deprecatedMorphPrefix { err = s.restartMorph() } else { err = s.restartMainChain() @@ -1076,8 +1107,8 @@ func (s *Server) createClient(ctx context.Context, p chainParams, errChan chan<- }), client.WithMinRequiredBlockHeight(p.from), } - if p.withAutoSidechainScope { - options = append(options, client.WithAutoSidechainScope()) + if p.withAutoFSChainScope { + options = append(options, client.WithAutoFSChainScope()) } return client.New(p.key, options...) @@ -1148,7 +1179,7 @@ func (s *Server) nextEpochBlockDelta() (uint32, error) { blockHeight, err := s.morphClient.BlockCount() if err != nil { - return 0, fmt.Errorf("can't get side chain height: %w", err) + return 0, fmt.Errorf("can't get FS chain height: %w", err) } delta := uint32(s.epochDuration.Load()) + epochBlock @@ -1197,7 +1228,7 @@ func (s *Server) restartMorph() error { err := s.initConfigFromBlockchain() if err != nil { - return fmt.Errorf("side chain config reinitialization: %w", err) + return fmt.Errorf("FS chain config reinitialization: %w", err) } for _, t := range s.blockTimers { diff --git a/pkg/innerring/netmap.go b/pkg/innerring/netmap.go index 03b13b0530..66a10338ef 100644 --- a/pkg/innerring/netmap.go +++ b/pkg/innerring/netmap.go @@ -14,13 +14,13 @@ File contains dependencies for processor of the Netmap contract's notifications. // wraps Netmap contract's client and provides state.NetworkSettings. type networkSettings netmapclient.Client -// MaintenanceModeAllowed requests network configuration from the Sidechain +// MaintenanceModeAllowed requests network configuration from FS chain // and check allowance of storage node's maintenance mode according to it. // Always returns state.ErrMaintenanceModeDisallowed. func (s *networkSettings) MaintenanceModeAllowed() error { allowed, err := (*netmapclient.Client)(s).MaintenanceModeAllowed() if err != nil { - return fmt.Errorf("read maintenance mode's allowance from the Sidechain: %w", err) + return fmt.Errorf("read maintenance mode's allowance from FS chain: %w", err) } else if allowed { return nil } diff --git a/pkg/innerring/notary.go b/pkg/innerring/notary.go index 2106b246b3..7f44cbdd6f 100644 --- a/pkg/innerring/notary.go +++ b/pkg/innerring/notary.go @@ -39,13 +39,13 @@ func (s *Server) depositMainNotary() error { return s.mainnetClient.DepositNotary(depositAmount, till) } -func (s *Server) depositSideNotary() error { +func (s *Server) depositFSNotary() error { depositAmount, err := client.CalculateNotaryDepositAmount(s.morphClient, gasMultiplier, gasDivisor) if err != nil { - return fmt.Errorf("could not calculate side notary deposit amount: %w", err) + return fmt.Errorf("could not calculate FS notary deposit amount: %w", err) } - s.log.Debug("making neofs chain endless notary deposit", zap.Stringer("fixed8 deposit", depositAmount)) + s.log.Debug("making FS chain endless notary deposit", zap.Stringer("fixed8 deposit", depositAmount)) return s.morphClient.DepositEndlessNotary(depositAmount) } @@ -58,8 +58,8 @@ func (s *Server) notaryHandler(_ event.Event) { } } - err := s.depositSideNotary() + err := s.depositFSNotary() if err != nil { - s.log.Error("can't make notary deposit in side chain", zap.Error(err)) + s.log.Error("can't make notary deposit in FS chain", zap.Error(err)) } } diff --git a/pkg/innerring/processors/alphabet/processor.go b/pkg/innerring/processors/alphabet/processor.go index 99325ee397..4570bd0f2c 100644 --- a/pkg/innerring/processors/alphabet/processor.go +++ b/pkg/innerring/processors/alphabet/processor.go @@ -31,7 +31,7 @@ type ( GetByIndex(int) (util.Uint160, bool) } - // Processor of events produced for alphabet contracts in the sidechain. + // Processor of events produced for alphabet contracts in FS chain. Processor struct { log *zap.Logger pool *ants.Pool diff --git a/pkg/innerring/processors/container/processor.go b/pkg/innerring/processors/container/processor.go index ac96ff3e50..232d65ab3d 100644 --- a/pkg/innerring/processors/container/processor.go +++ b/pkg/innerring/processors/container/processor.go @@ -19,7 +19,7 @@ type ( IsAlphabet() bool } - // Processor of events produced by container contract in the sidechain. + // Processor of events produced by container contract in FS chain. Processor struct { log *zap.Logger pool *ants.Pool diff --git a/pkg/innerring/processors/governance/list.go b/pkg/innerring/processors/governance/list.go index 9f982f7c6e..f65efa48ad 100644 --- a/pkg/innerring/processors/governance/list.go +++ b/pkg/innerring/processors/governance/list.go @@ -9,25 +9,25 @@ import ( ) var ( - errNotEnoughKeys = errors.New("alphabet list in mainnet is too short") - errNotEqualLen = errors.New("old and new alphabet lists have different length") - errEmptySidechain = errors.New("sidechain list is empty") + errNotEnoughKeys = errors.New("alphabet list in mainnet is too short") + errNotEqualLen = errors.New("old and new alphabet lists have different length") + errEmptyFSChain = errors.New("FS chain list is empty") ) -// newAlphabetList returns an updated list of sidechain keys with no more than 1\3 -// of new keys from the mainnet list. The function returns `errEmptySidechain` if -// the sidechain list is empty. The function returns `errNotEnoughKeys` if the mainnet -// list contains less keys than the sidechain list. The function returns (nil, nil) if -// the mainnet list contains all keys from the sidechain list. +// newAlphabetList returns an updated list of FS chain keys with no more than 1\3 +// of new keys from the mainnet list. The function returns `errEmptyFSChain` if +// FS chain list is empty. The function returns `errNotEnoughKeys` if the mainnet +// list contains less keys than FS chain list. The function returns (nil, nil) if +// the mainnet list contains all keys from FS chain list. // // Sorts passed slices. -func newAlphabetList(sidechain, mainnet keys.PublicKeys) (keys.PublicKeys, error) { - sort.Sort(sidechain) +func newAlphabetList(fsChain, mainnet keys.PublicKeys) (keys.PublicKeys, error) { + sort.Sort(fsChain) sort.Sort(mainnet) - ln := len(sidechain) + ln := len(fsChain) if ln == 0 { - return nil, errEmptySidechain + return nil, errEmptyFSChain } if len(mainnet) < ln { @@ -37,7 +37,7 @@ func newAlphabetList(sidechain, mainnet keys.PublicKeys) (keys.PublicKeys, error hmap := make(map[string]bool, ln) result := make(keys.PublicKeys, 0, ln) - for _, node := range sidechain { + for _, node := range fsChain { hmap[node.Address()] = false } @@ -68,7 +68,7 @@ func newAlphabetList(sidechain, mainnet keys.PublicKeys) (keys.PublicKeys, error return nil, nil } - for _, node := range sidechain { + for _, node := range fsChain { if len(result) == ln { break } diff --git a/pkg/innerring/processors/governance/list_test.go b/pkg/innerring/processors/governance/list_test.go index 7867d3b274..39f2391e92 100644 --- a/pkg/innerring/processors/governance/list_test.go +++ b/pkg/innerring/processors/governance/list_test.go @@ -15,9 +15,9 @@ func TestNewAlphabetList(t *testing.T) { orig := keys.PublicKeys{k[0], k[1], k[2], k[3], k[4], k[5], k[6]} - t.Run("no sidechain keys", func(t *testing.T) { + t.Run("no FS chain keys", func(t *testing.T) { _, err := newAlphabetList(nil, orig) - require.ErrorIs(t, err, errEmptySidechain) + require.ErrorIs(t, err, errEmptyFSChain) }) t.Run("same keys", func(t *testing.T) { diff --git a/pkg/innerring/processors/governance/process_update.go b/pkg/innerring/processors/governance/process_update.go index 49b6cdaf29..bdc161d354 100644 --- a/pkg/innerring/processors/governance/process_update.go +++ b/pkg/innerring/processors/governance/process_update.go @@ -27,16 +27,16 @@ func (gp *Processor) processAlphabetSync(txHash util.Uint256) { return } - sidechainAlphabet, err := gp.morphClient.Committee() + fsChainAlphabet, err := gp.morphClient.Committee() if err != nil { - gp.log.Error("can't fetch alphabet list from side chain", + gp.log.Error("can't fetch alphabet list from FS chain", zap.Error(err)) return } - newAlphabet, err := newAlphabetList(sidechainAlphabet, mainnetAlphabet) + newAlphabet, err := newAlphabetList(fsChainAlphabet, mainnetAlphabet) if err != nil { - gp.log.Error("can't merge alphabet lists from main net and side chain", + gp.log.Error("can't merge alphabet lists from main net and FS chain", zap.Error(err)) return } @@ -47,24 +47,24 @@ func (gp *Processor) processAlphabetSync(txHash util.Uint256) { } gp.log.Info("alphabet list has been changed, starting update", - zap.String("side_chain_alphabet", prettyKeys(sidechainAlphabet)), + zap.String("fs_chain_alphabet", prettyKeys(fsChainAlphabet)), zap.String("new_alphabet", prettyKeys(newAlphabet)), ) - // 1. Vote to sidechain committee via alphabet contracts. - err = gp.voter.VoteForSidechainValidator(newAlphabet, &txHash) + // 1. Vote to FS chain committee via alphabet contracts. + err = gp.voter.VoteForFSChainValidator(newAlphabet, &txHash) if err != nil { - gp.log.Error("can't vote for side chain committee", + gp.log.Error("can't vote for FS chain committee", zap.Error(err)) } - // 2. Update NeoFSAlphabet role in the sidechain. + // 2. Update NeoFSAlphabet role in FS chain. innerRing, err := gp.irFetcher.InnerRingKeys() if err != nil { - gp.log.Error("can't fetch inner ring list from side chain", + gp.log.Error("can't fetch inner ring list from FS chain", zap.Error(err)) } else { - newInnerRing, err := updateInnerRing(innerRing, sidechainAlphabet, newAlphabet) + newInnerRing, err := updateInnerRing(innerRing, fsChainAlphabet, newAlphabet) if err != nil { gp.log.Error("can't create new inner ring list with new alphabet keys", zap.Error(err)) @@ -85,10 +85,10 @@ func (gp *Processor) processAlphabetSync(txHash util.Uint256) { } } - // 3. Update notary role in the sidechain. + // 3. Update notary role in FS chain. err = gp.morphClient.UpdateNotaryList(newAlphabet, txHash) if err != nil { - gp.log.Error("can't update list of notary nodes in side chain", + gp.log.Error("can't update list of notary nodes in FS chain", zap.Error(err)) } diff --git a/pkg/innerring/processors/governance/processor.go b/pkg/innerring/processors/governance/processor.go index e9b6d7d715..3a7b59763d 100644 --- a/pkg/innerring/processors/governance/processor.go +++ b/pkg/innerring/processors/governance/processor.go @@ -30,7 +30,7 @@ type ( // Voter is a callback interface for alphabet contract voting. type Voter interface { - VoteForSidechainValidator(keys.PublicKeys, *util.Uint256) error + VoteForFSChainValidator(keys.PublicKeys, *util.Uint256) error } type ( @@ -88,7 +88,7 @@ func New(p *Params) (*Processor, error) { case p.MainnetClient == nil: return nil, errors.New("ir/governance: neo:mainnet client is not set") case p.MorphClient == nil: - return nil, errors.New("ir/governance: neo:sidechain client is not set") + return nil, errors.New("ir/governance: neo: FS client is not set") case p.AlphabetState == nil: return nil, errors.New("ir/governance: global state is not set") case p.EpochState == nil: diff --git a/pkg/innerring/processors/neofs/process_assets.go b/pkg/innerring/processors/neofs/process_assets.go index ad8dd14ecc..40e460a3d8 100644 --- a/pkg/innerring/processors/neofs/process_assets.go +++ b/pkg/innerring/processors/neofs/process_assets.go @@ -13,7 +13,7 @@ const ( ) // Process deposit event by invoking a balance contract and sending native -// gas in the sidechain. +// gas in FS chain. func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) { if !np.alphabetState.IsAlphabet() { np.log.Info("non alphabet mode, ignore deposit") diff --git a/pkg/innerring/processors/neofs/process_config.go b/pkg/innerring/processors/neofs/process_config.go index d816853600..d3b2570a01 100644 --- a/pkg/innerring/processors/neofs/process_config.go +++ b/pkg/innerring/processors/neofs/process_config.go @@ -6,8 +6,7 @@ import ( "go.uber.org/zap" ) -// Process config event by setting configuration value from the mainchain in -// the sidechain. +// Process config event by setting configuration value from the mainchain in FS chain. func (np *Processor) processConfig(config *neofsEvent.Config) { if !np.alphabetState.IsAlphabet() { np.log.Info("non alphabet mode, ignore config") diff --git a/pkg/innerring/settlement.go b/pkg/innerring/settlement.go index 8671e51c29..6d994dace1 100644 --- a/pkg/innerring/settlement.go +++ b/pkg/innerring/settlement.go @@ -91,7 +91,7 @@ func (c containerWrapper) Owner() user.ID { func (s settlementDeps) AuditResultsForEpoch(epoch uint64) ([]*auditsvc.Result, error) { idList, err := s.auditClient.ListAuditResultIDByEpoch(epoch) if err != nil { - return nil, fmt.Errorf("could not list audit results in sidechain: %w", err) + return nil, fmt.Errorf("could not list audit results in FS chain: %w", err) } res := make([]*auditsvc.Result, 0, len(idList)) @@ -135,7 +135,7 @@ func (s settlementDeps) buildContainer(e uint64, cid cid.ID) ([][]netmapAPI.Node cnr, err := s.cnrSrc.Get(cid) if err != nil { - return nil, nil, fmt.Errorf("could not get container from sidechain: %w", err) + return nil, nil, fmt.Errorf("could not get container from FS chain: %w", err) } cn, err := nm.ContainerNodes( diff --git a/pkg/innerring/state.go b/pkg/innerring/state.go index da545bb947..3e6d83c8ff 100644 --- a/pkg/innerring/state.go +++ b/pkg/innerring/state.go @@ -18,8 +18,9 @@ import ( const voteMethod = "vote" var ( - persistateMainChainLastBlockKey = []byte("main_chain_last_processed_block") - persistateSideChainLastBlockKey = []byte("side_chain_last_processed_block") + persistateMainChainLastBlockKey = []byte("main_chain_last_processed_block") + persistateFSChainLastBlockKey = []byte("fs_chain_last_processed_block") + persistateDeprecatedSidechainLastBlockKey = []byte("side_chain_last_processed_block") ) // EpochCounter is a getter for a global epoch counter. @@ -93,7 +94,7 @@ func (s *Server) AlphabetIndex() int { return int(index) } -func (s *Server) voteForSidechainValidator(validators keys.PublicKeys, trigger *util.Uint256) error { +func (s *Server) voteForFSChainValidator(validators keys.PublicKeys, trigger *util.Uint256) error { index := s.InnerRingIndex() if s.contracts.alphabet.indexOutOfRange(index) { s.log.Info("ignore validator vote: node not in alphabet range") @@ -169,11 +170,11 @@ func (s *Server) alreadyVoted(validatorsToVote keys.PublicKeys) (bool, error) { return true, nil } -// VoteForSidechainValidator calls vote method on alphabet contracts with +// VoteForFSChainValidator calls vote method on alphabet contracts with // the provided list of keys and hash of the triggering transaction. -func (s *Server) VoteForSidechainValidator(validators keys.PublicKeys, trigger *util.Uint256) error { +func (s *Server) VoteForFSChainValidator(validators keys.PublicKeys, trigger *util.Uint256) error { sort.Sort(validators) - return s.voteForSidechainValidator(validators, trigger) + return s.voteForFSChainValidator(validators, trigger) } // WriteReport composes the audit result structure from the audit report diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index 54a204ae92..6ec0a93155 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -459,7 +459,7 @@ func (c *Client) TxHeight(h util.Uint256) (res uint32, err error) { } // NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain -// stores alphabet node keys of inner ring there, however the sidechain stores both +// stores alphabet node keys of inner ring there, however FS chain stores both // alphabet and non alphabet node keys of inner ring. func (c *Client) NeoFSAlphabetList() (res keys.PublicKeys, err error) { var conn = c.conn.Load() diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 76fbfe2ea5..d4969e6851 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -37,8 +37,8 @@ type cfg struct { logger *zap.Logger // logging component - autoSidechainScope bool - signer *transaction.Signer + autoFSChainScope bool + signer *transaction.Signer endpointsLock *sync.RWMutex endpoints []string @@ -201,8 +201,8 @@ func (c *Client) newConnectionWS(cli *rpcclient.WSClient) (*connection, error) { if err != nil { return nil, fmt.Errorf("WS client initialization: %w", err) } - if c.cfg.autoSidechainScope { - err = autoSidechainScope(cli, &c.cfg) + if c.cfg.autoFSChainScope { + err = autoFSChainScope(cli, &c.cfg) if err != nil { return nil, fmt.Errorf("scope setup: %w", err) } @@ -349,12 +349,12 @@ func WithMinRequiredBlockHeight(h uint32) Option { } } -// WithAutoSidechainScope returns a client constructor +// WithAutoFSChainScope returns a client constructor // option that sets automatic transaction scope detection to // true which overrides the default CalledByEntry to a set of -// Rules made specifically for the sidechain. -func WithAutoSidechainScope() Option { +// Rules made specifically for FS chain. +func WithAutoFSChainScope() Option { return func(c *cfg) { - c.autoSidechainScope = true + c.autoFSChainScope = true } } diff --git a/pkg/morph/client/netmap/config.go b/pkg/morph/client/netmap/config.go index 7174d603d8..90678419f4 100644 --- a/pkg/morph/client/netmap/config.go +++ b/pkg/morph/client/netmap/config.go @@ -58,7 +58,7 @@ func (c *Client) AuditFee() (uint64, error) { return fee, nil } -// EpochDuration returns number of sidechain blocks per one NeoFS epoch. +// EpochDuration returns number of FS chain blocks per one NeoFS epoch. func (c *Client) EpochDuration() (uint64, error) { epochDuration, err := c.readUInt64Config(EpochDurationConfig) if err != nil { @@ -143,7 +143,7 @@ func (c *Client) WithdrawFee() (uint64, error) { } // MaintenanceModeAllowed reads admission of "maintenance" state from the -// NeoFS network configuration stored in the Sidechain. The admission means +// NeoFS network configuration stored in FS chain. The admission means // that storage nodes are allowed to switch their state to "maintenance". // // By default, maintenance state is disallowed. @@ -172,7 +172,7 @@ func (c *Client) readStringConfig(key string) (string, error) { } // reads boolean value by the given key from the NeoFS network configuration -// stored in the Sidechain. Returns false if key is not presented. +// stored in FS chain. Returns false if key is not presented. func (c *Client) readBoolConfig(key string) (bool, error) { v, err := c.config([]byte(key), BoolAssert) if err != nil { @@ -180,7 +180,7 @@ func (c *Client) readBoolConfig(key string) (bool, error) { return false, nil } - return false, fmt.Errorf("read boolean configuration value %s from the Sidechain: %w", key, err) + return false, fmt.Errorf("read boolean configuration value %s from FS chain: %w", key, err) } // BoolAssert is guaranteed to return bool if the error is nil. @@ -232,7 +232,7 @@ type RawNetworkParameter struct { } // NetworkConfiguration represents NeoFS network configuration stored -// in the NeoFS Sidechain. +// in FS chain. type NetworkConfiguration struct { MaxObjectSize uint64 @@ -261,7 +261,7 @@ type NetworkConfiguration struct { Raw []RawNetworkParameter } -// ReadNetworkConfiguration reads NetworkConfiguration from the NeoFS Sidechain. +// ReadNetworkConfiguration reads NetworkConfiguration from FS chain. func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) { var res NetworkConfiguration prm := client.TestInvokePrm{} diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index 5e0df2290c..efb06faceb 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -82,20 +82,20 @@ func (c *Client) NNSHash() (util.Uint160, error) { return *nnsHash, nil } -// InitSidechainScope allows to replace [WithAutoSidechainScope] option and -// postpone Sidechain scope initialization when NNS contract is not yet ready +// InitFSChainScope allows to replace [WithAutoFSChainScope] option and +// postpone FS chain scope initialization when NNS contract is not yet ready // while Client is already needed. -func (c *Client) InitSidechainScope() error { +func (c *Client) InitFSChainScope() error { var conn = c.conn.Load() if conn == nil { return ErrConnectionLost } - return autoSidechainScope(conn.client, &c.cfg) + return autoFSChainScope(conn.client, &c.cfg) } -func autoSidechainScope(ws *rpcclient.WSClient, conf *cfg) error { +func autoFSChainScope(ws *rpcclient.WSClient, conf *cfg) error { nnsHash, err := nns.InferHash(ws) if err != nil { return fmt.Errorf("resolve NNS contract address: %w", err) diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 286e5e6ac4..4424ca975b 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -32,7 +32,7 @@ import ( type ( notaryInfo struct { txValidTime uint32 // minimum amount of blocks when mainTx will be valid - roundTime uint32 // extra amount of blocks to synchronize sidechain height diff of inner ring nodes + roundTime uint32 // extra amount of blocks to synchronize FS chain height diff of inner ring nodes alphabetSource AlphabetKeys // source of alphabet node keys to prepare witness @@ -281,7 +281,7 @@ func (c *Client) UpdateNotaryList(notaries keys.PublicKeys, txHash util.Uint256) } // UpdateNeoFSAlphabetList updates list of alphabet nodes in designate contract. -// As for sidechain list should contain all inner ring nodes. +// As for FS chain list should contain all inner ring nodes. // Requires committee multi signature. // // This function must be invoked with notary enabled otherwise it throws panic. @@ -618,7 +618,7 @@ func WithTxValidTime(t uint32) NotaryOption { } // WithRoundTime returns a notary support option for client -// that specifies extra blocks to synchronize side chain +// that specifies extra blocks to synchronize FS chain // height diff of inner ring nodes. func WithRoundTime(t uint32) NotaryOption { return func(c *notaryCfg) { @@ -629,7 +629,7 @@ func WithRoundTime(t uint32) NotaryOption { // WithAlphabetSource returns a notary support option for client // that specifies function to return list of alphabet node keys. // By default notary subsystem uses committee as a source. This is -// valid for side chain but notary in main chain should override it. +// valid for FS chain but notary in main chain should override it. func WithAlphabetSource(t AlphabetKeys) NotaryOption { return func(c *notaryCfg) { c.alphabetSource = t diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 4c9059453b..ab16715d59 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -42,11 +42,11 @@ type Reader interface { // Writer is an interface of container storage updater. type Writer interface { - // Put stores specified container in the side chain. + // Put stores specified container in FS chain. Put(containercore.Container) (*cid.ID, error) - // Delete removes specified container from the side chain. + // Delete removes specified container from FS chain. Delete(containercore.RemovalWitness) error - // PutEACL updates extended ACL table of specified container in the side chain. + // PutEACL updates extended ACL table of specified container in FS chain. PutEACL(containercore.EACL) error } diff --git a/pkg/util/state/storage.go b/pkg/util/state/storage.go index 72e65065a7..5dbb12df01 100644 --- a/pkg/util/state/storage.go +++ b/pkg/util/state/storage.go @@ -104,3 +104,17 @@ func (p PersistentStorage) Bytes(key []byte) (res []byte, err error) { return } + +func (p PersistentStorage) Delete(key []byte) error { + return p.db.Update(func(tx *bbolt.Tx) error { + b := tx.Bucket(stateBucket) + if b != nil { + err := b.Delete(key) + if err != nil { + return fmt.Errorf("can't delete state: %w", err) + } + } + + return nil + }) +}