This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Update contract multi-block migration #14313
Merged
Merged
Changes from 15 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
5c14529
move migrate sequence to config
juangirini e8c493c
remove commented out code
juangirini 0e62930
Update frame/contracts/src/lib.rs
juangirini 14a7175
remove Migrations generic
juangirini 2601d79
make runtime use noop migrations
juangirini e88854a
restrict is_upgrade_supported
juangirini a8caaf2
Update contract multi-block migration
pgherveou 1400ab0
undo is_upgrade_supported change
juangirini cc7609c
Update bin/node/runtime/src/lib.rs
juangirini 92360cd
wip
pgherveou 137ecc8
fix comment (#14316)
pgherveou cfaf7e8
Merge branch 'jg/remove-default-migrate-sequence' into pg/more_migrat…
pgherveou 27e5cf8
fix test
pgherveou 2935e99
fix
pgherveou a4bb302
Update frame/contracts/src/migration.rs
pgherveou f3e81ce
fix test doc
pgherveou f10f5bd
Apply suggestions from code review
pgherveou dc556df
Fix compilation with feature runtime-benchmarks
pgherveou a7ef997
fix example
pgherveou 6a89133
fix cargo doc --document-private-items
pgherveou 86e6696
private links
pgherveou 6417dde
Remove dup comment
pgherveou e6bb63d
add doc for MigrationInProgress
pgherveou 1841f23
PR review remove duplicate asserts
pgherveou 0236ca0
simplify upper bound
pgherveou 4686c03
fix link
pgherveou 5e029e1
typo
pgherveou c7846be
typo
pgherveou d4349fb
no unwrap()
pgherveou 7511bac
correct log message
pgherveou e4e5ba1
Merge branch 'master' into pg/more_migratinons_per_block
pgherveou 3545f04
missing
pgherveou 08f84fb
fix typo
pgherveou 85f334f
PR comment
pgherveou 103d50c
Add example with single element tuple
pgherveou dbb20d3
Improve migration message
pgherveou 3b3c179
Update frame/contracts/src/benchmarking/mod.rs
pgherveou fc977cb
Update frame/contracts/src/migration.rs
pgherveou d45d570
Update frame/contracts/src/migration.rs
pgherveou 9d5b6b8
use saturating_accrue instead of +=
pgherveou fe412a7
add more doc
pgherveou 921dc43
Merge branch 'master' into pg/more_migratinons_per_block
pgherveou 8643fcd
Contracts: Better migration types (#14418)
pgherveou 7a2c272
Add explicit error, if try-runtime runs a noop migration
pgherveou 030554d
use mut remaining_weight
pgherveou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,12 +87,12 @@ mod address; | |
| mod benchmarking; | ||
| mod exec; | ||
| mod gas; | ||
| mod migration; | ||
| mod schedule; | ||
| mod storage; | ||
| mod wasm; | ||
|
|
||
| pub mod chain_extension; | ||
| pub mod migration; | ||
| pub mod weights; | ||
|
|
||
| #[cfg(test)] | ||
|
|
@@ -319,18 +319,31 @@ pub mod pallet { | |
| /// The maximum length of the debug buffer in bytes. | ||
| #[pallet::constant] | ||
| type MaxDebugBufferLen: Get<u32>; | ||
|
|
||
| /// The sequence of migration steps that will be applied during a migration. | ||
| type Migrations: MigrateSequence; | ||
| } | ||
|
|
||
| #[pallet::hooks] | ||
| impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { | ||
| fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight { | ||
| use migration::MigrateResult::*; | ||
|
|
||
| let (result, weight) = Migration::<T>::migrate(remaining_weight); | ||
| let remaining_weight = remaining_weight.saturating_sub(weight); | ||
|
|
||
| if !matches!(result, Completed | NoMigrationInProgress) { | ||
| return weight | ||
| let mut remaining_weight = remaining_weight; | ||
|
pgherveou marked this conversation as resolved.
Outdated
|
||
|
|
||
| loop { | ||
| let (result, weight) = Migration::<T>::migrate(remaining_weight); | ||
| remaining_weight.saturating_reduce(weight); | ||
|
|
||
| match result { | ||
| // There is not enough weight to perform a migration, or make any progress, we | ||
| // just return the remaining weight. | ||
| NoMigrationPerformed | InProgress { steps_done: 0 } => return remaining_weight, | ||
|
pgherveou marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that the same as just
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well this case means that there might be a migration in progress, but we did not have enough gas to make any kind of progress, so you want to exit early here, are doing any work in this function is unsafe is there an actual migration going on. |
||
| // Migration is still in progress, we can start the next step. | ||
| InProgress { .. } => {}, | ||
|
pgherveou marked this conversation as resolved.
Outdated
|
||
| // There are no migration in progress, or we are done with all migrations, we | ||
| // can do some more work with the remaining weight. | ||
|
pgherveou marked this conversation as resolved.
Outdated
|
||
| Completed | NoMigrationInProgress => break, | ||
| } | ||
| } | ||
|
|
||
| ContractInfo::<T>::process_deletion_queue_batch(remaining_weight) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.