<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nikania</title>
    <description>The latest articles on DEV Community by nikania (@nikania).</description>
    <link>https://dev.to/nikania</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F395668%2F8ba0129c-a57f-46bb-8799-000dd8233697.png</url>
      <title>DEV Community: nikania</title>
      <link>https://dev.to/nikania</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikania"/>
    <language>en</language>
    <item>
      <title>Updating parachain with migrations</title>
      <dc:creator>nikania</dc:creator>
      <pubDate>Tue, 30 May 2023 11:44:20 +0000</pubDate>
      <link>https://dev.to/nikania/updating-parachain-with-migrations-222j</link>
      <guid>https://dev.to/nikania/updating-parachain-with-migrations-222j</guid>
      <description>&lt;p&gt;How to look and add migrations while upgrading parachain to new version via runtime upgrade.&lt;/p&gt;

&lt;p&gt;We use example of simple &lt;a href="https://github.com/substrate-developer-hub/substrate-parachain-template/"&gt;parachain node template&lt;/a&gt; with tag &lt;code&gt;polkadot-v0.9.32&lt;/code&gt; and upgrade it to &lt;code&gt;polkadot-v0.9.40&lt;/code&gt;. &lt;br&gt;
To test this upgrade we need local testnet. How to create simple testnet &lt;a href="https://dev.to/nikania/quick-list-starting-local-parachain-testnet-3ncg"&gt;short guide here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Build &lt;code&gt;polkadot-v0.9.32&lt;/code&gt; parachain-template version
&lt;/h2&gt;

&lt;p&gt;First, we add some pallets that changed between these two versions to parachain-template:&lt;br&gt;
&lt;code&gt;pallet-alliance&lt;/code&gt; and &lt;code&gt;pallet_assets&lt;/code&gt;.&lt;br&gt;
Then, we build and place parachain in &lt;code&gt;/bin&lt;/code&gt; folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo build &lt;span class="nt"&gt;--release&lt;/span&gt;
&lt;span class="nb"&gt;mkdir &lt;/span&gt;bin
&lt;span class="nb"&gt;cp&lt;/span&gt; ./target/release/parachain-template-node &lt;span class="se"&gt;\&lt;/span&gt;
    ./bin/parachain-template-node-v0.9.32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Prepare for runtime upgrade
&lt;/h2&gt;

&lt;p&gt;(official guide &lt;a href="https://docs.substrate.io/maintain/runtime-upgrades/"&gt;here&lt;/a&gt;)&lt;br&gt;
a) change versions &lt;code&gt;polkadot-v0.9.32&lt;/code&gt; to &lt;code&gt;polkadot-v0.9.40&lt;/code&gt; in Cargo.toml&lt;br&gt;
b) fix compile errors🤯&lt;br&gt;
a1)-b1) it's faster to use &lt;code&gt;polkadot-v0.9.40&lt;/code&gt; parachain-template version instead upgrading in this example😎&lt;br&gt;
c) change spec_version&lt;/p&gt;

