referrerpolicy=no-referrer-when-downgrade
pallet_contracts::migration

Trait MigrateSequence

Source
pub trait MigrateSequence: Sealed {
    const VERSION_RANGE: (u16, u16);

    // Required methods
    fn new(version: StorageVersion) -> Cursor;
    fn steps(
        version: StorageVersion,
        cursor: &[u8],
        meter: &mut WeightMeter,
    ) -> StepResult;
    fn integrity_test(max_block_weight: Weight);

    // Provided methods
    fn pre_upgrade_step(
        _version: StorageVersion,
    ) -> Result<Vec<u8>, TryRuntimeError> { ... }
    fn post_upgrade_step(
        _version: StorageVersion,
        _state: Vec<u8>,
    ) -> Result<(), TryRuntimeError> { ... }
    fn is_upgrade_supported(
        in_storage: StorageVersion,
        target: StorageVersion,
    ) -> bool { ... }
}
Expand description

Defines a sequence of migrations.

The sequence must be defined by a tuple of migrations, each of which must implement the MigrationStep trait. Migrations must be ordered by their versions with no gaps.

Required Associated Constants§

Source

const VERSION_RANGE: (u16, u16)

Returns the range of versions that this migrations sequence can handle. Migrations must be ordered by their versions with no gaps.

The following code will fail to compile:

	let _ = <(NoopMigration<1>, NoopMigration<3>)>::VERSION_RANGE;

The following code will compile:

	let _ = <(NoopMigration<1>, NoopMigration<2>)>::VERSION_RANGE;

Required Methods§

Source

fn new(version: StorageVersion) -> Cursor

Returns the default cursor for the given version.

Source

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Execute the migration step until the available weight is consumed.

Source

fn integrity_test(max_block_weight: Weight)

Verify that the migration step fits into Cursor, and that max_step_weight is not greater than max_block_weight.

Provided Methods§

Source

fn pre_upgrade_step( _version: StorageVersion, ) -> Result<Vec<u8>, TryRuntimeError>

Source

fn post_upgrade_step( _version: StorageVersion, _state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Source

fn is_upgrade_supported( in_storage: StorageVersion, target: StorageVersion, ) -> bool

Returns whether migrating from in_storage to target is supported.

A migration is supported if VERSION_RANGE is (in_storage + 1, target).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MigrateSequence for ()

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep> MigrateSequence for (TupleElement0,)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Source§

impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep, TupleElement9: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)

Source§

fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>

Execute the pre-checks of the step associated with this version.

Source§

fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>

Execute the post-checks of the step associated with this version.

Source§

const VERSION_RANGE: (u16, u16) = _

Source§

fn new(version: StorageVersion) -> Cursor

Source§

fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult

Source§

fn integrity_test(max_block_weight: Weight)

Implementors§