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

FEAT: Display extra owners data #6083

Draft
wants to merge 5 commits into
base: rc/v1.7.0
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 28 additions & 10 deletions epochStart/metachain/auctionListDisplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/multiversx/mx-chain-go/config"
errorsCommon "github.com/multiversx/mx-chain-go/errors"
"github.com/multiversx/mx-chain-go/state"
logger "github.com/multiversx/mx-chain-logger-go"
)

const maxPubKeyDisplayableLen = 20
Expand Down Expand Up @@ -69,9 +68,6 @@ func checkDisplayerNilArgs(args ArgsAuctionListDisplayer) error {

// DisplayOwnersData will display initial owners data for auction selection
func (ald *auctionListDisplayer) DisplayOwnersData(ownersData map[string]*OwnerAuctionData) {
if log.GetLevel() > logger.LogDebug {
return
}

tableHeader := []string{
"Owner",
Expand Down Expand Up @@ -100,6 +96,34 @@ func (ald *auctionListDisplayer) DisplayOwnersData(ownersData map[string]*OwnerA
ald.tableDisplayer.DisplayTable(tableHeader, lines, "Initial nodes config in auction list")
}

func (ald *auctionListDisplayer) DisplayExtraOwnersData(ownersData map[string]*OwnerAuctionData) {
tableHeader := []string{
"Owner",
"Num staked nodes",
"Num active nodes",
"Num auction nodes",
"Total top up",
"Top up per node",
"Auction list nodes",
}

lines := make([]*display.LineData, 0, len(ownersData))
for ownerPubKey, owner := range ownersData {
line := []string{
ald.addressPubKeyConverter.SilentEncode([]byte(ownerPubKey), log),
strconv.Itoa(int(owner.numStakedNodes)),
strconv.Itoa(int(owner.numActiveNodes)),
strconv.Itoa(int(owner.numAuctionNodes)),
getPrettyValue(owner.totalTopUp, ald.softAuctionConfig.denominator),
getPrettyValue(owner.topUpPerNode, ald.softAuctionConfig.denominator),
ald.getShortDisplayableBlsKeys(owner.auctionList),
}
lines = append(lines, display.NewLineData(false, line))
}

ald.tableDisplayer.DisplayTable(tableHeader, lines, "All nodes config with and without auction")
}

func getPrettyValue(val *big.Int, denominator *big.Int) string {
first := big.NewInt(0).Div(val, denominator).String()
decimals := big.NewInt(0).Mod(val, denominator).String()
Expand Down Expand Up @@ -144,9 +168,6 @@ func (ald *auctionListDisplayer) getShortKey(pubKey []byte) string {

// DisplayOwnersSelectedNodes will display owners' selected nodes
func (ald *auctionListDisplayer) DisplayOwnersSelectedNodes(ownersData map[string]*OwnerAuctionData) {
if log.GetLevel() > logger.LogDebug {
return
}

tableHeader := []string{
"Owner",
Expand Down Expand Up @@ -185,9 +206,6 @@ func (ald *auctionListDisplayer) DisplayAuctionList(
ownersData map[string]*OwnerAuctionData,
numOfSelectedNodes uint32,
) {
if log.GetLevel() > logger.LogDebug {
return
}

tableHeader := []string{"Owner", "Registered key", "Qualified TopUp per node"}
lines := make([]*display.LineData, 0, len(auctionList))
Expand Down
24 changes: 19 additions & 5 deletions epochStart/metachain/auctionListSelector.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (als *auctionListSelector) SelectNodesFromAuctionList(
return process.ErrNilRandSeed
}

ownersData, auctionListSize := als.getAuctionData()
ownersData, extraOwnersData, auctionListSize := als.getAuctionData()
if auctionListSize == 0 {
log.Info("auctionListSelector.SelectNodesFromAuctionList: empty auction list; skip selection")
return nil
Expand Down Expand Up @@ -230,6 +230,7 @@ func (als *auctionListSelector) SelectNodesFromAuctionList(
)

als.auctionListDisplayer.DisplayOwnersData(ownersData)
als.auctionListDisplayer.(*auctionListDisplayer).DisplayExtraOwnersData(extraOwnersData)
numOfAvailableNodeSlots := core.MinUint32(auctionListSize, availableSlots)

sw := core.NewStopWatch()
Expand All @@ -242,8 +243,9 @@ func (als *auctionListSelector) SelectNodesFromAuctionList(
return als.sortAuctionList(ownersData, numOfAvailableNodeSlots, validatorsInfoMap, randomness)
}

func (als *auctionListSelector) getAuctionData() (map[string]*OwnerAuctionData, uint32) {
func (als *auctionListSelector) getAuctionData() (map[string]*OwnerAuctionData, map[string]*OwnerAuctionData, uint32) {
ownersData := make(map[string]*OwnerAuctionData)
extraOwnersData := make(map[string]*OwnerAuctionData)
numOfNodesInAuction := uint32(0)

for owner, ownerData := range als.stakingDataProvider.GetOwnersData() {
Expand All @@ -263,9 +265,21 @@ func (als *auctionListSelector) getAuctionData() (map[string]*OwnerAuctionData,
copy(ownersData[owner].auctionList, ownerData.AuctionList)
numOfNodesInAuction += uint32(numAuctionNodes)
}
numAuctionNodes := len(ownerData.AuctionList)
extraOwnersData[owner] = &OwnerAuctionData{
numActiveNodes: ownerData.NumActiveNodes,
numAuctionNodes: int64(numAuctionNodes),
numQualifiedAuctionNodes: int64(numAuctionNodes),
numStakedNodes: ownerData.NumStakedNodes,
totalTopUp: ownerData.TotalTopUp,
topUpPerNode: ownerData.TopUpPerNode,
qualifiedTopUpPerNode: ownerData.TopUpPerNode,
auctionList: make([]state.ValidatorInfoHandler, numAuctionNodes),
}
copy(extraOwnersData[owner].auctionList, ownerData.AuctionList)
}

return ownersData, numOfNodesInAuction
return ownersData, extraOwnersData, numOfNodesInAuction
}

func isInAuction(validator state.ValidatorInfoHandler) bool {
Expand Down Expand Up @@ -297,7 +311,7 @@ func (als *auctionListSelector) calcSoftAuctionNodesConfig(
) map[string]*OwnerAuctionData {
ownersData := copyOwnersData(data)
minTopUp, maxTopUp := als.getMinMaxPossibleTopUp(ownersData)
log.Debug("auctionListSelector: calc min and max possible top up",
log.Info("auctionListSelector: calc min and max possible top up",
"min top up per node", getPrettyValue(minTopUp, als.softAuctionConfig.denominator),
"max top up per node", getPrettyValue(maxTopUp, als.softAuctionConfig.denominator),
)
Expand All @@ -319,7 +333,7 @@ func (als *auctionListSelector) calcSoftAuctionNodesConfig(
maxNumberOfIterationsReached = iterationNumber >= als.softAuctionConfig.maxNumberOfIterations
}

log.Debug("auctionListSelector: found min required",
log.Info("auctionListSelector: found min required",
"topUp", getPrettyValue(topUp, als.softAuctionConfig.denominator),
"after num of iterations", iterationNumber,
)
Expand Down
2 changes: 1 addition & 1 deletion epochStart/metachain/tableDisplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (tb *tableDisplayer) DisplayTable(tableHeader []string, lines []*display.Li
}

msg := fmt.Sprintf("%s\n%s", message, table)
log.Debug(msg)
log.Info(msg)
}

// IsInterfaceNil checks if the underlying pointer is nil
Expand Down
4 changes: 2 additions & 2 deletions epochStart/metachain/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func (t *trigger) Update(round uint64, nonce uint64) {
t.currEpochStartRound = t.currentRound

msg := fmt.Sprintf("EPOCH %d BEGINS IN ROUND (%d)", t.epoch, t.currentRound)
log.Debug(display.Headline(msg, "", "#"))
log.Debug("trigger.Update", "isEpochStart", t.isEpochStart)
log.Info(display.Headline(msg, "", "#"))
log.Info("trigger.Update", "isEpochStart", t.isEpochStart)
logger.SetCorrelationEpoch(t.epoch)
t.nextEpochStartRound = disabledRoundForForceEpochStart
}
Expand Down
4 changes: 2 additions & 2 deletions epochStart/shardchain/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ func (t *trigger) updateTriggerFromMeta() {
t.epochStartNotifier.NotifyEpochChangeConfirmed(t.metaEpoch)

msg := fmt.Sprintf("EPOCH %d BEGINS IN ROUND (%d)", t.metaEpoch, t.epochStartRound)
log.Debug(display.Headline(msg, "", "#"))
log.Debug("trigger.updateTriggerFromMeta", "isEpochStart", t.isEpochStart)
log.Info(display.Headline(msg, "", "#"))
log.Info("trigger.updateTriggerFromMeta", "isEpochStart", t.isEpochStart)
logger.SetCorrelationEpoch(t.metaEpoch)
t.clearMissingMiniBlocksMap(t.metaEpoch)
t.clearMissingValidatorsInfoMap(t.metaEpoch)
Expand Down