-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite and will continue to be automatically updated while this PR remains open. |
8988cef
to
485f7a2
Compare
7798ce2
to
1cf29fd
Compare
485f7a2
to
7afadb3
Compare
1cf29fd
to
a229573
Compare
7afadb3
to
19f746f
Compare
a229573
to
7f07f90
Compare
19f746f
to
9c18425
Compare
7f07f90
to
c856b7b
Compare
/// If a candidate from the specified parachain were submitted at the current block, this | ||
/// function returns if that candidate passes the acceptance criteria. | ||
pub(crate) fn can_upgrade_validation_code(id: ParaId) -> bool { | ||
FutureCodeHash::<T>::get(&id).is_none() && UpgradeRestrictionSignal::<T>::get(&id).is_none() |
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.
This predicate seems to be equivalent to the previous condition, i.e.:
let valid_upgrade_attempt = <paras::Pallet<T>>::last_code_upgrade(para_id, true)
.map_or(true, |last| {
last <= self.relay_parent_number &&
self.relay_parent_number.saturating_sub(last) >=
self.config.validation_upgrade_frequency
});
But needs double-checking
polkadot/runtime/parachains/src/inclusion.rs Lines 965 to 970 in 0043fe5
We might want to keep it so this snippet can be altered as a part of asynchronous backing. Otherwise code changes would result in service interruptions for a few blocks. Worth noting. |
runtime/parachains/src/inclusion.rs
Outdated
@@ -962,7 +958,7 @@ impl<T: Config> CandidateCheckContext<T> { | |||
Error::<T>::NotCollatorSigned, | |||
); | |||
|
|||
let validation_code_hash = <paras::Pallet<T>>::validation_code_hash_at(para_id, now, None) | |||
let validation_code_hash = <paras::Pallet<T>>::current_code_hash(para_id) |
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.
i.e. this was previously future-proof changes to add asynchronous backing (old relay parent where code hadn't yet changed) but is not future-proof anymore
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.
Probably fine, from a product perspective - if we build parachains 1 block in advance then a code upgrade block would lead to a 6 second service interruption. Workarounds possible but not needed for the moment
7e91fa0
to
a0ec003
Compare
a0ec003
to
4f2e4d7
Compare
@rphmeier when I wrote this code that thought crossed my mind. I had to chase it away because I felt it was overthinking: it's not easy to predict the precise API that will actually be required by async execution and at the same time there is no benefit for that either: we can easily add/remove parameters and shuffle the code around when the time comes (and when we a better grasp of the actual needs). Then this change also does not alter any on-chain storage, so we can actually restore any code from git history and it will work. Although I had planned to remove the storage eventually as well. I am also a bit confused since I was under impression that the context should be passed through a relay-chain state merkle proof. That's why here I thought it is acceptable to remove the historical data from the current state. |
4f2e4d7
to
c00dd07
Compare
Yeah, it's fine as is. The latest version of contextual execution might not need merkle proofs |
This PR is a part of #3211. This PR prepares ground for the following runtime changes required for PVF pre-checking. Specifically, we do several changes here: 1. We remove `validation_code_at` and `validation_code_hash_at`. Those functions are not used. They were added in the early days with intent to use it later but turned out that we do not need them. 2. We replace `validation_code_hash_at` with just `current_code_hash` for the case of inclusion and candidate checking. 3. We also replace `last_code_upgrade` with a direct query into `FutureCodeHash` and `UpgradeRestrictionSignal`. Those in conjunction should replace the logic that was used for allowing/disallowing upgrades. This requires special attention of the reviewers. 4. Then we remove the machinery required to support those queries. Specifically the code related to `UseCodeAt`. We do not need it since we do not answer the historical queries. However, we still leave all the data on-chain. At some point we may clean it up, but that would be needed to be done with a dedicated migration which can be done as follow-up. 5. Some now irrelevant tests were removed and/or adapted.
c00dd07
to
e094cf2
Compare
bot merge |
Bot will approve on the behalf of @pepyakin, since they are a team lead, in an attempt to reach the minimum approval count |
(merged assuming this was an implicit approval and due to that this is a small change) |
This commit incorporates the changes made to the runtime in the following PRs: - #4408 - #4457 - #4540 - #4542 - #4581 Note that this PR does not include the description of the PVF pre-checker subsystem. This should be addressed within #4611 Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This commit incorporates the changes made to the runtime in the following PRs: - #4408 - #4457 - #4540 - #4542 - #4581 Note that this PR does not include the description of the PVF pre-checker subsystem. This should be addressed within #4611 Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This commit incorporates the changes made to the runtime in the following PRs: - #4408 - #4457 - #4540 - #4542 - #4581 Note that this PR does not include the description of the PVF pre-checker subsystem. This should be addressed within #4611 Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This commit incorporates the changes made to the runtime in the following PRs: - #4408 - #4457 - #4540 - #4542 - #4581 Note that this PR does not include the description of the PVF pre-checker subsystem. This should be addressed within #4611 Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This commit incorporates the changes made to the runtime in the following PRs: - paritytech#4408 - paritytech#4457 - paritytech#4540 - paritytech#4542 - paritytech#4581 Note that this PR does not include the description of the PVF pre-checker subsystem. This should be addressed within paritytech#4611 Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This PR is a part of
#3211.
This PR prepares ground for the following runtime changes required for
PVF pre-checking. Specifically, we do several changes here:
validation_code_at
andvalidation_code_hash_at
. Thosefunctions are not used. They were added in the early days with intent
to use it later but turned out that we do not need them.
validation_code_hash_at
with justcurrent_code_hash
for the case of inclusion and candidate checking.
last_code_upgrade
with a direct query intoFutureCodeHash
andUpgradeRestrictionSignal
. Those in conjunctionshould replace the logic that was used for allowing/disallowing
upgrades. This requires special attention of the reviewers.
Specifically the code related to
UseCodeAt
. We do not need it sincewe do not answer the historical queries. However, we still leave all
the data on-chain. At some point we may clean it up, but that would
be needed to be done with a dedicated migration which can be done as
follow-up.
NOTE: This fixes a small bug related to parachain upgrades. Before, the acceptance function would allow the following behavior:
expected_at
block, the parachain produces a block that schedules an upgrade.After this change this is not allowed. This is because we do not allow an upgrade until
FutureCodeHash
is cleared andFutureCodeHash
is consumed by a enacting a candidate that has the relay-parent ≥expected_at
.I say that this is a bug because even though such a candidate will pass the acceptance check, the upgrade it signals won't be enacted. This is because enacting consists of scheduling the upgrade first if any and only then calling
note_new_head
.schedule_code_upgrade
bails if there is a pending upgrade and the pending upgrade only is enacted bynote_new_head
.