Skip to content

Commit

Permalink
refactor(consensus): avoid passing default args when running the script
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaastarkware committed Aug 26, 2024
1 parent 5208d58 commit e184ed1
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions crates/sequencing/papyrus_consensus/run_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} "
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e184ed1

Please sign in to comment.