Is there any way to speed-up the blockchain in a way that 180 epochs happen in a reasonable time-frame in the CKB local devchain?

※ Open Thread in Discord

  • phroi (Tue Apr 18 07:44:05 2023):

    Hi all~ I’m working on a local devchain, I was wondering: is there any way to speed-up the blockchain in a way that 180 epochs happen in a reasonable time-frame?

  • doitian (Tue Apr 18 08:42:19 2023):

    When we test some CKB features, we make the number of elsapsed epochs configurable.

  • phroi (Tue Apr 18 09:08:33 2023):

    r @doitian: When we test some CKB…

    That would be perfect, can you point me to the right code or the right flags to set?

  • phroi (Tue Apr 18 09:13:00 2023):

    By the way, is your proposed approach compatible with Lumos?

  • doitian (Tue Apr 18 09:18:41 2023):

    I’m not sure about Lumos.

    This is an example: ckb/test/src/specs/dao/dao_tx.rs at 9d019a98f73b554dffd5a79476664f3dcba9fc1b · nervosnetwork/ckb · GitHub

    It modifies the two spec parameter:

    genesis_epoch_length: how many blocks in the genesis epoch
    epoch_duration_target: target duration of an epoch, a small value ensure we still have a small epoch length after genesis epoch.

Start a new dev chain. Edit the spec file specs/dev.toml. Find the following two options and change their values to 2:

epoch_duration_target = 2  
genesis_epoch_length = 2  

The option genesis_epoch_length sets the number of blocks in the genesis epoch (the first epoch which contains the genesis block). The small value of epoch_duration_target ensures that the number of blocks will not increase significantly in the following epochs.

Then open the config file ckb.toml, and add a valid [block_assembler] for miner.

The last, open miner config file ckb-miner, and set the option value in the section [[miner.workers]] to a smaller value, e.g., 200, which means producing a block every 200ms.

Now start the ckb server and miner. It will take 0.2s to create a block. Each epoch will have only two blocks, so it will take 1.5 minutes to generate 180 epochs.

2 Likes