From e4989f10cd52de1bcd00de2e8a28c59d9bf232ec Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Thu, 16 May 2024 22:49:29 +0800 Subject: [PATCH] feat: quorum --- precompiles/dasigners/IDASigners.abi | 101 ++-- precompiles/dasigners/contract.go | 127 +++-- precompiles/dasigners/dasigners.go | 11 +- precompiles/dasigners/query.go | 28 +- precompiles/dasigners/types.go | 46 +- proto/zgc/dasigners/v1/dasigners.proto | 6 +- proto/zgc/dasigners/v1/genesis.proto | 12 +- proto/zgc/dasigners/v1/query.proto | 29 +- x/dasigners/v1/genesis.go | 14 +- x/dasigners/v1/keeper/abci.go | 31 +- x/dasigners/v1/keeper/grpc_query.go | 78 +-- x/dasigners/v1/keeper/keeper.go | 37 +- x/dasigners/v1/types/dasigners.pb.go | 258 +++++++-- x/dasigners/v1/types/errors.go | 13 +- x/dasigners/v1/types/genesis.go | 26 +- x/dasigners/v1/types/genesis.pb.go | 165 +++--- x/dasigners/v1/types/keys.go | 13 +- x/dasigners/v1/types/query.pb.go | 714 +++++++++++++++++++------ x/dasigners/v1/types/query.pb.gw.go | 117 +++- 19 files changed, 1300 insertions(+), 526 deletions(-) diff --git a/precompiles/dasigners/IDASigners.abi b/precompiles/dasigners/IDASigners.abi index 0bb6d20f..37631432 100644 --- a/precompiles/dasigners/IDASigners.abi +++ b/precompiles/dasigners/IDASigners.abi @@ -84,12 +84,17 @@ "inputs": [ { "internalType": "uint256", - "name": "epoch", + "name": "_epoch", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_quorumId", "type": "uint256" }, { "internalType": "bytes", - "name": "signersBitmap", + "name": "_quorumBitmap", "type": "bytes" } ], @@ -129,9 +134,33 @@ { "inputs": [ { - "internalType": "address", - "name": "account", - "type": "address" + "internalType": "uint256", + "name": "_epoch", + "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", @@ -183,9 +212,9 @@ "type": "tuple" } ], - "internalType": "struct IDASigners.SignerDetail", + "internalType": "struct IDASigners.SignerDetail[]", "name": "", - "type": "tuple" + "type": "tuple[]" } ], "stateMutability": "view", @@ -195,62 +224,16 @@ "inputs": [ { "internalType": "uint256", - "name": "epoch", + "name": "_epoch", "type": "uint256" } ], - "name": "getSigners", + "name": "quorumCount", "outputs": [ { - "components": [ - { - "internalType": "address", - "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[]" + "internalType": "uint256", + "name": "", + "type": "uint256" } ], "stateMutability": "view", @@ -361,7 +344,7 @@ "inputs": [ { "internalType": "string", - "name": "socket", + "name": "_socket", "type": "string" } ], diff --git a/precompiles/dasigners/contract.go b/precompiles/dasigners/contract.go index 8966d62f..566fefda 100644 --- a/precompiles/dasigners/contract.go +++ b/precompiles/dasigners/contract.go @@ -30,7 +30,7 @@ var ( // DASignersMetaData contains all meta data concerning the DASigners contract. var DASignersMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"indexed\":false,\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"name\":\"NewSigner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"}],\"name\":\"SocketUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"epochNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signersBitmap\",\"type\":\"bytes\"}],\"name\":\"getAggPkG1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"aggPkG1\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"hit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getSigner\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"internalType\":\"structIDASigners.SignerDetail\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epoch\",\"type\":\"uint256\"}],\"name\":\"getSigners\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"internalType\":\"structIDASigners.SignerDetail[]\",\"name\":\"details\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"_signature\",\"type\":\"tuple\"}],\"name\":\"registerNextEpoch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"internalType\":\"structIDASigners.SignerDetail\",\"name\":\"_signer\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"_signature\",\"type\":\"tuple\"}],\"name\":\"registerSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"}],\"name\":\"updateSocket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"indexed\":false,\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"name\":\"NewSigner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"}],\"name\":\"SocketUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"epochNumber\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_quorumId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_quorumBitmap\",\"type\":\"bytes\"}],\"name\":\"getAggPkG1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"aggPkG1\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"hit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"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\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"internalType\":\"structIDASigners.SignerDetail[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"quorumCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"_signature\",\"type\":\"tuple\"}],\"name\":\"registerNextEpoch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"socket\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"pkG1\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"X\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"Y\",\"type\":\"uint256[2]\"}],\"internalType\":\"structBN254.G2Point\",\"name\":\"pkG2\",\"type\":\"tuple\"}],\"internalType\":\"structIDASigners.SignerDetail\",\"name\":\"_signer\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"X\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"Y\",\"type\":\"uint256\"}],\"internalType\":\"structBN254.G1Point\",\"name\":\"_signature\",\"type\":\"tuple\"}],\"name\":\"registerSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_socket\",\"type\":\"string\"}],\"name\":\"updateSocket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // DASignersABI is the input ABI used to generate the binding from. @@ -210,16 +210,16 @@ func (_DASigners *DASignersCallerSession) EpochNumber() (*big.Int, error) { return _DASigners.Contract.EpochNumber(&_DASigners.CallOpts) } -// GetAggPkG1 is a free data retrieval call binding the contract method 0x86fafce5. +// GetAggPkG1 is a free data retrieval call binding the contract method 0x50b73739. // -// Solidity: function getAggPkG1(uint256 epoch, bytes signersBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) -func (_DASigners *DASignersCaller) GetAggPkG1(opts *bind.CallOpts, epoch *big.Int, signersBitmap []byte) (struct { +// Solidity: function getAggPkG1(uint256 _epoch, uint256 _quorumId, bytes _quorumBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) +func (_DASigners *DASignersCaller) GetAggPkG1(opts *bind.CallOpts, _epoch *big.Int, _quorumId *big.Int, _quorumBitmap []byte) (struct { AggPkG1 BN254G1Point Total *big.Int Hit *big.Int }, error) { var out []interface{} - err := _DASigners.contract.Call(opts, &out, "getAggPkG1", epoch, signersBitmap) + err := _DASigners.contract.Call(opts, &out, "getAggPkG1", _epoch, _quorumId, _quorumBitmap) outstruct := new(struct { AggPkG1 BN254G1Point @@ -238,65 +238,65 @@ func (_DASigners *DASignersCaller) GetAggPkG1(opts *bind.CallOpts, epoch *big.In } -// GetAggPkG1 is a free data retrieval call binding the contract method 0x86fafce5. +// GetAggPkG1 is a free data retrieval call binding the contract method 0x50b73739. // -// Solidity: function getAggPkG1(uint256 epoch, bytes signersBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) -func (_DASigners *DASignersSession) GetAggPkG1(epoch *big.Int, signersBitmap []byte) (struct { +// Solidity: function getAggPkG1(uint256 _epoch, uint256 _quorumId, bytes _quorumBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) +func (_DASigners *DASignersSession) GetAggPkG1(_epoch *big.Int, _quorumId *big.Int, _quorumBitmap []byte) (struct { AggPkG1 BN254G1Point Total *big.Int Hit *big.Int }, error) { - return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, epoch, signersBitmap) + return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, _epoch, _quorumId, _quorumBitmap) } -// GetAggPkG1 is a free data retrieval call binding the contract method 0x86fafce5. +// GetAggPkG1 is a free data retrieval call binding the contract method 0x50b73739. // -// Solidity: function getAggPkG1(uint256 epoch, bytes signersBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) -func (_DASigners *DASignersCallerSession) GetAggPkG1(epoch *big.Int, signersBitmap []byte) (struct { +// Solidity: function getAggPkG1(uint256 _epoch, uint256 _quorumId, bytes _quorumBitmap) view returns((uint256,uint256) aggPkG1, uint256 total, uint256 hit) +func (_DASigners *DASignersCallerSession) GetAggPkG1(_epoch *big.Int, _quorumId *big.Int, _quorumBitmap []byte) (struct { AggPkG1 BN254G1Point Total *big.Int Hit *big.Int }, error) { - return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, epoch, signersBitmap) + return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, _epoch, _quorumId, _quorumBitmap) } -// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// GetQuorum is a free data retrieval call binding the contract method 0x6ab6f654. // -// Solidity: function getSigner(address account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))) -func (_DASigners *DASignersCaller) GetSigner(opts *bind.CallOpts, account common.Address) (IDASignersSignerDetail, error) { +// Solidity: function getQuorum(uint256 _epoch, uint256 _quorumId) view returns(address[]) +func (_DASigners *DASignersCaller) GetQuorum(opts *bind.CallOpts, _epoch *big.Int, _quorumId *big.Int) ([]common.Address, error) { var out []interface{} - err := _DASigners.contract.Call(opts, &out, "getSigner", account) + err := _DASigners.contract.Call(opts, &out, "getQuorum", _epoch, _quorumId) if err != nil { - return *new(IDASignersSignerDetail), err + return *new([]common.Address), err } - out0 := *abi.ConvertType(out[0], new(IDASignersSignerDetail)).(*IDASignersSignerDetail) + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) return out0, err } -// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// GetQuorum is a free data retrieval call binding the contract method 0x6ab6f654. // -// Solidity: function getSigner(address account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))) -func (_DASigners *DASignersSession) GetSigner(account common.Address) (IDASignersSignerDetail, error) { - return _DASigners.Contract.GetSigner(&_DASigners.CallOpts, account) +// Solidity: function getQuorum(uint256 _epoch, uint256 _quorumId) view returns(address[]) +func (_DASigners *DASignersSession) GetQuorum(_epoch *big.Int, _quorumId *big.Int) ([]common.Address, error) { + return _DASigners.Contract.GetQuorum(&_DASigners.CallOpts, _epoch, _quorumId) } -// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// GetQuorum is a free data retrieval call binding the contract method 0x6ab6f654. // -// Solidity: function getSigner(address account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))) -func (_DASigners *DASignersCallerSession) GetSigner(account common.Address) (IDASignersSignerDetail, error) { - return _DASigners.Contract.GetSigner(&_DASigners.CallOpts, account) +// Solidity: function getQuorum(uint256 _epoch, uint256 _quorumId) view returns(address[]) +func (_DASigners *DASignersCallerSession) GetQuorum(_epoch *big.Int, _quorumId *big.Int) ([]common.Address, error) { + return _DASigners.Contract.GetQuorum(&_DASigners.CallOpts, _epoch, _quorumId) } -// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// GetSigner is a free data retrieval call binding the contract method 0xd1f5e5f8. // -// Solidity: function getSigners(uint256 epoch) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[] details) -func (_DASigners *DASignersCaller) GetSigners(opts *bind.CallOpts, epoch *big.Int) ([]IDASignersSignerDetail, error) { +// Solidity: function getSigner(address[] _account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[]) +func (_DASigners *DASignersCaller) GetSigner(opts *bind.CallOpts, _account []common.Address) ([]IDASignersSignerDetail, error) { var out []interface{} - err := _DASigners.contract.Call(opts, &out, "getSigners", epoch) + err := _DASigners.contract.Call(opts, &out, "getSigner", _account) if err != nil { return *new([]IDASignersSignerDetail), err @@ -308,18 +308,49 @@ func (_DASigners *DASignersCaller) GetSigners(opts *bind.CallOpts, epoch *big.In } -// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// GetSigner is a free data retrieval call binding the contract method 0xd1f5e5f8. // -// Solidity: function getSigners(uint256 epoch) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[] details) -func (_DASigners *DASignersSession) GetSigners(epoch *big.Int) ([]IDASignersSignerDetail, error) { - return _DASigners.Contract.GetSigners(&_DASigners.CallOpts, epoch) +// Solidity: function getSigner(address[] _account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[]) +func (_DASigners *DASignersSession) GetSigner(_account []common.Address) ([]IDASignersSignerDetail, error) { + return _DASigners.Contract.GetSigner(&_DASigners.CallOpts, _account) } -// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// GetSigner is a free data retrieval call binding the contract method 0xd1f5e5f8. // -// Solidity: function getSigners(uint256 epoch) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[] details) -func (_DASigners *DASignersCallerSession) GetSigners(epoch *big.Int) ([]IDASignersSignerDetail, error) { - return _DASigners.Contract.GetSigners(&_DASigners.CallOpts, epoch) +// Solidity: function getSigner(address[] _account) view returns((address,string,(uint256,uint256),(uint256[2],uint256[2]))[]) +func (_DASigners *DASignersCallerSession) GetSigner(_account []common.Address) ([]IDASignersSignerDetail, error) { + return _DASigners.Contract.GetSigner(&_DASigners.CallOpts, _account) +} + +// QuorumCount is a free data retrieval call binding the contract method 0x5ecba503. +// +// Solidity: function quorumCount(uint256 _epoch) view returns(uint256) +func (_DASigners *DASignersCaller) QuorumCount(opts *bind.CallOpts, _epoch *big.Int) (*big.Int, error) { + var out []interface{} + err := _DASigners.contract.Call(opts, &out, "quorumCount", _epoch) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// QuorumCount is a free data retrieval call binding the contract method 0x5ecba503. +// +// Solidity: function quorumCount(uint256 _epoch) view returns(uint256) +func (_DASigners *DASignersSession) QuorumCount(_epoch *big.Int) (*big.Int, error) { + return _DASigners.Contract.QuorumCount(&_DASigners.CallOpts, _epoch) +} + +// QuorumCount is a free data retrieval call binding the contract method 0x5ecba503. +// +// Solidity: function quorumCount(uint256 _epoch) view returns(uint256) +func (_DASigners *DASignersCallerSession) QuorumCount(_epoch *big.Int) (*big.Int, error) { + return _DASigners.Contract.QuorumCount(&_DASigners.CallOpts, _epoch) } // RegisterNextEpoch is a paid mutator transaction binding the contract method 0x56a32372. @@ -366,23 +397,23 @@ func (_DASigners *DASignersTransactorSession) RegisterSigner(_signer IDASignersS // UpdateSocket is a paid mutator transaction binding the contract method 0x0cf4b767. // -// Solidity: function updateSocket(string socket) returns() -func (_DASigners *DASignersTransactor) UpdateSocket(opts *bind.TransactOpts, socket string) (*types.Transaction, error) { - return _DASigners.contract.Transact(opts, "updateSocket", socket) +// Solidity: function updateSocket(string _socket) returns() +func (_DASigners *DASignersTransactor) UpdateSocket(opts *bind.TransactOpts, _socket string) (*types.Transaction, error) { + return _DASigners.contract.Transact(opts, "updateSocket", _socket) } // UpdateSocket is a paid mutator transaction binding the contract method 0x0cf4b767. // -// Solidity: function updateSocket(string socket) returns() -func (_DASigners *DASignersSession) UpdateSocket(socket string) (*types.Transaction, error) { - return _DASigners.Contract.UpdateSocket(&_DASigners.TransactOpts, socket) +// Solidity: function updateSocket(string _socket) returns() +func (_DASigners *DASignersSession) UpdateSocket(_socket string) (*types.Transaction, error) { + return _DASigners.Contract.UpdateSocket(&_DASigners.TransactOpts, _socket) } // UpdateSocket is a paid mutator transaction binding the contract method 0x0cf4b767. // -// Solidity: function updateSocket(string socket) returns() -func (_DASigners *DASignersTransactorSession) UpdateSocket(socket string) (*types.Transaction, error) { - return _DASigners.Contract.UpdateSocket(&_DASigners.TransactOpts, socket) +// Solidity: function updateSocket(string _socket) returns() +func (_DASigners *DASignersTransactorSession) UpdateSocket(_socket string) (*types.Transaction, error) { + return _DASigners.Contract.UpdateSocket(&_DASigners.TransactOpts, _socket) } // DASignersNewSignerIterator is returned from FilterNewSigner and is used to iterate over the raw logs and unpacked data for NewSigner events raised by the DASigners contract. diff --git a/precompiles/dasigners/dasigners.go b/precompiles/dasigners/dasigners.go index 61ba2a17..87816ae6 100644 --- a/precompiles/dasigners/dasigners.go +++ b/precompiles/dasigners/dasigners.go @@ -19,11 +19,12 @@ const ( RequiredGasMax uint64 = 1000_000_000 DASignersFunctionEpochNumber = "epochNumber" + DASignersFunctionQuorumCount = "quorumCount" DASignersFunctionGetSigner = "getSigner" - DASignersFunctionGetSigners = "getSigners" + DASignersFunctionGetQuorum = "getQuorum" + DASignersFunctionRegisterSigner = "registerSigner" DASignersFunctionUpdateSocket = "updateSocket" DASignersFunctionRegisterNextEpoch = "registerNextEpoch" - DASignersFunctionRegisterSigner = "registerSigner" DASignersFunctionGetAggPkG1 = "getAggPkG1" ) @@ -111,10 +112,12 @@ func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly b // queries case DASignersFunctionEpochNumber: bz, err = d.EpochNumber(ctx, evm, method, args) + case DASignersFunctionQuorumCount: + bz, err = d.QuorumCount(ctx, evm, method, args) case DASignersFunctionGetSigner: bz, err = d.GetSigner(ctx, evm, method, args) - case DASignersFunctionGetSigners: - bz, err = d.GetSigners(ctx, evm, method, args) + case DASignersFunctionGetQuorum: + bz, err = d.GetQuorum(ctx, evm, method, args) case DASignersFunctionGetAggPkG1: bz, err = d.GetAggPkG1(ctx, evm, method, args) // txs diff --git a/precompiles/dasigners/query.go b/precompiles/dasigners/query.go index 2a63aeff..b50ec1a5 100644 --- a/precompiles/dasigners/query.go +++ b/precompiles/dasigners/query.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" "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))) } +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) { req, err := NewQuerySignerRequest(args) if err != nil { @@ -25,21 +35,25 @@ func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi. if err != nil { 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) { - req, err := NewQueryEpochSignerSetRequest(args) +func (d *DASignersPrecompile) GetQuorum(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewQueryEpochQuorumRequest(args) if err != nil { return nil, err } - response, err := d.dasignersKeeper.EpochSignerSet(sdk.WrapSDKContext(ctx), req) + response, err := d.dasignersKeeper.EpochQuorum(sdk.WrapSDKContext(ctx), req) if err != nil { return nil, err } - signers := make([]IDASignersSignerDetail, 0) - for _, signer := range response.Signers { - signers = append(signers, NewIDASignersSignerDetail(signer)) + signers := make([]common.Address, len(response.Quorum.Signers)) + for i, signer := range response.Quorum.Signers { + signers[i] = common.HexToAddress(signer) } return method.Outputs.Pack(signers) } diff --git a/precompiles/dasigners/types.go b/precompiles/dasigners/types.go index 16237286..689ed256 100644 --- a/precompiles/dasigners/types.go +++ b/precompiles/dasigners/types.go @@ -63,34 +63,50 @@ func SerializeG2(p BN254G2Point) []byte { return b } -func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, error) { +func NewQueryQuorumCountRequest(args []interface{}) (*dasignerstypes.QueryQuorumCountRequest, error) { if len(args) != 1 { return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args)) } - return &dasignerstypes.QuerySignerRequest{ - 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{ + return &dasignerstypes.QueryQuorumCountRequest{ EpochNumber: args[0].(*big.Int).Uint64(), }, 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 { 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{ - EpochNumber: args[0].(*big.Int).Uint64(), - SignersBitmap: args[1].([]byte), + EpochNumber: args[0].(*big.Int).Uint64(), + QuorumId: args[1].(*big.Int).Uint64(), + QuorumBitmap: args[2].([]byte), }, nil } diff --git a/proto/zgc/dasigners/v1/dasigners.proto b/proto/zgc/dasigners/v1/dasigners.proto index 91dc6dec..ee32ed3b 100644 --- a/proto/zgc/dasigners/v1/dasigners.proto +++ b/proto/zgc/dasigners/v1/dasigners.proto @@ -20,6 +20,10 @@ message Signer { bytes pubkey_g2 = 4; } -message EpochSignerSet { +message Quorum { repeated string signers = 1; } + +message Quorums { + repeated Quorum quorums = 1; +} diff --git a/proto/zgc/dasigners/v1/genesis.proto b/proto/zgc/dasigners/v1/genesis.proto index 154cb987..41f387db 100644 --- a/proto/zgc/dasigners/v1/genesis.proto +++ b/proto/zgc/dasigners/v1/genesis.proto @@ -10,10 +10,10 @@ import "zgc/dasigners/v1/dasigners.proto"; option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types"; message Params { - uint64 quorum_size = 1; - string tokens_per_vote = 2; - uint64 max_votes = 3; - uint64 epoch_blocks = 4; + string tokens_per_vote = 1; + uint64 max_votes = 2; + uint64 epoch_blocks = 3; + uint64 encoded_slices = 4; } // GenesisState defines the dasigners module's genesis state. @@ -24,6 +24,6 @@ message GenesisState { uint64 epoch_number = 2; // signers defines all signers information repeated Signer signers = 3; - // signers_by_epoch defines chosen signers by epoch - repeated EpochSignerSet signers_by_epoch = 4; + // quorums_by_epoch defines chosen quorums by epoch + repeated Quorums quorums_by_epoch = 4; } diff --git a/proto/zgc/dasigners/v1/query.proto b/proto/zgc/dasigners/v1/query.proto index b8811d26..2ab36c4c 100644 --- a/proto/zgc/dasigners/v1/query.proto +++ b/proto/zgc/dasigners/v1/query.proto @@ -16,8 +16,11 @@ service Query { rpc EpochNumber(QueryEpochNumberRequest) returns (QueryEpochNumberResponse) { option (google.api.http).get = "/0g/dasigners/v1/epoch-number"; } - rpc EpochSignerSet(QueryEpochSignerSetRequest) returns (QueryEpochSignerSetResponse) { - option (google.api.http).get = "/0g/dasigners/v1/epoch-signer-set"; + rpc QuorumCount(QueryQuorumCountRequest) returns (QueryQuorumCountResponse) { + 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) { option (google.api.http).get = "/0g/dasigners/v1/aggregate-pubkey-g1"; @@ -28,11 +31,11 @@ service Query { } message QuerySignerRequest { - string account = 1; + repeated string accounts = 1; } message QuerySignerResponse { - Signer signer = 1; + repeated Signer signer = 1; } message QueryEpochNumberRequest {} @@ -41,17 +44,27 @@ message QueryEpochNumberResponse { uint64 epoch_number = 1; } -message QueryEpochSignerSetRequest { +message QueryQuorumCountRequest { uint64 epoch_number = 1; } -message QueryEpochSignerSetResponse { - repeated Signer signers = 1; +message QueryQuorumCountResponse { + uint64 quorum_count = 1; +} + +message QueryEpochQuorumRequest { + uint64 epoch_number = 1; + uint64 quorum_id = 2; +} + +message QueryEpochQuorumResponse { + Quorum quorum = 1; } message QueryAggregatePubkeyG1Request { uint64 epoch_number = 1; - bytes signersBitmap = 2; + uint64 quorum_id = 2; + bytes quorum_bitmap = 3; } message QueryAggregatePubkeyG1Response { diff --git a/x/dasigners/v1/genesis.go b/x/dasigners/v1/genesis.go index 64354d00..71a0339c 100644 --- a/x/dasigners/v1/genesis.go +++ b/x/dasigners/v1/genesis.go @@ -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)) } } - for epoch, signers := range gs.SignersByEpoch { - keeper.SetEpochSignerSet(ctx, uint64(epoch), *signers) + for epoch, quorums := range gs.QuorumsByEpoch { + keeper.SetEpochQuorums(ctx, uint64(epoch), *quorums) } keeper.SetParams(ctx, gs.Params) } @@ -38,13 +38,13 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { signers = append(signers, &signer) return false }) - epochSignerSets := make([]*types.EpochSignerSet, 0) + epochQuorums := make([]*types.Quorums, 0) for i := 0; i < int(epochNumber); i += 1 { - epochSignerSet, found := keeper.GetEpochSignerSet(ctx, uint64(i)) + quorums, found := keeper.GetEpochQuorums(ctx, uint64(i)) 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) } diff --git a/x/dasigners/v1/keeper/abci.go b/x/dasigners/v1/keeper/abci.go index bff45f85..cc509269 100644 --- a/x/dasigners/v1/keeper/abci.go +++ b/x/dasigners/v1/keeper/abci.go @@ -72,17 +72,32 @@ func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sort.Slice(ballots, func(i, j int) bool { return bytes.Compare(ballots[i].content, ballots[j].content) < 0 }) - chosen := make(map[string]struct{}) - epochSignerSet := types.EpochSignerSet{ - Signers: make([]string, 0), + + quorums := types.Quorums{ + Quorums: make([]*types.Quorum, 0), } - for _, ballot := range ballots { - if _, ok := chosen[ballot.account]; !ok { - chosen[ballot.account] = struct{}{} - epochSignerSet.Signers = append(epochSignerSet.Signers, ballot.account) + if len(ballots) >= int(params.EncodedSlices) { + for i := 0; i+int(params.EncodedSlices) < len(ballots); i += 1 { + quorum := types.Quorum{ + 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 - k.SetEpochSignerSet(ctx, expectedEpoch, epochSignerSet) + k.SetEpochQuorums(ctx, expectedEpoch, quorums) k.SetEpochNumber(ctx, expectedEpoch) } diff --git a/x/dasigners/v1/keeper/grpc_query.go b/x/dasigners/v1/keeper/grpc_query.go index 4dc1c749..484d970c 100644 --- a/x/dasigners/v1/keeper/grpc_query.go +++ b/x/dasigners/v1/keeper/grpc_query.go @@ -13,17 +13,22 @@ var _ types.QueryServer = Keeper{} func (k Keeper) Signer( c context.Context, - req *types.QuerySignerRequest, + request *types.QuerySignerRequest, ) (*types.QuerySignerResponse, error) { ctx := sdk.UnwrapSDKContext(c) - signer, found, err := k.GetSigner(ctx, req.Account) - if err != nil { - return nil, err + n := len(request.Accounts) + response := types.QuerySignerResponse{Signer: make([]*types.Signer, n)} + 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 nil, nil - } - return &types.QuerySignerResponse{Signer: &signer}, nil + return &response, nil } func (k Keeper) EpochNumber( @@ -38,43 +43,56 @@ func (k Keeper) EpochNumber( 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) - 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 { - return nil, types.ErrEpochSignerSetNotFound + return nil, types.ErrQuorumNotFound } - epochSignerSet := make([]*types.Signer, len(signers.Signers)) - for _, account := range signers.Signers { - signer, found, err := k.GetSigner(ctx, account) - if err != nil { - return nil, err - } - if !found { - return nil, types.ErrSignerNotFound - } - epochSignerSet = append(epochSignerSet, &signer) + if len(quorums.Quorums) <= int(request.QuorumId) { + return nil, types.ErrQuorumIdOutOfBound } - 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) { ctx := sdk.UnwrapSDKContext(c) - signers, found := k.GetEpochSignerSet(ctx, request.EpochNumber) + quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber) if !found { - return nil, types.ErrEpochSignerSetNotFound + return nil, types.ErrQuorumNotFound } - if len(request.SignersBitmap) != (len(signers.Signers)+7)/8 { - return nil, types.ErrSignerLengthNotMatch + if len(quorums.Quorums) <= int(request.QuorumId) { + 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) hit := 0 - for i, account := range signers.Signers { - b := request.SignersBitmap[i/8] & (1 << (i % 8)) + added := make(map[string]struct{}) + for i, signer := range quorum.Signers { + b := request.QuorumBitmap[i/8] & (1 << (i % 8)) if b == 0 { 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 { return nil, err } @@ -86,7 +104,7 @@ func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggrega } return &types.QueryAggregatePubkeyG1Response{ AggregatePubkeyG1: bn254util.SerializeG1(aggPubkeyG1), - Total: uint64(len(signers.Signers)), + Total: uint64(len(quorum.Signers)), Hit: uint64(hit), }, nil } diff --git a/x/dasigners/v1/keeper/keeper.go b/x/dasigners/v1/keeper/keeper.go index 44d437e5..6d4de856 100644 --- a/x/dasigners/v1/keeper/keeper.go +++ b/x/dasigners/v1/keeper/keeper.go @@ -64,6 +64,20 @@ func (k Keeper) SetEpochNumber(ctx sdk.Context, epoch uint64) { 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) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix) 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) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochSignerSetKeyPrefix) - bz := store.Get(types.GetEpochSignerSetKeyFromEpoch(epoch)) +func (k Keeper) GetEpochQuorums(ctx sdk.Context, epoch uint64) (types.Quorums, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix) + bz := store.Get(types.GetEpochQuorumsKeyFromEpoch(epoch)) if bz == nil { - return types.EpochSignerSet{}, false + return types.Quorums{}, false } - var signers types.EpochSignerSet - k.cdc.MustUnmarshal(bz, &signers) - return signers, true + var quorums types.Quorums + k.cdc.MustUnmarshal(bz, &quorums) + return quorums, true } -func (k Keeper) SetEpochSignerSet(ctx sdk.Context, epoch uint64, signers types.EpochSignerSet) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochSignerSetKeyPrefix) - bz := k.cdc.MustMarshal(&signers) - store.Set(types.GetEpochSignerSetKeyFromEpoch(epoch), bz) +func (k Keeper) SetEpochQuorums(ctx sdk.Context, epoch uint64, quorums types.Quorums) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix) + bz := k.cdc.MustMarshal(&quorums) + 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) { diff --git a/x/dasigners/v1/types/dasigners.pb.go b/x/dasigners/v1/types/dasigners.pb.go index 8310ff9c..a26b19af 100644 --- a/x/dasigners/v1/types/dasigners.pb.go +++ b/x/dasigners/v1/types/dasigners.pb.go @@ -70,22 +70,22 @@ func (m *Signer) XXX_DiscardUnknown() { var xxx_messageInfo_Signer proto.InternalMessageInfo -type EpochSignerSet struct { +type Quorum struct { Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` } -func (m *EpochSignerSet) Reset() { *m = EpochSignerSet{} } -func (m *EpochSignerSet) String() string { return proto.CompactTextString(m) } -func (*EpochSignerSet) ProtoMessage() {} -func (*EpochSignerSet) Descriptor() ([]byte, []int) { +func (m *Quorum) Reset() { *m = Quorum{} } +func (m *Quorum) String() string { return proto.CompactTextString(m) } +func (*Quorum) ProtoMessage() {} +func (*Quorum) Descriptor() ([]byte, []int) { 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) } -func (m *EpochSignerSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Quorum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EpochSignerSet.Marshal(b, m, deterministic) + return xxx_messageInfo_Quorum.Marshal(b, m, deterministic) } else { b = b[:cap(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 } } -func (m *EpochSignerSet) XXX_Merge(src proto.Message) { - xxx_messageInfo_EpochSignerSet.Merge(m, src) +func (m *Quorum) XXX_Merge(src proto.Message) { + xxx_messageInfo_Quorum.Merge(m, src) } -func (m *EpochSignerSet) XXX_Size() int { +func (m *Quorum) XXX_Size() int { return m.Size() } -func (m *EpochSignerSet) XXX_DiscardUnknown() { - xxx_messageInfo_EpochSignerSet.DiscardUnknown(m) +func (m *Quorum) XXX_DiscardUnknown() { + 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() { 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) } var fileDescriptor_b7328dc8ffac059e = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xc1, 0x4a, 0xc3, 0x30, - 0x1c, 0xc6, 0x1b, 0x27, 0xd3, 0x05, 0x11, 0x29, 0x22, 0xd9, 0x84, 0x50, 0x76, 0x1a, 0x82, 0xcd, - 0x3a, 0xdf, 0x40, 0x10, 0x4f, 0x5e, 0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f, 0xbb, 0x6f, 0xea, 0xec, - 0x4a, 0x8a, 0xf6, 0x25, 0x45, 0x5f, 0x25, 0x45, 0x1f, 0x15, 0x75, 0xf6, 0x15, 0x75, 0x3e, 0x2b, - 0xea, 0xbc, 0x32, 0x15, 0x9b, 0x28, 0x0f, 0x7d, 0x01, 0x6b, 0x36, 0x56, 0x2b, 0x1e, 0x6a, 0x36, - 0x56, 0xf7, 0x22, 0xe2, 0x71, 0xc2, 0xde, 0x8f, 0x87, 0x37, 0x45, 0x2a, 0x75, 0xd8, 0x6d, 0xee, - 0x7e, 0xf8, 0x09, 0x00, 0x00, 0xff, 0xff, 0x77, 0x51, 0x09, 0xd9, 0x99, 0x01, 0x00, 0x00, + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xb1, 0x6e, 0xea, 0x30, + 0x14, 0x86, 0xe3, 0xcb, 0x55, 0x28, 0x6e, 0x87, 0x2a, 0xaa, 0x2a, 0x43, 0x25, 0x2b, 0xca, 0xc4, + 0xd2, 0x98, 0xa4, 0x73, 0x97, 0x2e, 0x9d, 0x3a, 0x94, 0x6e, 0x5d, 0x90, 0x63, 0x52, 0x13, 0x01, + 0x39, 0x34, 0xb6, 0x51, 0xe1, 0x29, 0xfa, 0x58, 0x8c, 0x8c, 0x1d, 0x5b, 0x78, 0x91, 0x0a, 0x3b, + 0x88, 0xc2, 0x76, 0xbe, 0xff, 0xfb, 0xa5, 0x23, 0x1f, 0xe3, 0x70, 0x29, 0x05, 0x1b, 0x72, 0x55, + 0xc8, 0x32, 0xaf, 0x14, 0x9b, 0x27, 0x07, 0x88, 0x67, 0x15, 0x68, 0x08, 0x2e, 0x97, 0x52, 0xc4, + 0x87, 0x70, 0x9e, 0x74, 0xda, 0x02, 0xd4, 0x14, 0xd4, 0xc0, 0x7a, 0xe6, 0xc0, 0x95, 0x3b, 0x57, + 0x12, 0x24, 0xb8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0x03, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x80, 0xdc, + 0x60, 0xd0, 0x01, 0x00, 0x00, } 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 } -func (m *EpochSignerSet) Marshal() (dAtA []byte, err error) { +func (m *Quorum) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -197,12 +237,12 @@ func (m *EpochSignerSet) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EpochSignerSet) MarshalTo(dAtA []byte) (int, error) { +func (m *Quorum) MarshalTo(dAtA []byte) (int, error) { size := m.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 var l int @@ -219,6 +259,43 @@ func (m *EpochSignerSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 { offset -= sovDasigners(v) base := offset @@ -255,7 +332,7 @@ func (m *Signer) Size() (n int) { return n } -func (m *EpochSignerSet) Size() (n int) { +func (m *Quorum) Size() (n int) { if m == nil { return 0 } @@ -270,6 +347,21 @@ func (m *EpochSignerSet) Size() (n int) { 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) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -458,7 +550,7 @@ func (m *Signer) Unmarshal(dAtA []byte) error { } return nil } -func (m *EpochSignerSet) Unmarshal(dAtA []byte) error { +func (m *Quorum) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -481,10 +573,10 @@ func (m *EpochSignerSet) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) 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 { - 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 { case 1: @@ -540,6 +632,90 @@ func (m *EpochSignerSet) Unmarshal(dAtA []byte) error { } 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) { l := len(dAtA) iNdEx := 0 diff --git a/x/dasigners/v1/types/errors.go b/x/dasigners/v1/types/errors.go index f2d5d88f..35d89ad6 100644 --- a/x/dasigners/v1/types/errors.go +++ b/x/dasigners/v1/types/errors.go @@ -3,10 +3,11 @@ package types import errorsmod "cosmossdk.io/errors" var ( - ErrSignerExists = errorsmod.Register(ModuleName, 1, "signer exists") - ErrEpochNumberNotSet = errorsmod.Register(ModuleName, 2, "epoch number not set") - ErrSignerNotFound = errorsmod.Register(ModuleName, 3, "signer not found") - ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature") - ErrEpochSignerSetNotFound = errorsmod.Register(ModuleName, 5, "signer set for epoch not found") - ErrSignerLengthNotMatch = errorsmod.Register(ModuleName, 6, "signer set length not match") + ErrSignerExists = errorsmod.Register(ModuleName, 1, "signer exists") + ErrEpochNumberNotSet = errorsmod.Register(ModuleName, 2, "epoch number not set") + ErrSignerNotFound = errorsmod.Register(ModuleName, 3, "signer not found") + ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature") + ErrQuorumNotFound = errorsmod.Register(ModuleName, 5, "quorum for epoch not found") + ErrQuorumIdOutOfBound = errorsmod.Register(ModuleName, 6, "quorum id out of bound") + ErrQuorumBitmapLengthMismatch = errorsmod.Register(ModuleName, 6, "quorum bitmap length mismatch") ) diff --git a/x/dasigners/v1/types/genesis.go b/x/dasigners/v1/types/genesis.go index b3a4c651..d13aa4c4 100644 --- a/x/dasigners/v1/types/genesis.go +++ b/x/dasigners/v1/types/genesis.go @@ -3,23 +3,23 @@ package types import "fmt" // 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{ Params: params, EpochNumber: epoch, Signers: signers, - SignersByEpoch: signersByEpoch, + QuorumsByEpoch: quorumsByEpoch, } } // DefaultGenesisState returns the default genesis state for the module. func DefaultGenesisState() *GenesisState { return NewGenesisState(Params{ - QuorumSize: 1024, TokensPerVote: "100", MaxVotes: 100, 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. @@ -31,16 +31,18 @@ func (gs GenesisState) Validate() error { } registered[signer.Account] = struct{}{} } - if len(gs.SignersByEpoch) != int(gs.EpochNumber) { + if len(gs.QuorumsByEpoch) != int(gs.EpochNumber) { return fmt.Errorf("epoch history missing") } - for _, signers := range gs.SignersByEpoch { - for _, signer := range signers.Signers { - if err := ValidateHexAddress(signer); err != nil { - return err - } - if _, ok := registered[signer]; !ok { - return fmt.Errorf("historical signer detail missing") + for _, quorums := range gs.QuorumsByEpoch { + for _, quorum := range quorums.Quorums { + for _, signer := range quorum.Signers { + if err := ValidateHexAddress(signer); err != nil { + return err + } + if _, ok := registered[signer]; !ok { + return fmt.Errorf("historical signer detail missing") + } } } } diff --git a/x/dasigners/v1/types/genesis.pb.go b/x/dasigners/v1/types/genesis.pb.go index 0564b2c4..90ce4088 100644 --- a/x/dasigners/v1/types/genesis.pb.go +++ b/x/dasigners/v1/types/genesis.pb.go @@ -27,10 +27,10 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { - QuorumSize uint64 `protobuf:"varint,1,opt,name=quorum_size,json=quorumSize,proto3" json:"quorum_size,omitempty"` - TokensPerVote string `protobuf:"bytes,2,opt,name=tokens_per_vote,json=tokensPerVote,proto3" json:"tokens_per_vote,omitempty"` - MaxVotes uint64 `protobuf:"varint,3,opt,name=max_votes,json=maxVotes,proto3" json:"max_votes,omitempty"` - EpochBlocks uint64 `protobuf:"varint,4,opt,name=epoch_blocks,json=epochBlocks,proto3" json:"epoch_blocks,omitempty"` + TokensPerVote string `protobuf:"bytes,1,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"` + EpochBlocks uint64 `protobuf:"varint,3,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{} } @@ -66,13 +66,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetQuorumSize() uint64 { - if m != nil { - return m.QuorumSize - } - return 0 -} - func (m *Params) GetTokensPerVote() string { if m != nil { return m.TokensPerVote @@ -94,6 +87,13 @@ func (m *Params) GetEpochBlocks() uint64 { return 0 } +func (m *Params) GetEncodedSlices() uint64 { + if m != nil { + return m.EncodedSlices + } + return 0 +} + // GenesisState defines the dasigners module's genesis state. type GenesisState struct { // 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"` // signers defines all signers information Signers []*Signer `protobuf:"bytes,3,rep,name=signers,proto3" json:"signers,omitempty"` - // signers_by_epoch defines chosen signers by epoch - SignersByEpoch []*EpochSignerSet `protobuf:"bytes,4,rep,name=signers_by_epoch,json=signersByEpoch,proto3" json:"signers_by_epoch,omitempty"` + // quorums_by_epoch defines chosen quorums by epoch + QuorumsByEpoch []*Quorums `protobuf:"bytes,4,rep,name=quorums_by_epoch,json=quorumsByEpoch,proto3" json:"quorums_by_epoch,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -160,9 +160,9 @@ func (m *GenesisState) GetSigners() []*Signer { return nil } -func (m *GenesisState) GetSignersByEpoch() []*EpochSignerSet { +func (m *GenesisState) GetQuorumsByEpoch() []*Quorums { if m != nil { - return m.SignersByEpoch + return m.QuorumsByEpoch } return nil } @@ -175,33 +175,34 @@ func init() { func init() { proto.RegisterFile("zgc/dasigners/v1/genesis.proto", fileDescriptor_896efa766aaca3be) } var fileDescriptor_896efa766aaca3be = []byte{ - // 415 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x6e, 0xd3, 0x30, - 0x1c, 0xc6, 0x6b, 0x1a, 0x15, 0xe6, 0x0e, 0x98, 0x2c, 0x0e, 0xd9, 0x90, 0xd2, 0xb0, 0x03, 0xda, - 0x85, 0x78, 0x1b, 0x12, 0x0f, 0x10, 0x09, 0x21, 0x38, 0xa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, 0xff, 0xd0, 0x84, 0xf4, 0xab, 0x94, 0x02, 0x00, 0x00, + // 417 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0x63, 0x12, 0x05, 0xba, 0xfd, 0x43, 0x65, 0x71, 0x70, 0x8a, 0xe4, 0x86, 0x4a, 0xa0, + 0x5e, 0xf0, 0xb6, 0x45, 0xe2, 0x01, 0x82, 0x10, 0xe2, 0x82, 0x8a, 0x23, 0x71, 0xe0, 0x62, 0xad, + 0x37, 0xc3, 0xc6, 0x6a, 0xd6, 0x63, 0x3c, 0xeb, 0x28, 0xe9, 0x53, 0x70, 0xe3, 0x95, 0x7a, 0xec, + 0x91, 0x13, 0x42, 0xce, 0x8b, 0xa0, 0x8e, 0x17, 0x2a, 0x5a, 0x6e, 0x3b, 0xdf, 0xf7, 0x9b, 0xd1, + 0xb7, 0x33, 0x22, 0xbe, 0x34, 0x5a, 0xce, 0x14, 0x15, 0xa6, 0x84, 0x9a, 0xe4, 0xf2, 0x54, 0x1a, + 0x28, 0x81, 0x0a, 0x4a, 0xaa, 0x1a, 0x1d, 0x86, 0xfb, 0x97, 0x46, 0x27, 0x7f, 0xfd, 0x64, 0x79, + 0x7a, 0x30, 0xd2, 0x48, 0x16, 0x29, 0x63, 0x5f, 0x76, 0x45, 0x07, 0x1f, 0x3c, 0x31, 0x68, 0xb0, + 0xd3, 0x6f, 0x5e, 0x5e, 0x1d, 0x19, 0x44, 0xb3, 0x00, 0xc9, 0x55, 0xde, 0x7c, 0x91, 0xaa, 0x5c, + 0x7b, 0xeb, 0xf0, 0xae, 0xe5, 0x0a, 0x0b, 0xe4, 0x94, 0xad, 0x3c, 0x30, 0xbe, 0x17, 0xef, 0x36, + 0x0b, 0x13, 0x47, 0xdf, 0x03, 0x31, 0x3c, 0x57, 0xb5, 0xb2, 0x14, 0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, 0x8d, + 0x83, 0xeb, 0x36, 0x0e, 0x7e, 0xb5, 0x71, 0xf0, 0x6d, 0x13, 0xf7, 0xae, 0x37, 0x71, 0xef, 0xc7, + 0x26, 0xee, 0x7d, 0x96, 0xa6, 0x70, 0xf3, 0x26, 0x4f, 0x34, 0x5a, 0x79, 0x62, 0x16, 0x2a, 0x27, + 0x79, 0x62, 0x5e, 0xea, 0xb9, 0x2a, 0x4a, 0xb9, 0xfa, 0xf7, 0xa6, 0x6e, 0x5d, 0x01, 0xe5, 0x43, + 0x3e, 0xe8, 0xab, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x46, 0x09, 0x1c, 0x6e, 0x93, 0x02, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -224,27 +225,27 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EncodedSlices != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.EncodedSlices)) + i-- + dAtA[i] = 0x20 + } if m.EpochBlocks != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.EpochBlocks)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x18 } if m.MaxVotes != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.MaxVotes)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x10 } if len(m.TokensPerVote) > 0 { i -= len(m.TokensPerVote) copy(dAtA[i:], m.TokensPerVote) i = encodeVarintGenesis(dAtA, i, uint64(len(m.TokensPerVote))) i-- - dAtA[i] = 0x12 - } - if m.QuorumSize != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.QuorumSize)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -269,10 +270,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.SignersByEpoch) > 0 { - for iNdEx := len(m.SignersByEpoch) - 1; iNdEx >= 0; iNdEx-- { + if len(m.QuorumsByEpoch) > 0 { + 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 { return 0, err } @@ -332,9 +333,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.QuorumSize != 0 { - n += 1 + sovGenesis(uint64(m.QuorumSize)) - } l = len(m.TokensPerVote) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -345,6 +343,9 @@ func (m *Params) Size() (n int) { if m.EpochBlocks != 0 { n += 1 + sovGenesis(uint64(m.EpochBlocks)) } + if m.EncodedSlices != 0 { + n += 1 + sovGenesis(uint64(m.EncodedSlices)) + } return n } @@ -365,8 +366,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.SignersByEpoch) > 0 { - for _, e := range m.SignersByEpoch { + if len(m.QuorumsByEpoch) > 0 { + for _, e := range m.QuorumsByEpoch { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -410,25 +411,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { 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 { 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]) iNdEx = postIndex - case 3: + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxVotes", wireType) } @@ -479,7 +461,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 4: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EpochBlocks", wireType) } @@ -498,6 +480,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { 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: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -636,7 +637,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: 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 for shift := uint(0); ; shift += 7 { @@ -663,8 +664,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SignersByEpoch = append(m.SignersByEpoch, &EpochSignerSet{}) - if err := m.SignersByEpoch[len(m.SignersByEpoch)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.QuorumsByEpoch = append(m.QuorumsByEpoch, &Quorums{}) + if err := m.QuorumsByEpoch[len(m.QuorumsByEpoch)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/dasigners/v1/types/keys.go b/x/dasigners/v1/types/keys.go index d49436fc..163cdd09 100644 --- a/x/dasigners/v1/types/keys.go +++ b/x/dasigners/v1/types/keys.go @@ -19,9 +19,10 @@ const ( var ( // prefix - SignerKeyPrefix = []byte{0x00} - EpochSignerSetKeyPrefix = []byte{0x01} - RegistrationKeyPrefix = []byte{0x02} + SignerKeyPrefix = []byte{0x00} + EpochQuorumsKeyPrefix = []byte{0x01} + RegistrationKeyPrefix = []byte{0x02} + QuorumCountKeyPrefix = []byte{0x03} // keys ParamsKey = []byte{0x05} @@ -32,7 +33,11 @@ func GetSignerKeyFromAccount(account string) ([]byte, error) { 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) } diff --git a/x/dasigners/v1/types/query.pb.go b/x/dasigners/v1/types/query.pb.go index fac6e645..84f44e35 100644 --- a/x/dasigners/v1/types/query.pb.go +++ b/x/dasigners/v1/types/query.pb.go @@ -33,7 +33,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QuerySignerRequest struct { - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Accounts []string `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` } func (m *QuerySignerRequest) Reset() { *m = QuerySignerRequest{} } @@ -70,7 +70,7 @@ func (m *QuerySignerRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySignerRequest proto.InternalMessageInfo type QuerySignerResponse struct { - Signer *Signer `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Signer []*Signer `protobuf:"bytes,1,rep,name=signer,proto3" json:"signer,omitempty"` } func (m *QuerySignerResponse) Reset() { *m = QuerySignerResponse{} } @@ -179,22 +179,22 @@ func (m *QueryEpochNumberResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEpochNumberResponse proto.InternalMessageInfo -type QueryEpochSignerSetRequest struct { +type QueryQuorumCountRequest struct { EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` } -func (m *QueryEpochSignerSetRequest) Reset() { *m = QueryEpochSignerSetRequest{} } -func (m *QueryEpochSignerSetRequest) String() string { return proto.CompactTextString(m) } -func (*QueryEpochSignerSetRequest) ProtoMessage() {} -func (*QueryEpochSignerSetRequest) Descriptor() ([]byte, []int) { +func (m *QueryQuorumCountRequest) Reset() { *m = QueryQuorumCountRequest{} } +func (m *QueryQuorumCountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryQuorumCountRequest) ProtoMessage() {} +func (*QueryQuorumCountRequest) Descriptor() ([]byte, []int) { return fileDescriptor_991a610b84b5964c, []int{4} } -func (m *QueryEpochSignerSetRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryQuorumCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEpochSignerSetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryQuorumCountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEpochSignerSetRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryQuorumCountRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -204,34 +204,34 @@ func (m *QueryEpochSignerSetRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryEpochSignerSetRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEpochSignerSetRequest.Merge(m, src) +func (m *QueryQuorumCountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryQuorumCountRequest.Merge(m, src) } -func (m *QueryEpochSignerSetRequest) XXX_Size() int { +func (m *QueryQuorumCountRequest) XXX_Size() int { return m.Size() } -func (m *QueryEpochSignerSetRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEpochSignerSetRequest.DiscardUnknown(m) +func (m *QueryQuorumCountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryQuorumCountRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryEpochSignerSetRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryQuorumCountRequest proto.InternalMessageInfo -type QueryEpochSignerSetResponse struct { - Signers []*Signer `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` +type QueryQuorumCountResponse struct { + QuorumCount uint64 `protobuf:"varint,1,opt,name=quorum_count,json=quorumCount,proto3" json:"quorum_count,omitempty"` } -func (m *QueryEpochSignerSetResponse) Reset() { *m = QueryEpochSignerSetResponse{} } -func (m *QueryEpochSignerSetResponse) String() string { return proto.CompactTextString(m) } -func (*QueryEpochSignerSetResponse) ProtoMessage() {} -func (*QueryEpochSignerSetResponse) Descriptor() ([]byte, []int) { +func (m *QueryQuorumCountResponse) Reset() { *m = QueryQuorumCountResponse{} } +func (m *QueryQuorumCountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryQuorumCountResponse) ProtoMessage() {} +func (*QueryQuorumCountResponse) Descriptor() ([]byte, []int) { return fileDescriptor_991a610b84b5964c, []int{5} } -func (m *QueryEpochSignerSetResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryQuorumCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEpochSignerSetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryQuorumCountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEpochSignerSetResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryQuorumCountResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -241,28 +241,104 @@ func (m *QueryEpochSignerSetResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryEpochSignerSetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEpochSignerSetResponse.Merge(m, src) +func (m *QueryQuorumCountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryQuorumCountResponse.Merge(m, src) } -func (m *QueryEpochSignerSetResponse) XXX_Size() int { +func (m *QueryQuorumCountResponse) XXX_Size() int { return m.Size() } -func (m *QueryEpochSignerSetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEpochSignerSetResponse.DiscardUnknown(m) +func (m *QueryQuorumCountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryQuorumCountResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryEpochSignerSetResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryQuorumCountResponse proto.InternalMessageInfo + +type QueryEpochQuorumRequest struct { + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + QuorumId uint64 `protobuf:"varint,2,opt,name=quorum_id,json=quorumId,proto3" json:"quorum_id,omitempty"` +} + +func (m *QueryEpochQuorumRequest) Reset() { *m = QueryEpochQuorumRequest{} } +func (m *QueryEpochQuorumRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEpochQuorumRequest) ProtoMessage() {} +func (*QueryEpochQuorumRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{6} +} +func (m *QueryEpochQuorumRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochQuorumRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochQuorumRequest.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 *QueryEpochQuorumRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochQuorumRequest.Merge(m, src) +} +func (m *QueryEpochQuorumRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochQuorumRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochQuorumRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochQuorumRequest proto.InternalMessageInfo + +type QueryEpochQuorumResponse struct { + Quorum *Quorum `protobuf:"bytes,1,opt,name=quorum,proto3" json:"quorum,omitempty"` +} + +func (m *QueryEpochQuorumResponse) Reset() { *m = QueryEpochQuorumResponse{} } +func (m *QueryEpochQuorumResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochQuorumResponse) ProtoMessage() {} +func (*QueryEpochQuorumResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{7} +} +func (m *QueryEpochQuorumResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochQuorumResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochQuorumResponse.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 *QueryEpochQuorumResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochQuorumResponse.Merge(m, src) +} +func (m *QueryEpochQuorumResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochQuorumResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochQuorumResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochQuorumResponse proto.InternalMessageInfo type QueryAggregatePubkeyG1Request struct { - EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` - SignersBitmap []byte `protobuf:"bytes,2,opt,name=signersBitmap,proto3" json:"signersBitmap,omitempty"` + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + QuorumId uint64 `protobuf:"varint,2,opt,name=quorum_id,json=quorumId,proto3" json:"quorum_id,omitempty"` + QuorumBitmap []byte `protobuf:"bytes,3,opt,name=quorum_bitmap,json=quorumBitmap,proto3" json:"quorum_bitmap,omitempty"` } func (m *QueryAggregatePubkeyG1Request) Reset() { *m = QueryAggregatePubkeyG1Request{} } func (m *QueryAggregatePubkeyG1Request) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePubkeyG1Request) ProtoMessage() {} func (*QueryAggregatePubkeyG1Request) Descriptor() ([]byte, []int) { - return fileDescriptor_991a610b84b5964c, []int{6} + return fileDescriptor_991a610b84b5964c, []int{8} } func (m *QueryAggregatePubkeyG1Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -301,7 +377,7 @@ func (m *QueryAggregatePubkeyG1Response) Reset() { *m = QueryAggregatePu func (m *QueryAggregatePubkeyG1Response) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePubkeyG1Response) ProtoMessage() {} func (*QueryAggregatePubkeyG1Response) Descriptor() ([]byte, []int) { - return fileDescriptor_991a610b84b5964c, []int{7} + return fileDescriptor_991a610b84b5964c, []int{9} } func (m *QueryAggregatePubkeyG1Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -335,8 +411,10 @@ func init() { proto.RegisterType((*QuerySignerResponse)(nil), "zgc.dasigners.v1.QuerySignerResponse") proto.RegisterType((*QueryEpochNumberRequest)(nil), "zgc.dasigners.v1.QueryEpochNumberRequest") proto.RegisterType((*QueryEpochNumberResponse)(nil), "zgc.dasigners.v1.QueryEpochNumberResponse") - proto.RegisterType((*QueryEpochSignerSetRequest)(nil), "zgc.dasigners.v1.QueryEpochSignerSetRequest") - proto.RegisterType((*QueryEpochSignerSetResponse)(nil), "zgc.dasigners.v1.QueryEpochSignerSetResponse") + proto.RegisterType((*QueryQuorumCountRequest)(nil), "zgc.dasigners.v1.QueryQuorumCountRequest") + proto.RegisterType((*QueryQuorumCountResponse)(nil), "zgc.dasigners.v1.QueryQuorumCountResponse") + proto.RegisterType((*QueryEpochQuorumRequest)(nil), "zgc.dasigners.v1.QueryEpochQuorumRequest") + proto.RegisterType((*QueryEpochQuorumResponse)(nil), "zgc.dasigners.v1.QueryEpochQuorumResponse") proto.RegisterType((*QueryAggregatePubkeyG1Request)(nil), "zgc.dasigners.v1.QueryAggregatePubkeyG1Request") proto.RegisterType((*QueryAggregatePubkeyG1Response)(nil), "zgc.dasigners.v1.QueryAggregatePubkeyG1Response") } @@ -344,45 +422,49 @@ func init() { func init() { proto.RegisterFile("zgc/dasigners/v1/query.proto", fileDescriptor_991a610b84b5964c) } var fileDescriptor_991a610b84b5964c = []byte{ - // 600 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x6f, 0xd3, 0x4e, - 0x10, 0x8d, 0xfb, 0x57, 0xbf, 0x6d, 0x7e, 0xa8, 0xdd, 0x56, 0xaa, 0x63, 0x5a, 0x27, 0x35, 0x29, - 0x6a, 0x51, 0xed, 0x4d, 0xc2, 0x19, 0x21, 0x2a, 0xa1, 0x9e, 0x40, 0xd4, 0xbd, 0x71, 0x89, 0xd6, - 0x66, 0xd9, 0x58, 0xc4, 0x5e, 0x37, 0x5e, 0x47, 0x4d, 0x8f, 0x5c, 0xb9, 0x20, 0x71, 0xe1, 0x03, - 0xf0, 0x61, 0x7a, 0xa3, 0x12, 0x17, 0x8e, 0x90, 0xf0, 0x41, 0x50, 0x76, 0x37, 0x09, 0x8e, 0x71, - 0xc9, 0x6d, 0xf7, 0xcd, 0x9b, 0x79, 0x6f, 0x76, 0x46, 0x0b, 0xf6, 0xae, 0xa9, 0x8f, 0xde, 0xe0, - 0x24, 0xa0, 0x11, 0xe9, 0x25, 0xa8, 0xdf, 0x44, 0x97, 0x29, 0xe9, 0x0d, 0x9c, 0xb8, 0xc7, 0x38, - 0x83, 0x9b, 0xd7, 0xd4, 0x77, 0xa6, 0x51, 0xa7, 0xdf, 0x34, 0x2a, 0x3e, 0x4b, 0x42, 0x96, 0xb4, - 0x45, 0x1c, 0xc9, 0x8b, 0x24, 0x1b, 0x3b, 0x94, 0x51, 0x26, 0xf1, 0xf1, 0x49, 0xa1, 0x7b, 0x94, - 0x31, 0xda, 0x25, 0x08, 0xc7, 0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x83, 0xa5, 0x4c, 0x54, 0x85, 0x89, 0x0a, 0xdc, 0xcd, 0x99, 0x90, 0xc7, 0xd3, 0x17, - 0x37, 0x3f, 0xcd, 0xd2, 0xcd, 0xd0, 0xd4, 0x6e, 0x87, 0xa6, 0xf6, 0x63, 0x68, 0x6a, 0x1f, 0x47, - 0x66, 0xe9, 0x76, 0x64, 0x96, 0xbe, 0x8f, 0xcc, 0xd2, 0x6b, 0x44, 0x03, 0xde, 0x49, 0x3d, 0xc7, - 0x67, 0x21, 0x6a, 0xd0, 0x2e, 0xf6, 0x12, 0xd4, 0xa0, 0xb6, 0xdf, 0xc1, 0x41, 0x84, 0xae, 0xb2, - 0xf5, 0xf8, 0x20, 0x26, 0x89, 0xb7, 0x26, 0xbe, 0xbc, 0xc7, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, - 0x9b, 0xb2, 0x92, 0x94, 0xd1, 0x05, 0x00, 0x00, + // 658 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xde, 0xf2, 0x2f, 0x30, 0xf0, 0x4b, 0x60, 0x20, 0xa1, 0xdb, 0x1f, 0x94, 0xb5, 0x82, 0x41, + 0xe3, 0x76, 0xba, 0x78, 0xd5, 0x83, 0x18, 0x43, 0x4c, 0xd4, 0x48, 0x3d, 0xe9, 0x65, 0x33, 0x2d, + 0xe3, 0x6c, 0x23, 0xed, 0x74, 0xb7, 0x53, 0x02, 0x1c, 0x8d, 0x37, 0x2f, 0x26, 0x7e, 0x05, 0x3f, + 0x0c, 0x47, 0x12, 0x2f, 0x1e, 0x15, 0xfc, 0x20, 0x66, 0x67, 0xa6, 0xdb, 0x2d, 0xdd, 0x2e, 0x7b, + 0xf0, 0x36, 0xf3, 0xbe, 0xef, 0xf3, 0x3e, 0xcf, 0x3c, 0x3c, 0x74, 0xc1, 0xc6, 0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9b, + 0x13, 0x3f, 0x12, 0x8f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x8c, 0xd5, 0xcf, 0x03, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -398,7 +480,8 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { EpochNumber(ctx context.Context, in *QueryEpochNumberRequest, opts ...grpc.CallOption) (*QueryEpochNumberResponse, error) - EpochSignerSet(ctx context.Context, in *QueryEpochSignerSetRequest, opts ...grpc.CallOption) (*QueryEpochSignerSetResponse, error) + QuorumCount(ctx context.Context, in *QueryQuorumCountRequest, opts ...grpc.CallOption) (*QueryQuorumCountResponse, error) + EpochQuorum(ctx context.Context, in *QueryEpochQuorumRequest, opts ...grpc.CallOption) (*QueryEpochQuorumResponse, error) AggregatePubkeyG1(ctx context.Context, in *QueryAggregatePubkeyG1Request, opts ...grpc.CallOption) (*QueryAggregatePubkeyG1Response, error) Signer(ctx context.Context, in *QuerySignerRequest, opts ...grpc.CallOption) (*QuerySignerResponse, error) } @@ -420,9 +503,18 @@ func (c *queryClient) EpochNumber(ctx context.Context, in *QueryEpochNumberReque return out, nil } -func (c *queryClient) EpochSignerSet(ctx context.Context, in *QueryEpochSignerSetRequest, opts ...grpc.CallOption) (*QueryEpochSignerSetResponse, error) { - out := new(QueryEpochSignerSetResponse) - err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/EpochSignerSet", in, out, opts...) +func (c *queryClient) QuorumCount(ctx context.Context, in *QueryQuorumCountRequest, opts ...grpc.CallOption) (*QueryQuorumCountResponse, error) { + out := new(QueryQuorumCountResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/QuorumCount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) EpochQuorum(ctx context.Context, in *QueryEpochQuorumRequest, opts ...grpc.CallOption) (*QueryEpochQuorumResponse, error) { + out := new(QueryEpochQuorumResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/EpochQuorum", in, out, opts...) if err != nil { return nil, err } @@ -450,7 +542,8 @@ func (c *queryClient) Signer(ctx context.Context, in *QuerySignerRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { EpochNumber(context.Context, *QueryEpochNumberRequest) (*QueryEpochNumberResponse, error) - EpochSignerSet(context.Context, *QueryEpochSignerSetRequest) (*QueryEpochSignerSetResponse, error) + QuorumCount(context.Context, *QueryQuorumCountRequest) (*QueryQuorumCountResponse, error) + EpochQuorum(context.Context, *QueryEpochQuorumRequest) (*QueryEpochQuorumResponse, error) AggregatePubkeyG1(context.Context, *QueryAggregatePubkeyG1Request) (*QueryAggregatePubkeyG1Response, error) Signer(context.Context, *QuerySignerRequest) (*QuerySignerResponse, error) } @@ -462,8 +555,11 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) EpochNumber(ctx context.Context, req *QueryEpochNumberRequest) (*QueryEpochNumberResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EpochNumber not implemented") } -func (*UnimplementedQueryServer) EpochSignerSet(ctx context.Context, req *QueryEpochSignerSetRequest) (*QueryEpochSignerSetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EpochSignerSet not implemented") +func (*UnimplementedQueryServer) QuorumCount(ctx context.Context, req *QueryQuorumCountRequest) (*QueryQuorumCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QuorumCount not implemented") +} +func (*UnimplementedQueryServer) EpochQuorum(ctx context.Context, req *QueryEpochQuorumRequest) (*QueryEpochQuorumResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EpochQuorum not implemented") } func (*UnimplementedQueryServer) AggregatePubkeyG1(ctx context.Context, req *QueryAggregatePubkeyG1Request) (*QueryAggregatePubkeyG1Response, error) { return nil, status.Errorf(codes.Unimplemented, "method AggregatePubkeyG1 not implemented") @@ -494,20 +590,38 @@ func _Query_EpochNumber_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Query_EpochSignerSet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryEpochSignerSetRequest) +func _Query_QuorumCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryQuorumCountRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).EpochSignerSet(ctx, in) + return srv.(QueryServer).QuorumCount(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zgc.dasigners.v1.Query/EpochSignerSet", + FullMethod: "/zgc.dasigners.v1.Query/QuorumCount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).EpochSignerSet(ctx, req.(*QueryEpochSignerSetRequest)) + return srv.(QueryServer).QuorumCount(ctx, req.(*QueryQuorumCountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_EpochQuorum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEpochQuorumRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochQuorum(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Query/EpochQuorum", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochQuorum(ctx, req.(*QueryEpochQuorumRequest)) } return interceptor(ctx, in, info, handler) } @@ -557,8 +671,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_EpochNumber_Handler, }, { - MethodName: "EpochSignerSet", - Handler: _Query_EpochSignerSet_Handler, + MethodName: "QuorumCount", + Handler: _Query_QuorumCount_Handler, + }, + { + MethodName: "EpochQuorum", + Handler: _Query_EpochQuorum_Handler, }, { MethodName: "AggregatePubkeyG1", @@ -593,12 +711,14 @@ func (m *QuerySignerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Account) > 0 { - i -= len(m.Account) - copy(dAtA[i:], m.Account) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Account))) - i-- - dAtA[i] = 0xa + if len(m.Accounts) > 0 { + for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Accounts[iNdEx]) + copy(dAtA[i:], m.Accounts[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Accounts[iNdEx]))) + i-- + dAtA[i] = 0xa + } } return len(dAtA) - i, nil } @@ -623,17 +743,19 @@ func (m *QuerySignerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Signer != nil { - { - size, err := m.Signer.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Signer) > 0 { + for iNdEx := len(m.Signer) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Signer[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -689,7 +811,7 @@ func (m *QueryEpochNumberResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QueryEpochSignerSetRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryQuorumCountRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -699,12 +821,12 @@ func (m *QueryEpochSignerSetRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryEpochSignerSetRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryQuorumCountRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEpochSignerSetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryQuorumCountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -717,7 +839,7 @@ func (m *QueryEpochSignerSetRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryEpochSignerSetResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryQuorumCountResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -727,29 +849,88 @@ func (m *QueryEpochSignerSetResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryEpochSignerSetResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryQuorumCountResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEpochSignerSetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryQuorumCountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Signers) > 0 { - for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Signers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + if m.QuorumCount != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QuorumCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryEpochQuorumRequest) 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 *QueryEpochQuorumRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochQuorumRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QuorumId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QuorumId)) + i-- + dAtA[i] = 0x10 + } + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryEpochQuorumResponse) 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 *QueryEpochQuorumResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochQuorumResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Quorum != nil { + { + size, err := m.Quorum.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -774,12 +955,17 @@ func (m *QueryAggregatePubkeyG1Request) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.SignersBitmap) > 0 { - i -= len(m.SignersBitmap) - copy(dAtA[i:], m.SignersBitmap) - i = encodeVarintQuery(dAtA, i, uint64(len(m.SignersBitmap))) + if len(m.QuorumBitmap) > 0 { + i -= len(m.QuorumBitmap) + copy(dAtA[i:], m.QuorumBitmap) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuorumBitmap))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.QuorumId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QuorumId)) + i-- + dAtA[i] = 0x10 } if m.EpochNumber != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) @@ -846,9 +1032,11 @@ func (m *QuerySignerRequest) Size() (n int) { } var l int _ = l - l = len(m.Account) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.Accounts) > 0 { + for _, s := range m.Accounts { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } } return n } @@ -859,9 +1047,11 @@ func (m *QuerySignerResponse) Size() (n int) { } var l int _ = l - if m.Signer != nil { - l = m.Signer.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Signer) > 0 { + for _, e := range m.Signer { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } return n } @@ -887,7 +1077,7 @@ func (m *QueryEpochNumberResponse) Size() (n int) { return n } -func (m *QueryEpochSignerSetRequest) Size() (n int) { +func (m *QueryQuorumCountRequest) Size() (n int) { if m == nil { return 0 } @@ -899,17 +1089,42 @@ func (m *QueryEpochSignerSetRequest) Size() (n int) { return n } -func (m *QueryEpochSignerSetResponse) Size() (n int) { +func (m *QueryQuorumCountResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Signers) > 0 { - for _, e := range m.Signers { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } + if m.QuorumCount != 0 { + n += 1 + sovQuery(uint64(m.QuorumCount)) + } + return n +} + +func (m *QueryEpochQuorumRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if m.QuorumId != 0 { + n += 1 + sovQuery(uint64(m.QuorumId)) + } + return n +} + +func (m *QueryEpochQuorumResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Quorum != nil { + l = m.Quorum.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } @@ -923,7 +1138,10 @@ func (m *QueryAggregatePubkeyG1Request) Size() (n int) { if m.EpochNumber != 0 { n += 1 + sovQuery(uint64(m.EpochNumber)) } - l = len(m.SignersBitmap) + if m.QuorumId != 0 { + n += 1 + sovQuery(uint64(m.QuorumId)) + } + l = len(m.QuorumBitmap) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -986,7 +1204,7 @@ func (m *QuerySignerRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Accounts", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1014,7 +1232,7 @@ func (m *QuerySignerRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Account = string(dAtA[iNdEx:postIndex]) + m.Accounts = append(m.Accounts, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -1095,10 +1313,8 @@ func (m *QuerySignerResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Signer == nil { - m.Signer = &Signer{} - } - if err := m.Signer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Signer = append(m.Signer, &Signer{}) + if err := m.Signer[len(m.Signer)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1242,7 +1458,7 @@ func (m *QueryEpochNumberResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryEpochSignerSetRequest) Unmarshal(dAtA []byte) error { +func (m *QueryQuorumCountRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1265,10 +1481,10 @@ func (m *QueryEpochSignerSetRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryEpochSignerSetRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryQuorumCountRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEpochSignerSetRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryQuorumCountRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1311,7 +1527,7 @@ func (m *QueryEpochSignerSetRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryEpochSignerSetResponse) Unmarshal(dAtA []byte) error { +func (m *QueryQuorumCountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1334,15 +1550,172 @@ func (m *QueryEpochSignerSetResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryEpochSignerSetResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryQuorumCountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEpochSignerSetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryQuorumCountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuorumCount", wireType) + } + m.QuorumCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuorumCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEpochQuorumRequest) 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 ErrIntOverflowQuery + } + 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: QueryEpochQuorumRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochQuorumRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) + } + m.EpochNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuorumId", wireType) + } + m.QuorumId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuorumId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryEpochQuorumResponse) 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 ErrIntOverflowQuery + } + 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: QueryEpochQuorumResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochQuorumResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Quorum", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1369,8 +1742,10 @@ func (m *QueryEpochSignerSetResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signers = append(m.Signers, &Signer{}) - if err := m.Signers[len(m.Signers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Quorum == nil { + m.Quorum = &Quorum{} + } + if err := m.Quorum.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1444,8 +1819,27 @@ func (m *QueryAggregatePubkeyG1Request) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuorumId", wireType) + } + m.QuorumId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuorumId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SignersBitmap", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field QuorumBitmap", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1472,9 +1866,9 @@ func (m *QueryAggregatePubkeyG1Request) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SignersBitmap = append(m.SignersBitmap[:0], dAtA[iNdEx:postIndex]...) - if m.SignersBitmap == nil { - m.SignersBitmap = []byte{} + m.QuorumBitmap = append(m.QuorumBitmap[:0], dAtA[iNdEx:postIndex]...) + if m.QuorumBitmap == nil { + m.QuorumBitmap = []byte{} } iNdEx = postIndex default: diff --git a/x/dasigners/v1/types/query.pb.gw.go b/x/dasigners/v1/types/query.pb.gw.go index 362db812..c4e13717 100644 --- a/x/dasigners/v1/types/query.pb.gw.go +++ b/x/dasigners/v1/types/query.pb.gw.go @@ -52,37 +52,73 @@ func local_request_Query_EpochNumber_0(ctx context.Context, marshaler runtime.Ma } 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) { - var protoReq QueryEpochSignerSetRequest +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 QueryQuorumCountRequest 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_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) } - 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 } -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) { - var protoReq QueryEpochSignerSetRequest +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 QueryQuorumCountRequest 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_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) } - 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 } @@ -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()) defer cancel() 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) 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()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -207,7 +243,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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()) defer cancel() 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) 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) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 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 ( 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))) @@ -394,7 +475,9 @@ var ( var ( 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