[go: up one dir, main page]

Agnostic_baker : Unify CLI

What

Parent MR : !16730 (merged)

Closes #7762 (closed).

Why

As motivated in the corresponding issue, we want to have a single place which controls the allowed baking CLI arguments. This is because if the arguments depend on the protocol, then in a new protocol a developer can easily implement a new mandatory baking argument (for instance) and this will mean that the new agnostic baker will not complain until migration to the new protocol. This will be very bad if a lot of people run the agnostic baker, because at migration, the chain might get stuck.

How

This is handled by copying (rather than moving, because we do not want to change the behaviour of the existing protocol baking binaries yet) the baking arguments from the protocol code to the agnostic baker library. Then, we use these arguments to run the baker code from the protocol (via run_baker function). This function is exposed from the plugin now.

However, there is a catch: some of the arguments are interpreted based on the protocol code. For instance, if we take the --minimal-fees, the type of the argument is Tez.t, which comes from the protocol code (more precisely the Alpha_context module associated to the protocol). Therefore, we cannot just expect a run_baker function in the agnostic_baker library which has the Tez.t type in its signature.

Therefore, the solution presented here is to obtain the "protocol-dependent" arguments in the agnostic_baker library with types that are protocol independent, and then to parse them in the plugin. This is the case for the following:

  • minimal_fees : int64 -> Protocol.Alpha_context.Tez.t
  • liquidity_baking_vote : string option -> Protocol.Alpha_context.Per_block_votes.per_block_vote option
  • adaptive_issuance_vote : string option -> Protocol.Alpha_context.Per_block_votes.per_block_vote option
  • extra_operations : Uri.t option -> Baking_configuration.Operations_source.t option
  • state_recorder : bool -> Baking_configuration.state_recorder_config

(there are not arguments from the CLI, but are needed for the run_baker):

  • baking_mode : string option -> Baking_commands.baking_mode
  • sources : Tezos_crypto.Signature.public_key_hash list -> Tezos_crypto.Signature.V1.public_key_hash list

This can be seen more explicitly in the plugin file for each protocol (src/proto_<protocol>/lib_agnostic_baker/baker_args_parser.ml).

Manually testing the MR

CI green

The goal of this MR has been achieved, as it can be seen that if someone wants to add/remove a mandatory argument from the CLI, they must do it in the configuration.ml file of the lib_agnostic_baker library, which will mean adapting the code for all the protocols, because this will mean changing the run_baker main entry point.

(Making a test for an incompatibility between CLIs for two consecutive protocols is doable, but the MR is quite big already, so this can be done afterwards)

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Gabriel Moise

Merge request reports

Loading