Skip to content

Commit d6c277b

Browse files
scripts: create a script for simply waiting on the proposal success of a node (#9985)
1 parent b664920 commit d6c277b

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
from common_lib import (
6+
NamespaceAndInstructionArgs,
7+
RestartStrategy,
8+
Service,
9+
print_error,
10+
wait_until_y_or_n,
11+
)
12+
from metrics_lib import MetricConditionGater
13+
from restarter_lib import WaitOnMetricRestarter
14+
from update_config_and_restart_nodes_lib import (
15+
ApolloArgsParserBuilder,
16+
update_config_and_restart_nodes,
17+
)
18+
19+
20+
class WaitForProposalIncrease:
21+
def __init__(self):
22+
self.last_proposal_count = None
23+
24+
def check_if_proposal_count_increased(self, proposal_count: int) -> bool:
25+
if self.last_proposal_count is None:
26+
# First time we're checking, so we don't know if the proposal count has increased.
27+
# Save the current count and on the next increase we'll know we had a successful proposal.
28+
self.last_proposal_count = proposal_count
29+
30+
if proposal_count > self.last_proposal_count:
31+
# Set the last proposal count to None so that next time we check we know we have to
32+
# again first get the current value.
33+
self.last_proposal_count = None
34+
return True
35+
36+
return False
37+
38+
39+
def main():
40+
args_builder = ApolloArgsParserBuilder(
41+
"Wait for each Core to successfully propose a block",
42+
"python wait_for_cores_to_succesfully_propose.py -n apollo-sepolia-integration -m 3 -t all_at_once",
43+
include_restart_strategy=False,
44+
)
45+
args = args_builder.build()
46+
47+
namespace_list = NamespaceAndInstructionArgs.get_namespace_list_from_args(args)
48+
context_list = NamespaceAndInstructionArgs.get_context_list_from_args(args)
49+
instructions = ["Checking node proposed successfully."] * len(namespace_list)
50+
51+
namespace_and_instruction_args = NamespaceAndInstructionArgs(
52+
namespace_list,
53+
context_list,
54+
instructions,
55+
)
56+
57+
if not wait_until_y_or_n(
58+
"Please update and or restart the first core as needed and press 'y' when ready to proceed."
59+
):
60+
print_error("Operation cancelled by user")
61+
sys.exit(1)
62+
63+
proposal_increase_checker = WaitForProposalIncrease()
64+
update_config_and_restart_nodes(
65+
None,
66+
namespace_and_instruction_args,
67+
Service.Core,
68+
WaitOnMetricRestarter(
69+
namespace_and_instruction_args,
70+
Service.Core,
71+
[
72+
MetricConditionGater.Metric(
73+
"consensus_decisions_reached_as_proposer",
74+
proposal_increase_checker.check_if_proposal_count_increased,
75+
)
76+
],
77+
8082,
78+
RestartStrategy.NO_RESTART,
79+
),
80+
)
81+
82+
83+
if __name__ == "__main__":
84+
main()

0 commit comments

Comments
 (0)