4

I want to spin up parachain LOCALLY faster. each 6 sec. How to configure polkadot with parachain?

I have seen this and this and this post

So my zombienet contains polkadot(obviusly😊) and two parachains. each of them with one collator node.

I changed relaychain

pub const MILLISECS_PER_BLOCK: u64 = 3000;

and now relay chain produce the block each 3 sec. it is good.

enter image description here

I changed for parachain runtime. the value. from 12000 to 6000

pub const MILLISECS_PER_BLOCK: u64 = 6000;

BUT parachain still produce the block each 12 sec instead of 6 even when relay chain produce block each 3 sec.

I understand that i need to reconfigure relay chain to sign and send transaction to parachain more often. set_validate_data extrinisc in parachain system

enter image description here

1

2 Answers 2

2

If you want to run the relay chain and parachain locally follow https://docs.substrate.io/tutorials/build-a-parachain/prepare-a-local-relay-chain/.

The above tutorial will help you set up a relay chain locally and also will tell you how to connect a local parachain to it, after setting up the chain you can configure it according to your needs.

3
  • thanks. i aware about how to run locally. i am interested how to configure relaychain + parachain to produce block faster for parachain. at least every 6 sec instead of 12 sec.
    – rust.dev
    Commented May 18, 2023 at 9:31
  • 1
    it should have worked by changing the MILLISECS_PER_BLOCK, time also doesn't changed on parachain's explorer as well? Commented May 18, 2023 at 10:20
  • Once i changed MILLISECS_PER_BLOCK for parachain runtime it does not work. Still 12 sec per block instead of 6. even when relay chain produces the block each 3 sec.
    – rust.dev
    Commented May 18, 2023 at 10:39
1

polkadot/service/chain_spec.rs will override

MILLISECS_PER_BLOCK

So you do not need change MILLISECS_PER_BLOCK directly. You need to change

session_length_in_blocks

#[cfg(feature = "rococo-native")]
pub fn rococo_development_config() -> Result<RococoChainSpec, String> {
    let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;

        Ok(RococoChainSpec::from_genesis(
            "Development",
            "rococo_dev",
            ChainType::Development,
            move || RococoGenesisExt {
                runtime_genesis_config: rococo_development_config_genesis(wasm_binary),
                // Use 1 minute session length.
                session_length_in_blocks: Some(10),
            },
            vec![],
            None,
            Some(DEFAULT_PROTOCOL_ID),
            None,
            None,
            Default::default(),
        ))
    }

Because the value of MILLISECS_PER_BLOCK will be overided byt this code

#[cfg(feature = "rococo-native")]
impl sp_runtime::BuildStorage for RococoGenesisExt {
    fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> {
        sp_state_machine::BasicExternalities::execute_with_storage(storage, || {
            if let Some(length) = self.session_length_in_blocks.as_ref() {
                rococo_runtime_constants::time::EpochDurationInBlocks::set(&length);
            }
        });
        self.runtime_genesis_config.assimilate_storage(storage)
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.