-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove post runtime digests in the runtime before executing a block #63
Comments
Hello, linking this issue since I saw the comment that you are referring to in the source code while looking at another issue that prevents Edgeware (Aura chain) to sync the history. I think those two could be related. |
Currently we rely on the client side to remove this seal. While that works, it is also shitty because people often run into these problems where they try to execute a block and it fails. It mainly fails because of the mismatch in the number of digests, which is expected because the runtime isn't putting the seal onto the block. However, with this pr it would only be about executing the block and the runtime would take care of checking and removing the seal. We would need to make all the code backwards compatible, because the old runtimes don't support the seal alongside the block. We could do this for example by bumping the |
Okay, after thinking again about this. We should probably not bump the version of the Core api. Instead we can just bump the respective runtime api versions of Babe and Aura. |
Okay, so the main goal of this issue is that blocks reach the runtime unaltered, making some tooling much simpler.
At the end of this fix, seals will be checked both in the client and - if Babe/Aura is used - also in the runtime. And |
I don't get this. What you mean by "handle the unaltered block header"? When would that happen? |
See the following post as some sort of brain dump:
|
@wigy-opensource-developer please before continuing, prepare some benchmark that compares the seal verification of Aura from the wasm runtime vs using the client code. This doesn't need to be anything fancy for the beginning. Just some dirty code that runs the verification in a loop and you post the numbers in here. |
Do you see a good shortcut compared to building a test client with a test runtime, getting it to author some blocks, create another test client with a slightly different test runtime, where I can revert the last block easier and then measure the time spent in validating the blocks generated by the first test client? I could not find smaller scope existing tests for pallets like Aura and Babe. So even if it is not fancy, fulfilling all dependencies for this test is quite some coding. Alternatively, I can extract static methods from the pallets and exercise benchmarks on them, but their performance depends on the WASM executor, so it needs to be embedded there somehow. |
Something like this. You clearly will not need to build a full block. In the end it is just about creating a signature and verifying the signature in the runtime. Maybe we already have some numbers for this as part of the benchmarking. @ggwpez do you know if these numbers? |
We have both, just the verification function or full blocks (PS: I forgot to explain the full blocks below).
WASM: ./target/production/substrate benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet="frame-benchmarking" --extrinsic='sr25519_verification' --execution=wasm --wasm-execution=compiled or native: ./target/production/substrate benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet="frame-benchmarking" --extrinsic='sr25519_verification' --execution=native It returns the following:
It's nearly the same 🤔, kinda weird. |
The WASM code will call into a host function to do the actual signature verification, so the small difference should be just the overhead of dispatching from the runtime into a host function. I guess in this case it is negligible. The only thing that I expect could cause a performance difference is moving the BABE slot assignment computation from floats to using |
That is perfect! Ty @ggwpez for your help :) The rest is as @andresilva explained. |
There are digests that are added after a block was build by the runtime. This includes digests like
Seals
that are added by the individual consensus implementations. Currently we rely on having the client code checking these seals and removing them from the header before we execute a block. This ensures that the generated header is equal to the one that is passed in as part of the block.While this works for standalone blockchains, it does not work for parachains. As a parachains also need to validate a block as part of the block validation on the relay chain, they need to have this
Seal
removing code inside the runtime. For AURA this is done for example here. ThisBlockExecutor
can be "stacked", as we do it currently with theBlockImport
s and then we would call these stacked block executors (while Executive being the inner most one) when we need to execute a block.CC @andresilva
The text was updated successfully, but these errors were encountered: