Skip to content

Commit

Permalink
Sync validator keys: Add proposal builder flag for Teku and Prysm (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyc60 authored Sep 14, 2022
1 parent 0d187da commit ac25fde
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 13 additions & 3 deletions stakewise_cli/commands/sync_validator_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,20 @@
help="The path to solo validator's fee distribution path",
type=click.Path(exists=True, file_okay=True, dir_okay=False),
)
@click.option(
"--proposal-builder-enabled",
help="Enable proposal builder for Teku and Prysm clients.",
default=True,
type=click.BOOL,
)
def sync_validator_keys(
network: str,
db_url: str,
index: int,
output_dir: str,
web3signer_url_env: str,
solo_fees_file: str,
proposal_builder_enabled: bool,
) -> None:
"""
The command is running by the init container in validator pods.
Expand Down Expand Up @@ -114,6 +121,7 @@ def sync_validator_keys(
proposer_config = _generate_proposer_config(
default_fee_recipient=default_fee_recipient,
solo_fee_mapping=solo_fee_mapping,
proposal_builder_enabled=proposal_builder_enabled,
)
with open(join(output_dir, SIGNER_PROPOSER_CONFIG_FILENAME), "w") as f:
f.write(proposer_config)
Expand Down Expand Up @@ -170,7 +178,9 @@ def _generate_signer_keys_config(public_keys: List[str]) -> str:


def _generate_proposer_config(
default_fee_recipient: str, solo_fee_mapping: Dict[str, str]
default_fee_recipient: str,
solo_fee_mapping: Dict[str, str],
proposal_builder_enabled: bool,
) -> str:
"""
Generate config for Teku and Prysm clients
Expand All @@ -181,7 +191,7 @@ def _generate_proposer_config(
public_key: {
"fee_recipient": fee_recipient,
"builder": {
"enabled": True,
"enabled": proposal_builder_enabled,
},
}
for public_key, fee_recipient in solo_fee_mapping.items()
Expand All @@ -190,7 +200,7 @@ def _generate_proposer_config(
"default_config": {
"fee_recipient": default_fee_recipient,
"builder": {
"enabled": True,
"enabled": proposal_builder_enabled,
},
},
}
Expand Down
4 changes: 3 additions & 1 deletion stakewise_cli/tests/test_sync_validator_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def test_sync_validator_keys(self, *mocks):
"./valdata",
"--solo-fees-file",
"./solo-fees.json",
"--proposal-builder-enabled",
False,
]
with runner.isolated_filesystem():
with open("./solo-fees.json", "w") as f:
Expand Down Expand Up @@ -87,7 +89,7 @@ def test_sync_validator_keys(self, *mocks):

with open("./valdata/proposerConfig.json") as f:
s = (
'{"proposer_config": {"%s": {"fee_recipient": "%s", "builder": {"enabled": true}}}, "default_config": {"fee_recipient": "%s", "builder": {"enabled": true}}}'
'{"proposer_config": {"%s": {"fee_recipient": "%s", "builder": {"enabled": false}}}, "default_config": {"fee_recipient": "%s", "builder": {"enabled": false}}}'
% (
solo_pub_key,
solo_address,
Expand Down

0 comments on commit ac25fde

Please sign in to comment.