From 9c1fb0b55ebff1537f0b186d6b750259182f9668 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 29 Jul 2021 13:06:25 +0300 Subject: [PATCH] [#728] neofs-adm: update to neofs-contract@v0.10.1 Add config parameters to netmap and neofs contracts. Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize.go | 8 ++++ .../modules/morph/initialize_deploy.go | 47 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index f3e5bdce..18cb8813 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -119,6 +119,14 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex return nil, fmt.Errorf("can't find consensus account: %w", err) } + if viper.GetInt64(epochDurationInitFlag) <= 0 { + return nil, fmt.Errorf("epoch duration must be positive") + } + + if viper.GetInt64(maxObjectSizeInitFlag) <= 0 { + return nil, fmt.Errorf("max object size must be positive") + } + initCtx := &initializeContext{ Client: c, ConsensusAcc: consensusAcc, diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index f6c1b945..7f3993c3 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -15,6 +15,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/innerring" + "github.com/spf13/viper" ) const ( @@ -31,6 +32,26 @@ const ( reputationContract = "reputation" ) +const ( + netmapEpochKey = "EpochDuration" + netmapMaxObjectSizeKey = "MaxObjectSize" + netmapAuditFeeKey = "AuditFee" + netmapContainerFeeKey = "ContainerFee" + netmapEigenTrustIterationsKey = "EigenTrustIterations" + netmapEigenTrustAlphaKey = "EigenTrustAlpha" + netmapBasicIncomeRateKey = "BasicIncomeRate" + netmapInnerRingCandidateFeeKey = "InnerRingCandidateFee" + netmapWithdrawFeeKey = "WithdrawFee" + + defaultAuditFee = 10000 + defaultContainerFee = 1000 + defaultEigenTrustIterations = 4 + defaultEigenTrustAlpha = "0.1" + defaultBasicIncomeRate = 100000000 + defaultInnerRingCandidateFee = 10000000000 + defaultWithdrawFee = 100000000 +) + var contractList = []string{ auditContract, balanceContract, @@ -238,7 +259,8 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []sm case neofsContract: items = append(items, newContractParameter(smartcontract.Hash160Type, c.Contracts[processingContract].Hash), - newContractParameter(smartcontract.ArrayType, keysParam)) + newContractParameter(smartcontract.ArrayType, keysParam), + newContractParameter(smartcontract.ArrayType, smartcontract.Parameter{})) case processingContract: items = append(items, newContractParameter(smartcontract.Hash160Type, c.Contracts[neofsContract].Hash)) return items[1:] // no notary info @@ -259,10 +281,31 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []sm newContractParameter(smartcontract.Hash160Type, c.Contracts[netmapContract].Hash), newContractParameter(smartcontract.Hash160Type, c.Contracts[containerContract].Hash)) case netmapContract: + configParam := []smartcontract.Parameter{ + {Type: smartcontract.StringType, Value: netmapEpochKey}, + {Type: smartcontract.IntegerType, Value: viper.GetInt64(epochDurationInitFlag)}, + {Type: smartcontract.StringType, Value: netmapMaxObjectSizeKey}, + {Type: smartcontract.IntegerType, Value: viper.GetInt64(maxObjectSizeInitFlag)}, + {Type: smartcontract.StringType, Value: netmapAuditFeeKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultAuditFee)}, + {Type: smartcontract.StringType, Value: netmapContainerFeeKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultContainerFee)}, + {Type: smartcontract.StringType, Value: netmapEigenTrustIterationsKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultEigenTrustIterations)}, + {Type: smartcontract.StringType, Value: netmapEigenTrustAlphaKey}, + {Type: smartcontract.StringType, Value: defaultEigenTrustAlpha}, + {Type: smartcontract.StringType, Value: netmapBasicIncomeRateKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultBasicIncomeRate)}, + {Type: smartcontract.StringType, Value: netmapInnerRingCandidateFeeKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultInnerRingCandidateFee)}, + {Type: smartcontract.StringType, Value: netmapWithdrawFeeKey}, + {Type: smartcontract.IntegerType, Value: int64(defaultWithdrawFee)}, + } items = append(items, newContractParameter(smartcontract.Hash160Type, c.Contracts[balanceContract].Hash), newContractParameter(smartcontract.Hash160Type, c.Contracts[containerContract].Hash), - newContractParameter(smartcontract.ArrayType, keysParam)) + newContractParameter(smartcontract.ArrayType, keysParam), + newContractParameter(smartcontract.ArrayType, configParam)) case proxyContract: items = append(items, newContractParameter(smartcontract.Hash160Type, c.Contracts[netmapContract].Hash)) case reputationContract: