title |
---|
Schedule an Upgrade |
Now that the Node Template has been upgraded to include the Scheduler pallet,
the schedule
function
can be used to perform the next runtime upgrade. In the previous section, the
sudo_unchecked_weight
function was used to override the weight associated with the set_code
function; in this section, the runtime upgrade will be scheduled so that it can be processed as
the only extrinsic in a block.
This upgrade is more straightforward than the previous one and only requires updating a single value
in runtime/src/lib.rs
aside from the runtime's spec_version
.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node-template"),
impl_name: create_runtime_str!("node-template"),
authoring_version: 1,
spec_version: 102, // *Increment* this value.
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
/*** snip ***/
parameter_types! {
pub const ExistentialDeposit: u128 = 1000; // Update this value.
pub const MaxLocks: u32 = 50;
}
/*** snip ***/
This change increases the value of the Balances pallet's
ExistentialDeposit
- the
minimum balance needed to keep an account alive from the point-of-view of the Balances pallet.
Keep in mind that this change will not cause all accounts with balances between 500 and 1000 to be reaped - that would require a storage migration, which is out of scope for this tutorial.
cargo build --release -p node-template-runtime
This will override any privous build artifacts! So if you want to have a copy on hand of your last runtime Wasm build files, be sure to copy them somewhere else.
In the previous section, the Scheduler pallet was configured with the Root
origin as its
ScheduleOrigin
,
which means that the sudo
function (not sudo_unchecked_weight
) can be used to invoke the
schedule
function. To upgrade the runtime:
- Use this link to open the Polkadot JS Apps UI's Sudo tab. Refresh your browser if you have it already running to make sure that the Extrinsics for the Scheduler pallet show.
- Wait until all the other fields
have been filled in before providing the
when
parameter. - Leave the
maybe_periodic
parameter empty and thepriority
parameter at its default value of0
. - Select the System pallet's
set_code
function as thecall
parameter and provide the Wasm binary as before. - Leave the "with weight override" option deactivated.
Once all the other fields have been filled in, use a
block number about 10 blocks (1 minute) in the future to fill in the when
parameter and quickly
submit the transaction.
You can use the template node's command line output or the Polkadot JS Apps UI block explorer to watch as this scheuled call takes place.
After the target block has been included in the chain, the version number in the upper-left-hand
corner of Polkadot JS Apps UI should reflect that the runtime version is now 102
.
You can then observe the specific changes that were made in the upgrade by using the
Polkadot JS Apps UI Chain State
app to query the existentialDeposit
constant value from the Balances pallet. (You may again need
to refresh the page)