&lt;h3&gt;
  
  
  d) add migrations
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;this was the most unclear&lt;/em&gt; to me (do I need to apply them? where to find migrations? how to apply them?), but I'll show you &lt;strong&gt;how to add substrate migrations&lt;/strong&gt; (not your own):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;look through the &lt;a href="https://github.com/paritytech/polkadot/releases"&gt;releases&lt;/a&gt; in Polkadot repo and search for migrations description, here I found migrations in 
&lt;a href="https://github.com/paritytech/polkadot/releases/tag/v0.9.34"&gt;v0.9.34 release&lt;/a&gt;,
&lt;a href="https://github.com/paritytech/polkadot/releases/tag/v0.9.38"&gt;v0.9.38 release&lt;/a&gt;,
&lt;a href="https://github.com/paritytech/polkadot/releases/tag/v0.9.40"&gt;v0.9.40 release&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;download the source code and look for migrations in &lt;code&gt;runtime/polkadot/src/lib.rs&lt;/code&gt; in struct &lt;code&gt;frame_executive::Executive&lt;/code&gt;, migrations can be summed in type &lt;code&gt;Migrations&lt;/code&gt; or just put there, 
here I found the following migrations:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in v0.9.34&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="c1"&gt;//9320&lt;/span&gt;
    &lt;span class="c1"&gt;// "Bound uses of call" &amp;lt;https://github.com/paritytech/polkadot/pull/5729&amp;gt;&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_preimage&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Migration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_scheduler&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v3&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV4&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_democracy&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migrations&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Migration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_multisig&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migrations&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// "Properly migrate weights to v2" &amp;lt;https://github.com/paritytech/polkadot/pull/6091&amp;gt;&lt;/span&gt;
    &lt;span class="nn"&gt;parachains_configuration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v3&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV3&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;//9330&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_election_provider_multi_phase&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migrations&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_fast_unstake&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migrations&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;//9340&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_balances&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToTrackInactive&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;xcm_config&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CheckAccount&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;crowdloan&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToTrackInactive&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in v.0.9.38&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="c1"&gt;// "Use 2D weights in XCM v3" &amp;lt;https://github.com/paritytech/polkadot/pull/6134&amp;gt;&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_xcm&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;parachains_ump&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// Remove stale entries in the set id -&amp;gt; session index storage map (after&lt;/span&gt;
    &lt;span class="c1"&gt;// this release they will be properly pruned after the bonding duration has&lt;/span&gt;
    &lt;span class="c1"&gt;// elapsed)&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_grandpa&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migrations&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CleanupSetIdSessionMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in v0.9.40&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_nomination_pools&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v4&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV4&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
        &lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;NominationPoolsMigrationV4OldPallet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;also look for migrations in Cumulus repo, here I found &lt;a href="https://github.com/paritytech/cumulus/releases/tag/parachains-v9360"&gt;v9360&lt;/a&gt; &lt;a href="https://github.com/paritytech/cumulus/releases/tag/parachains-v9330"&gt;v9330&lt;/a&gt; &lt;a href="https://github.com/paritytech/cumulus/releases/tag/parachains-v9380"&gt;v9380&lt;/a&gt; &lt;a href="https://github.com/paritytech/cumulus/releases/tag/parachains-v9400"&gt;v9400&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;migrations found in Cumulus:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// v9400&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;pallet_nfts&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,);&lt;/span&gt;
&lt;span class="c1"&gt;// v9380&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;pallet_contracts&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Migration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,);&lt;/span&gt;
&lt;span class="c1"&gt;// v9360&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_alliance&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Migration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_balances&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToTrackInactive&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;xcm_config&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CheckingAccount&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// v9330&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Executive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;frame_executive&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Executive&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
    &lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;frame_system&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ChainContext&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;AllPalletsWithSystem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_assets&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;for all pallet that exist in your chain, add migrations, here I added (don't need to add balances: read instructions in &lt;code&gt;pallet_balances::migration::MigrateToTrackInactive&lt;/code&gt;):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Migrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_xcm&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_alliance&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Migration&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nn"&gt;pallet_assets&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;migration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MigrateToV1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Runtime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="c1"&gt;// added myself just to look in logs&lt;/span&gt;
    &lt;span class="n"&gt;TestOnRuntimeUpgrade&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;TestOnRuntimeUpgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;OnRuntimeUpgrade&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;TestOnRuntimeUpgrade&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;on_runtime_upgrade&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nn"&gt;frame_support&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Weight&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nn"&gt;frame_support&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;info!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ಠ_ಠ 🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞 migrations applied"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nn"&gt;Weight&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_ref_time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;e) build &lt;code&gt;cargo b -r&lt;/code&gt;, save wasm&lt;/p&gt;

