7

From where do I get the internal logic of --force-authoring flag?

Here is my scenario: I've added a custom chain-spec that is similar to the default one where we are setting the environment for --dev flag in my solo chain, and while running the node using the customized chain spec, my node is not producing blocks, and when we are explicitly passing --force-authoring flag then the blocks are being produced.

I don't want to pass the --force-authoring flag explicitly so is there any way to customize it internally?

2 Answers 2

8

The --force-authoring flag tells a node to produce blocks when it is "offline", i.e. has no other peers.

By default, a node assumes if it has no peers, that it is not connected to the internet or any other nodes, and thus should not try to produce blocks since it would be building on its own fork, and this could be bad if suddenly chains got back online again and had to resolve all those forks.

However, if you are running a single node test network, you absolutely do want to produce blocks without any peers, so you include the --force-authoring flag to do that.

I don't want to pass the --force-authoring flag explicitly so is there any way to customize it internally?

You can probably customize your own nodes CLI to have a single flag which wraps certain behaviors like --force-authoring, but it doesn't sound like the cost of adding such a custom behavior is worth just adding a few characters to starting your node.

2
  • Thanks for the response Shawn, yes, I agree with your point, adding just one flag is always good than customizing the code. I was planning to customize it to learn more about the internals of these flags. Is there any specific location from where I can get the business logic of this flag? Thanks Commented Mar 17, 2022 at 14:25
  • Right here: github.com/paritytech/substrate/blob/… Just passing a bool.
    – Shawn Tabrizi
    Commented Mar 17, 2022 at 15:22
4

--force-authoring is defined here.

It is part of the config so you can call it internally like so config.force_authoring.

As far as it's logic in the code-base, I see it being used explicitly here:

if !self.force_authoring() &&
    self.sync_oracle().is_offline() &&
    authorities_len.map(|a| a > 1).unwrap_or(false)
{
    debug!(target: logging_target, "Skipping proposal slot. Waiting for the network.");
    telemetry!(
        telemetry;
        CONSENSUS_DEBUG;
        "slots.skipping_proposal_slot";
        "authorities_len" => authorities_len,
    );

    return None
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.