Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consensus v2 integration tests with logs #6738

Draft
wants to merge 15 commits into
base: feat/equivalent-messages
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

# ChainParametersByEpoch defines chain operation configurable values that can be modified based on epochs
ChainParametersByEpoch = [
{ EnableEpoch = 0, RoundDuration = 6000, ShardConsensusGroupSize = 7, ShardMinNumNodes = 10, MetachainConsensusGroupSize = 10, MetachainMinNumNodes = 10, Hysteresis = 0.2, Adaptivity = false }
{ EnableEpoch = 0, RoundDuration = 6000, ShardConsensusGroupSize = 3, ShardMinNumNodes = 3, MetachainConsensusGroupSize = 3, MetachainMinNumNodes = 3, Hysteresis = 0.2, Adaptivity = false }
]

[HardwareRequirements]
Expand Down Expand Up @@ -631,7 +631,7 @@
[EpochStartConfig]
GenesisEpoch = 0
MinRoundsBetweenEpochs = 20
RoundsPerEpoch = 200
RoundsPerEpoch = 21
# Min and Max ShuffledOutRestartThreshold represents the minimum and maximum duration of an epoch (in percentage) after a node which
# has been shuffled out has to restart its process in order to start in a new shard
MinShuffledOutRestartThreshold = 0.05
Expand Down
2 changes: 2 additions & 0 deletions consensus/chronology/argChronology.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-go/consensus"
"github.com/multiversx/mx-chain-go/ntp"
logger "github.com/multiversx/mx-chain-logger-go"
)

