[#1680] morph/netmap: Support HomomorphicHashingDisabled config

`NetworkConfiguration` represents NeoFS network configuration stored in
the Sidechain. In previous implementation the configuration missed flag
of disabled homomorphic hashing.

Add `NetworkConfiguration.HomomorphicHashingDisabled` boolean field.
Decode the field in `Client.ReadNetworkConfiguration` method. Print this
value in `netmap netinfo` command of NeoFS CLI.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-09-19 19:31:56 +04:00 committed by fyrchik
parent e0194dbde5
commit d2d4191868
3 changed files with 19 additions and 0 deletions

View file

@ -47,6 +47,7 @@ var netInfoCmd = &cobra.Command{
cmd.Printf(format, "Inner Ring candidate fee", netInfo.IRCandidateFee()) cmd.Printf(format, "Inner Ring candidate fee", netInfo.IRCandidateFee())
cmd.Printf(format, "Maximum object size", netInfo.MaxObjectSize()) cmd.Printf(format, "Maximum object size", netInfo.MaxObjectSize())
cmd.Printf(format, "Withdrawal fee", netInfo.WithdrawalFee()) cmd.Printf(format, "Withdrawal fee", netInfo.WithdrawalFee())
cmd.Printf(format, "Homomorphic hashing disabled", netInfo.HomomorphicHashingDisabled())
cmd.Println("NeoFS network configuration (other)") cmd.Println("NeoFS network configuration (other)")
netInfo.IterateRawNetworkParameters(func(name string, value []byte) { netInfo.IterateRawNetworkParameters(func(name string, value []byte) {

View file

@ -400,6 +400,10 @@ func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) {
ni.SetIRCandidateFee(netInfoMorph.IRCandidateFee) ni.SetIRCandidateFee(netInfoMorph.IRCandidateFee)
ni.SetWithdrawalFee(netInfoMorph.WithdrawalFee) ni.SetWithdrawalFee(netInfoMorph.WithdrawalFee)
if netInfoMorph.HomomorphicHashingDisabled {
ni.DisableHomomorphicHashing()
}
for i := range netInfoMorph.Raw { for i := range netInfoMorph.Raw {
ni.SetRawNetworkParameter(netInfoMorph.Raw[i].Name, netInfoMorph.Raw[i].Value) ni.SetRawNetworkParameter(netInfoMorph.Raw[i].Name, netInfoMorph.Raw[i].Value)
} }

View file

@ -244,6 +244,8 @@ type NetworkConfiguration struct {
WithdrawalFee uint64 WithdrawalFee uint64
HomomorphicHashingDisabled bool
Raw []RawNetworkParameter Raw []RawNetworkParameter
} }
@ -308,6 +310,8 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
res.IRCandidateFee = bytesToUint64(value) res.IRCandidateFee = bytesToUint64(value)
case withdrawFeeConfig: case withdrawFeeConfig:
res.WithdrawalFee = bytesToUint64(value) res.WithdrawalFee = bytesToUint64(value)
case homomorphicHashingDisabledKey:
res.HomomorphicHashingDisabled = bytesToBool(value)
} }
return nil return nil
@ -323,6 +327,16 @@ func bytesToUint64(val []byte) uint64 {
return bigint.FromBytes(val).Uint64() return bigint.FromBytes(val).Uint64()
} }
func bytesToBool(val []byte) bool {
for i := range val {
if val[i] != 0 {
return true
}
}
return false
}
// ErrConfigNotFound is returned when the requested key was not found // ErrConfigNotFound is returned when the requested key was not found
// in the network config (returned value is `Null`). // in the network config (returned value is `Null`).
var ErrConfigNotFound = errors.New("config value not found") var ErrConfigNotFound = errors.New("config value not found")