&lt;h2&gt;
  
  
  Perform upgrade and check everything is ok
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;run old-versioned parachain in local testnet (can use &lt;a href="https://dev.to/nikania/quick-list-starting-local-parachain-testnet-3ncg"&gt;quick list&lt;/a&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo run ./bin/parachain-template-node-v0.9.32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;upgrade runtime (&lt;a href="https://docs.substrate.io/tutorials/build-a-blockchain/upgrade-a-running-network/"&gt;official guide&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Migrations of &lt;code&gt;pallet_xcm&lt;/code&gt;, &lt;code&gt;pallet_alliance&lt;/code&gt; and &lt;code&gt;pallet_assets&lt;/code&gt; are needed only if there is something in the storage of these pallets. Therefore, in this example migrations are unnecessary. I did this example only to show how to find the migrations.&lt;/p&gt;

&lt;p&gt;Any comments, corrections and suggestions are appreciated!💬&lt;/p&gt;

</description>
      <category>substrate</category>
      <category>polkadot</category>
      <category>runtimeupgrade</category>
      <category>parachain</category>
    </item>
    <item>
      <title>Quick list - starting local parachain testnet</title>
      <dc:creator>nikania</dc:creator>
      <pubDate>Fri, 21 Apr 2023 15:24:51 +0000</pubDate>
      <link>https://dev.to/nikania/quick-list-starting-local-parachain-testnet-3ncg</link>
      <guid>https://dev.to/nikania/quick-list-starting-local-parachain-testnet-3ncg</guid>
      <description>&lt;p&gt;Quick CLI reference to start local testnet with 2 relay chain nodes and 1 parachain node. Based on detailed &lt;a href="https://docs.substrate.io/tutorials/build-a-parachain/connect-a-local-parachain/"&gt;official tutorial&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  To start relay chain, firstly build chain spec:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./target/release/polkadot \ 
build-spec --chain rococo-local --raw &amp;gt; rococo_local_raw.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the resulting file set &lt;code&gt;"bootNodes": []&lt;/code&gt; (and unique &lt;code&gt;"id": "qwerty"&lt;/code&gt; - optional, only if there are other testnets in your local network)&lt;/p&gt;

&lt;p&gt;Start Relay &lt;code&gt;Alice&lt;/code&gt; node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./target/release/polkadot \
--alice \
--validator \
--base-path /tmp/relay/alice \
--chain rococo_local_raw.json \
--port 30333 \
--ws-port 9944
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start Relay &lt;code&gt;Bob&lt;/code&gt; node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./target/release/polkadot \
--bob \
--validator \
--base-path /tmp/relay-bob \
--chain  rococo_local_raw.json \
--port 30334 \
--ws-port 9945
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case of restart, purge previous chain state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf /tmp/relay/alice
rm -rf /tmp/relay-bob 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To start parachain
&lt;/h3&gt;

&lt;p&gt;build spec (again, set unique "id" if needed) and wasm and genesis:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./target/release/parachain-collator \ 
build-spec --disable-default-bootnode &amp;gt; rococo-local-parachain-plain.json
./target/release/parachain-collator \
build-spec --chain rococo-local-parachain-plain.json --raw \
--disable-default-bootnode &amp;gt; rococo-local-parachain-2000-raw.json

./target/release/parachain-collator \
export-genesis-wasm --chain rococo-local-parachain-2000-raw.json &amp;gt; para-2000-wasm
./target/release/parachain-collator \
export-genesis-state --chain rococo-local-parachain-2000-raw.json &amp;gt; para-2000-genesis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;register ParaId by Alice on relay chain&lt;/p&gt;

&lt;p&gt;Start parachain&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./target/release/parachain-collator \
--alice \
--collator \
--force-authoring \
--chain rococo-local-parachain-2000-raw.json \
--base-path /tmp/parachain/sora-parachain-alice \
--port 40333 \
--ws-port 8844 \
--log xcm=trace \
-- \
--execution wasm \
--chain .._path_to_relay_chain_spec_/rococo_local_raw.json \
--port 30344 \
--ws-port 9977
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Submit sudo on relay chain: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HY-GLOJh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98q4twho7sga99k5ps06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HY-GLOJh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98q4twho7sga99k5ps06.png" alt="Image description" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>substrate</category>
      <category>parachain</category>
      <category>testnet</category>
    </item>
    <item>
      <title>Using log in Substrate</title>
      <dc:creator>nikania</dc:creator>
      <pubDate>Wed, 10 Aug 2022 10:57:00 +0000</pubDate>
      <link>https://dev.to/nikania/using-log-in-substrate-4mm9</link>
      <guid>https://dev.to/nikania/using-log-in-substrate-4mm9</guid>
      <description>&lt;p&gt;How to log in substrate pallets and how to see logs when running node (can be useful to see existing logs in polkadot when debugging).&lt;/p&gt;

&lt;p&gt;Import log crate in Cargo.toml of pallets/template&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[dependencies]&lt;/span&gt;
&lt;span class="py"&gt;log&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.4"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add some logging to extrinsic &lt;code&gt;do_something&lt;/code&gt; in pallet-template (gibberish in my case)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"lalala"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is working!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"ononono"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is working!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"test::werr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is working!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"lalala"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is done!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"ononono"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is done!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;log&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;trace!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"test::werr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"do_something is done!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build node, and run with log filtering (filters only &lt;code&gt;target: "lalala"&lt;/code&gt; trace logs):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/node-template &lt;span class="nt"&gt;--dev&lt;/span&gt; &lt;span class="nt"&gt;--tmp&lt;/span&gt; &lt;span class="nt"&gt;--log&lt;/span&gt; &lt;span class="nv"&gt;lalala&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;when execute extrinsics, trace log is in output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kmqffKVd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yd38rbgox3wxo563ala.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kmqffKVd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yd38rbgox3wxo563ala.png" alt="Image description" width="622" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;different filtering (notice that &lt;code&gt;target: "test::werr"&lt;/code&gt; can be filtered like that &lt;code&gt;test=trace&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./target/release/node-template &lt;span class="nt"&gt;--dev&lt;/span&gt; &lt;span class="nt"&gt;--tmp&lt;/span&gt; &lt;span class="nt"&gt;--log&lt;/span&gt; &lt;span class="nv"&gt;lalala&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;trace &lt;span class="nv"&gt;ononono&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;trace &lt;span class="nb"&gt;test&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;--different output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R3ZZbGuo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gls1fukp92ygitbvq49t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R3ZZbGuo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gls1fukp92ygitbvq49t.png" alt="Image description" width="623" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example to trace xcm messages in parachains/relay chain filter can be used: &lt;code&gt;--log xcm=trace&lt;/code&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>log</category>
      <category>substrate</category>
    </item>
    <item>
      <title>List of common coding errors using Substrate</title>
      <dc:creator>nikania</dc:creator>
      <pubDate>Mon, 21 Mar 2022 15:51:39 +0000</pubDate>
      <link>https://dev.to/nikania/list-of-common-beginner-errors-while-writing-code-using-substrate-4f08</link>
      <guid>https://dev.to/nikania/list-of-common-beginner-errors-while-writing-code-using-substrate-4f08</guid>
      <description>&lt;p&gt;I have started to study Substrate recently, and encountered a lot of simple but not-so-easy to solve errors. So I decided to make a list of them, for future use and for others)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;error[E0432]: unresolved import &lt;code&gt;pallet&lt;/code&gt;&lt;br&gt;
This is compile error caused by errors in&lt;br&gt;
&lt;code&gt;pub mod pallet { &amp;lt;fix errors here&amp;gt; }&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;error: failed to download &lt;code&gt;parity-db v0.2.2&lt;/code&gt;&lt;br&gt;
can be resolved by:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo update -p parity-db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;many errors while building substrate-node-template often can be resolved with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo update -p &amp;lt;package causing problem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;error
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.iter().map(|x| x.amount).sum();
      the trait `Sum&amp;lt;&amp;lt;T as pallet_*::Config&amp;gt;::Balance&amp;gt;` is not implemented for `&amp;amp;&amp;lt;T as pallet_*::Config&amp;gt;::Balance`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can be resolved by using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.fold(T::Balance::default(), |acc, x| acc + x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of &lt;code&gt;.sum()&lt;/code&gt; OR if u use custom asset pallet and can make changes in it, adding trait &lt;code&gt;Sum&amp;lt;Self::Balance&amp;gt;&lt;/code&gt; to Balance let u use &lt;code&gt;.sum()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// The units in which we record balances.  
type Balance: Member + Parameter + AtLeast32BitUnsigned + Default + Copy + Sum&amp;lt;Self::Balance&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;error 1002 (in polkadot.js.org/apps/)
1002: Verification Error: Runtime error: Execution failed: ApiError("Could not convert parameter &lt;code&gt;tx&lt;/code&gt; between node and runtime: Could not decode &lt;code&gt;Call::MyPallet.0&lt;/code&gt;:\n\tCould not decode &lt;code&gt;Call::create.3&lt;/code&gt;:\n\t\tNot enough data to fill buffer\n")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This error appears because of wrong types.json - wrong type here: &lt;code&gt;Call::create.3&lt;/code&gt; - 3rd argument with start from 0 (0,1,2,3)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;error&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>substrate</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
