substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Ensure custom select chain is applied consistently

Open gnunicorn opened this issue 6 years ago • 3 comments

following #2240 , which focused on refactoring client to provide to customize the strategy to pick a fork easily, it has been pointed out that ForkChoiceStrategy and some related code in client.rs that uses it, might still implicitly pick the longest chain.

Let's go through client.rs and all other places ForkChoiceStrategy influences and make sure that:

  1. the customised strategy is applied successfully and no other code implies to know which best chain to pick instead
  2. ForkChoiceStrategy is in a consistent state with the chosen strategy

gnunicorn avatar May 13 '19 10:05 gnunicorn

I think we can unify the two if we add a new method to SelectChain:

fn is_new_best(&self, &Header) -> Result<bool, Error>;

Which we can use when importing a new block (https://github.com/paritytech/substrate/blob/master/core/client/src/client.rs#L824).

andresilva avatar May 13 '19 11:05 andresilva

And dropping ForkChoiceStrategy - sounds good to me!

Though we might want to do this past #2532, to make sure an implementation doesn't accidentially dead lock on that call - as LongestChain currently would.

gnunicorn avatar May 13 '19 11:05 gnunicorn

@andresilva , I assume either a U3-nice-to-have, or closable?

ghost avatar Mar 04 '23 12:03 ghost

Hi, @gavofyork sorry for pinging. We want to use a kinda custom select chain and we are not sure if this issue is still relevant. Do we now have some confidence that the select chain is applied consistently? Thx

kostekIV avatar Aug 14 '23 14:08 kostekIV

@kostekIV select chain should be used by the block production and block finalization, which is done currently. Do you have issues?

bkchr avatar Aug 15 '23 08:08 bkchr

No, I don't have issues with it but I saw that this issue was open and I have started worrying that there might be some inconsistencies left.

kostekIV avatar Aug 16 '23 06:08 kostekIV

The handling is not perfect, but the most important point are the consensus engines and they are using SelectChain.

bkchr avatar Aug 16 '23 11:08 bkchr