Skip to content

Commit

Permalink
debug ir gas distribution
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Mar 20, 2024
1 parent b46f515 commit e5d4bec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
10 changes: 0 additions & 10 deletions pkg/innerring/blocktimer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/alphabet"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
timerEvent "github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/morph/timer"
Expand Down Expand Up @@ -139,12 +138,3 @@ func newEpochTimer(args *epochTimerArgs) *timer.BlockTimer {

return epochTimer
}

func newEmissionTimer(args *emitTimerArgs) *timer.BlockTimer {
return timer.NewBlockTimer(
timer.StaticBlockMeter(args.emitDuration),
func() {
args.ap.HandleGasEmission(timerEvent.NewAlphabetEmitTick{})
},
)
}
12 changes: 2 additions & 10 deletions pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
emissionHardcoded := 10_0000_0000

Check warning on line 976 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L976

Added line #L976 was not covered by tests

// create alphabet processor
alphabetProcessor, err := alphabet.New(&alphabet.Params{
alphaProcessor, err := alphabet.New(&alphabet.Params{

Check warning on line 979 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L979

Added line #L979 was not covered by tests
Log: log,
PoolSize: cfg.GetInt("workers.alphabet"),
AlphabetContracts: server.contracts.alphabet,
Expand All @@ -990,7 +990,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
return nil, err
}

err = bindMorphProcessor(alphabetProcessor, server)
err = bindMorphProcessor(alphaProcessor, server)

Check warning on line 993 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L993

Added line #L993 was not covered by tests
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1039,14 +1039,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-

server.addBlockTimer(server.epochTimer)

// initialize emission timer
emissionTimer := newEmissionTimer(&emitTimerArgs{
ap: alphabetProcessor,
emitDuration: cfg.GetUint32("timers.emit"),
})

server.addBlockTimer(emissionTimer)

return server, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/innerring/processors/alphabet/handlers.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package alphabet

import (
"github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
"go.uber.org/zap"
)

func (ap *Processor) HandleGasEmission(ev event.Event) {
_ = ev.(timers.NewAlphabetEmitTick)
_ = ev.(netmapEvent.NewEpoch)

Check warning on line 10 in pkg/innerring/processors/alphabet/handlers.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/handlers.go#L10

Added line #L10 was not covered by tests
ap.log.Info("tick", zap.String("type", "alphabet gas emit"))

// send event to the worker pool
Expand Down
27 changes: 25 additions & 2 deletions pkg/innerring/processors/alphabet/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
"github.com/panjf2000/ants/v2"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -82,14 +83,36 @@ func New(p *Params) (*Processor, error) {
}, nil
}

const newEpochNotification = "NewEpoch"

// ListenerNotificationParsers for the 'event.Listener' event producer.
func (ap *Processor) ListenerNotificationParsers() []event.NotificationParserInfo {
return nil
parsers := make([]event.NotificationParserInfo, 0, 1)

Check warning on line 90 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L90

Added line #L90 was not covered by tests

var p event.NotificationParserInfo
p.SetScriptHash(ap.netmapClient.ContractAddress())

Check warning on line 93 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L92-L93

Added lines #L92 - L93 were not covered by tests

// new epoch event
p.SetType(newEpochNotification)
p.SetParser(netmapEvent.ParseNewEpoch)
parsers = append(parsers, p)

Check warning on line 98 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L96-L98

Added lines #L96 - L98 were not covered by tests

return parsers

Check warning on line 100 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L100

Added line #L100 was not covered by tests
}

// ListenerNotificationHandlers for the 'event.Listener' event producer.
func (ap *Processor) ListenerNotificationHandlers() []event.NotificationHandlerInfo {
return nil
handlers := make([]event.NotificationHandlerInfo, 0, 1)

Check warning on line 105 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L105

Added line #L105 was not covered by tests

var i event.NotificationHandlerInfo
i.SetScriptHash(ap.netmapClient.ContractAddress())

Check warning on line 108 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L107-L108

Added lines #L107 - L108 were not covered by tests

// new epoch handler
i.SetType(newEpochNotification)
i.SetHandler(ap.HandleGasEmission)
handlers = append(handlers, i)

Check warning on line 113 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L111-L113

Added lines #L111 - L113 were not covered by tests

return handlers

Check warning on line 115 in pkg/innerring/processors/alphabet/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/alphabet/processor.go#L115

Added line #L115 was not covered by tests
}

// ListenerNotaryParsers for the 'event.Listener' event producer.
Expand Down

0 comments on commit e5d4bec

Please sign in to comment.