Consensus Contract

The Consensus contract is essentially used for managing block producers and synchronizing data.

view methods

For reference, you can find here the available view methods.

GetCurrentMinerList

rpc GetCurrentMinerList (google.protobuf.Empty) returns (MinerList){}

message MinerList {
    repeated bytes pubkeys = 1;
}

Gets the list of current miners.

  • Returns
    • pubkeys: miners’ public keys.

GetCurrentMinerPubkeyList

rpc GetCurrentMinerPubkeyList (google.protobuf.Empty) returns (PubkeyList){}

message PubkeyList {
    repeated string pubkeys = 1;
}

Gets the list of current miners, each item a block producer’s public key in hexadecimal format.

  • Returns
    • pubkeys: miner’s public key (hexadecimal string).

GetCurrentMinerListWithRoundNumber

rpc GetCurrentMinerListWithRoundNumber (google.protobuf.Empty) returns (MinerListWithRoundNumber){}

message MinerListWithRoundNumber {
    MinerList miner_list = 1;
    int64 round_number = 2;
}

message MinerList {
    repeated bytes pubkeys = 1;
}

Gets the list of current miners along with the round number.

  • Returns
    • miner list: miners list.
    • round number: current round number.
  • MinerList
    • pubkeys: miners’ public keys.

GetRoundInformation

rpc GetRoundInformation (aelf.SInt64Value) returns (Round){}

message SInt64Value
{
    sint64 value = 1;
}

message Round {
    int64 round_number = 1;
    map<string, MinerInRound> real_time_miners_information = 2;
    int64 main_chain_miners_round_number = 3;
    int64 blockchain_age = 4;
    string extra_block_producer_of_previous_round = 5;
    int64 term_number = 6;
    int64 confirmed_irreversible_block_height = 7;
    int64 confirmed_irreversible_block_round_number = 8;
    bool is_miner_list_just_changed = 9;
    int64 round_id_for_validation = 10;
}

message MinerInRound {
    int32 order = 1;
    bool is_extra_block_producer = 2;
    aelf.Hash in_value = 3;
    aelf.Hash out_value = 4;
    aelf.Hash signature = 5;
    google.protobuf.Timestamp expected_mining_time = 6;
    int64 produced_blocks = 7;
    int64 missed_time_slots = 8;
    string pubkey = 9;
    aelf.Hash previous_in_value = 10;
    int32 supposed_order_of_next_round = 11;
    int32 final_order_of_next_round = 12;
    repeated google.protobuf.Timestamp actual_mining_times = 13;// Miners must fill actual mining time when they do the mining.
    map<string, bytes> encrypted_pieces = 14;
    map<string, bytes> decrypted_pieces = 15;
    int64 produced_tiny_blocks = 16;
    int64 implied_irreversible_block_height = 17;
}

Gets information of the round specified as input.

  • SInt64Value
    • value: round number.
  • Returns
    • round number: round number.
    • real time miners information: public key => miner information.
    • blockchain age: current time minus block chain start time (if the round number is 1, the block chain age is 1), represented in seconds.
    • extra block producer of previous round: the public key (hexadecimal string) of the first miner, who comes from the last term, in the current term.
    • term number: the current term number.
    • confirmed irreversible block height: irreversible block height.
    • confirmed irreversible block round number: irreversible block round number.
    • is miner list just changed: is miner list different from the the miner list in the previous round.
    • round id for validation: round id, calculated by summing block producers’ expecting time (second).
  • MinerInRound
    • order: the order of miners producing block.
    • is extra block producer: The miner who is the first miner in the first round of each term.
    • in value: the previous miner’s public key.
    • out value: the post miner’s public key.
    • signature: self signature.
    • expected mining time: expected mining time.
    • produced blocks: produced blocks.
    • missed time slots: missed time slots.
    • pubkey: public key string.
    • previous in value: previous miner’s public key.
    • supposed order of next round: evaluated order in next round.
    • final order of next round: the real order in the next round.
    • actual mining times: the real mining time.
    • encrypted pieces: public key (miners in the current round) => message encrypted by shares information and public key (represented by hexadecimal string).
    • decrypted pieces: the message of miners in the previous round.
    • produced tiny blocks: produced tiny blocks.
    • implied irreversible block height: miner records a irreversible block height.

GetCurrentRoundNumber

rpc GetCurrentRoundNumber (google.protobuf.Empty) returns (aelf.SInt64Value){}

message SInt64Value
{
    sint64 value = 1;
}

Gets the current round number.

  • Returns
    • value: number of current round.

GetCurrentRoundInformation

Gets the current round’s information.

 rpc GetCurrentRoundInformation (google.protobuf.Empty) returns (Round){}

note: for Round see GetRoundInformation

GetPreviousRoundInformation

Gets the previous round information.

rpc GetPreviousRoundInformation (google.protobuf.Empty) returns (Round){}

note: for Round see GetRoundInformation

GetCurrentTermNumber

rpc GetCurrentTermNumber (google.protobuf.Empty) returns (aelf.SInt64Value){}

message SInt64Value
{
    sint64 value = 1;
}

Gets the current term number.

  • Returns
    • value: the current term number.

GetCurrentWelfareReward

rpc GetCurrentWelfareReward (google.protobuf.Empty) returns (aelf.SInt64Value){}

message SInt64Value
{
    sint64 value = 1;
}

Gets the current welfare reward.

  • Returns
    • value: the current welfare reward.

GetPreviousMinerList

rpc GetPreviousMinerList (google.protobuf.Empty) returns (MinerList){}

message MinerList {
    repeated bytes pubkeys = 1;
}

Gets the miners in the previous term.

  • MinerList
    • pubkeys: public keys (represented by hexadecimal strings) of miners in the previous term.

GetMinedBlocksOfPreviousTerm

rpc GetMinedBlocksOfPreviousTerm (google.protobuf.Empty) returns (aelf.SInt64Value){}

message SInt64Value
{
    sint64 value = 1;
}

Gets the number of mined blocks during the previous term.

  • Returns
    • value: the number of mined blocks.

GetNextMinerPubkey

rpc GetNextMinerPubkey (google.protobuf.Empty) returns (google.protobuf.StringValue){}

message StringValue {
  string value = 1;
}

Gets the miner who will produce the block next, which means the miner is the first one whose expected mining time is greater than the current time. If this miner can not be found, the first miner who is extra block producer will be selected.

  • Returns
    • value: the miner’s public key.

GetCurrentMinerPubkey

rpc GetCurrentMinerPubkey (google.protobuf.Empty) returns (google.protobuf.StringValue){}

message StringValue {
  string value = 1;
}

Gets the current miner.

  • Returns:
    • value: miner’s public key.

IsCurrentMiner

rpc IsCurrentMiner (aelf.Address) returns (google.protobuf.BoolValue){
}

message Address
{
    bytes value = 1;
}

Query whether the miner is the current miner.

  • Address
    • value: miner’s address.
  • Returns
    • value: indicates if the input miner is the current miner.

GetNextElectCountDown

rpc GetNextElectCountDown (google.protobuf.Empty) returns (google.protobuf.Int64Value){}

message Int64Value
{
    int64 value = 1;
}

Count down to the next election.

  • Returns
    • value: total seconds to next election.