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.
Prepare an Upgraded Runtime
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: 3, // Update 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;
}
impl pallet_balances::Trait for Runtime {
type MaxLocks = MaxLocks;
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
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
dropped - that would require a storage migration, which is out of the scope of this tutorial.
Build the upgraded runtime.
cargo build --release -p node-template-runtime
Upgrade the Runtime
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. Use this link to open the Polkadot JS Apps UI's Sudo tab:
https://polkadot.js.org/apps/#/sudo?rpc=ws://127.0.0.1:9944. Wait until all the other fields have
been filled in before providing the when
parameter. Leave the maybe_periodic
parameter empty and
the priority
parameter at its default value of 0
. Select the System pallet's set_code
function
as the call
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 select a block number.
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 3
.
You can observe the 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.