phala-blockchain: Fast block speed in dev network

Now it’s fixed at 6s per-block. However we want a much faster block speed in development to save time. This is especially useful for e2e test, which can easily takes a few minutes to finish.

Substrate offers “Instant Seal” consensus engine, which can produce block every time when it receives a transaction instantly. However it doesn’t meet our needs. We heavily depends on GRANDPA consensus and block justification to bridge the blockchain and pRuntime, but instant seal consensus engine doesn’t have block justification at all. In theory we can open a hole in pRuntime to short-circuit the light validation logic all together, but it’s still an error prone code change.

So an easier way is to just make the consensus engine produce blocks faster (<1s) for dev blockchain.

For Bounty Hunters

  • Deliverable:
    1. Fast block time while not breaking the existing system (should pass all unit tests & e2e test (under e2e/))
    2. The block time should be adjustable via cli option, and we should figure out the best value for it
    3. Document the changes
  • Resources
    • To build the project, follow the wiki tutorial environment section. The wiki is out-of-date, but it generally works expect we use rust nightly-2021-05-11 and llvm-10.
    • To run the e2e test, enter e2e/ and run yarn && yarn test. You should have phala-node, pherry (phost in the tutorial), and pruntime already compiled before running the e2e test.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

@bernardoaraujor Congratulations! I confirm the submission is accepted. We have paid the bounty at: https://polkadot.subscan.io/extrinsic/6466071-1

Thank you for your contribution!

The investigation sounds very reasonable. Let me give you some background. phala-blockchain is a standalone Substrate blockchain mainly for our daily development. And there’s another repo called khala-parachain, which is our real live blockchain (we adopt the parachain architecture and won a slot on Kusama).

Therefore we will probably never run a live network (even for public test) on phala-blockchain. We still stick to the standalone blockchain project for development because it’s easier to set up and faster (6s vs 12s block time; 1 node vs 5 nodes in minimal). In this task, we’d love to make the end-to-end test faster by reducing the block time, but as you pointed out, any block time less than 6s is not recommended, we don’t really want to hard code a shorter block interval. That’s why we wanted to make it adjustable, and only use it in the end-to-end test.

To inject block duration into the runtime, I’d suggest to search session_length in paritytech/cumulus project. They have made the session time (also a constant) adjustable in chain-spec.rs, which can be further controlled by the command line flags.

Hello @bernardoaraujor. Thanks for your interest on the bounty task.

You are right, the tutorial is out-of-date, but I just meant to take it as a reference to build the project. So it means you need to install the deps (llvm-10, the latest sgx sdk), and then work on the master branch instead. I’d suggest to always stick to nightly-2021-005-11.