-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
I am not sure with the abstraction level that you are using, and I don't see any code that specifies on top of which state you are executing the given block. What I can say for sure is that to execute any arbitrary block, you certainly need its parent state, which may not be available. This error that you said also rings a bell for me in |
I thought I did correctly specify the parent state by calling the runtime API at the block's parent's hash: runtime_api.execute_block(&BlockId::Hash(*parent_hash), block) |
that sounds correct to me. Perhaps to double check: if you pass an old-block's hash to a non-archive node, do you get an error? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In generally I'm against adding new rpc methods that are added for everybody by default. However, the functionality here could maybe added to the state_traceBlock
rpc method. Or if you want to keep it separate, it should be put into its own crate.
Isn't modifying existing RPCs that are included for anyone even worse?
This sounds sensible. |
I mean we would just add some data to the output that you can just ignore on the calling site. |
This is basically modifying the RPC in a backwards compatible way. So is adding a new RPC. Why is adding a new one worse? |
@dvdplm We are kind of unsure what would be the best place to put this new RPC. Asking for your opinion because I don't know how this ties into the jsonrpsee transition. I think we should not append it to the Options are:
|
My two cents:
In other words: no objections to merge this from me (but it'd be good to start making up our minds about how to add RPCs, the sooner the better). |
This is relative easy. Don't add RPCs automatically to every node building on Substrate. Adding RPC functionality to Substrate isn't bad and we can name them |
So a new category within |
Yeah, a new category in |
@dvdplm said to me: The less boilerplate the better for our transition to jsonrpsee. So even adding a new category has a lot of boilerplate and makes the transition more work. That said, we need to balance this against how bad it is for RPCs to "just show up" when you bump substrate. |
The amount of work for devs is quite similar, maybe slightly less but not by much. |
Okay so I will add a new category then. I still have no idea how to call this category. I was thinking about calling it What do you think? |
Ready for review now:
|
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the stuff are just nitpicks, otherwise it looks good.
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Left some nitpicks. :)
Co-authored-by: David <dvdplm@gmail.com>
bot merge |
* Add chain_getBlockStats rpc * Fix broken doc link * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * Fix compilation * Move Blockstats * Apply suggestions from code review Co-authored-by: David <dvdplm@gmail.com> * fmt Co-authored-by: ascjones <ascjones@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
* Add chain_getBlockStats rpc * Fix broken doc link * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * Fix compilation * Move Blockstats * Apply suggestions from code review Co-authored-by: David <dvdplm@gmail.com> * fmt Co-authored-by: ascjones <ascjones@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
* Add chain_getBlockStats rpc * Fix broken doc link * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * Fix compilation * Move Blockstats * Apply suggestions from code review Co-authored-by: David <dvdplm@gmail.com> * fmt Co-authored-by: ascjones <ascjones@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
* Add chain_getBlockStats rpc * Fix broken doc link * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * Fix compilation * Move Blockstats * Apply suggestions from code review Co-authored-by: David <dvdplm@gmail.com> * fmt Co-authored-by: ascjones <ascjones@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
* Add chain_getBlockStats rpc * Fix broken doc link * Apply suggestions from code review Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fmt * Fix compilation * Move Blockstats * Apply suggestions from code review Co-authored-by: David <dvdplm@gmail.com> * fmt Co-authored-by: ascjones <ascjones@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
This adds a new RPC:
It is meant as a way to gain insides about the bottle necks of a given chain. While some information can only be learned through this RPC (witness related information) some of them are redundant: You can query the whole block and then measure the size of the block and the number of extrinsics. However, I think it still makes sense to include them as this saves us from transmitting the whole block to the RPC client (possibly over the internet) in order to learn about these statistics.
I have written a CLI tool that queries this draft version of the RPC:
cargo install --git https://github.com/athei/povstats.git --locked # This will just connect to a locally running node and calls the RPC on each new block povstats
The output when running this against a
substrate --dev
node without submitting any extrinsics to it looks like this: