From e184ed19181abf60d865ba5be49ab7ade566882b Mon Sep 17 00:00:00 2001 From: Asmaa Magdoub Date: Tue, 20 Aug 2024 13:46:55 +0300 Subject: [PATCH] refactor(consensus): avoid passing default args when running the script --- .../papyrus_consensus/run_consensus.py | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/crates/sequencing/papyrus_consensus/run_consensus.py b/crates/sequencing/papyrus_consensus/run_consensus.py index d2cf6ed58e..cfe496d62c 100644 --- a/crates/sequencing/papyrus_consensus/run_consensus.py +++ b/crates/sequencing/papyrus_consensus/run_consensus.py @@ -139,16 +139,22 @@ def build_node(data_dir, logs_dir, i, papryus_args): f"--rpc.server_address 127.0.0.1:{find_free_port()} " f"--monitoring_gateway.server_address 127.0.0.1:{monitoring_gateway_server_port} " f"--consensus.test.#is_none false " - f"--consensus.timeouts.proposal_timeout {papryus_args.proposal_timeout} " - f"--consensus.timeouts.prevote_timeout {papryus_args.prevote_timeout} " - f"--consensus.timeouts.precommit_timeout {papryus_args.precommit_timeout} " - f"--consensus.test.cache_size {papryus_args.cache_size} " - f"--consensus.test.random_seed {papryus_args.random_seed} " - f"--consensus.test.drop_probability {papryus_args.drop_probability} " - f"--consensus.test.invalid_probability {papryus_args.invalid_probability} " f"--collect_metrics true " ) + conditional_params = { + "timeouts.proposal_timeout": papryus_args.proposal_timeout, + "timeouts.prevote_timeout": papryus_args.prevote_timeout, + "timeouts.precommit_timeout": papryus_args.precommit_timeout, + "test.cache_size": papryus_args.cache_size, + "test.random_seed": papryus_args.random_seed, + "test.drop_probability": papryus_args.drop_probability, + "test.invalid_probability": papryus_args.invalid_probability, + } + for key, value in conditional_params.items(): + if value is not None: + cmd += f"--consensus.{key} {value} " + if is_bootstrap: cmd += ( f"--network.secret_key {SECRET_KEY} " @@ -278,49 +284,49 @@ def main(papyrus_args, run_consensus_args): "--proposal_timeout", type=float, required=False, - default=3, + default=None, help="The timeout (seconds) for a proposal.", ) parser.add_argument( "--prevote_timeout", type=float, required=False, - default=1, + default=None, help="The timeout (seconds) for a prevote.", ) parser.add_argument( "--precommit_timeout", type=float, required=False, - default=1, + default=None, help="The timeout (seconds) for a precommit.", ) parser.add_argument( "--cache_size", type=int, required=False, - default=1000, + default=None, help="Cache size for the test simulation.", ) parser.add_argument( "--random_seed", type=int, required=False, - default=0, + default=None, help="Random seed for test simulation.", ) parser.add_argument( "--drop_probability", type=float, required=False, - default=0, + default=None, help="Probability of dropping a message for test simulation.", ) parser.add_argument( "--invalid_probability", type=float, required=False, - default=0, + default=None, help="Probability of sending an invalid message for test simulation.", ) args = parser.parse_args()