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

Added block timestamp + scripts update for the round duration #6108

Merged
merged 1 commit into from
Apr 11, 2024
Merged
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
3 changes: 3 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ const MetricCurrentRound = "erd_current_round"
// MetricNonce is the metric for monitoring the nonce of a node
const MetricNonce = "erd_nonce"

// MetricBlockTimestamp is the metric for monitoring the timestamp of the last synchronized block
const MetricBlockTimestamp = "erd_block_timestamp"

// MetricProbableHighestNonce is the metric for monitoring the max speculative nonce received by the node by listening on the network
const MetricProbableHighestNonce = "erd_probable_highest_nonce"

Expand Down
1 change: 1 addition & 0 deletions dataRetriever/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (bc *blockChain) SetCurrentBlockHeaderAndRootHash(header data.HeaderHandler

bc.appStatusHandler.SetUInt64Value(common.MetricNonce, h.GetNonce())
bc.appStatusHandler.SetUInt64Value(common.MetricSynchronizedRound, h.GetRound())
bc.appStatusHandler.SetUInt64Value(common.MetricBlockTimestamp, h.GetTimeStamp())

bc.mut.Lock()
bc.currentBlockHeader = h.ShallowClone()
Expand Down
1 change: 1 addition & 0 deletions dataRetriever/blockchain/metachain.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (mc *metaChain) SetCurrentBlockHeaderAndRootHash(header data.HeaderHandler,

mc.appStatusHandler.SetUInt64Value(common.MetricNonce, currHead.Nonce)
mc.appStatusHandler.SetUInt64Value(common.MetricSynchronizedRound, currHead.Round)
mc.appStatusHandler.SetUInt64Value(common.MetricBlockTimestamp, currHead.GetTimeStamp())

mc.mut.Lock()
mc.currentBlockHeader = currHead.ShallowClone()
Expand Down
1 change: 1 addition & 0 deletions node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func InitBaseMetrics(appStatusHandler core.AppStatusHandler) error {

appStatusHandler.SetUInt64Value(common.MetricSynchronizedRound, initUint)
appStatusHandler.SetUInt64Value(common.MetricNonce, initUint)
appStatusHandler.SetUInt64Value(common.MetricBlockTimestamp, initUint)
appStatusHandler.SetUInt64Value(common.MetricCountConsensus, initUint)
appStatusHandler.SetUInt64Value(common.MetricCountLeader, initUint)
appStatusHandler.SetUInt64Value(common.MetricCountAcceptedBlocks, initUint)
Expand Down
1 change: 1 addition & 0 deletions node/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestInitBaseMetrics(t *testing.T) {
expectedKeys := []string{
common.MetricSynchronizedRound,
common.MetricNonce,
common.MetricBlockTimestamp,
common.MetricCountConsensus,
common.MetricCountLeader,
common.MetricCountAcceptedBlocks,
Expand Down
3 changes: 2 additions & 1 deletion scripts/testnet/include/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ generateConfig() {
-num-of-observers-in-metachain $TMP_META_OBSERVERCOUNT \
-metachain-consensus-group-size $META_CONSENSUS_SIZE \
-stake-type $GENESIS_STAKE_TYPE \
-hysteresis $HYSTERESIS
-hysteresis $HYSTERESIS \
-round-duration $ROUND_DURATION_IN_MS
bogdan-rosianu marked this conversation as resolved.
Show resolved Hide resolved
popd
}

Expand Down
2 changes: 2 additions & 0 deletions scripts/testnet/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export META_VALIDATORCOUNT=3
export META_OBSERVERCOUNT=1
export META_CONSENSUS_SIZE=$META_VALIDATORCOUNT

export ROUND_DURATION_IN_MS=6000

# MULTI_KEY_NODES if set to 1, one observer will be generated on each shard that will handle all generated keys
export MULTI_KEY_NODES=0

Expand Down
1 change: 1 addition & 0 deletions statusHandler/persister/persistentHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (psh *PersistentStatusHandler) initMap() {
psh.persistentMetrics.Store(common.MetricNumProcessedTxs, initUint)
psh.persistentMetrics.Store(common.MetricNumShardHeadersProcessed, initUint)
psh.persistentMetrics.Store(common.MetricNonce, initUint)
psh.persistentMetrics.Store(common.MetricBlockTimestamp, initUint)
psh.persistentMetrics.Store(common.MetricCurrentRound, initUint)
psh.persistentMetrics.Store(common.MetricNonceAtEpochStart, initUint)
psh.persistentMetrics.Store(common.MetricRoundAtEpochStart, initUint)
Expand Down
1 change: 1 addition & 0 deletions statusHandler/statusMetricsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (sm *statusMetrics) saveUint64NetworkMetricsInMap(networkMetrics map[string
currentNonce := sm.uint64Metrics[common.MetricNonce]
nonceAtEpochStart := sm.uint64Metrics[common.MetricNonceAtEpochStart]
networkMetrics[common.MetricNonce] = currentNonce
networkMetrics[common.MetricBlockTimestamp] = sm.uint64Metrics[common.MetricBlockTimestamp]
networkMetrics[common.MetricHighestFinalBlock] = sm.uint64Metrics[common.MetricHighestFinalBlock]
networkMetrics[common.MetricCurrentRound] = currentRound
networkMetrics[common.MetricRoundAtEpochStart] = roundNumberAtEpochStart
Expand Down
4 changes: 4 additions & 0 deletions statusHandler/statusMetricsProvider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func TestStatusMetrics_NetworkMetrics(t *testing.T) {
sm.SetUInt64Value(common.MetricCurrentRound, 200)
sm.SetUInt64Value(common.MetricRoundAtEpochStart, 100)
sm.SetUInt64Value(common.MetricNonce, 180)
sm.SetUInt64Value(common.MetricBlockTimestamp, 18000)
sm.SetUInt64Value(common.MetricHighestFinalBlock, 181)
sm.SetUInt64Value(common.MetricNonceAtEpochStart, 95)
sm.SetUInt64Value(common.MetricEpochNumber, 1)
Expand All @@ -240,6 +241,7 @@ func TestStatusMetrics_NetworkMetrics(t *testing.T) {
"erd_current_round": uint64(200),
"erd_round_at_epoch_start": uint64(100),
"erd_nonce": uint64(180),
"erd_block_timestamp": uint64(18000),
"erd_highest_final_nonce": uint64(181),
"erd_nonce_at_epoch_start": uint64(95),
"erd_epoch_number": uint64(1),
Expand Down Expand Up @@ -270,6 +272,7 @@ func TestStatusMetrics_StatusMetricsMapWithoutP2P(t *testing.T) {
sm.SetUInt64Value(common.MetricCurrentRound, 100)
sm.SetUInt64Value(common.MetricRoundAtEpochStart, 200)
sm.SetUInt64Value(common.MetricNonce, 300)
sm.SetUInt64Value(common.MetricBlockTimestamp, 30000)
sm.SetStringValue(common.MetricAppVersion, "400")
sm.SetUInt64Value(common.MetricRoundsPassedInCurrentEpoch, 95)
sm.SetUInt64Value(common.MetricNoncesPassedInCurrentEpoch, 1)
Expand All @@ -281,6 +284,7 @@ func TestStatusMetrics_StatusMetricsMapWithoutP2P(t *testing.T) {
require.Equal(t, uint64(100), res[common.MetricCurrentRound])
require.Equal(t, uint64(200), res[common.MetricRoundAtEpochStart])
require.Equal(t, uint64(300), res[common.MetricNonce])
require.Equal(t, uint64(30000), res[common.MetricBlockTimestamp])
require.Equal(t, "400", res[common.MetricAppVersion])
require.NotContains(t, res, common.MetricRoundsPassedInCurrentEpoch)
require.NotContains(t, res, common.MetricNoncesPassedInCurrentEpoch)
Expand Down