forked from TrueCloudLab/frostfs-node
[#248] innerring: Remove audit and settlement code
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
8b2aae73c6
commit
8879c6ea4a
36 changed files with 8 additions and 3008 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/alphabet"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/audit"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/balance"
|
||||
cont "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/frostfs"
|
||||
|
@ -17,25 +16,19 @@ import (
|
|||
nodevalidator "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation"
|
||||
addrvalidator "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/maddress"
|
||||
statevalidation "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/settlement"
|
||||
auditSettlement "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/settlement/audit"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
auditClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/audit"
|
||||
balanceClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/balance"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container"
|
||||
frostfsClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/frostfs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/frostfsid"
|
||||
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
||||
audittask "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/audit/taskmanager"
|
||||
control "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
||||
controlsrv "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
||||
util2 "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||
utilConfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
|
@ -43,9 +36,7 @@ import (
|
|||
|
||||
func (s *Server) initNetmapProcessor(cfg *viper.Viper,
|
||||
cnrClient *container.Client,
|
||||
alphaSync event.Handler,
|
||||
auditProcessor *audit.Processor,
|
||||
settlementProcessor *settlement.Processor) error {
|
||||
alphaSync event.Handler) error {
|
||||
locodeValidator, err := s.newLocodeValidator(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -70,15 +61,9 @@ func (s *Server) initNetmapProcessor(cfg *viper.Viper,
|
|||
CleanupEnabled: cfg.GetBool("netmap_cleaner.enabled"),
|
||||
CleanupThreshold: cfg.GetUint64("netmap_cleaner.threshold"),
|
||||
ContainerWrapper: cnrClient,
|
||||
HandleAudit: s.onlyActiveEventHandler(
|
||||
auditProcessor.StartAuditHandler(),
|
||||
),
|
||||
NotaryDepositHandler: s.onlyAlphabetEventHandler(
|
||||
s.notaryHandler,
|
||||
),
|
||||
AuditSettlementsHandler: s.onlyAlphabetEventHandler(
|
||||
settlementProcessor.HandleAuditEvent,
|
||||
),
|
||||
AlphabetSyncHandler: s.onlyAlphabetEventHandler(
|
||||
alphaSync,
|
||||
),
|
||||
|
@ -171,93 +156,6 @@ func (s *Server) initNotaryConfig() {
|
|||
)
|
||||
}
|
||||
|
||||
func (s *Server) createAuditProcessor(cfg *viper.Viper, clientCache *ClientCache, cnrClient *container.Client) (*audit.Processor, error) {
|
||||
auditPool, err := ants.NewPool(cfg.GetInt("audit.task.exec_pool_size"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pdpPoolSize := cfg.GetInt("audit.pdp.pairs_pool_size")
|
||||
porPoolSize := cfg.GetInt("audit.por.pool_size")
|
||||
|
||||
// create audit processor dependencies
|
||||
auditTaskManager := audittask.New(
|
||||
audittask.WithQueueCapacity(cfg.GetUint32("audit.task.queue_capacity")),
|
||||
audittask.WithWorkerPool(auditPool),
|
||||
audittask.WithLogger(s.log),
|
||||
audittask.WithContainerCommunicator(clientCache),
|
||||
audittask.WithMaxPDPSleepInterval(cfg.GetDuration("audit.pdp.max_sleep_interval")),
|
||||
audittask.WithPDPWorkerPoolGenerator(func() (util2.WorkerPool, error) {
|
||||
return ants.NewPool(pdpPoolSize)
|
||||
}),
|
||||
audittask.WithPoRWorkerPoolGenerator(func() (util2.WorkerPool, error) {
|
||||
return ants.NewPool(porPoolSize)
|
||||
}),
|
||||
)
|
||||
|
||||
s.workers = append(s.workers, auditTaskManager.Listen)
|
||||
|
||||
// create audit processor
|
||||
return audit.New(&audit.Params{
|
||||
Log: s.log,
|
||||
NetmapClient: s.netmapClient,
|
||||
ContainerClient: cnrClient,
|
||||
IRList: s,
|
||||
EpochSource: s,
|
||||
SGSource: clientCache,
|
||||
Key: &s.key.PrivateKey,
|
||||
RPCSearchTimeout: cfg.GetDuration("audit.timeout.search"),
|
||||
TaskManager: auditTaskManager,
|
||||
Reporter: s,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) createSettlementProcessor(clientCache *ClientCache, cnrClient *container.Client) *settlement.Processor {
|
||||
// create settlement processor dependencies
|
||||
settlementDeps := settlementDeps{
|
||||
log: s.log,
|
||||
cnrSrc: container.AsContainerSource(cnrClient),
|
||||
auditClient: s.auditClient,
|
||||
nmClient: s.netmapClient,
|
||||
clientCache: clientCache,
|
||||
balanceClient: s.balanceClient,
|
||||
}
|
||||
|
||||
settlementDeps.settlementCtx = auditSettlementContext
|
||||
auditCalcDeps := &auditSettlementDeps{
|
||||
settlementDeps: settlementDeps,
|
||||
}
|
||||
|
||||
settlementDeps.settlementCtx = basicIncomeSettlementContext
|
||||
basicSettlementDeps := &basicIncomeSettlementDeps{
|
||||
settlementDeps: settlementDeps,
|
||||
cnrClient: cnrClient,
|
||||
}
|
||||
|
||||
auditSettlementCalc := auditSettlement.NewCalculator(
|
||||
&auditSettlement.CalculatorPrm{
|
||||
ResultStorage: auditCalcDeps,
|
||||
ContainerStorage: auditCalcDeps,
|
||||
PlacementCalculator: auditCalcDeps,
|
||||
SGStorage: auditCalcDeps,
|
||||
AccountStorage: auditCalcDeps,
|
||||
Exchanger: auditCalcDeps,
|
||||
AuditFeeFetcher: s.netmapClient,
|
||||
},
|
||||
auditSettlement.WithLogger(s.log),
|
||||
)
|
||||
|
||||
// create settlement processor
|
||||
return settlement.New(
|
||||
settlement.Prm{
|
||||
AuditProcessor: (*auditSettlementCalculator)(auditSettlementCalc),
|
||||
BasicIncome: &basicSettlementConstructor{dep: basicSettlementDeps},
|
||||
State: s,
|
||||
},
|
||||
settlement.WithLogger(s.log),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) createAlphaSync(cfg *viper.Viper, frostfsCli *frostfsClient.Client, irf irFetcher) (event.Handler, error) {
|
||||
var alphaSync event.Handler
|
||||
|
||||
|
@ -316,16 +214,6 @@ func (s *Server) initTimers(cfg *viper.Viper, processors *serverProcessors, morp
|
|||
epoch: s,
|
||||
stopEstimationDMul: cfg.GetUint32("timers.stop_estimation.mul"),
|
||||
stopEstimationDDiv: cfg.GetUint32("timers.stop_estimation.div"),
|
||||
collectBasicIncome: subEpochEventHandler{
|
||||
handler: processors.SettlementProcessor.HandleIncomeCollectionEvent,
|
||||
durationMul: cfg.GetUint32("timers.collect_basic_income.mul"),
|
||||
durationDiv: cfg.GetUint32("timers.collect_basic_income.div"),
|
||||
},
|
||||
distributeBasicIncome: subEpochEventHandler{
|
||||
handler: processors.SettlementProcessor.HandleIncomeDistributionEvent,
|
||||
durationMul: cfg.GetUint32("timers.distribute_basic_income.mul"),
|
||||
durationDiv: cfg.GetUint32("timers.distribute_basic_income.div"),
|
||||
},
|
||||
})
|
||||
|
||||
s.addBlockTimer(s.epochTimer)
|
||||
|
@ -493,12 +381,6 @@ func (s *Server) initClientsFromMorph() (*serverMorphClients, error) {
|
|||
var err error
|
||||
|
||||
fee := s.feeConfig.SideChainFee()
|
||||
// do not use TryNotary() in audit wrapper
|
||||
// audit operations do not require multisignatures
|
||||
s.auditClient, err = auditClient.NewFromMorph(s.morphClient, s.contracts.audit, fee)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// form morph container client's options
|
||||
morphCnrOpts := make([]container.Option, 0, 3)
|
||||
|
@ -545,8 +427,7 @@ func (s *Server) initClientsFromMorph() (*serverMorphClients, error) {
|
|||
}
|
||||
|
||||
type serverProcessors struct {
|
||||
AlphabetProcessor *alphabet.Processor
|
||||
SettlementProcessor *settlement.Processor
|
||||
AlphabetProcessor *alphabet.Processor
|
||||
}
|
||||
|
||||
func (s *Server) initProcessors(cfg *viper.Viper, morphClients *serverMorphClients) (*serverProcessors, error) {
|
||||
|
@ -561,32 +442,12 @@ func (s *Server) initProcessors(cfg *viper.Viper, morphClients *serverMorphClien
|
|||
cfg.GetDuration("indexer.cache_timeout"),
|
||||
)
|
||||
|
||||
clientCache := newClientCache(&clientCacheParams{
|
||||
Log: s.log,
|
||||
Key: &s.key.PrivateKey,
|
||||
SGTimeout: cfg.GetDuration("audit.timeout.get"),
|
||||
HeadTimeout: cfg.GetDuration("audit.timeout.head"),
|
||||
RangeTimeout: cfg.GetDuration("audit.timeout.rangehash"),
|
||||
AllowExternal: cfg.GetBool("audit.allow_external"),
|
||||
})
|
||||
|
||||
s.registerNoErrCloser(clientCache.cache.CloseAll)
|
||||
|
||||
// create audit processor
|
||||
auditProcessor, err := s.createAuditProcessor(cfg, clientCache, morphClients.CnrClient)
|
||||
alphaSync, err := s.createAlphaSync(cfg, morphClients.FrostFSClient, irf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result.SettlementProcessor = s.createSettlementProcessor(clientCache, morphClients.CnrClient)
|
||||
|
||||
var alphaSync event.Handler
|
||||
alphaSync, err = s.createAlphaSync(cfg, morphClients.FrostFSClient, irf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.initNetmapProcessor(cfg, morphClients.CnrClient, alphaSync, auditProcessor, result.SettlementProcessor)
|
||||
err = s.initNetmapProcessor(cfg, morphClients.CnrClient, alphaSync)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue