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

code-substitute: Switch from block_hash to block_number #10600

Merged
merged 5 commits into from
Jan 9, 2022

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Jan 6, 2022

This will make it easier for light clients to work with the code-substitute.

For more information on this see: #10589

Closes: #10589

polkadot companion: paritytech/polkadot#4667

This will make it easier for light clients to work with the code-substitute.

For more information on this see: #10589

Closes: #10589
@bkchr bkchr added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Jan 6, 2022
@bkchr bkchr added B5-clientnoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels Jan 6, 2022
client/service/src/client/wasm_substitutes.rs Outdated Show resolved Hide resolved
client/service/src/builder.rs Outdated Show resolved Hide resolved
@tomaka
Copy link
Contributor

tomaka commented Jan 6, 2022

This is still not ideal, because if there's a code substitute at block 10, and a light client warp syncs to block 15, it will have to download the runtime at block 10, the runtime at block 15, compare them, and if they're equal then do the substitution.

Basically the problem is that the client has no way to know whether the substitute is still relevant.
If there's a code substitute at block 100 and we warp sync to block 9000000, even though it's likely that there's been a runtime upgrade in between, the light client has no way to know and will still have to download the runtime of block 100 to check whether it is the same.

@bkchr
Copy link
Member Author

bkchr commented Jan 6, 2022

This is still not ideal, because if there's a code substitute at block 10, and a light client warp syncs to block 15, it will have to download the runtime at block 10, the runtime at block 15, compare them, and if they're equal then do the substitution.

We already had discussed this once :D You don't need to download the runtime at 10, because you should use the wasm binary provided in the chain spec. You could, as we are doing it, check the spec_version on startup and then you will just need to compare them against the spec_version of 15.

Basically the problem is that the client has no way to know whether the substitute is still relevant.
If there's a code substitute at block 100 and we warp sync to block 9000000, even though it's likely that there's been a runtime upgrade in between, the light client has no way to know and will still have to download the runtime of block 100 to check whether it is the same.

Same as above, you have the binary in the chain spec. You don't need to download it, because if you download it you will also not get the correct one. (You will get the one from on chain, while you want the one that is present in the chain spec)

bkchr and others added 3 commits January 6, 2022 14:09
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't review the code, but 👍

…aritytech/substrate into bkchr-code-substitute-use-block-number
@bkchr
Copy link
Member Author

bkchr commented Jan 9, 2022

bot merge

@paritytech-processbot
Copy link

Error: It's not possible to meet the minimal approval count of 1 in paritytech/polkadot#4667

@bkchr bkchr merged commit b54c21f into master Jan 9, 2022
@bkchr bkchr deleted the bkchr-code-substitute-use-block-number branch January 9, 2022 19:48
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…ch#10600)

* code-substitute: Switch from `block_hash` to `block_number`

This will make it easier for light clients to work with the code-substitute.

For more information on this see: paritytech#10589

Closes: paritytech#10589

* FMT

* Update client/service/src/client/wasm_substitutes.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update client/service/src/builder.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…ch#10600)

* code-substitute: Switch from `block_hash` to `block_number`

This will make it easier for light clients to work with the code-substitute.

For more information on this see: paritytech#10589

Closes: paritytech#10589

* FMT

* Update client/service/src/client/wasm_substitutes.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update client/service/src/builder.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve code-substitutes for light clients
3 participants