// ArgChronology holds all dependencies required by the chronology component
type ArgChronology struct {
Logger logger.Logger
GenesisTime time.Time
RoundHandler consensus.RoundHandler
SyncTimer ntp.SyncTimer
Expand Down
18 changes: 12 additions & 6 deletions consensus/chronology/chronology.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/closing"
"github.com/multiversx/mx-chain-core-go/display"
"github.com/multiversx/mx-chain-logger-go"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/consensus"
Expand All @@ -20,8 +20,6 @@ import (
var _ consensus.ChronologyHandler = (*chronology)(nil)
var _ closing.Closer = (*chronology)(nil)

var log = logger.GetOrCreate("consensus/chronology")

// srBeforeStartRound defines the state which exist before the start of the round
const srBeforeStartRound = -1

Expand All @@ -30,6 +28,7 @@ const chronologyAlarmID = "chronology"

// chronology defines the data needed by the chronology
type chronology struct {
log logger.Logger
genesisTime time.Time

roundHandler consensus.RoundHandler
Expand All @@ -48,13 +47,19 @@ type chronology struct {

// NewChronology creates a new chronology object
func NewChronology(arg ArgChronology) (*chronology, error) {
var log logger.Logger
log = logger.GetOrCreate("consensus/chronology")
if arg.Logger != nil {
log = arg.Logger
}

err := checkNewChronologyParams(arg)
if err != nil {
return nil, err
}

chr := chronology{
log: log,
genesisTime: arg.GenesisTime,
roundHandler: arg.RoundHandler,
syncTimer: arg.SyncTimer,
Expand Down Expand Up @@ -123,7 +128,7 @@ func (chr *chronology) startRounds(ctx context.Context) {
for {
select {
case <-ctx.Done():
log.Debug("chronology's go routine is stopping...")
chr.log.Debug("chronology's go routine is stopping...")
return
case <-time.After(time.Millisecond):
}
Expand All @@ -144,11 +149,12 @@ func (chr *chronology) startRound(ctx context.Context) {

sr := chr.loadSubroundHandler(chr.subroundId)
if sr == nil {
// chr.log.Trace("chronology: nil subround handler", "subroundId", chr.subroundId)
return
}

msg := fmt.Sprintf("SUBROUND %s BEGINS", sr.Name())
log.Debug(display.Headline(msg, chr.syncTimer.FormattedCurrentTime(), "."))
chr.log.Debug(display.Headline(msg, chr.syncTimer.FormattedCurrentTime(), "."))
logger.SetCorrelationSubround(sr.Name())

if !sr.DoWork(ctx, chr.roundHandler) {
Expand All @@ -167,7 +173,7 @@ func (chr *chronology) updateRound() {
if oldRoundIndex != chr.roundHandler.Index() {
chr.watchdog.Reset(chronologyAlarmID)
msg := fmt.Sprintf("ROUND %d BEGINS (%d)", chr.roundHandler.Index(), chr.roundHandler.TimeStamp().Unix())
log.Debug(display.Headline(msg, chr.syncTimer.FormattedCurrentTime(), "#"))
chr.log.Debug(display.Headline(msg, chr.syncTimer.FormattedCurrentTime(), "#"))
logger.SetCorrelationRound(chr.roundHandler.Index())

chr.initRound()
Expand Down
5 changes: 5 additions & 0 deletions consensus/spos/bls/proxy/subroundsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var log = logger.GetOrCreate("consensus/spos/bls/proxy")

// SubroundsHandlerArgs struct contains the needed data for the SubroundsHandler
type SubroundsHandlerArgs struct {
Logger logger.Logger
Chronology consensus.ChronologyHandler
ConsensusCoreHandler spos.ConsensusCoreHandler
ConsensusState spos.ConsensusStateHandler
Expand All @@ -42,6 +43,7 @@ type consensusStateMachineType int

// SubroundsHandler struct contains the needed data for the SubroundsHandler
type SubroundsHandler struct {
log logger.Logger
chronology consensus.ChronologyHandler
consensusCoreHandler spos.ConsensusCoreHandler
consensusState spos.ConsensusStateHandler
Expand Down Expand Up @@ -78,6 +80,7 @@ func NewSubroundsHandler(args *SubroundsHandlerArgs) (*SubroundsHandler, error)
}

subroundHandler := &SubroundsHandler{
log: args.Logger,
chronology: args.Chronology,
consensusCoreHandler: args.ConsensusCoreHandler,
consensusState: args.ConsensusState,
Expand Down Expand Up @@ -151,6 +154,7 @@ func (s *SubroundsHandler) initSubroundsForEpoch(epoch uint32) error {

s.currentConsensusType = consensusV2
fct, err = v2.NewSubroundsFactory(
s.log,
s.consensusCoreHandler,
s.consensusState,
s.worker,
Expand All @@ -176,6 +180,7 @@ func (s *SubroundsHandler) initSubroundsForEpoch(epoch uint32) error {
s.appStatusHandler,
s.sentSignatureTracker,
s.outportHandler,
s.log,
)
}
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions consensus/spos/bls/v1/blsSubroundsFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/consensus/spos"
"github.com/multiversx/mx-chain-go/consensus/spos/bls"
Expand All @@ -23,6 +24,7 @@ type factory struct {
sentSignaturesTracker spos.SentSignaturesTracker
chainID []byte
currentPid core.PeerID
log logger.Logger
}

// NewSubroundsFactory creates a new consensusState object
Expand All @@ -35,6 +37,7 @@ func NewSubroundsFactory(
appStatusHandler core.AppStatusHandler,
sentSignaturesTracker spos.SentSignaturesTracker,
outportHandler outport.OutportHandler,
logger logger.Logger,
) (*factory, error) {
// no need to check the outportHandler, it can be nil
err := checkNewFactoryParams(
Expand Down Expand Up @@ -148,6 +151,7 @@ func (fct *factory) generateStartRoundSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -190,6 +194,7 @@ func (fct *factory) generateBlockSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -228,6 +233,7 @@ func (fct *factory) generateSignatureSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -264,6 +270,7 @@ func (fct *factory) generateEndRoundSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions consensus/spos/bls/v1/subroundEndRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func (sr *subroundEndRound) doEndRoundJobByLeader() bool {
return false
}

log.Error("doEndRoundJobByLeader.SetSignature", "set sig", "sig", sig)
err = header.SetSignature(sig)
if err != nil {
log.Debug("doEndRoundJobByLeader.SetSignature", "error", err.Error())
Expand Down
8 changes: 8 additions & 0 deletions consensus/spos/bls/v2/blsSubroundsFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/consensus/spos"
"github.com/multiversx/mx-chain-go/consensus/spos/bls"
Expand All @@ -14,6 +15,7 @@ import (
// factory defines the data needed by this factory to create all the subrounds and give them their specific
// functionality
type factory struct {
log logger.Logger
consensusCore spos.ConsensusCoreHandler
consensusState spos.ConsensusStateHandler
worker spos.WorkerHandler
Expand All @@ -28,6 +30,7 @@ type factory struct {

// NewSubroundsFactory creates a new consensusState object
func NewSubroundsFactory(
logger logger.Logger,
consensusDataContainer spos.ConsensusCoreHandler,
consensusState spos.ConsensusStateHandler,
worker spos.WorkerHandler,
Expand All @@ -53,6 +56,7 @@ func NewSubroundsFactory(
}

fct := factory{
log: logger,
consensusCore: consensusDataContainer,
consensusState: consensusState,
worker: worker,
Expand Down Expand Up @@ -156,6 +160,7 @@ func (fct *factory) generateStartRoundSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -196,6 +201,7 @@ func (fct *factory) generateBlockSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -232,6 +238,7 @@ func (fct *factory) generateSignatureSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down Expand Up @@ -268,6 +275,7 @@ func (fct *factory) generateEndRoundSubround() error {
fct.chainID,
fct.currentPid,
fct.appStatusHandler,
fct.log,
)
if err != nil {
return err
Expand Down
Loading
Loading