diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index f31354fa9a..516192baa3 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -64,8 +64,6 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("contracts.proxy", "") cfg.SetDefault("contracts.processing", "") cfg.SetDefault("contracts.reputation", "") - // alphabet contracts - cfg.SetDefault("contracts.alphabet.amount", 7) cfg.SetDefault("timers.epoch", "0") cfg.SetDefault("timers.emit", "0") diff --git a/pkg/innerring/contracts.go b/pkg/innerring/contracts.go index dcc59ed7f0..5c5504f27e 100644 --- a/pkg/innerring/contracts.go +++ b/pkg/innerring/contracts.go @@ -1,6 +1,7 @@ package innerring import ( + "errors" "fmt" "strings" @@ -87,18 +88,34 @@ func parseAlphabetContracts(cfg *viper.Viper, morph *client.Client) (alphabetCon return nil, fmt.Errorf("amount of alphabet contracts overflows glagolitsa %d > %d", num, lastLetterNum) } + thresholdIsSet := num != 0 + + if !thresholdIsSet { + // try to read maximum alphabet contracts + // if threshold has not been set manually + num = lastLetterNum + } + for letter := az; letter < num; letter++ { contractHash, err := parseContract(cfg, morph, "contracts.alphabet."+letter.String(), client.NNSAlphabetContractName(int(letter)), ) if err != nil { + if errors.Is(err, client.ErrNNSRecordNotFound) { + break + } + return nil, fmt.Errorf("invalid alphabet %s contract: %w", letter, err) } alpha.set(letter, contractHash) } + if thresholdIsSet && len(alpha) != int(num) { + return nil, fmt.Errorf("could not read all contracts: required %d, read %d", num, len(alpha)) + } + return alpha, nil }