1

I have been making my own custom blockchain just as a practice for the past few weeks. The code is available here link to github repo

I have hitherto implemented the Execution Layer, so to speak. I didn't name it that because i didn't intend on following the Ethereum's specs. But the Exec Layer has its own gossip and p2p protocol; RPC and JSON apis for client to query the blockchain.

Having completed this I went on the impelement the Consensus Layer/Mechanism; of which I naivley decided on implementing the PoS. Then I had to read the internals of Ethereum's Architecture. I understand that the Consensus and Execution Layers have their separate p2p mechanisms and communicate internally via a local RPC mechanism.

Ethereum Node Architecture

I was thinking of implementing something similar in my app; so i decided that instead of using an Engine API to communicate between the CL and EL I would share the RPC channel and the TCP Transport Layer between the two. This meant that both the EL and CL share the same copy of peers connected to them.

Now this is what I don't understand;

  • What should be the structure of the Consensus Layer?
type ConsensusClientOpts struct {
    BlockTime    time.Duration
    EpochTime    time.Duration
    Logger       log.Logger
    RPCProcessor network.RPCProcessor
    // TCPTransport *network.TCPTransport
    ExecutionClient *network.Server
}

type ConsensusClient struct {
    ConsensusClientOpts
    mu         *sync.RWMutex
    validators []*network.Server
    rpcCh      chan network.RPC
    Committees []*Committee
    ID         string
    quitCh     chan struct{}
}

This is what i have currently; by injection the Execution Layer directly into the CL i can have direct access to various necessary structures of EL.

But this creates loads of security concerns and the code is ofcourse tightly coupled

How instead should I compose the structure of CL given that I'll be implementing the PoS Mechanism here...

  • How is a validator chosen in Ethereum's Network?

From what I understand about PoS as per Casper's implementation, at the start of each epoch, 32 committees need to be randomly formed and be assigned to each of the 32 time slots each lasting 12 sec. Within each time slot, one validator inside a committee will be randomly chosen as Validator and the rest of the validators will have to attest to it.

  • But here 66% of the network has not attested to the block; only the attesters in the committee have; so how can it be added to the chain?
  • (This is the most imp question; kindly answer this) This random formation of committees is done by whom exactly? Because one node may not have information about all the other nodes in the network and their stake amts etc? So i believe that we need a master node that has visibility of the whole network to be able to form random committees and dictate the selected validator that they are to propose a block in this time slot. Sort of like how Master Node in the Kubernetes Cluster works.
    • Also if the entire process is distributed then each node in the network would create their own randomized configuration for Committees and since each would be different it would be difficult to orchestrate it all? How exactly is it implemented in Ethereum?

Any guidance or ref to resources would be much appreciated! I am just a junior dev so excuse me for my lack of knowledge.

0

Your Answer

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