[#1365] adm: Add homomorphic hash disabling option

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-05 21:28:11 +03:00 committed by Evgenii Stratonikov
parent adcda361a7
commit 2d9c805c81
3 changed files with 72 additions and 63 deletions

View file

@ -14,17 +14,18 @@ import (
) )
type configTemplate struct { type configTemplate struct {
Endpoint string Endpoint string
AlphabetDir string AlphabetDir string
MaxObjectSize int MaxObjectSize int
EpochDuration int EpochDuration int
BasicIncomeRate int BasicIncomeRate int
AuditFee int AuditFee int
CandidateFee int CandidateFee int
ContainerFee int ContainerFee int
ContainerAliasFee int ContainerAliasFee int
WithdrawFee int WithdrawFee int
Glagolitics []string Glagolitics []string
HomomorphicHashDisabled bool
} }
const configTxtTemplate = `rpc-endpoint: {{ .Endpoint}} const configTxtTemplate = `rpc-endpoint: {{ .Endpoint}}
@ -33,6 +34,7 @@ network:
max_object_size: {{ .MaxObjectSize}} max_object_size: {{ .MaxObjectSize}}
epoch_duration: {{ .EpochDuration}} epoch_duration: {{ .EpochDuration}}
basic_income_rate: {{ .BasicIncomeRate}} basic_income_rate: {{ .BasicIncomeRate}}
homomorphic_hash_disabled: {{ .HomomorphicHashDisabled}}
fee: fee:
audit: {{ .AuditFee}} audit: {{ .AuditFee}}
candidate: {{ .CandidateFee}} candidate: {{ .CandidateFee}}
@ -106,16 +108,17 @@ func defaultConfigPath() (string, error) {
// some comments as well. // some comments as well.
func generateConfigExample(appDir string, credSize int) (string, error) { func generateConfigExample(appDir string, credSize int) (string, error) {
tmpl := configTemplate{ tmpl := configTemplate{
Endpoint: "https://neo.rpc.node:30333", Endpoint: "https://neo.rpc.node:30333",
MaxObjectSize: 67108864, // 64 MiB MaxObjectSize: 67108864, // 64 MiB
EpochDuration: 240, // 1 hour with 15s per block EpochDuration: 240, // 1 hour with 15s per block
BasicIncomeRate: 1_0000_0000, // 0.0001 GAS per GiB (Fixed12) BasicIncomeRate: 1_0000_0000, // 0.0001 GAS per GiB (Fixed12)
AuditFee: 1_0000, // 0.00000001 GAS per audit (Fixed12) HomomorphicHashDisabled: false, // object homomorphic hash is enabled
CandidateFee: 100_0000_0000, // 100.0 GAS (Fixed8) AuditFee: 1_0000, // 0.00000001 GAS per audit (Fixed12)
ContainerFee: 1000, // 0.000000001 * 7 GAS per container (Fixed12) CandidateFee: 100_0000_0000, // 100.0 GAS (Fixed8)
ContainerAliasFee: 500, // ContainerFee / 2 ContainerFee: 1000, // 0.000000001 * 7 GAS per container (Fixed12)
WithdrawFee: 1_0000_0000, // 1.0 GAS (Fixed8) ContainerAliasFee: 500, // ContainerFee / 2
Glagolitics: make([]string, 0, credSize), WithdrawFee: 1_0000_0000, // 1.0 GAS (Fixed8)
Glagolitics: make([]string, 0, credSize),
} }
appDir, err := filepath.Abs(appDir) appDir, err := filepath.Abs(appDir)

View file

@ -47,16 +47,17 @@ const (
) )
const ( const (
netmapEpochKey = "EpochDuration" netmapEpochKey = "EpochDuration"
netmapMaxObjectSizeKey = "MaxObjectSize" netmapMaxObjectSizeKey = "MaxObjectSize"
netmapAuditFeeKey = "AuditFee" netmapAuditFeeKey = "AuditFee"
netmapContainerFeeKey = "ContainerFee" netmapContainerFeeKey = "ContainerFee"
netmapContainerAliasFeeKey = "ContainerAliasFee" netmapContainerAliasFeeKey = "ContainerAliasFee"
netmapEigenTrustIterationsKey = "EigenTrustIterations" netmapEigenTrustIterationsKey = "EigenTrustIterations"
netmapEigenTrustAlphaKey = "EigenTrustAlpha" netmapEigenTrustAlphaKey = "EigenTrustAlpha"
netmapBasicIncomeRateKey = "BasicIncomeRate" netmapBasicIncomeRateKey = "BasicIncomeRate"
netmapInnerRingCandidateFeeKey = "InnerRingCandidateFee" netmapInnerRingCandidateFeeKey = "InnerRingCandidateFee"
netmapWithdrawFeeKey = "WithdrawFee" netmapWithdrawFeeKey = "WithdrawFee"
netmapHomomorphicHashDisabledKey = "HomomorphicHashingDisabled"
defaultEigenTrustIterations = 4 defaultEigenTrustIterations = 4
defaultEigenTrustAlpha = "0.1" defaultEigenTrustAlpha = "0.1"
@ -544,6 +545,7 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []in
netmapBasicIncomeRateKey, viper.GetInt64(incomeRateInitFlag), netmapBasicIncomeRateKey, viper.GetInt64(incomeRateInitFlag),
netmapInnerRingCandidateFeeKey, viper.GetInt64(candidateFeeInitFlag), netmapInnerRingCandidateFeeKey, viper.GetInt64(candidateFeeInitFlag),
netmapWithdrawFeeKey, viper.GetInt64(withdrawFeeInitFlag), netmapWithdrawFeeKey, viper.GetInt64(withdrawFeeInitFlag),
netmapHomomorphicHashDisabledKey, viper.GetBool(homomorphicHashDisabledInitFlag),
} }
items = append(items, items = append(items,
c.Contracts[balanceContract].Hash, c.Contracts[balanceContract].Hash,

View file

@ -6,38 +6,40 @@ import (
) )
const ( const (
alphabetWalletsFlag = "alphabet-wallets" alphabetWalletsFlag = "alphabet-wallets"
alphabetSizeFlag = "size" alphabetSizeFlag = "size"
endpointFlag = "rpc-endpoint" endpointFlag = "rpc-endpoint"
storageWalletFlag = "storage-wallet" storageWalletFlag = "storage-wallet"
storageWalletLabelFlag = "label" storageWalletLabelFlag = "label"
storageGasCLIFlag = "initial-gas" storageGasCLIFlag = "initial-gas"
storageGasConfigFlag = "storage.initial_gas" storageGasConfigFlag = "storage.initial_gas"
contractsInitFlag = "contracts" contractsInitFlag = "contracts"
maxObjectSizeInitFlag = "network.max_object_size" maxObjectSizeInitFlag = "network.max_object_size"
maxObjectSizeCLIFlag = "max-object-size" maxObjectSizeCLIFlag = "max-object-size"
epochDurationInitFlag = "network.epoch_duration" epochDurationInitFlag = "network.epoch_duration"
epochDurationCLIFlag = "epoch-duration" epochDurationCLIFlag = "epoch-duration"
incomeRateInitFlag = "network.basic_income_rate" incomeRateInitFlag = "network.basic_income_rate"
incomeRateCLIFlag = "basic-income-rate" incomeRateCLIFlag = "basic-income-rate"
auditFeeInitFlag = "network.fee.audit" auditFeeInitFlag = "network.fee.audit"
auditFeeCLIFlag = "audit-fee" auditFeeCLIFlag = "audit-fee"
containerFeeInitFlag = "network.fee.container" containerFeeInitFlag = "network.fee.container"
containerAliasFeeInitFlag = "network.fee.container_alias" containerAliasFeeInitFlag = "network.fee.container_alias"
containerFeeCLIFlag = "container-fee" containerFeeCLIFlag = "container-fee"
containerAliasFeeCLIFlag = "container-alias-fee" containerAliasFeeCLIFlag = "container-alias-fee"
candidateFeeInitFlag = "network.fee.candidate" candidateFeeInitFlag = "network.fee.candidate"
candidateFeeCLIFlag = "candidate-fee" candidateFeeCLIFlag = "candidate-fee"
withdrawFeeInitFlag = "network.fee.withdraw" homomorphicHashDisabledInitFlag = "network.homomorphic_hash_disabled"
withdrawFeeCLIFlag = "withdraw-fee" homomorphicHashDisabledCLIFlag = "homomorphic-disabled"
containerDumpFlag = "dump" withdrawFeeInitFlag = "network.fee.withdraw"
containerContractFlag = "container-contract" withdrawFeeCLIFlag = "withdraw-fee"
containerIDsFlag = "cid" containerDumpFlag = "dump"
refillGasAmountFlag = "gas" containerContractFlag = "container-contract"
walletAccountFlag = "account" containerIDsFlag = "cid"
notaryDepositTillFlag = "till" refillGasAmountFlag = "gas"
localDumpFlag = "local-dump" walletAccountFlag = "account"
protoConfigPath = "protocol" notaryDepositTillFlag = "till"
localDumpFlag = "local-dump"
protoConfigPath = "protocol"
) )
var ( var (
@ -66,6 +68,7 @@ var (
_ = viper.BindPFlag(epochDurationInitFlag, cmd.Flags().Lookup(epochDurationCLIFlag)) _ = viper.BindPFlag(epochDurationInitFlag, cmd.Flags().Lookup(epochDurationCLIFlag))
_ = viper.BindPFlag(maxObjectSizeInitFlag, cmd.Flags().Lookup(maxObjectSizeCLIFlag)) _ = viper.BindPFlag(maxObjectSizeInitFlag, cmd.Flags().Lookup(maxObjectSizeCLIFlag))
_ = viper.BindPFlag(incomeRateInitFlag, cmd.Flags().Lookup(incomeRateCLIFlag)) _ = viper.BindPFlag(incomeRateInitFlag, cmd.Flags().Lookup(incomeRateCLIFlag))
_ = viper.BindPFlag(homomorphicHashDisabledInitFlag, cmd.Flags().Lookup(homomorphicHashDisabledCLIFlag))
_ = viper.BindPFlag(auditFeeInitFlag, cmd.Flags().Lookup(auditFeeCLIFlag)) _ = viper.BindPFlag(auditFeeInitFlag, cmd.Flags().Lookup(auditFeeCLIFlag))
_ = viper.BindPFlag(candidateFeeInitFlag, cmd.Flags().Lookup(candidateFeeCLIFlag)) _ = viper.BindPFlag(candidateFeeInitFlag, cmd.Flags().Lookup(candidateFeeCLIFlag))
_ = viper.BindPFlag(containerFeeInitFlag, cmd.Flags().Lookup(containerFeeCLIFlag)) _ = viper.BindPFlag(containerFeeInitFlag, cmd.Flags().Lookup(containerFeeCLIFlag))
@ -210,6 +213,7 @@ func init() {
initCmd.Flags().String(contractsInitFlag, "", "path to archive with compiled NeoFS contracts (default fetched from latest github release)") 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 side chain blocks in one NeoFS epoch")
initCmd.Flags().Uint(maxObjectSizeCLIFlag, 67108864, "max single object size in bytes") 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. // Defaults are taken from neo-preodolenie.
initCmd.Flags().Uint64(containerFeeCLIFlag, 1000, "container registration fee") initCmd.Flags().Uint64(containerFeeCLIFlag, 1000, "container registration fee")
initCmd.Flags().Uint64(containerAliasFeeCLIFlag, 500, "container alias fee") initCmd.Flags().Uint64(containerAliasFeeCLIFlag, 500, "container alias fee")