mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
feat: quorum
This commit is contained in:
parent
1680cd6b32
commit
93cceff23c
@ -84,12 +84,17 @@
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "epoch",
|
"name": "_epoch",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "_quorumId",
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "bytes",
|
"internalType": "bytes",
|
||||||
"name": "signersBitmap",
|
"name": "_quorumBitmap",
|
||||||
"type": "bytes"
|
"type": "bytes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -129,9 +134,33 @@
|
|||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"internalType": "address",
|
"internalType": "uint256",
|
||||||
"name": "account",
|
"name": "_epoch",
|
||||||
"type": "address"
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "_quorumId",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getQuorum",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address[]",
|
||||||
|
"name": "",
|
||||||
|
"type": "address[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "address[]",
|
||||||
|
"name": "_account",
|
||||||
|
"type": "address[]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "getSigner",
|
"name": "getSigner",
|
||||||
@ -183,9 +212,9 @@
|
|||||||
"type": "tuple"
|
"type": "tuple"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"internalType": "struct IDASigners.SignerDetail",
|
"internalType": "struct IDASigners.SignerDetail[]",
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "tuple"
|
"type": "tuple[]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
@ -195,62 +224,16 @@
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "epoch",
|
"name": "_epoch",
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "getSigners",
|
"name": "quorumCount",
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"components": [
|
"internalType": "uint256",
|
||||||
{
|
"name": "",
|
||||||
"internalType": "address",
|
"type": "uint256"
|
||||||
"name": "signer",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "string",
|
|
||||||
"name": "socket",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "X",
|
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "Y",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"internalType": "struct BN254.G1Point",
|
|
||||||
"name": "pkG1",
|
|
||||||
"type": "tuple"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"internalType": "uint256[2]",
|
|
||||||
"name": "X",
|
|
||||||
"type": "uint256[2]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256[2]",
|
|
||||||
"name": "Y",
|
|
||||||
"type": "uint256[2]"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"internalType": "struct BN254.G2Point",
|
|
||||||
"name": "pkG2",
|
|
||||||
"type": "tuple"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"internalType": "struct IDASigners.SignerDetail[]",
|
|
||||||
"name": "details",
|
|
||||||
"type": "tuple[]"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
@ -361,7 +344,7 @@
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"internalType": "string",
|
"internalType": "string",
|
||||||
"name": "socket",
|
"name": "_socket",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
File diff suppressed because one or more lines are too long
@ -19,11 +19,12 @@ const (
|
|||||||
RequiredGasMax uint64 = 1000_000_000
|
RequiredGasMax uint64 = 1000_000_000
|
||||||
|
|
||||||
DASignersFunctionEpochNumber = "epochNumber"
|
DASignersFunctionEpochNumber = "epochNumber"
|
||||||
|
DASignersFunctionQuorumCount = "quorumCount"
|
||||||
DASignersFunctionGetSigner = "getSigner"
|
DASignersFunctionGetSigner = "getSigner"
|
||||||
DASignersFunctionGetSigners = "getSigners"
|
DASignersFunctionGetQuorum = "getQuorum"
|
||||||
|
DASignersFunctionRegisterSigner = "registerSigner"
|
||||||
DASignersFunctionUpdateSocket = "updateSocket"
|
DASignersFunctionUpdateSocket = "updateSocket"
|
||||||
DASignersFunctionRegisterNextEpoch = "registerNextEpoch"
|
DASignersFunctionRegisterNextEpoch = "registerNextEpoch"
|
||||||
DASignersFunctionRegisterSigner = "registerSigner"
|
|
||||||
DASignersFunctionGetAggPkG1 = "getAggPkG1"
|
DASignersFunctionGetAggPkG1 = "getAggPkG1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -111,10 +112,12 @@ func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly b
|
|||||||
// queries
|
// queries
|
||||||
case DASignersFunctionEpochNumber:
|
case DASignersFunctionEpochNumber:
|
||||||
bz, err = d.EpochNumber(ctx, evm, method, args)
|
bz, err = d.EpochNumber(ctx, evm, method, args)
|
||||||
|
case DASignersFunctionQuorumCount:
|
||||||
|
bz, err = d.QuorumCount(ctx, evm, method, args)
|
||||||
case DASignersFunctionGetSigner:
|
case DASignersFunctionGetSigner:
|
||||||
bz, err = d.GetSigner(ctx, evm, method, args)
|
bz, err = d.GetSigner(ctx, evm, method, args)
|
||||||
case DASignersFunctionGetSigners:
|
case DASignersFunctionGetQuorum:
|
||||||
bz, err = d.GetSigners(ctx, evm, method, args)
|
bz, err = d.GetQuorum(ctx, evm, method, args)
|
||||||
case DASignersFunctionGetAggPkG1:
|
case DASignersFunctionGetAggPkG1:
|
||||||
bz, err = d.GetAggPkG1(ctx, evm, method, args)
|
bz, err = d.GetAggPkG1(ctx, evm, method, args)
|
||||||
// txs
|
// txs
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,6 +17,15 @@ func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *ab
|
|||||||
return method.Outputs.Pack(big.NewInt(int64(epochNumber)))
|
return method.Outputs.Pack(big.NewInt(int64(epochNumber)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DASignersPrecompile) QuorumCount(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||||
|
req, err := NewQueryQuorumCountRequest(args)
|
||||||
|
response, err := d.dasignersKeeper.QuorumCount(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return method.Outputs.Pack(big.NewInt(int64(response.QuorumCount)))
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||||
req, err := NewQuerySignerRequest(args)
|
req, err := NewQuerySignerRequest(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -25,21 +35,25 @@ func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return method.Outputs.Pack(NewIDASignersSignerDetail(response.Signer))
|
signers := make([]IDASignersSignerDetail, len(response.Signer))
|
||||||
|
for i, signer := range response.Signer {
|
||||||
|
signers[i] = NewIDASignersSignerDetail(signer)
|
||||||
|
}
|
||||||
|
return method.Outputs.Pack(signers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DASignersPrecompile) GetSigners(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
func (d *DASignersPrecompile) GetQuorum(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||||
req, err := NewQueryEpochSignerSetRequest(args)
|
req, err := NewQueryEpochQuorumRequest(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
response, err := d.dasignersKeeper.EpochSignerSet(sdk.WrapSDKContext(ctx), req)
|
response, err := d.dasignersKeeper.EpochQuorum(sdk.WrapSDKContext(ctx), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
signers := make([]IDASignersSignerDetail, 0)
|
signers := make([]common.Address, len(response.Quorum.Signers))
|
||||||
for _, signer := range response.Signers {
|
for i, signer := range response.Quorum.Signers {
|
||||||
signers = append(signers, NewIDASignersSignerDetail(signer))
|
signers[i] = common.HexToAddress(signer)
|
||||||
}
|
}
|
||||||
return method.Outputs.Pack(signers)
|
return method.Outputs.Pack(signers)
|
||||||
}
|
}
|
||||||
|
@ -63,34 +63,50 @@ func SerializeG2(p BN254G2Point) []byte {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, error) {
|
func NewQueryQuorumCountRequest(args []interface{}) (*dasignerstypes.QueryQuorumCountRequest, error) {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &dasignerstypes.QuerySignerRequest{
|
return &dasignerstypes.QueryQuorumCountRequest{
|
||||||
Account: ToLowerHexWithoutPrefix(args[0].(common.Address)),
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryEpochSignerSetRequest(args []interface{}) (*dasignerstypes.QueryEpochSignerSetRequest, error) {
|
|
||||||
if len(args) != 1 {
|
|
||||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
|
||||||
}
|
|
||||||
|
|
||||||
return &dasignerstypes.QueryEpochSignerSetRequest{
|
|
||||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQueryAggregatePubkeyG1Request(args []interface{}) (*dasignerstypes.QueryAggregatePubkeyG1Request, error) {
|
func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, error) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||||
|
}
|
||||||
|
accounts := args[0].([]common.Address)
|
||||||
|
req := dasignerstypes.QuerySignerRequest{
|
||||||
|
Accounts: make([]string, len(accounts)),
|
||||||
|
}
|
||||||
|
for i, account := range accounts {
|
||||||
|
req.Accounts[i] = ToLowerHexWithoutPrefix(account)
|
||||||
|
}
|
||||||
|
return &req, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewQueryEpochQuorumRequest(args []interface{}) (*dasignerstypes.QueryEpochQuorumRequest, error) {
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &dasignerstypes.QueryEpochQuorumRequest{
|
||||||
|
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||||
|
QuorumId: args[1].(*big.Int).Uint64(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewQueryAggregatePubkeyG1Request(args []interface{}) (*dasignerstypes.QueryAggregatePubkeyG1Request, error) {
|
||||||
|
if len(args) != 3 {
|
||||||
|
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 3, len(args))
|
||||||
|
}
|
||||||
|
|
||||||
return &dasignerstypes.QueryAggregatePubkeyG1Request{
|
return &dasignerstypes.QueryAggregatePubkeyG1Request{
|
||||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||||
SignersBitmap: args[1].([]byte),
|
QuorumId: args[1].(*big.Int).Uint64(),
|
||||||
|
QuorumBitmap: args[2].([]byte),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ message Signer {
|
|||||||
bytes pubkey_g2 = 4;
|
bytes pubkey_g2 = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EpochSignerSet {
|
message Quorum {
|
||||||
repeated string signers = 1;
|
repeated string signers = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Quorums {
|
||||||
|
repeated Quorum quorums = 1;
|
||||||
|
}
|
||||||
|
@ -10,10 +10,10 @@ import "zgc/dasigners/v1/dasigners.proto";
|
|||||||
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
||||||
|
|
||||||
message Params {
|
message Params {
|
||||||
uint64 quorum_size = 1;
|
string tokens_per_vote = 1;
|
||||||
string tokens_per_vote = 2;
|
uint64 max_votes = 2;
|
||||||
uint64 max_votes = 3;
|
uint64 epoch_blocks = 3;
|
||||||
uint64 epoch_blocks = 4;
|
uint64 encoded_slices = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenesisState defines the dasigners module's genesis state.
|
// GenesisState defines the dasigners module's genesis state.
|
||||||
@ -24,6 +24,6 @@ message GenesisState {
|
|||||||
uint64 epoch_number = 2;
|
uint64 epoch_number = 2;
|
||||||
// signers defines all signers information
|
// signers defines all signers information
|
||||||
repeated Signer signers = 3;
|
repeated Signer signers = 3;
|
||||||
// signers_by_epoch defines chosen signers by epoch
|
// quorums_by_epoch defines chosen quorums by epoch
|
||||||
repeated EpochSignerSet signers_by_epoch = 4;
|
repeated Quorums quorums_by_epoch = 4;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,11 @@ service Query {
|
|||||||
rpc EpochNumber(QueryEpochNumberRequest) returns (QueryEpochNumberResponse) {
|
rpc EpochNumber(QueryEpochNumberRequest) returns (QueryEpochNumberResponse) {
|
||||||
option (google.api.http).get = "/0g/dasigners/v1/epoch-number";
|
option (google.api.http).get = "/0g/dasigners/v1/epoch-number";
|
||||||
}
|
}
|
||||||
rpc EpochSignerSet(QueryEpochSignerSetRequest) returns (QueryEpochSignerSetResponse) {
|
rpc QuorumCount(QueryQuorumCountRequest) returns (QueryQuorumCountResponse) {
|
||||||
option (google.api.http).get = "/0g/dasigners/v1/epoch-signer-set";
|
option (google.api.http).get = "/0g/dasigners/v1/quorum-count";
|
||||||
|
}
|
||||||
|
rpc EpochQuorum(QueryEpochQuorumRequest) returns (QueryEpochQuorumResponse) {
|
||||||
|
option (google.api.http).get = "/0g/dasigners/v1/epoch-quorum";
|
||||||
}
|
}
|
||||||
rpc AggregatePubkeyG1(QueryAggregatePubkeyG1Request) returns (QueryAggregatePubkeyG1Response) {
|
rpc AggregatePubkeyG1(QueryAggregatePubkeyG1Request) returns (QueryAggregatePubkeyG1Response) {
|
||||||
option (google.api.http).get = "/0g/dasigners/v1/aggregate-pubkey-g1";
|
option (google.api.http).get = "/0g/dasigners/v1/aggregate-pubkey-g1";
|
||||||
@ -28,11 +31,11 @@ service Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message QuerySignerRequest {
|
message QuerySignerRequest {
|
||||||
string account = 1;
|
repeated string accounts = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QuerySignerResponse {
|
message QuerySignerResponse {
|
||||||
Signer signer = 1;
|
repeated Signer signer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryEpochNumberRequest {}
|
message QueryEpochNumberRequest {}
|
||||||
@ -41,17 +44,27 @@ message QueryEpochNumberResponse {
|
|||||||
uint64 epoch_number = 1;
|
uint64 epoch_number = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryEpochSignerSetRequest {
|
message QueryQuorumCountRequest {
|
||||||
uint64 epoch_number = 1;
|
uint64 epoch_number = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryEpochSignerSetResponse {
|
message QueryQuorumCountResponse {
|
||||||
repeated Signer signers = 1;
|
uint64 quorum_count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryEpochQuorumRequest {
|
||||||
|
uint64 epoch_number = 1;
|
||||||
|
uint64 quorum_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryEpochQuorumResponse {
|
||||||
|
Quorum quorum = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryAggregatePubkeyG1Request {
|
message QueryAggregatePubkeyG1Request {
|
||||||
uint64 epoch_number = 1;
|
uint64 epoch_number = 1;
|
||||||
bytes signersBitmap = 2;
|
uint64 quorum_id = 2;
|
||||||
|
bytes quorum_bitmap = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message QueryAggregatePubkeyG1Response {
|
message QueryAggregatePubkeyG1Response {
|
||||||
|
@ -20,8 +20,8 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) {
|
|||||||
panic(fmt.Sprintf("failed to write genesis state into store: %s", err))
|
panic(fmt.Sprintf("failed to write genesis state into store: %s", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for epoch, signers := range gs.SignersByEpoch {
|
for epoch, quorums := range gs.QuorumsByEpoch {
|
||||||
keeper.SetEpochSignerSet(ctx, uint64(epoch), *signers)
|
keeper.SetEpochQuorums(ctx, uint64(epoch), *quorums)
|
||||||
}
|
}
|
||||||
keeper.SetParams(ctx, gs.Params)
|
keeper.SetParams(ctx, gs.Params)
|
||||||
}
|
}
|
||||||
@ -38,13 +38,13 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
|
|||||||
signers = append(signers, &signer)
|
signers = append(signers, &signer)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
epochSignerSets := make([]*types.EpochSignerSet, 0)
|
epochQuorums := make([]*types.Quorums, 0)
|
||||||
for i := 0; i < int(epochNumber); i += 1 {
|
for i := 0; i < int(epochNumber); i += 1 {
|
||||||
epochSignerSet, found := keeper.GetEpochSignerSet(ctx, uint64(i))
|
quorums, found := keeper.GetEpochQuorums(ctx, uint64(i))
|
||||||
if !found {
|
if !found {
|
||||||
panic("historical epoch signer set not found")
|
panic("historical quorums not found")
|
||||||
}
|
}
|
||||||
epochSignerSets = append(epochSignerSets, &epochSignerSet)
|
epochQuorums = append(epochQuorums, &quorums)
|
||||||
}
|
}
|
||||||
return types.NewGenesisState(params, epochNumber, signers, epochSignerSets)
|
return types.NewGenesisState(params, epochNumber, signers, epochQuorums)
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,32 @@ func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
|||||||
sort.Slice(ballots, func(i, j int) bool {
|
sort.Slice(ballots, func(i, j int) bool {
|
||||||
return bytes.Compare(ballots[i].content, ballots[j].content) < 0
|
return bytes.Compare(ballots[i].content, ballots[j].content) < 0
|
||||||
})
|
})
|
||||||
chosen := make(map[string]struct{})
|
|
||||||
epochSignerSet := types.EpochSignerSet{
|
quorums := types.Quorums{
|
||||||
Signers: make([]string, 0),
|
Quorums: make([]*types.Quorum, 0),
|
||||||
}
|
}
|
||||||
for _, ballot := range ballots {
|
if len(ballots) >= int(params.EncodedSlices) {
|
||||||
if _, ok := chosen[ballot.account]; !ok {
|
for i := 0; i+int(params.EncodedSlices) < len(ballots); i += 1 {
|
||||||
chosen[ballot.account] = struct{}{}
|
quorum := types.Quorum{
|
||||||
epochSignerSet.Signers = append(epochSignerSet.Signers, ballot.account)
|
Signers: make([]string, params.EncodedSlices),
|
||||||
|
}
|
||||||
|
for j := 0; j < int(params.EncodedSlices); j += 1 {
|
||||||
|
quorum.Signers[j] = ballots[i+j].account
|
||||||
|
}
|
||||||
|
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
quorum := types.Quorum{
|
||||||
|
Signers: make([]string, params.EncodedSlices),
|
||||||
|
}
|
||||||
|
n := len(ballots)
|
||||||
|
for i := 0; i < int(params.EncodedSlices); i += 1 {
|
||||||
|
quorum.Signers[i] = ballots[i%n].account
|
||||||
|
}
|
||||||
|
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// save to store
|
// save to store
|
||||||
k.SetEpochSignerSet(ctx, expectedEpoch, epochSignerSet)
|
k.SetEpochQuorums(ctx, expectedEpoch, quorums)
|
||||||
k.SetEpochNumber(ctx, expectedEpoch)
|
k.SetEpochNumber(ctx, expectedEpoch)
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,22 @@ var _ types.QueryServer = Keeper{}
|
|||||||
|
|
||||||
func (k Keeper) Signer(
|
func (k Keeper) Signer(
|
||||||
c context.Context,
|
c context.Context,
|
||||||
req *types.QuerySignerRequest,
|
request *types.QuerySignerRequest,
|
||||||
) (*types.QuerySignerResponse, error) {
|
) (*types.QuerySignerResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
signer, found, err := k.GetSigner(ctx, req.Account)
|
n := len(request.Accounts)
|
||||||
if err != nil {
|
response := types.QuerySignerResponse{Signer: make([]*types.Signer, n)}
|
||||||
return nil, err
|
for i := 0; i < n; i += 1 {
|
||||||
|
signer, found, err := k.GetSigner(ctx, request.Accounts[i])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
response.Signer[i] = &signer
|
||||||
}
|
}
|
||||||
if !found {
|
return &response, nil
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return &types.QuerySignerResponse{Signer: &signer}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) EpochNumber(
|
func (k Keeper) EpochNumber(
|
||||||
@ -38,43 +43,56 @@ func (k Keeper) EpochNumber(
|
|||||||
return &types.QueryEpochNumberResponse{EpochNumber: epochNumber}, nil
|
return &types.QueryEpochNumberResponse{EpochNumber: epochNumber}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) EpochSignerSet(c context.Context, request *types.QueryEpochSignerSetRequest) (*types.QueryEpochSignerSetResponse, error) {
|
func (k Keeper) QuorumCount(
|
||||||
|
c context.Context,
|
||||||
|
request *types.QueryQuorumCountRequest,
|
||||||
|
) (*types.QueryQuorumCountResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
signers, found := k.GetEpochSignerSet(ctx, request.EpochNumber)
|
quorumCount, err := k.GetQuorumCount(ctx, request.EpochNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &types.QueryQuorumCountResponse{QuorumCount: quorumCount}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k Keeper) EpochQuorum(c context.Context, request *types.QueryEpochQuorumRequest) (*types.QueryEpochQuorumResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, types.ErrEpochSignerSetNotFound
|
return nil, types.ErrQuorumNotFound
|
||||||
}
|
}
|
||||||
epochSignerSet := make([]*types.Signer, len(signers.Signers))
|
if len(quorums.Quorums) <= int(request.QuorumId) {
|
||||||
for _, account := range signers.Signers {
|
return nil, types.ErrQuorumIdOutOfBound
|
||||||
signer, found, err := k.GetSigner(ctx, account)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, types.ErrSignerNotFound
|
|
||||||
}
|
|
||||||
epochSignerSet = append(epochSignerSet, &signer)
|
|
||||||
}
|
}
|
||||||
return &types.QueryEpochSignerSetResponse{Signers: epochSignerSet}, nil
|
return &types.QueryEpochQuorumResponse{Quorum: quorums.Quorums[request.QuorumId]}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggregatePubkeyG1Request) (*types.QueryAggregatePubkeyG1Response, error) {
|
func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggregatePubkeyG1Request) (*types.QueryAggregatePubkeyG1Response, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
signers, found := k.GetEpochSignerSet(ctx, request.EpochNumber)
|
quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, types.ErrEpochSignerSetNotFound
|
return nil, types.ErrQuorumNotFound
|
||||||
}
|
}
|
||||||
if len(request.SignersBitmap) != (len(signers.Signers)+7)/8 {
|
if len(quorums.Quorums) <= int(request.QuorumId) {
|
||||||
return nil, types.ErrSignerLengthNotMatch
|
return nil, types.ErrQuorumIdOutOfBound
|
||||||
|
}
|
||||||
|
quorum := quorums.Quorums[request.QuorumId]
|
||||||
|
if (len(quorum.Signers)+7)/8 != len(request.QuorumBitmap) {
|
||||||
|
return nil, types.ErrQuorumBitmapLengthMismatch
|
||||||
}
|
}
|
||||||
aggPubkeyG1 := new(bn254.G1Affine)
|
aggPubkeyG1 := new(bn254.G1Affine)
|
||||||
hit := 0
|
hit := 0
|
||||||
for i, account := range signers.Signers {
|
added := make(map[string]struct{})
|
||||||
b := request.SignersBitmap[i/8] & (1 << (i % 8))
|
for i, signer := range quorum.Signers {
|
||||||
|
b := request.QuorumBitmap[i/8] & (1 << (i % 8))
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
signer, found, err := k.GetSigner(ctx, account)
|
if _, ok := added[signer]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
added[signer] = struct{}{}
|
||||||
|
signer, found, err := k.GetSigner(ctx, signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -86,7 +104,7 @@ func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggrega
|
|||||||
}
|
}
|
||||||
return &types.QueryAggregatePubkeyG1Response{
|
return &types.QueryAggregatePubkeyG1Response{
|
||||||
AggregatePubkeyG1: bn254util.SerializeG1(aggPubkeyG1),
|
AggregatePubkeyG1: bn254util.SerializeG1(aggPubkeyG1),
|
||||||
Total: uint64(len(signers.Signers)),
|
Total: uint64(len(quorum.Signers)),
|
||||||
Hit: uint64(hit),
|
Hit: uint64(hit),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,20 @@ func (k Keeper) SetEpochNumber(ctx sdk.Context, epoch uint64) {
|
|||||||
store.Set(types.EpochNumberKey, sdk.Uint64ToBigEndian(epoch))
|
store.Set(types.EpochNumberKey, sdk.Uint64ToBigEndian(epoch))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k Keeper) GetQuorumCount(ctx sdk.Context, epoch uint64) (uint64, error) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.QuorumCountKeyPrefix)
|
||||||
|
bz := store.Get(types.GetQuorumCountKey(epoch))
|
||||||
|
if bz == nil {
|
||||||
|
return 0, types.ErrQuorumNotFound
|
||||||
|
}
|
||||||
|
return sdk.BigEndianToUint64(bz), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k Keeper) SetQuorumCount(ctx sdk.Context, epoch uint64, quorums uint64) {
|
||||||
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.QuorumCountKeyPrefix)
|
||||||
|
store.Set(types.GetQuorumCountKey(epoch), sdk.Uint64ToBigEndian(quorums))
|
||||||
|
}
|
||||||
|
|
||||||
func (k Keeper) GetSigner(ctx sdk.Context, account string) (types.Signer, bool, error) {
|
func (k Keeper) GetSigner(ctx sdk.Context, account string) (types.Signer, bool, error) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix)
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix)
|
||||||
key, err := types.GetSignerKeyFromAccount(account)
|
key, err := types.GetSignerKeyFromAccount(account)
|
||||||
@ -122,21 +136,22 @@ func (k Keeper) IterateSigners(ctx sdk.Context, fn func(index int64, signer type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) GetEpochSignerSet(ctx sdk.Context, epoch uint64) (types.EpochSignerSet, bool) {
|
func (k Keeper) GetEpochQuorums(ctx sdk.Context, epoch uint64) (types.Quorums, bool) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochSignerSetKeyPrefix)
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix)
|
||||||
bz := store.Get(types.GetEpochSignerSetKeyFromEpoch(epoch))
|
bz := store.Get(types.GetEpochQuorumsKeyFromEpoch(epoch))
|
||||||
if bz == nil {
|
if bz == nil {
|
||||||
return types.EpochSignerSet{}, false
|
return types.Quorums{}, false
|
||||||
}
|
}
|
||||||
var signers types.EpochSignerSet
|
var quorums types.Quorums
|
||||||
k.cdc.MustUnmarshal(bz, &signers)
|
k.cdc.MustUnmarshal(bz, &quorums)
|
||||||
return signers, true
|
return quorums, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) SetEpochSignerSet(ctx sdk.Context, epoch uint64, signers types.EpochSignerSet) {
|
func (k Keeper) SetEpochQuorums(ctx sdk.Context, epoch uint64, quorums types.Quorums) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochSignerSetKeyPrefix)
|
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix)
|
||||||
bz := k.cdc.MustMarshal(&signers)
|
bz := k.cdc.MustMarshal(&quorums)
|
||||||
store.Set(types.GetEpochSignerSetKeyFromEpoch(epoch), bz)
|
store.Set(types.GetEpochQuorumsKeyFromEpoch(epoch), bz)
|
||||||
|
k.SetQuorumCount(ctx, epoch, uint64(len(quorums.Quorums)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) GetRegistration(ctx sdk.Context, epoch uint64, account string) ([]byte, bool, error) {
|
func (k Keeper) GetRegistration(ctx sdk.Context, epoch uint64, account string) ([]byte, bool, error) {
|
||||||
|
@ -70,22 +70,22 @@ func (m *Signer) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_Signer proto.InternalMessageInfo
|
var xxx_messageInfo_Signer proto.InternalMessageInfo
|
||||||
|
|
||||||
type EpochSignerSet struct {
|
type Quorum struct {
|
||||||
Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"`
|
Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *EpochSignerSet) Reset() { *m = EpochSignerSet{} }
|
func (m *Quorum) Reset() { *m = Quorum{} }
|
||||||
func (m *EpochSignerSet) String() string { return proto.CompactTextString(m) }
|
func (m *Quorum) String() string { return proto.CompactTextString(m) }
|
||||||
func (*EpochSignerSet) ProtoMessage() {}
|
func (*Quorum) ProtoMessage() {}
|
||||||
func (*EpochSignerSet) Descriptor() ([]byte, []int) {
|
func (*Quorum) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_b7328dc8ffac059e, []int{1}
|
return fileDescriptor_b7328dc8ffac059e, []int{1}
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) XXX_Unmarshal(b []byte) error {
|
func (m *Quorum) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *Quorum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
if deterministic {
|
if deterministic {
|
||||||
return xxx_messageInfo_EpochSignerSet.Marshal(b, m, deterministic)
|
return xxx_messageInfo_Quorum.Marshal(b, m, deterministic)
|
||||||
} else {
|
} else {
|
||||||
b = b[:cap(b)]
|
b = b[:cap(b)]
|
||||||
n, err := m.MarshalToSizedBuffer(b)
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
@ -95,45 +95,85 @@ func (m *EpochSignerSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro
|
|||||||
return b[:n], nil
|
return b[:n], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) XXX_Merge(src proto.Message) {
|
func (m *Quorum) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_EpochSignerSet.Merge(m, src)
|
xxx_messageInfo_Quorum.Merge(m, src)
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) XXX_Size() int {
|
func (m *Quorum) XXX_Size() int {
|
||||||
return m.Size()
|
return m.Size()
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) XXX_DiscardUnknown() {
|
func (m *Quorum) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_EpochSignerSet.DiscardUnknown(m)
|
xxx_messageInfo_Quorum.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_EpochSignerSet proto.InternalMessageInfo
|
var xxx_messageInfo_Quorum proto.InternalMessageInfo
|
||||||
|
|
||||||
|
type Quorums struct {
|
||||||
|
Quorums []*Quorum `protobuf:"bytes,1,rep,name=quorums,proto3" json:"quorums,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Quorums) Reset() { *m = Quorums{} }
|
||||||
|
func (m *Quorums) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Quorums) ProtoMessage() {}
|
||||||
|
func (*Quorums) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_b7328dc8ffac059e, []int{2}
|
||||||
|
}
|
||||||
|
func (m *Quorums) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *Quorums) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_Quorums.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *Quorums) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Quorums.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Quorums) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *Quorums) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Quorums.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Quorums proto.InternalMessageInfo
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Signer)(nil), "zgc.dasigners.v1.Signer")
|
proto.RegisterType((*Signer)(nil), "zgc.dasigners.v1.Signer")
|
||||||
proto.RegisterType((*EpochSignerSet)(nil), "zgc.dasigners.v1.EpochSignerSet")
|
proto.RegisterType((*Quorum)(nil), "zgc.dasigners.v1.Quorum")
|
||||||
|
proto.RegisterType((*Quorums)(nil), "zgc.dasigners.v1.Quorums")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("zgc/dasigners/v1/dasigners.proto", fileDescriptor_b7328dc8ffac059e) }
|
func init() { proto.RegisterFile("zgc/dasigners/v1/dasigners.proto", fileDescriptor_b7328dc8ffac059e) }
|
||||||
|
|
||||||
var fileDescriptor_b7328dc8ffac059e = []byte{
|
var fileDescriptor_b7328dc8ffac059e = []byte{
|
||||||
// 287 bytes of a gzipped FileDescriptorProto
|
// 309 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xc1, 0x4a, 0xc3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xb1, 0x6e, 0xea, 0x30,
|
||||||
0x1c, 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27, 0x6f, 0xc5, 0x88, 0x17, 0x25, 0xfb, 0x38, 0xfe, 0x2f, 0xbd,
|
||||||
|
0x98, 0xe5, 0x2a, 0xf3, 0xed, 0xb9, 0xee, 0x7e, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x80, 0xdc,
|
||||||
|
0x60, 0xd0, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Signer) Marshal() (dAtA []byte, err error) {
|
func (m *Signer) Marshal() (dAtA []byte, err error) {
|
||||||
@ -187,7 +227,7 @@ func (m *Signer) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *EpochSignerSet) Marshal() (dAtA []byte, err error) {
|
func (m *Quorum) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
@ -197,12 +237,12 @@ func (m *EpochSignerSet) Marshal() (dAtA []byte, err error) {
|
|||||||
return dAtA[:n], nil
|
return dAtA[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *EpochSignerSet) MarshalTo(dAtA []byte) (int, error) {
|
func (m *Quorum) MarshalTo(dAtA []byte) (int, error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *EpochSignerSet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
func (m *Quorum) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i := len(dAtA)
|
i := len(dAtA)
|
||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
@ -219,6 +259,43 @@ func (m *EpochSignerSet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Quorums) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Quorums) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Quorums) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Quorums) > 0 {
|
||||||
|
for iNdEx := len(m.Quorums) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
|
{
|
||||||
|
size, err := m.Quorums[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintDasigners(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func encodeVarintDasigners(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintDasigners(dAtA []byte, offset int, v uint64) int {
|
||||||
offset -= sovDasigners(v)
|
offset -= sovDasigners(v)
|
||||||
base := offset
|
base := offset
|
||||||
@ -255,7 +332,7 @@ func (m *Signer) Size() (n int) {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *EpochSignerSet) Size() (n int) {
|
func (m *Quorum) Size() (n int) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -270,6 +347,21 @@ func (m *EpochSignerSet) Size() (n int) {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Quorums) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Quorums) > 0 {
|
||||||
|
for _, e := range m.Quorums {
|
||||||
|
l = e.Size()
|
||||||
|
n += 1 + l + sovDasigners(uint64(l))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func sovDasigners(x uint64) (n int) {
|
func sovDasigners(x uint64) (n int) {
|
||||||
return (math_bits.Len64(x|1) + 6) / 7
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
}
|
}
|
||||||
@ -458,7 +550,7 @@ func (m *Signer) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (m *EpochSignerSet) Unmarshal(dAtA []byte) error {
|
func (m *Quorum) Unmarshal(dAtA []byte) error {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
for iNdEx < l {
|
for iNdEx < l {
|
||||||
@ -481,10 +573,10 @@ func (m *EpochSignerSet) Unmarshal(dAtA []byte) error {
|
|||||||
fieldNum := int32(wire >> 3)
|
fieldNum := int32(wire >> 3)
|
||||||
wireType := int(wire & 0x7)
|
wireType := int(wire & 0x7)
|
||||||
if wireType == 4 {
|
if wireType == 4 {
|
||||||
return fmt.Errorf("proto: EpochSignerSet: wiretype end group for non-group")
|
return fmt.Errorf("proto: Quorum: wiretype end group for non-group")
|
||||||
}
|
}
|
||||||
if fieldNum <= 0 {
|
if fieldNum <= 0 {
|
||||||
return fmt.Errorf("proto: EpochSignerSet: illegal tag %d (wire type %d)", fieldNum, wire)
|
return fmt.Errorf("proto: Quorum: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
@ -540,6 +632,90 @@ func (m *EpochSignerSet) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (m *Quorums) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDasigners
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: Quorums: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: Quorums: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Quorums", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDasigners
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthDasigners
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthDasigners
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Quorums = append(m.Quorums, &Quorum{})
|
||||||
|
if err := m.Quorums[len(m.Quorums)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipDasigners(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthDasigners
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func skipDasigners(dAtA []byte) (n int, err error) {
|
func skipDasigners(dAtA []byte) (n int, err error) {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
|
@ -3,10 +3,11 @@ package types
|
|||||||
import errorsmod "cosmossdk.io/errors"
|
import errorsmod "cosmossdk.io/errors"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrSignerExists = errorsmod.Register(ModuleName, 1, "signer exists")
|
ErrSignerExists = errorsmod.Register(ModuleName, 1, "signer exists")
|
||||||
ErrEpochNumberNotSet = errorsmod.Register(ModuleName, 2, "epoch number not set")
|
ErrEpochNumberNotSet = errorsmod.Register(ModuleName, 2, "epoch number not set")
|
||||||
ErrSignerNotFound = errorsmod.Register(ModuleName, 3, "signer not found")
|
ErrSignerNotFound = errorsmod.Register(ModuleName, 3, "signer not found")
|
||||||
ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature")
|
ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature")
|
||||||
ErrEpochSignerSetNotFound = errorsmod.Register(ModuleName, 5, "signer set for epoch not found")
|
ErrQuorumNotFound = errorsmod.Register(ModuleName, 5, "quorum for epoch not found")
|
||||||
ErrSignerLengthNotMatch = errorsmod.Register(ModuleName, 6, "signer set length not match")
|
ErrQuorumIdOutOfBound = errorsmod.Register(ModuleName, 6, "quorum id out of bound")
|
||||||
|
ErrQuorumBitmapLengthMismatch = errorsmod.Register(ModuleName, 6, "quorum bitmap length mismatch")
|
||||||
)
|
)
|
||||||
|
@ -3,23 +3,23 @@ package types
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// NewGenesisState returns a new genesis state object for the module.
|
// NewGenesisState returns a new genesis state object for the module.
|
||||||
func NewGenesisState(params Params, epoch uint64, signers []*Signer, signersByEpoch []*EpochSignerSet) *GenesisState {
|
func NewGenesisState(params Params, epoch uint64, signers []*Signer, quorumsByEpoch []*Quorums) *GenesisState {
|
||||||
return &GenesisState{
|
return &GenesisState{
|
||||||
Params: params,
|
Params: params,
|
||||||
EpochNumber: epoch,
|
EpochNumber: epoch,
|
||||||
Signers: signers,
|
Signers: signers,
|
||||||
SignersByEpoch: signersByEpoch,
|
QuorumsByEpoch: quorumsByEpoch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultGenesisState returns the default genesis state for the module.
|
// DefaultGenesisState returns the default genesis state for the module.
|
||||||
func DefaultGenesisState() *GenesisState {
|
func DefaultGenesisState() *GenesisState {
|
||||||
return NewGenesisState(Params{
|
return NewGenesisState(Params{
|
||||||
QuorumSize: 1024,
|
|
||||||
TokensPerVote: "100",
|
TokensPerVote: "100",
|
||||||
MaxVotes: 100,
|
MaxVotes: 100,
|
||||||
EpochBlocks: 1000,
|
EpochBlocks: 1000,
|
||||||
}, 0, make([]*Signer, 0), make([]*EpochSignerSet, 0))
|
EncodedSlices: 3072,
|
||||||
|
}, 0, make([]*Signer, 0), make([]*Quorums, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs basic validation of genesis data.
|
// Validate performs basic validation of genesis data.
|
||||||
@ -31,16 +31,18 @@ func (gs GenesisState) Validate() error {
|
|||||||
}
|
}
|
||||||
registered[signer.Account] = struct{}{}
|
registered[signer.Account] = struct{}{}
|
||||||
}
|
}
|
||||||
if len(gs.SignersByEpoch) != int(gs.EpochNumber) {
|
if len(gs.QuorumsByEpoch) != int(gs.EpochNumber) {
|
||||||
return fmt.Errorf("epoch history missing")
|
return fmt.Errorf("epoch history missing")
|
||||||
}
|
}
|
||||||
for _, signers := range gs.SignersByEpoch {
|
for _, quorums := range gs.QuorumsByEpoch {
|
||||||
for _, signer := range signers.Signers {
|
for _, quorum := range quorums.Quorums {
|
||||||
if err := ValidateHexAddress(signer); err != nil {
|
for _, signer := range quorum.Signers {
|
||||||
return err
|
if err := ValidateHexAddress(signer); err != nil {
|
||||||
}
|
return err
|
||||||
if _, ok := registered[signer]; !ok {
|
}
|
||||||
return fmt.Errorf("historical signer detail missing")
|
if _, ok := registered[signer]; !ok {
|
||||||
|
return fmt.Errorf("historical signer detail missing")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ var _ = math.Inf
|
|||||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
type Params struct {
|
type Params struct {
|
||||||
QuorumSize uint64 `protobuf:"varint,1,opt,name=quorum_size,json=quorumSize,proto3" json:"quorum_size,omitempty"`
|
TokensPerVote string `protobuf:"bytes,1,opt,name=tokens_per_vote,json=tokensPerVote,proto3" json:"tokens_per_vote,omitempty"`
|
||||||
TokensPerVote string `protobuf:"bytes,2,opt,name=tokens_per_vote,json=tokensPerVote,proto3" json:"tokens_per_vote,omitempty"`
|
MaxVotes uint64 `protobuf:"varint,2,opt,name=max_votes,json=maxVotes,proto3" json:"max_votes,omitempty"`
|
||||||
MaxVotes uint64 `protobuf:"varint,3,opt,name=max_votes,json=maxVotes,proto3" json:"max_votes,omitempty"`
|
EpochBlocks uint64 `protobuf:"varint,3,opt,name=epoch_blocks,json=epochBlocks,proto3" json:"epoch_blocks,omitempty"`
|
||||||
EpochBlocks uint64 `protobuf:"varint,4,opt,name=epoch_blocks,json=epochBlocks,proto3" json:"epoch_blocks,omitempty"`
|
EncodedSlices uint64 `protobuf:"varint,4,opt,name=encoded_slices,json=encodedSlices,proto3" json:"encoded_slices,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Reset() { *m = Params{} }
|
func (m *Params) Reset() { *m = Params{} }
|
||||||
@ -66,13 +66,6 @@ func (m *Params) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_Params proto.InternalMessageInfo
|
var xxx_messageInfo_Params proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *Params) GetQuorumSize() uint64 {
|
|
||||||
if m != nil {
|
|
||||||
return m.QuorumSize
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Params) GetTokensPerVote() string {
|
func (m *Params) GetTokensPerVote() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.TokensPerVote
|
return m.TokensPerVote
|
||||||
@ -94,6 +87,13 @@ func (m *Params) GetEpochBlocks() uint64 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Params) GetEncodedSlices() uint64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.EncodedSlices
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// GenesisState defines the dasigners module's genesis state.
|
// GenesisState defines the dasigners module's genesis state.
|
||||||
type GenesisState struct {
|
type GenesisState struct {
|
||||||
// params defines all the parameters of related to deposit.
|
// params defines all the parameters of related to deposit.
|
||||||
@ -102,8 +102,8 @@ type GenesisState struct {
|
|||||||
EpochNumber uint64 `protobuf:"varint,2,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"`
|
EpochNumber uint64 `protobuf:"varint,2,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"`
|
||||||
// signers defines all signers information
|
// signers defines all signers information
|
||||||
Signers []*Signer `protobuf:"bytes,3,rep,name=signers,proto3" json:"signers,omitempty"`
|
Signers []*Signer `protobuf:"bytes,3,rep,name=signers,proto3" json:"signers,omitempty"`
|
||||||
// signers_by_epoch defines chosen signers by epoch
|
// quorums_by_epoch defines chosen quorums by epoch
|
||||||
SignersByEpoch []*EpochSignerSet `protobuf:"bytes,4,rep,name=signers_by_epoch,json=signersByEpoch,proto3" json:"signers_by_epoch,omitempty"`
|
QuorumsByEpoch []*Quorums `protobuf:"bytes,4,rep,name=quorums_by_epoch,json=quorumsByEpoch,proto3" json:"quorums_by_epoch,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||||
@ -160,9 +160,9 @@ func (m *GenesisState) GetSigners() []*Signer {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GenesisState) GetSignersByEpoch() []*EpochSignerSet {
|
func (m *GenesisState) GetQuorumsByEpoch() []*Quorums {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.SignersByEpoch
|
return m.QuorumsByEpoch
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -175,33 +175,34 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("zgc/dasigners/v1/genesis.proto", fileDescriptor_896efa766aaca3be) }
|
func init() { proto.RegisterFile("zgc/dasigners/v1/genesis.proto", fileDescriptor_896efa766aaca3be) }
|
||||||
|
|
||||||
var fileDescriptor_896efa766aaca3be = []byte{
|
var fileDescriptor_896efa766aaca3be = []byte{
|
||||||
// 415 bytes of a gzipped FileDescriptorProto
|
// 417 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x6e, 0xd3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x6e, 0xd3, 0x40,
|
||||||
0x1c, 0xc6, 0x6b, 0x1a, 0x15, 0xe6, 0x0e, 0x98, 0x2c, 0x0e, 0xd9, 0x90, 0xd2, 0xb0, 0x03, 0xda,
|
0x10, 0xc6, 0x63, 0x12, 0x05, 0xba, 0xfd, 0x43, 0x65, 0x71, 0x70, 0x8a, 0xe4, 0x86, 0x4a, 0xa0,
|
||||||
0x85, 0x78, 0x1b, 0x12, 0x0f, 0x10, 0x09, 0x21, 0x38, 0xa0, 0x29, 0x91, 0x38, 0x70, 0x89, 0x9c,
|
0x5e, 0xf0, 0xb6, 0x45, 0xe2, 0x01, 0x82, 0x10, 0xe2, 0x82, 0x8a, 0x23, 0x71, 0xe0, 0x62, 0xad,
|
||||||
0xf0, 0xc7, 0x8d, 0x56, 0xc7, 0x21, 0x76, 0xaa, 0x26, 0x4f, 0x01, 0x6f, 0xb5, 0xe3, 0x8e, 0x9c,
|
0x37, 0xc3, 0xc6, 0x6a, 0xd6, 0x63, 0x3c, 0xeb, 0x28, 0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09, 0x1c, 0x6e, 0x93, 0x02, 0x00,
|
||||||
|
0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||||
@ -224,27 +225,27 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
|
if m.EncodedSlices != 0 {
|
||||||
|
i = encodeVarintGenesis(dAtA, i, uint64(m.EncodedSlices))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x20
|
||||||
|
}
|
||||||
if m.EpochBlocks != 0 {
|
if m.EpochBlocks != 0 {
|
||||||
i = encodeVarintGenesis(dAtA, i, uint64(m.EpochBlocks))
|
i = encodeVarintGenesis(dAtA, i, uint64(m.EpochBlocks))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x20
|
dAtA[i] = 0x18
|
||||||
}
|
}
|
||||||
if m.MaxVotes != 0 {
|
if m.MaxVotes != 0 {
|
||||||
i = encodeVarintGenesis(dAtA, i, uint64(m.MaxVotes))
|
i = encodeVarintGenesis(dAtA, i, uint64(m.MaxVotes))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x18
|
dAtA[i] = 0x10
|
||||||
}
|
}
|
||||||
if len(m.TokensPerVote) > 0 {
|
if len(m.TokensPerVote) > 0 {
|
||||||
i -= len(m.TokensPerVote)
|
i -= len(m.TokensPerVote)
|
||||||
copy(dAtA[i:], m.TokensPerVote)
|
copy(dAtA[i:], m.TokensPerVote)
|
||||||
i = encodeVarintGenesis(dAtA, i, uint64(len(m.TokensPerVote)))
|
i = encodeVarintGenesis(dAtA, i, uint64(len(m.TokensPerVote)))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0xa
|
||||||
}
|
|
||||||
if m.QuorumSize != 0 {
|
|
||||||
i = encodeVarintGenesis(dAtA, i, uint64(m.QuorumSize))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
}
|
}
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
@ -269,10 +270,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if len(m.SignersByEpoch) > 0 {
|
if len(m.QuorumsByEpoch) > 0 {
|
||||||
for iNdEx := len(m.SignersByEpoch) - 1; iNdEx >= 0; iNdEx-- {
|
for iNdEx := len(m.QuorumsByEpoch) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
{
|
{
|
||||||
size, err := m.SignersByEpoch[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
size, err := m.QuorumsByEpoch[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -332,9 +333,6 @@ func (m *Params) Size() (n int) {
|
|||||||
}
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if m.QuorumSize != 0 {
|
|
||||||
n += 1 + sovGenesis(uint64(m.QuorumSize))
|
|
||||||
}
|
|
||||||
l = len(m.TokensPerVote)
|
l = len(m.TokensPerVote)
|
||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovGenesis(uint64(l))
|
n += 1 + l + sovGenesis(uint64(l))
|
||||||
@ -345,6 +343,9 @@ func (m *Params) Size() (n int) {
|
|||||||
if m.EpochBlocks != 0 {
|
if m.EpochBlocks != 0 {
|
||||||
n += 1 + sovGenesis(uint64(m.EpochBlocks))
|
n += 1 + sovGenesis(uint64(m.EpochBlocks))
|
||||||
}
|
}
|
||||||
|
if m.EncodedSlices != 0 {
|
||||||
|
n += 1 + sovGenesis(uint64(m.EncodedSlices))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,8 +366,8 @@ func (m *GenesisState) Size() (n int) {
|
|||||||
n += 1 + l + sovGenesis(uint64(l))
|
n += 1 + l + sovGenesis(uint64(l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(m.SignersByEpoch) > 0 {
|
if len(m.QuorumsByEpoch) > 0 {
|
||||||
for _, e := range m.SignersByEpoch {
|
for _, e := range m.QuorumsByEpoch {
|
||||||
l = e.Size()
|
l = e.Size()
|
||||||
n += 1 + l + sovGenesis(uint64(l))
|
n += 1 + l + sovGenesis(uint64(l))
|
||||||
}
|
}
|
||||||
@ -410,25 +411,6 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field QuorumSize", wireType)
|
|
||||||
}
|
|
||||||
m.QuorumSize = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenesis
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.QuorumSize |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field TokensPerVote", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field TokensPerVote", wireType)
|
||||||
}
|
}
|
||||||
@ -460,7 +442,7 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.TokensPerVote = string(dAtA[iNdEx:postIndex])
|
m.TokensPerVote = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 3:
|
case 2:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field MaxVotes", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field MaxVotes", wireType)
|
||||||
}
|
}
|
||||||
@ -479,7 +461,7 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 4:
|
case 3:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field EpochBlocks", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field EpochBlocks", wireType)
|
||||||
}
|
}
|
||||||
@ -498,6 +480,25 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 4:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field EncodedSlices", wireType)
|
||||||
|
}
|
||||||
|
m.EncodedSlices = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowGenesis
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.EncodedSlices |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipGenesis(dAtA[iNdEx:])
|
skippy, err := skipGenesis(dAtA[iNdEx:])
|
||||||
@ -636,7 +637,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 4:
|
case 4:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field SignersByEpoch", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field QuorumsByEpoch", wireType)
|
||||||
}
|
}
|
||||||
var msglen int
|
var msglen int
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -663,8 +664,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||||||
if postIndex > l {
|
if postIndex > l {
|
||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
m.SignersByEpoch = append(m.SignersByEpoch, &EpochSignerSet{})
|
m.QuorumsByEpoch = append(m.QuorumsByEpoch, &Quorums{})
|
||||||
if err := m.SignersByEpoch[len(m.SignersByEpoch)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
if err := m.QuorumsByEpoch[len(m.QuorumsByEpoch)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
@ -19,9 +19,10 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// prefix
|
// prefix
|
||||||
SignerKeyPrefix = []byte{0x00}
|
SignerKeyPrefix = []byte{0x00}
|
||||||
EpochSignerSetKeyPrefix = []byte{0x01}
|
EpochQuorumsKeyPrefix = []byte{0x01}
|
||||||
RegistrationKeyPrefix = []byte{0x02}
|
RegistrationKeyPrefix = []byte{0x02}
|
||||||
|
QuorumCountKeyPrefix = []byte{0x03}
|
||||||
|
|
||||||
// keys
|
// keys
|
||||||
ParamsKey = []byte{0x05}
|
ParamsKey = []byte{0x05}
|
||||||
@ -32,7 +33,11 @@ func GetSignerKeyFromAccount(account string) ([]byte, error) {
|
|||||||
return hex.DecodeString(account)
|
return hex.DecodeString(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEpochSignerSetKeyFromEpoch(epoch uint64) []byte {
|
func GetEpochQuorumsKeyFromEpoch(epoch uint64) []byte {
|
||||||
|
return sdk.Uint64ToBigEndian(epoch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetQuorumCountKey(epoch uint64) []byte {
|
||||||
return sdk.Uint64ToBigEndian(epoch)
|
return sdk.Uint64ToBigEndian(epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -52,37 +52,73 @@ func local_request_Query_EpochNumber_0(ctx context.Context, marshaler runtime.Ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
filter_Query_EpochSignerSet_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
filter_Query_QuorumCount_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
)
|
)
|
||||||
|
|
||||||
func request_Query_EpochSignerSet_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_Query_QuorumCount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq QueryEpochSignerSetRequest
|
var protoReq QueryQuorumCountRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EpochSignerSet_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuorumCount_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := client.EpochSignerSet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.QuorumCount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_Query_EpochSignerSet_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_Query_QuorumCount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq QueryEpochSignerSetRequest
|
var protoReq QueryQuorumCountRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EpochSignerSet_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuorumCount_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := server.EpochSignerSet(ctx, &protoReq)
|
msg, err := server.QuorumCount(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_Query_EpochQuorum_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
)
|
||||||
|
|
||||||
|
func request_Query_EpochQuorum_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryEpochQuorumRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EpochQuorum_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.EpochQuorum(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_Query_EpochQuorum_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryEpochQuorumRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_EpochQuorum_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.EpochQuorum(ctx, &protoReq)
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -188,7 +224,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("GET", pattern_Query_EpochSignerSet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("GET", pattern_Query_QuorumCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var stream runtime.ServerTransportStream
|
var stream runtime.ServerTransportStream
|
||||||
@ -199,7 +235,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_Query_EpochSignerSet_0(rctx, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_Query_QuorumCount_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -207,7 +243,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_Query_EpochSignerSet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_Query_QuorumCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_EpochQuorum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_Query_EpochQuorum_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_EpochQuorum_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -318,7 +377,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.Handle("GET", pattern_Query_EpochSignerSet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle("GET", pattern_Query_QuorumCount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
@ -327,14 +386,34 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_Query_EpochSignerSet_0(rctx, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_Query_QuorumCount_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_Query_EpochSignerSet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_Query_QuorumCount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_EpochQuorum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_Query_EpochQuorum_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_EpochQuorum_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -384,7 +463,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||||||
var (
|
var (
|
||||||
pattern_Query_EpochNumber_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-number"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_EpochNumber_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-number"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
pattern_Query_EpochSignerSet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-signer-set"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_QuorumCount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "quorum-count"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
|
pattern_Query_EpochQuorum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "epoch-quorum"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
pattern_Query_AggregatePubkeyG1_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "aggregate-pubkey-g1"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_AggregatePubkeyG1_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "aggregate-pubkey-g1"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
@ -394,7 +475,9 @@ var (
|
|||||||
var (
|
var (
|
||||||
forward_Query_EpochNumber_0 = runtime.ForwardResponseMessage
|
forward_Query_EpochNumber_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_Query_EpochSignerSet_0 = runtime.ForwardResponseMessage
|
forward_Query_QuorumCount_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_Query_EpochQuorum_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_Query_AggregatePubkeyG1_0 = runtime.ForwardResponseMessage
|
forward_Query_AggregatePubkeyG1_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user