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

go/control: Show last consensus height seen by block history #6013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .changelog/5998.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
go/oasis_node: Add runtime block history status message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
go/oasis_node: Add runtime block history status message
go/oasis-node: Add runtime block history status message


A new field `history` has been added to the `oasis-node control status`
output under the runtime status section. This field displays the latest round
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
output under the runtime status section. This field displays the latest round
output under the runtime status section. This field displays the round

and consensus height of the latest runtime block seen by the block history.

This is useful for the node operators, so that they can estimate the history
reindex speed.
11 changes: 11 additions & 0 deletions go/control/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ type RuntimeStatus struct {
// Storage contains the storage worker status in case this node is a storage node.
Storage *storageWorker.Status `json:"storage,omitempty"`

// History is status of block history.
History *HistoryStatus `json:"history,omitempty"`

// Provisioner is the name of the runtime provisioner.
Provisioner string `json:"provisioner,omitempty"`

Expand Down Expand Up @@ -230,6 +233,14 @@ type SeedStatus struct {
NodePeers []string `json:"node_peers"`
}

// HistoryStatus is the status as observed by the block history.
type HistoryStatus struct {
// LastRound is the round of the latest block.
LastRound uint64 `json:"last_round"`
// LastHeight is the consensus height of the latest block.
LastHeight int64 `json:"last_height"`
}

Comment on lines +236 to +243
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want a status like we have for storage? e.g. initializing, reindexing blocks, syncing blocks?

If so this logic would have to be moved to consensus roothash, or we add a method to query it. Albeit, feels weird adding this functionality to roothash/api/Backend...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want a status like we have for storage? e.g. initializing, reindexing blocks, syncing blocks?

Yes, I would like to have percentages (and maybe optional status).

From you example, I would like to have at least 3 fields, two that say which range is reindexBlocks working on (800 - 1000), and percentages of reindexed blocks (30/200 = 15%). When this is done, the node will see that too many blocks are still to be indexed, so it will update status by updating range (1000 - 1100) and percentage (0/100 = 0%).

Having field LastRound might be a problem when you start doing things in parallel, as some lower rounds might not be processed yet. Range might be better.

// DebugModuleName is the module name for the debug controller service.
const DebugModuleName = "control/debug"

Expand Down
24 changes: 24 additions & 0 deletions go/oasis-node/cmd/node/node_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,30 @@ func (n *Node) getRuntimeStatus(ctx context.Context) (map[common.Namespace]contr
}
}

// Fetch block history status.
var historyStatus control.HistoryStatus
cBlk, err := rt.History().GetCommittedBlock(ctx, roothash.RoundLatest)
switch err {
case nil:
historyStatus.LastRound = cBlk.Header.Round
default:
n.logger.Error("failed to fetch block history latest block",
"err", err,
"runtime_id", rt.ID(),
)
}
height, err := rt.History().LastConsensusHeight()
switch err {
case nil:
historyStatus.LastHeight = height
default:
n.logger.Error("failed to fetch block history latest height",
"err", err,
"runtime_id", rt.ID(),
)
}
status.History = &historyStatus

// Fetch provisioner type.
status.Provisioner = "none"
if provisioner := rt.HostProvisioner(); provisioner != nil {
Expand Down
9 changes: 9 additions & 0 deletions go/roothash/api/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type BlockHistory interface {

// LastConsensusHeight returns the last consensus height which was seen
// by block history.
//
// This method can return height for block not yet synced to storage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole comment is a bit confusing, as the first part says seen while the second says that the block (which one, consensus or runtime?) doesn't need to be synced.

Can we change to

Suggested change
// This method can return height for block not yet synced to storage.
// LastConsensusHeight returns the consensus height of the last committed block.

LastConsensusHeight() (int64, error)

// GetCommittedBlock returns the committed block at a specific round.
Expand All @@ -57,6 +59,7 @@ type BlockHistory interface {
GetCommittedBlock(ctx context.Context, round uint64) (*block.Block, error)

// GetBlock returns the block at a specific round.
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be consistent and add new line in all places or nowhere.

// Passing the special value `RoundLatest` will return the latest block.
//
// This method returns blocks that are both committed and synced to storage.
Expand All @@ -65,13 +68,19 @@ type BlockHistory interface {
// GetAnnotatedBlock returns the annotated block at a specific round.
//
// Passing the special value `RoundLatest` will return the latest annotated block.
//
// This method returns blocks that are both committed and synced to storage.
GetAnnotatedBlock(ctx context.Context, round uint64) (*AnnotatedBlock, error)

// GetEarliestBlock returns the earliest known block.
//
// This method can return blocks not yet synced to storage.
GetEarliestBlock(ctx context.Context) (*block.Block, error)

// GetRoundResults returns the round results for the given round.
//
// Passing the special value `RoundLatest` will return results for the latest round.
//
// This method can return round results for block not yet synced to storage.
GetRoundResults(ctx context.Context, round uint64) (*RoundResults, error)
}
Loading