Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Expose some functions of frame-executive for building a custom executive easier #10711

Open
liuchengxu opened this issue Jan 21, 2022 · 10 comments

Comments

@liuchengxu
Copy link
Contributor

A custom executive is required in Subspace, specifically, we would like to have a hook right after initialize_block and apply_extrinsic to collect the intermediate storage root during the entire block execution.

One idea is to create a wrapped pallet-executive on frame-executive, only copy a few functions(basically execute_block because it ties the initialize_block and extrinsic execution tightly) and make some modifications there, delegating all the other functions to frame-executive directly to minimize the maintenance of this custom pallet-executive. These functions just need to be made public in that way:

fn initial_checks(block: &Block) {

fn idle_and_finalize_hook(block_number: NumberFor<Block>) {

fn final_checks(header: &System::Header) {

The another way could be some generic solution that is able to make the executive naturally more flexible to these custom needs, I haven't got a pretty clear idea though :P.

liuchengxu added a commit to autonomys/subspace that referenced this issue Jan 21, 2022
Switch back to paritytech/substrate once paritytech/substrate#10711 is resolved
liuchengxu added a commit to autonomys/subspace that referenced this issue Jan 22, 2022
Switch back to paritytech/substrate once paritytech/substrate#10711 is resolved
@liuchengxu
Copy link
Contributor Author

@bkchr Any thoughts on this feature request?

@bkchr
Copy link
Member

bkchr commented Jan 29, 2022

to collect the intermediate storage root during the entire block execution.

Collect and then? What you want to do with that?

What happens at block production?

@nazar-pc
Copy link
Contributor

Normally state root is collected after block execution, we also collect additional state roots after each transaction to make fraud proofs more efficient in our protocol.

@bkchr
Copy link
Member

bkchr commented Jan 29, 2022

And you store them in the state?

@nazar-pc
Copy link
Contributor

Currently yes

@bkchr
Copy link
Member

bkchr commented Jan 29, 2022

I just have skimmed your code and the only change you made is the storage root calculation after apply_extrinsic. Is that true?

If yes, adding some callback there should be enough for you?

@liuchengxu
Copy link
Contributor Author

liuchengxu commented Jan 29, 2022

I just have skimmed your code and the only change you made is the storage root calculation after apply_extrinsic. Is that true?

Nope. Not only after apply_extrinsic, but also after initialize_block https://github.com/subspace/subspace/blob/438c569b38/cumulus/pallets/executive/src/lib.rs#L238.

adding some callback there should be enough for you?

Yeah, that should be enough, I need two hooks to run right after initialize_block and apply_extrinsic.

@bkchr
Copy link
Member

bkchr commented Jan 30, 2022

Ahh okay, yeah than adding some callback to these both and maybe after calling on_finalize should be okay?

@bkchr
Copy link
Member

bkchr commented Jan 30, 2022

WDYT @shawntabrizi

@liuchengxu
Copy link
Contributor Author

Ping @shawntabrizi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants