1

enter image description here

I implemented my own staking pallet, which implemented the SessionManager. And I pass it to pallet_session::Config.

I can confirm the session keys are set correctly.

If I stop the Alice node, then the Bob start to produce blocks.

Why Alice always get the authority to produce block?

Code: https://github.com/darwinia-network/darwinia-2.0/blob/xavier/staking/pallet/staking/src/lib.rs

6
  • There's not enough information here for people to help. Have you confirmed that the output of new_session for your pallet is correct? Have you checked the validators are correct? You can get them from a running chain via the explorer: Chain State > session > validators. Dec 5, 2022 at 16:55
  • Yes, they are correct. As I said if I stop Alice node, then Bob starts to produce blocks. Which means the keys are correct. Dec 5, 2022 at 16:56
  • What about the set of authorities used by aura? If the set of authorities from aura is [Alice, Bob], then both should be producing blocks equally, so there is more than likely an issue somewhere between your pallet and the set of aura authorities. Dec 5, 2022 at 17:18
  • I think they are correct. I put the code link in the question. Maybe you could find some issues? Dec 5, 2022 at 17:22
  • I read through the code in the link, and everything looks correct there. Are you making sure to wait 2 sessions before expecting a new set of authorities to take effect? You can check aura authorities on a running chain by Chain State > aura > authorities. If the aura authorities are correct (alice + bob) and bob can author blocks only when alice disconnects, that would imply an issue within / with aura setup or keys somehow. Dec 5, 2022 at 17:46

1 Answer 1

3

The slot duration in your runtime is wrong:

pub const MILLISECS_PER_BLOCK: u64 = 6_000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;

You are running a parachain that can only produce a block every 12 seconds. You have set your slot time to 6 seconds. That means that you always skip Bob. Always when it is the turn of Bob, there is "no slot" in the relay chain to build a parachain block.

So, the solution is to set the following as slot duration:

pub const MILLISECS_PER_BLOCK: u64 = 12_000;

Your Answer

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

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