Skip to main content

Agile Coretime for Parachains

info

If you aren't sure what Agile Coretime is, be sure to read the introduction, terminology, and FAQ.

The landscape for parachains on Kusama changes with the rollout of Agile Coretime. With parachain auctions being phased out in favor of direct coretime sales, the existing parachains on the relaychain and the prospective parachains are presented with the following scenarios:

  • Migrating from a legacy parachain lease into a bulk coretime model
  • Starting with bulk coretime model from scratch
  • Running a parachain with on-demand coretime purchases ("pay as you go")

The parachain lease auctions will stop on-chain with the enactment of the runtime upgrade 1.2.0, and the existing leases will be migrated to bulk coretime automatically. Leases that are yet to be started will be canceled and the locked KSM
will be refunded. The existing parachains benefit from coretime renewals which allows for the continued assignment of bulk coretime for a core without going through the regular purchasing process.

info

The tutorials below assume that you have already developed the parachain runtime and a fully configured parachain collator for the target relay chain using the Polkadot SDK.

For the tutorials below, the adder test parachain on the Polkadot SDK has been used. To compile the adder-collator, run the command below in the root of the Polkadot SDK repository. You must have Rust and its associated tooling installed before following along.

Ensure the Polkadot SDK is cloned, and you are within the root directory (cd polkadot-sdk)

cargo build -r -p test-parachain-adder-collator

After the test parachain collator node is successfully compiled, export its genesis state and the code using the following commands. If the export succeeds, these two files should appear in the Polkadot-SDK repository.

./target/release/adder-collator export-genesis-state genesis
./target/release/adder-collator export-genesis-wasm genesis-wasm

Reserve ParaID

info

Reserving a ParaID requires a deposit of:

  • on Kusama
  • on Polkadot

The first step is to register a ParaID for the parachain. This can be done through Polkadot-JS UI by navigating to Network > Parachains > Parathreads and clicking on ParaID button. Ensure that you have sufficient tokens to reserve the displayed ParaID successfully.

coretime-reserve-paraID

Register Parachain State and Code

The next step is to register the parachain's genesis wasm and state, which you should have generated earlier. Note that for this example, we are using adder-collator, but in theory a custom runtime compiled from a template would work as well.

info

Registering the genesis state and WASM code of the parachain requires a deposit that is computed based on the size (a deposit is paid per byte uploaded):

  • Kusama: per byte
  • Polkadot: per byte

The deposit used for registering ParaID is already counted in for this deposit, the total deposit requirement for registering ParaID, state and code for adder-collator is around 46 KSM on Kusama and 116 DOT on Polkadot.

coretime-register-parathread

After successful registration, the parachain starts onboarding as a parathread.

coretime-onboarding-parathread

Run Parachain Collator

While the parachain is onboarding, start syncing the collator using the following command to rapidly sync with the specified relay chain.

./target/release/adder-collator --parachain-id= $ParaID --chain=rococo --sync fast-unsafe

Run a Parachain with Bulk Coretime

info

Note that we have two options: bulk coretime and on-demand coretime. Bulk coretime is purchased via the broker pallet, which is on the respective Coretime system parachain. On-demand coretime is ordered via the OnDemandAssignment pallet/module, which is located on the respective relay chain.

You can purchase bulk coretime on Coretime chain and assign the purchased core to the registered ParaID. The snapshot below is from Lastic interface.

coretime-bulk-assign-lastic

After successful assignment of the core, the adder-collator logs show new collations at regular intervals, gradually incrementing the state by 2.

coretime-collation-bulk

Run a Parachain with On-demand Coretime

After the collator node is fully synced with the relay chain, navigate to Developer > Extrinsics on the relay chain and issue onDemandAssignmentProvider.placeOrderAllowDeath extrinsic from the account that registered the ParaID by specifying sufficient maxAmountfor the transaction to go through successfully.

coretime-ondemand-assignment

info

There are two extrinsics which allow you to place orders for on-demand coretime:

  • onDemandAssignmentProvider.placeOrderAllowDeath will reap the account once the provided funds run out.

  • onDemandAssignmentProvider.placeOrderKeepAlive includes a check which will not reap the account if the provided funds will run out, ensuring the account is kept alive.

With each successful on-demand extrinsic, the parachain head changes (you may have to zoom out on the browser for parachain head details to show up on Polkadot-JS UI).

coretime-ondemand-parahead

The successful collation can also be verified in the parachain collator logs. It can be noticed that with each parachain block, the state of adder-collator is incremented by 2.

coretime-new-collation