Skip to content

Commit

Permalink
add choptsticks guide
Browse files Browse the repository at this point in the history
Signed-off-by: Iulian Barbu <[email protected]>
  • Loading branch information
iulianbarbu committed Nov 27, 2024
1 parent 897ea81 commit f913cec
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
29 changes: 27 additions & 2 deletions templates/parachain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,34 @@ Development parachains:
We recommend using [`chopsticks`](https://github.com/AcalaNetwork/chopsticks) when the focus is more on the runtime
development and `OmniNode` is enough as is.

### Install chopsticks

To use `chopsticks`, please install the latest version according to the installation [guide](https://github.com/AcalaNetwork/chopsticks?tab=readme-ov-file#install).

### Build a raw chain spec

Build the `parachain-template-runtime` as mentioned before in this guide and use `chain-spec-builder`
again but this time by passing `--raw-storage` flag:

```sh
chain-spec-builder create --raw-storage --relay-chain "rococo-local" --para-id 1000 --runtime \
target/release/wbuild/parachain-template-runtime/parachain_template_runtime.wasm named-preset development
```

### Start `chopsticks` with the chain spec

We'll also need to set `--allow-unresolved-imports=true` because the `parachain-template-runtime` is not built
with the benchmarking feature, and some of the host functions required for it are missing.

```sh
npx @acala-network/chopsticks@latest --chain-spec <path/to/chain_spec.json> --allow-unresolved-imports=true
```

### Alternatives

`OmniNode` can be still used for runtime development if using the `--dev` flag, while `parachain-template-node` doesn't
support it at this moment (but it can still be used to test a runtime in a full setup where it is started alongside a
relay chain network, as we do with the `zombienet.toml` file).
support it at this moment. It can still be used to test a runtime in a full setup where it is started alongside a
relay chain network (see [Parachain Template node](#parachain-template-node) setup).

## Contributing

Expand Down
5 changes: 3 additions & 2 deletions templates/parachain/runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ use super::{
MessageQueue, Nonce, PalletInfo, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent,
RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Session, SessionKeys,
System, WeightToFee, XcmpQueue, AVERAGE_ON_INITIALIZE_RATIO, EXISTENTIAL_DEPOSIT, HOURS,
MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, VERSION,
MAXIMUM_BLOCK_WEIGHT, MICRO_UNIT, MINIMUM_PERIOD, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
VERSION,
};
use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin};

Expand Down Expand Up @@ -133,7 +134,7 @@ impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = ConstU64<0>;
type MinimumPeriod = ConstU64<MINIMUM_PERIOD>;
type WeightInfo = ();
}

Expand Down
3 changes: 3 additions & 0 deletions templates/parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ mod block_times {
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK;

/// Minimum period between blocks set for the `pallet_timestamp`.
pub const MINIMUM_PERIOD: u64 = SLOT_DURATION / 2;
}
pub use block_times::*;

Expand Down

0 comments on commit f913cec

Please sign in to comment.