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

add pausable uptime manager #1340

Open
wants to merge 9 commits into
base: validator-state
Choose a base branch
from

Conversation

ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented Sep 12, 2024

Why this should be merged

Adds pausable uptime manager interface for uptime tracking

How this works

Pausable uptime manager extends the avalanchego uptime manager by introducing callback listeners for validators state (under plugin/evm/validators). The idea is to pause a node's uptime and then can continue whenever it's resumed. It also modifies Connect, Disconnect, StartTracking` accordingly.

How this was tested

Added tests

How is this documented

Comments in code

@ceyonur ceyonur changed the base branch from master to validator-state September 16, 2024 20:03
@ceyonur ceyonur marked this pull request as ready for review September 17, 2024 15:08
@ceyonur ceyonur requested review from darioush and a team as code owners September 17, 2024 15:08

var _ validators.StateCallbackListener = &pausableManager{}

var ErrPausedDc = errors.New("paused node cannot be disconnected")
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's avoid abbreviation of Disconnected to Dc

Comment on lines 61 to 62
// We should never see this case
return ErrPausedDc
Copy link
Collaborator

Choose a reason for hiding this comment

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

This error should not be triggered by calling exported functions if I understand correctly. (we can unexport it)


// pause pauses uptime tracking for the node with the given ID
// pause can disconnect the node from the uptime.Manager if it is connected.
// Returns an error if the node is already paused.
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems this is missing?


// resume resumes uptime tracking for the node with the given ID
// resume can connect the node to the uptime.Manager if it was connected.
// Returns an error if the node is not paused.
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems this is missing?

currentTime = addTime(clk, 8*time.Second)
// Uptime should have increased by 8 seconds since the node was connected
checkUptime(t, up, nodeID0, 21*time.Second, currentTime)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could improve this test using a table, may require some moving items around.
One approach could have callback fns like beforePause, afterPause etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

some test cases require restart/reinitializing of manager. so not sure converting it to a table is a easy one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants