Client::apply_block() has an awkward API
nazar-pc opened this issue · comments
While working with custom sync implementation for our chain I ended up in <Client as BlockImport>::import_block()
implementation:
polkadot-sdk/substrate/client/service/src/client/client.rs
Lines 1747 to 1778 in e192b76
What caught my eye is that Client::apply_block()
method takes 3 arguments, two of which (import_block.state_action
and storage_changes
) can potentially contain storage changes, which is really confusing. I see that client always replaces state action with StateAction::Skip
before actually calling Client::apply_block()
.
The fact that Client::apply_block()
takes BlockImportParams
as an argument seems like an accident because it intentionally skips state_action
field internally, which likely means a different data structure should have been used there instead, but someone was lazy and decided to reuse existing data structure that almost worked.
This is basically a request to consider changing API into something a bit more clearer, possibly just duplicating BlockImportParams
data structure without state_action
field.