mosaicdao / mosaic-1

Mosaic-1 : meta-blockchains on Ethereum 1.x
8 stars 12 forks source link

Tracking metablocks' rounds in the Consensus contract. #92

Closed pgev closed 4 years ago

pgev commented 4 years ago

Add in the Consensus contract, the following mappings named metablockchains and metablockTips:

  mapping(bytes20 /* chain id */ => mapping(uint256 => MetaBlock)) public metablockchains;
  mapping(bytes20 /* chain id */ => uint256 /* metablock number */) public metablockTips;

Metablock's struct:

    struct Metablock {
        bytes32 metablockHash;
        uint256 roundBlockNumber;
        MetablockRound round;
    }

Metablock's round:

  enum MetablockRound {
        Undefined,
        Precommitted,
        CommitteeFormed,
        CommitteeDecided,
        Committed,            
    }

The mapping metablockchains is updated in the following function calls:

To be able to update metablockchains and metablockTips mappings one of the below proposals should be picked:

Adding the following two mappings to Consensus:

  - mapping(address /* core */ => bytes20 /* chain id */) public cores;
  - mapping(address /* committee */ => bytes20 /* chain id */) public committees;

or,

Consensus is passing chainId into core and committee on creation. Core::precommitMetablockand Committee::registerCommitteeDecision specify the chainId on calling back.

Optional (optimization):

benjaminbollen commented 4 years ago

Great ticket thx

Thx!

pgev commented 4 years ago

@benjaminbollen

benjaminbollen commented 4 years ago

Do you mean to have "metablockChains" or "metablockchains"?

I think I would write "metablockchain" as one word, bc I write "blockchain" as one word too. So capitalisation is "metablockchains"

pgev commented 4 years ago

https://github.com/mosaicdao/mosaic-1/pull/103