diff --git a/.gitignore b/.gitignore index 195c68db..398d9ecb 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,7 @@ build/linux go.work go.work.sum .build/0gchaind +.build/da + +# runtime +run diff --git a/app/app.go b/app/app.go index a6b8b9f0..07f25f59 100644 --- a/app/app.go +++ b/app/app.go @@ -84,7 +84,6 @@ import ( "github.com/evmos/ethermint/x/evm" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/evmos/ethermint/x/evm/vm/geth" "github.com/evmos/ethermint/x/feemarket" feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" @@ -98,6 +97,8 @@ import ( "github.com/0glabs/0g-chain/app/ante" chainparams "github.com/0glabs/0g-chain/app/params" "github.com/0glabs/0g-chain/chaincfg" + dasignersprecompile "github.com/0glabs/0g-chain/precompiles/dasigners" + "github.com/0glabs/0g-chain/x/bep3" bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper" bep3types "github.com/0glabs/0g-chain/x/bep3/types" @@ -111,6 +112,9 @@ import ( das "github.com/0glabs/0g-chain/x/das/v1" daskeeper "github.com/0glabs/0g-chain/x/das/v1/keeper" dastypes "github.com/0glabs/0g-chain/x/das/v1/types" + dasigners "github.com/0glabs/0g-chain/x/dasigners/v1" + dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper" + dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types" evmutil "github.com/0glabs/0g-chain/x/evmutil" evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper" evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types" @@ -123,6 +127,8 @@ import ( validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting" validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest" validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" ) var ( @@ -164,6 +170,7 @@ var ( mint.AppModuleBasic{}, council.AppModuleBasic{}, das.AppModuleBasic{}, + dasigners.AppModuleBasic{}, ) // module account permissions @@ -247,6 +254,7 @@ type App struct { pricefeedKeeper pricefeedkeeper.Keeper committeeKeeper committeekeeper.Keeper mintKeeper mintkeeper.Keeper + dasignersKeeper dasignerskeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -296,6 +304,7 @@ func NewApp( minttypes.StoreKey, counciltypes.StoreKey, dastypes.StoreKey, + dasignerstypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -437,14 +446,23 @@ func NewApp( ) evmBankKeeper := evmutilkeeper.NewEvmBankKeeper(app.evmutilKeeper, app.bankKeeper, app.accountKeeper) + // dasigners keeper + app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper) + // precopmiles + precompiles := make(map[common.Address]vm.PrecompiledContract) + daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper) + if err != nil { + panic("initialize precompile failed") + } + precompiles[daSignersPrecompile.Address()] = daSignersPrecompile + // evm keeper app.evmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], govAuthorityAddr, app.accountKeeper, evmBankKeeper, app.stakingKeeper, app.feeMarketKeeper, - nil, // precompiled contracts - geth.NewEVM, options.EVMTrace, evmSubspace, + precompiles, ) app.evmutilKeeper.SetEvmKeeper(app.evmKeeper) @@ -591,6 +609,7 @@ func NewApp( mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, nil), council.NewAppModule(app.CouncilKeeper, app.stakingKeeper), das.NewAppModule(app.DasKeeper), + dasigners.NewAppModule(app.dasignersKeeper, app.stakingKeeper), ) // Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list. @@ -635,6 +654,7 @@ func NewApp( counciltypes.ModuleName, dastypes.ModuleName, + dasignerstypes.ModuleName, ) // Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list. @@ -668,6 +688,7 @@ func NewApp( minttypes.ModuleName, counciltypes.ModuleName, dastypes.ModuleName, + dasignerstypes.ModuleName, ) // Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list @@ -700,6 +721,7 @@ func NewApp( validatorvestingtypes.ModuleName, counciltypes.ModuleName, dastypes.ModuleName, + dasignerstypes.ModuleName, ) app.mm.RegisterInvariants(&app.crisisKeeper) diff --git a/app/app_test.go b/app/app_test.go index 9fd6cd60..d2569381 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -3,11 +3,7 @@ package app import ( "encoding/json" "fmt" - "os" - "sort" - "testing" - "time" - "github.com/0glabs/0g-chain/chaincfg" + "github.com/0glabs/0g-chain/chaincfg" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" @@ -19,6 +15,10 @@ import ( "github.com/tendermint/tendermint/libs/log" tmtypes "github.com/tendermint/tendermint/types" db "github.com/tendermint/tm-db" + "os" + "sort" + "testing" + "time" ) func TestNewApp(t *testing.T) { diff --git a/crypto/bn254util/bn254util.go b/crypto/bn254util/bn254util.go new file mode 100644 index 00000000..ea03660a --- /dev/null +++ b/crypto/bn254util/bn254util.go @@ -0,0 +1,166 @@ +package bn254util + +import ( + "math/big" + + "github.com/consensys/gnark-crypto/ecc/bn254" + "github.com/consensys/gnark-crypto/ecc/bn254/fp" + "github.com/consensys/gnark-crypto/ecc/bn254/fr" + "github.com/ethereum/go-ethereum/crypto" +) + +const ( + G1PointSize = 32 * 2 + G2PointSize = 32 * 2 * 2 +) + +var ( + FR_MODULUS, _ = new(big.Int).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10) +) + +func VerifySig(sig *bn254.G1Affine, pubkey *bn254.G2Affine, msgBytes [32]byte) (bool, error) { + + g2Gen := GetG2Generator() + + msgPoint := MapToCurve(msgBytes) + + var negSig bn254.G1Affine + negSig.Neg((*bn254.G1Affine)(sig)) + + P := [2]bn254.G1Affine{*msgPoint, negSig} + Q := [2]bn254.G2Affine{*pubkey, *g2Gen} + + ok, err := bn254.PairingCheck(P[:], Q[:]) + if err != nil { + return false, nil + } + return ok, nil + +} + +func MapToCurve(digest [32]byte) *bn254.G1Affine { + + one := new(big.Int).SetUint64(1) + three := new(big.Int).SetUint64(3) + x := new(big.Int) + x.SetBytes(digest[:]) + for { + // y = x^3 + 3 + xP3 := new(big.Int).Exp(x, big.NewInt(3), fp.Modulus()) + y := new(big.Int).Add(xP3, three) + y.Mod(y, fp.Modulus()) + + if y.ModSqrt(y, fp.Modulus()) == nil { + x.Add(x, one).Mod(x, fp.Modulus()) + } else { + var fpX, fpY fp.Element + fpX.SetBigInt(x) + fpY.SetBigInt(y) + return &bn254.G1Affine{ + X: fpX, + Y: fpY, + } + } + } +} + +func CheckG1AndG2DiscreteLogEquality(pointG1 *bn254.G1Affine, pointG2 *bn254.G2Affine) (bool, error) { + negGenG1 := new(bn254.G1Affine).Neg(GetG1Generator()) + return bn254.PairingCheck([]bn254.G1Affine{*pointG1, *negGenG1}, []bn254.G2Affine{*GetG2Generator(), *pointG2}) +} + +func GetG1Generator() *bn254.G1Affine { + g1Gen := new(bn254.G1Affine) + _, err := g1Gen.X.SetString("1") + if err != nil { + return nil + } + _, err = g1Gen.Y.SetString("2") + if err != nil { + return nil + } + return g1Gen +} + +func GetG2Generator() *bn254.G2Affine { + g2Gen := new(bn254.G2Affine) + g2Gen.X.SetString("10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634") + g2Gen.Y.SetString("8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531") + return g2Gen +} + +func MulByGeneratorG1(a *fr.Element) *bn254.G1Affine { + g1Gen := GetG1Generator() + return new(bn254.G1Affine).ScalarMultiplication(g1Gen, a.BigInt(new(big.Int))) +} + +func MulByGeneratorG2(a *fr.Element) *bn254.G2Affine { + g2Gen := GetG2Generator() + return new(bn254.G2Affine).ScalarMultiplication(g2Gen, a.BigInt(new(big.Int))) +} + +func SerializeG1(p *bn254.G1Affine) []byte { + b := make([]byte, 0) + tmp := p.X.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + tmp = p.Y.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + return b +} + +func DeserializeG1(b []byte) *bn254.G1Affine { + p := new(bn254.G1Affine) + p.X.SetBytes(b[0:32]) + p.Y.SetBytes(b[32:64]) + return p +} + +func SerializeG2(p *bn254.G2Affine) []byte { + b := make([]byte, 0) + tmp := p.X.A0.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + tmp = p.X.A1.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + tmp = p.Y.A0.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + tmp = p.Y.A1.Bytes() + for i := 0; i < 32; i++ { + b = append(b, tmp[i]) + } + return b +} + +func DeserializeG2(b []byte) *bn254.G2Affine { + p := new(bn254.G2Affine) + p.X.A0.SetBytes(b[0:32]) + p.X.A1.SetBytes(b[32:64]) + p.Y.A0.SetBytes(b[64:96]) + p.Y.A1.SetBytes(b[96:128]) + return p +} + +func Gamma(hash *bn254.G1Affine, signature *bn254.G1Affine, pkG1 *bn254.G1Affine, pkG2 *bn254.G2Affine) *big.Int { + toHash := make([]byte, 0) + toHash = append(toHash, SerializeG1(hash)...) + toHash = append(toHash, SerializeG1(signature)...) + toHash = append(toHash, SerializeG1(pkG1)...) + toHash = append(toHash, SerializeG2(pkG2)...) + + msgHash := crypto.Keccak256(toHash) + gamma := new(big.Int) + gamma.SetBytes(msgHash) + gamma.Mod(gamma, FR_MODULUS) + return gamma +} diff --git a/go.mod b/go.mod index f7a0e479..3d53e2d5 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 github.com/cenkalti/backoff/v4 v4.1.3 github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 + github.com/consensys/gnark-crypto v0.12.1 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.46.11 github.com/cosmos/go-bip39 v1.0.0 @@ -54,6 +55,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd v0.23.4 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/btcutil v1.1.3 // indirect @@ -65,6 +67,7 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect + github.com/consensys/bavard v0.1.13 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogoproto v1.4.6 // indirect github.com/cosmos/iavl v0.19.5 // indirect @@ -144,6 +147,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mtibben/percent v0.2.1 // indirect @@ -197,6 +201,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect + rsc.io/tmplfunc v0.0.3 // indirect ) replace ( @@ -208,8 +213,10 @@ replace ( github.com/cosmos/cosmos-sdk => github.com/kava-labs/cosmos-sdk v0.46.11-kava.3 // See https://github.com/cosmos/cosmos-sdk/pull/13093 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 + // Use go-ethereum fork with precompiles + github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support - github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.21.0-kava-v23-1 + github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.1 // See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 // Use the cosmos modified protobufs diff --git a/go.sum b/go.sum index bbd2b093..bbbbb97a 100644 --- a/go.sum +++ b/go.sum @@ -200,6 +200,8 @@ filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmG filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= +github.com/0glabs/ethermint v0.21.0-0g.v2.0.1 h1:loFnZAEZ8tboo3JO3+AE+1gJcUm6hkYuwcn+ZHBhjxE= +github.com/0glabs/ethermint v0.21.0-0g.v2.0.1/go.mod h1:peUmQT71k9BOBgoWoIRWRrM/O01mffVjIH0RLnoaFuI= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= @@ -207,6 +209,7 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSu github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= @@ -276,6 +279,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= @@ -287,8 +292,8 @@ github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZg github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= @@ -360,8 +365,12 @@ github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 h1:MFLTqgfJcl github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71/go.mod h1:TrHYHH4Wze7v7Hkwu1MH1W+mCPQKM+gs+PicdEV14o8= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= @@ -432,10 +441,9 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16 github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= @@ -461,13 +469,13 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= -github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= -github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/evmos/go-ethereum v1.10.26-evmos-rc2 h1:tYghk1ZZ8X4/OQ4YI9hvtm8aSN8OSqO0g9vo/sCMdBo= +github.com/evmos/go-ethereum v1.10.26-evmos-rc2/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -479,6 +487,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= @@ -647,6 +656,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -749,7 +759,6 @@ github.com/holiman/uint256 v1.2.1 h1:XRtyuda/zw2l+Bq/38n5XUoEF72aSOu/77Thd9pPp2o github.com/holiman/uint256 v1.2.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= @@ -810,8 +819,6 @@ github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1 h1:EZnZAkZ+dqK+1OM github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1/go.mod h1:mI/4J4IxRzPrXvMiwefrt0fucGwaQ5Hm9IKS7HnoJeI= github.com/kava-labs/cosmos-sdk v0.46.11-kava.3 h1:TOhyyW/xHso/9uIOgYdsrOWDIhXi6foORWZxVRe/wS0= github.com/kava-labs/cosmos-sdk v0.46.11-kava.3/go.mod h1:bSUUbmVwWkv1ZNVTWrQHa/i+73xIUvYYPsCvl5doiCs= -github.com/kava-labs/ethermint v0.21.0-kava-v23-1 h1:5TSyCtPvFdMuSe8p2iMVqXmFBlK3lHyjaT9EqN752aI= -github.com/kava-labs/ethermint v0.21.0-kava-v23-1/go.mod h1:rdm6AinxZ4dzPEv/cjH+/AGyTbKufJ3RE7M2MDyklH0= github.com/kava-labs/tm-db v0.6.7-kava.4 h1:M2RibOKmbi+k2OhAFry8z9+RJF0CYuDETB7/PrSdoro= github.com/kava-labs/tm-db v0.6.7-kava.4/go.mod h1:70tpLhNfwCP64nAlq+bU+rOiVfWr3Nnju1D1nhGDGKs= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -839,9 +846,11 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= @@ -915,6 +924,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -951,6 +963,7 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= @@ -1132,12 +1145,14 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -1177,6 +1192,7 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= +github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -1187,12 +1203,14 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= @@ -1264,6 +1282,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w= golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -1292,6 +1311,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1485,7 +1506,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1563,6 +1583,7 @@ golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1601,6 +1622,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1872,11 +1894,9 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= -gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1892,7 +1912,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1909,6 +1928,7 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/localtestnet.sh b/localtestnet.sh index bde45c2c..aab02408 100755 --- a/localtestnet.sh +++ b/localtestnet.sh @@ -48,12 +48,12 @@ $BINARY config keyring-backend test # Create validator keys and add account to genesis validatorKeyName="validator" -printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --recover +printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --eth --recover $BINARY add-genesis-account $validatorKeyName 2000000000000000000000ua0gi # Create faucet keys and add account to genesis faucetKeyName="faucet" -printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --recover +printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --eth --recover $BINARY add-genesis-account $faucetKeyName 1000000000000000000000ua0gi evmFaucetKeyName="evm-faucet" diff --git a/precompiles/common/errors.go b/precompiles/common/errors.go new file mode 100644 index 00000000..ca8c494e --- /dev/null +++ b/precompiles/common/errors.go @@ -0,0 +1,6 @@ +package common + +const ( + ErrGetStateDB = "get EVM StateDB failed" + ErrInvalidNumberOfArgs = "invalid number of arguments; expected %d; got: %d" +) diff --git a/precompiles/dasigners/IDASigners.abi b/precompiles/dasigners/IDASigners.abi new file mode 100644 index 00000000..0bb6d20f --- /dev/null +++ b/precompiles/dasigners/IDASigners.abi @@ -0,0 +1,373 @@ +[ + { + "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": "struct BN254.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": "struct BN254.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": "struct BN254.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": "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": "", + "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": "struct BN254.G1Point", + "name": "pkG1", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256[2]", + "name": "X", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2]", + "name": "Y", + "type": "uint256[2]" + } + ], + "internalType": "struct BN254.G2Point", + "name": "pkG2", + "type": "tuple" + } + ], + "internalType": "struct IDASigners.SignerDetail[]", + "name": "details", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "X", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "Y", + "type": "uint256" + } + ], + "internalType": "struct BN254.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": "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": "_signer", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "X", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "Y", + "type": "uint256" + } + ], + "internalType": "struct BN254.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" + } +] diff --git a/precompiles/dasigners/contract.go b/precompiles/dasigners/contract.go new file mode 100644 index 00000000..8966d62f --- /dev/null +++ b/precompiles/dasigners/contract.go @@ -0,0 +1,677 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package dasigners + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// 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\"}]", +} + +// DASignersABI is the input ABI used to generate the binding from. +// Deprecated: Use DASignersMetaData.ABI instead. +var DASignersABI = DASignersMetaData.ABI + +// DASigners is an auto generated Go binding around an Ethereum contract. +type DASigners struct { + DASignersCaller // Read-only binding to the contract + DASignersTransactor // Write-only binding to the contract + DASignersFilterer // Log filterer for contract events +} + +// DASignersCaller is an auto generated read-only Go binding around an Ethereum contract. +type DASignersCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DASignersTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DASignersTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DASignersFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DASignersFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DASignersSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DASignersSession struct { + Contract *DASigners // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DASignersCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DASignersCallerSession struct { + Contract *DASignersCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DASignersTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DASignersTransactorSession struct { + Contract *DASignersTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DASignersRaw is an auto generated low-level Go binding around an Ethereum contract. +type DASignersRaw struct { + Contract *DASigners // Generic contract binding to access the raw methods on +} + +// DASignersCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DASignersCallerRaw struct { + Contract *DASignersCaller // Generic read-only contract binding to access the raw methods on +} + +// DASignersTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DASignersTransactorRaw struct { + Contract *DASignersTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDASigners creates a new instance of DASigners, bound to a specific deployed contract. +func NewDASigners(address common.Address, backend bind.ContractBackend) (*DASigners, error) { + contract, err := bindDASigners(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &DASigners{DASignersCaller: DASignersCaller{contract: contract}, DASignersTransactor: DASignersTransactor{contract: contract}, DASignersFilterer: DASignersFilterer{contract: contract}}, nil +} + +// NewDASignersCaller creates a new read-only instance of DASigners, bound to a specific deployed contract. +func NewDASignersCaller(address common.Address, caller bind.ContractCaller) (*DASignersCaller, error) { + contract, err := bindDASigners(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DASignersCaller{contract: contract}, nil +} + +// NewDASignersTransactor creates a new write-only instance of DASigners, bound to a specific deployed contract. +func NewDASignersTransactor(address common.Address, transactor bind.ContractTransactor) (*DASignersTransactor, error) { + contract, err := bindDASigners(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DASignersTransactor{contract: contract}, nil +} + +// NewDASignersFilterer creates a new log filterer instance of DASigners, bound to a specific deployed contract. +func NewDASignersFilterer(address common.Address, filterer bind.ContractFilterer) (*DASignersFilterer, error) { + contract, err := bindDASigners(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DASignersFilterer{contract: contract}, nil +} + +// bindDASigners binds a generic wrapper to an already deployed contract. +func bindDASigners(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DASignersABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DASigners *DASignersRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DASigners.Contract.DASignersCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DASigners *DASignersRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DASigners.Contract.DASignersTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DASigners *DASignersRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DASigners.Contract.DASignersTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DASigners *DASignersCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DASigners.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DASigners *DASignersTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DASigners.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DASigners *DASignersTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DASigners.Contract.contract.Transact(opts, method, params...) +} + +// EpochNumber is a free data retrieval call binding the contract method 0xf4145a83. +// +// Solidity: function epochNumber() view returns(uint256) +func (_DASigners *DASignersCaller) EpochNumber(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _DASigners.contract.Call(opts, &out, "epochNumber") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// EpochNumber is a free data retrieval call binding the contract method 0xf4145a83. +// +// Solidity: function epochNumber() view returns(uint256) +func (_DASigners *DASignersSession) EpochNumber() (*big.Int, error) { + return _DASigners.Contract.EpochNumber(&_DASigners.CallOpts) +} + +// EpochNumber is a free data retrieval call binding the contract method 0xf4145a83. +// +// Solidity: function epochNumber() view returns(uint256) +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. +// +// 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 { + AggPkG1 BN254G1Point + Total *big.Int + Hit *big.Int +}, error) { + var out []interface{} + err := _DASigners.contract.Call(opts, &out, "getAggPkG1", epoch, signersBitmap) + + outstruct := new(struct { + AggPkG1 BN254G1Point + Total *big.Int + Hit *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.AggPkG1 = *abi.ConvertType(out[0], new(BN254G1Point)).(*BN254G1Point) + outstruct.Total = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Hit = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetAggPkG1 is a free data retrieval call binding the contract method 0x86fafce5. +// +// 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 { + AggPkG1 BN254G1Point + Total *big.Int + Hit *big.Int +}, error) { + return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, epoch, signersBitmap) +} + +// GetAggPkG1 is a free data retrieval call binding the contract method 0x86fafce5. +// +// 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 { + AggPkG1 BN254G1Point + Total *big.Int + Hit *big.Int +}, error) { + return _DASigners.Contract.GetAggPkG1(&_DASigners.CallOpts, epoch, signersBitmap) +} + +// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// +// 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, "getSigner", account) + + if err != nil { + return *new(IDASignersSignerDetail), err + } + + out0 := *abi.ConvertType(out[0], new(IDASignersSignerDetail)).(*IDASignersSignerDetail) + + return out0, err + +} + +// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// +// 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) +} + +// GetSigner is a free data retrieval call binding the contract method 0x1180b553. +// +// 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) +} + +// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// +// 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) { + var out []interface{} + err := _DASigners.contract.Call(opts, &out, "getSigners", epoch) + + if err != nil { + return *new([]IDASignersSignerDetail), err + } + + out0 := *abi.ConvertType(out[0], new([]IDASignersSignerDetail)).(*[]IDASignersSignerDetail) + + return out0, err + +} + +// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// +// 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) +} + +// GetSigners is a free data retrieval call binding the contract method 0xdfceceae. +// +// 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) +} + +// RegisterNextEpoch is a paid mutator transaction binding the contract method 0x56a32372. +// +// Solidity: function registerNextEpoch((uint256,uint256) _signature) returns() +func (_DASigners *DASignersTransactor) RegisterNextEpoch(opts *bind.TransactOpts, _signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.contract.Transact(opts, "registerNextEpoch", _signature) +} + +// RegisterNextEpoch is a paid mutator transaction binding the contract method 0x56a32372. +// +// Solidity: function registerNextEpoch((uint256,uint256) _signature) returns() +func (_DASigners *DASignersSession) RegisterNextEpoch(_signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.Contract.RegisterNextEpoch(&_DASigners.TransactOpts, _signature) +} + +// RegisterNextEpoch is a paid mutator transaction binding the contract method 0x56a32372. +// +// Solidity: function registerNextEpoch((uint256,uint256) _signature) returns() +func (_DASigners *DASignersTransactorSession) RegisterNextEpoch(_signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.Contract.RegisterNextEpoch(&_DASigners.TransactOpts, _signature) +} + +// RegisterSigner is a paid mutator transaction binding the contract method 0x7ca4dd5e. +// +// Solidity: function registerSigner((address,string,(uint256,uint256),(uint256[2],uint256[2])) _signer, (uint256,uint256) _signature) returns() +func (_DASigners *DASignersTransactor) RegisterSigner(opts *bind.TransactOpts, _signer IDASignersSignerDetail, _signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.contract.Transact(opts, "registerSigner", _signer, _signature) +} + +// RegisterSigner is a paid mutator transaction binding the contract method 0x7ca4dd5e. +// +// Solidity: function registerSigner((address,string,(uint256,uint256),(uint256[2],uint256[2])) _signer, (uint256,uint256) _signature) returns() +func (_DASigners *DASignersSession) RegisterSigner(_signer IDASignersSignerDetail, _signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.Contract.RegisterSigner(&_DASigners.TransactOpts, _signer, _signature) +} + +// RegisterSigner is a paid mutator transaction binding the contract method 0x7ca4dd5e. +// +// Solidity: function registerSigner((address,string,(uint256,uint256),(uint256[2],uint256[2])) _signer, (uint256,uint256) _signature) returns() +func (_DASigners *DASignersTransactorSession) RegisterSigner(_signer IDASignersSignerDetail, _signature BN254G1Point) (*types.Transaction, error) { + return _DASigners.Contract.RegisterSigner(&_DASigners.TransactOpts, _signer, _signature) +} + +// 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) +} + +// 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) +} + +// 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) +} + +// 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. +type DASignersNewSignerIterator struct { + Event *DASignersNewSigner // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DASignersNewSignerIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DASignersNewSigner) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DASignersNewSigner) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DASignersNewSignerIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DASignersNewSignerIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DASignersNewSigner represents a NewSigner event raised by the DASigners contract. +type DASignersNewSigner struct { + Signer common.Address + PkG1 BN254G1Point + PkG2 BN254G2Point + Raw types.Log // Blockchain specific contextual infos +} + +// FilterNewSigner is a free log retrieval operation binding the contract event 0x679917c2006df1daaa987a56bf1d66e99764d5ad317892d9e83a6eb4e3f051e7. +// +// Solidity: event NewSigner(address indexed signer, (uint256,uint256) pkG1, (uint256[2],uint256[2]) pkG2) +func (_DASigners *DASignersFilterer) FilterNewSigner(opts *bind.FilterOpts, signer []common.Address) (*DASignersNewSignerIterator, error) { + + var signerRule []interface{} + for _, signerItem := range signer { + signerRule = append(signerRule, signerItem) + } + + logs, sub, err := _DASigners.contract.FilterLogs(opts, "NewSigner", signerRule) + if err != nil { + return nil, err + } + return &DASignersNewSignerIterator{contract: _DASigners.contract, event: "NewSigner", logs: logs, sub: sub}, nil +} + +// WatchNewSigner is a free log subscription operation binding the contract event 0x679917c2006df1daaa987a56bf1d66e99764d5ad317892d9e83a6eb4e3f051e7. +// +// Solidity: event NewSigner(address indexed signer, (uint256,uint256) pkG1, (uint256[2],uint256[2]) pkG2) +func (_DASigners *DASignersFilterer) WatchNewSigner(opts *bind.WatchOpts, sink chan<- *DASignersNewSigner, signer []common.Address) (event.Subscription, error) { + + var signerRule []interface{} + for _, signerItem := range signer { + signerRule = append(signerRule, signerItem) + } + + logs, sub, err := _DASigners.contract.WatchLogs(opts, "NewSigner", signerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DASignersNewSigner) + if err := _DASigners.contract.UnpackLog(event, "NewSigner", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseNewSigner is a log parse operation binding the contract event 0x679917c2006df1daaa987a56bf1d66e99764d5ad317892d9e83a6eb4e3f051e7. +// +// Solidity: event NewSigner(address indexed signer, (uint256,uint256) pkG1, (uint256[2],uint256[2]) pkG2) +func (_DASigners *DASignersFilterer) ParseNewSigner(log types.Log) (*DASignersNewSigner, error) { + event := new(DASignersNewSigner) + if err := _DASigners.contract.UnpackLog(event, "NewSigner", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DASignersSocketUpdatedIterator is returned from FilterSocketUpdated and is used to iterate over the raw logs and unpacked data for SocketUpdated events raised by the DASigners contract. +type DASignersSocketUpdatedIterator struct { + Event *DASignersSocketUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DASignersSocketUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DASignersSocketUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DASignersSocketUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DASignersSocketUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DASignersSocketUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DASignersSocketUpdated represents a SocketUpdated event raised by the DASigners contract. +type DASignersSocketUpdated struct { + Signer common.Address + Socket string + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSocketUpdated is a free log retrieval operation binding the contract event 0x09617a966176a40f8f1410768b118506db0096484acd5811064fcc12038798de. +// +// Solidity: event SocketUpdated(address indexed signer, string socket) +func (_DASigners *DASignersFilterer) FilterSocketUpdated(opts *bind.FilterOpts, signer []common.Address) (*DASignersSocketUpdatedIterator, error) { + + var signerRule []interface{} + for _, signerItem := range signer { + signerRule = append(signerRule, signerItem) + } + + logs, sub, err := _DASigners.contract.FilterLogs(opts, "SocketUpdated", signerRule) + if err != nil { + return nil, err + } + return &DASignersSocketUpdatedIterator{contract: _DASigners.contract, event: "SocketUpdated", logs: logs, sub: sub}, nil +} + +// WatchSocketUpdated is a free log subscription operation binding the contract event 0x09617a966176a40f8f1410768b118506db0096484acd5811064fcc12038798de. +// +// Solidity: event SocketUpdated(address indexed signer, string socket) +func (_DASigners *DASignersFilterer) WatchSocketUpdated(opts *bind.WatchOpts, sink chan<- *DASignersSocketUpdated, signer []common.Address) (event.Subscription, error) { + + var signerRule []interface{} + for _, signerItem := range signer { + signerRule = append(signerRule, signerItem) + } + + logs, sub, err := _DASigners.contract.WatchLogs(opts, "SocketUpdated", signerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DASignersSocketUpdated) + if err := _DASigners.contract.UnpackLog(event, "SocketUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSocketUpdated is a log parse operation binding the contract event 0x09617a966176a40f8f1410768b118506db0096484acd5811064fcc12038798de. +// +// Solidity: event SocketUpdated(address indexed signer, string socket) +func (_DASigners *DASignersFilterer) ParseSocketUpdated(log types.Log) (*DASignersSocketUpdated, error) { + event := new(DASignersSocketUpdated) + if err := _DASigners.contract.UnpackLog(event, "SocketUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/precompiles/dasigners/dasigners.go b/precompiles/dasigners/dasigners.go new file mode 100644 index 00000000..61ba2a17 --- /dev/null +++ b/precompiles/dasigners/dasigners.go @@ -0,0 +1,139 @@ +package dasigners + +import ( + "fmt" + "strings" + + precopmiles_common "github.com/0glabs/0g-chain/precompiles/common" + dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/evmos/ethermint/x/evm/statedb" +) + +const ( + PrecompileAddress = "0x0000000000000000000000000000000000001000" + + RequiredGasMax uint64 = 1000_000_000 + + DASignersFunctionEpochNumber = "epochNumber" + DASignersFunctionGetSigner = "getSigner" + DASignersFunctionGetSigners = "getSigners" + DASignersFunctionUpdateSocket = "updateSocket" + DASignersFunctionRegisterNextEpoch = "registerNextEpoch" + DASignersFunctionRegisterSigner = "registerSigner" + DASignersFunctionGetAggPkG1 = "getAggPkG1" +) + +var RequiredGasBasic = map[string]uint64{ + "epochNumber": 1000, + "getSigner": 10000, + "getSigners": 1000000, + "updateSocket": 50000, + "registerNextEpoch": 100000, + "registerSigner": 100000, + "getAggPkG1": 1000000, +} + +var KVGasConfig storetypes.GasConfig = storetypes.GasConfig{ + HasCost: 0, + DeleteCost: 0, + ReadCostFlat: 0, + ReadCostPerByte: 0, + WriteCostFlat: 0, + WriteCostPerByte: 0, + IterNextCostFlat: 0, +} + +var _ vm.PrecompiledContract = &DASignersPrecompile{} + +type DASignersPrecompile struct { + abi abi.ABI + dasignersKeeper dasignerskeeper.Keeper +} + +func NewDASignersPrecompile(dasignersKeeper dasignerskeeper.Keeper) (*DASignersPrecompile, error) { + abi, err := abi.JSON(strings.NewReader(DASignersABI)) + if err != nil { + return nil, err + } + return &DASignersPrecompile{ + abi: abi, + dasignersKeeper: dasignersKeeper, + }, nil +} + +// Address implements vm.PrecompiledContract. +func (d *DASignersPrecompile) Address() common.Address { + return common.HexToAddress(PrecompileAddress) +} + +// RequiredGas implements vm.PrecompiledContract. +func (d *DASignersPrecompile) RequiredGas(input []byte) uint64 { + method, err := d.abi.MethodById(input[:4]) + if err != nil { + return RequiredGasMax + } + if gas, ok := RequiredGasBasic[method.Name]; ok { + return gas + } + return RequiredGasMax +} + +// Run implements vm.PrecompiledContract. +func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) { + // parse input + if len(contract.Input) < 4 { + return nil, vm.ErrExecutionReverted + } + method, err := d.abi.MethodById(contract.Input[:4]) + if err != nil { + return nil, vm.ErrExecutionReverted + } + args, err := method.Inputs.Unpack(contract.Input[4:]) + if err != nil { + return nil, err + } + // get state db and context + stateDB, ok := evm.StateDB.(*statedb.StateDB) + if !ok { + return nil, fmt.Errorf(precopmiles_common.ErrGetStateDB) + } + ctx := stateDB.GetContext() + // reset gas config + ctx = ctx.WithKVGasConfig(KVGasConfig) + initialGas := ctx.GasMeter().GasConsumed() + + var bz []byte + switch method.Name { + // queries + case DASignersFunctionEpochNumber: + bz, err = d.EpochNumber(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 DASignersFunctionGetAggPkG1: + bz, err = d.GetAggPkG1(ctx, evm, method, args) + // txs + case DASignersFunctionRegisterSigner: + bz, err = d.RegisterSigner(ctx, evm, stateDB, method, args) + case DASignersFunctionRegisterNextEpoch: + bz, err = d.RegisterNextEpoch(ctx, evm, stateDB, method, args) + case DASignersFunctionUpdateSocket: + bz, err = d.UpdateSocket(ctx, evm, stateDB, method, args) + } + + if err != nil { + return nil, err + } + + cost := ctx.GasMeter().GasConsumed() - initialGas + + if !contract.UseGas(cost) { + return nil, vm.ErrOutOfGas + } + return bz, nil +} diff --git a/precompiles/dasigners/errors.go b/precompiles/dasigners/errors.go new file mode 100644 index 00000000..ad08d35e --- /dev/null +++ b/precompiles/dasigners/errors.go @@ -0,0 +1,5 @@ +package dasigners + +const ( + ErrInvalidSender = "sender address %s is not the same as signer address %s" +) diff --git a/precompiles/dasigners/events.go b/precompiles/dasigners/events.go new file mode 100644 index 00000000..3ac0f4b5 --- /dev/null +++ b/precompiles/dasigners/events.go @@ -0,0 +1,60 @@ +package dasigners + +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/types" + "github.com/evmos/ethermint/x/evm/statedb" +) + +const ( + NewSignerEvent = "NewSigner" + SocketUpdatedEvent = "SocketUpdated" +) + +func (d *DASignersPrecompile) EmitNewSignerEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer IDASignersSignerDetail) error { + event := d.abi.Events[NewSignerEvent] + quries := make([]interface{}, 2) + quries[0] = event.ID + quries[1] = signer.Signer + topics, err := abi.MakeTopics(quries) + if err != nil { + return err + } + arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]} + b, err := arguments.Pack(signer.PkG1, signer.PkG2) + if err != nil { + return err + } + stateDB.AddLog(&types.Log{ + Address: d.Address(), + Topics: topics[0], + Data: b, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return d.EmitSocketUpdatedEvent(ctx, stateDB, signer.Signer, signer.Socket) +} + +func (d *DASignersPrecompile) EmitSocketUpdatedEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer common.Address, socket string) error { + event := d.abi.Events[SocketUpdatedEvent] + quries := make([]interface{}, 2) + quries[0] = event.ID + quries[1] = signer + topics, err := abi.MakeTopics(quries) + if err != nil { + return err + } + arguments := abi.Arguments{event.Inputs[1]} + b, err := arguments.Pack(socket) + if err != nil { + return err + } + stateDB.AddLog(&types.Log{ + Address: d.Address(), + Topics: topics[0], + Data: b, + BlockNumber: uint64(ctx.BlockHeight()), + }) + return nil +} diff --git a/precompiles/dasigners/query.go b/precompiles/dasigners/query.go new file mode 100644 index 00000000..2a63aeff --- /dev/null +++ b/precompiles/dasigners/query.go @@ -0,0 +1,57 @@ +package dasigners + +import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/core/vm" +) + +func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) { + epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx) + if err != nil { + return nil, err + } + return method.Outputs.Pack(big.NewInt(int64(epochNumber))) +} + +func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewQuerySignerRequest(args) + if err != nil { + return nil, err + } + response, err := d.dasignersKeeper.Signer(sdk.WrapSDKContext(ctx), req) + if err != nil { + return nil, err + } + return method.Outputs.Pack(NewIDASignersSignerDetail(response.Signer)) +} + +func (d *DASignersPrecompile) GetSigners(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewQueryEpochSignerSetRequest(args) + if err != nil { + return nil, err + } + response, err := d.dasignersKeeper.EpochSignerSet(sdk.WrapSDKContext(ctx), req) + if err != nil { + return nil, err + } + signers := make([]IDASignersSignerDetail, 0) + for _, signer := range response.Signers { + signers = append(signers, NewIDASignersSignerDetail(signer)) + } + return method.Outputs.Pack(signers) +} + +func (d *DASignersPrecompile) GetAggPkG1(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewQueryAggregatePubkeyG1Request(args) + if err != nil { + return nil, err + } + response, err := d.dasignersKeeper.AggregatePubkeyG1(sdk.WrapSDKContext(ctx), req) + if err != nil { + return nil, err + } + return method.Outputs.Pack(NewBN254G1Point(response.AggregatePubkeyG1), big.NewInt(int64(response.Total)), big.NewInt(int64(response.Hit))) +} diff --git a/precompiles/dasigners/tx.go b/precompiles/dasigners/tx.go new file mode 100644 index 00000000..ac7a7a5c --- /dev/null +++ b/precompiles/dasigners/tx.go @@ -0,0 +1,64 @@ +package dasigners + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/evmos/ethermint/x/evm/statedb" +) + +func (d *DASignersPrecompile) RegisterSigner(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) { + msg, err := NewMsgRegisterSigner(args) + if err != nil { + return nil, err + } + // validation + sender := ToLowerHexWithoutPrefix(evm.Origin) + if sender != msg.Signer.Account { + return nil, fmt.Errorf(ErrInvalidSender, sender, msg.Signer.Account) + } + // execute + _, err = d.dasignersKeeper.RegisterSigner(sdk.WrapSDKContext(ctx), msg) + if err != nil { + return nil, err + } + // emit events + err = d.EmitNewSignerEvent(ctx, stateDB, args[0].(IDASignersSignerDetail)) + if err != nil { + return nil, err + } + return method.Outputs.Pack() +} + +func (d *DASignersPrecompile) RegisterNextEpoch(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) { + msg, err := NewMsgRegisterNextEpoch(args, ToLowerHexWithoutPrefix(evm.Origin)) + if err != nil { + return nil, err + } + // execute + _, err = d.dasignersKeeper.RegisterNextEpoch(sdk.WrapSDKContext(ctx), msg) + if err != nil { + return nil, err + } + return method.Outputs.Pack() +} + +func (d *DASignersPrecompile) UpdateSocket(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) { + msg, err := NewMsgUpdateSocket(args, ToLowerHexWithoutPrefix(evm.Origin)) + if err != nil { + return nil, err + } + // execute + _, err = d.dasignersKeeper.UpdateSocket(sdk.WrapSDKContext(ctx), msg) + if err != nil { + return nil, err + } + // emit events + err = d.EmitSocketUpdatedEvent(ctx, stateDB, evm.Origin, args[0].(string)) + if err != nil { + return nil, err + } + return method.Outputs.Pack() +} diff --git a/precompiles/dasigners/types.go b/precompiles/dasigners/types.go new file mode 100644 index 00000000..16237286 --- /dev/null +++ b/precompiles/dasigners/types.go @@ -0,0 +1,147 @@ +package dasigners + +import ( + "fmt" + "math/big" + "strings" + + precopmiles_common "github.com/0glabs/0g-chain/precompiles/common" + dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types" + "github.com/ethereum/go-ethereum/common" +) + +type BN254G1Point = struct { + X *big.Int "json:\"X\"" + Y *big.Int "json:\"Y\"" +} + +type BN254G2Point = struct { + X [2]*big.Int "json:\"X\"" + Y [2]*big.Int "json:\"Y\"" +} + +type IDASignersSignerDetail = struct { + Signer common.Address "json:\"signer\"" + Socket string "json:\"socket\"" + PkG1 BN254G1Point "json:\"pkG1\"" + PkG2 BN254G2Point "json:\"pkG2\"" +} + +func NewBN254G1Point(b []byte) BN254G1Point { + return BN254G1Point{ + X: new(big.Int).SetBytes(b[:32]), + Y: new(big.Int).SetBytes(b[32:64]), + } +} + +func SerializeG1(p BN254G1Point) []byte { + b := make([]byte, 0) + b = append(b, common.LeftPadBytes(p.X.Bytes(), 32)...) + b = append(b, common.LeftPadBytes(p.Y.Bytes(), 32)...) + return b +} + +func NewBN254G2Point(b []byte) BN254G2Point { + return BN254G2Point{ + X: [2]*big.Int{ + new(big.Int).SetBytes(b[:32]), + new(big.Int).SetBytes(b[32:64]), + }, + Y: [2]*big.Int{ + new(big.Int).SetBytes(b[64:96]), + new(big.Int).SetBytes(b[96:128]), + }, + } +} + +func SerializeG2(p BN254G2Point) []byte { + b := make([]byte, 0) + b = append(b, common.LeftPadBytes(p.X[0].Bytes(), 32)...) + b = append(b, common.LeftPadBytes(p.X[1].Bytes(), 32)...) + b = append(b, common.LeftPadBytes(p.Y[0].Bytes(), 32)...) + b = append(b, common.LeftPadBytes(p.Y[1].Bytes(), 32)...) + return b +} + +func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, 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{ + EpochNumber: args[0].(*big.Int).Uint64(), + }, nil +} + +func NewQueryAggregatePubkeyG1Request(args []interface{}) (*dasignerstypes.QueryAggregatePubkeyG1Request, error) { + if len(args) != 2 { + return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args)) + } + + return &dasignerstypes.QueryAggregatePubkeyG1Request{ + EpochNumber: args[0].(*big.Int).Uint64(), + SignersBitmap: args[1].([]byte), + }, nil +} + +func NewIDASignersSignerDetail(signer *dasignerstypes.Signer) IDASignersSignerDetail { + return IDASignersSignerDetail{ + Signer: common.HexToAddress(signer.Account), + Socket: signer.Socket, + PkG1: NewBN254G1Point(signer.PubkeyG1), + PkG2: NewBN254G2Point(signer.PubkeyG2), + } +} + +func ToLowerHexWithoutPrefix(addr common.Address) string { + return strings.ToLower(addr.Hex()[2:]) +} + +func NewMsgRegisterSigner(args []interface{}) (*dasignerstypes.MsgRegisterSigner, error) { + if len(args) != 2 { + return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args)) + } + + signer := args[0].(IDASignersSignerDetail) + return &dasignerstypes.MsgRegisterSigner{ + Signer: &dasignerstypes.Signer{ + Account: ToLowerHexWithoutPrefix(signer.Signer), + Socket: signer.Socket, + PubkeyG1: SerializeG1(signer.PkG1), + PubkeyG2: SerializeG2(signer.PkG2), + }, + Signature: SerializeG1(args[1].(BN254G1Point)), + }, nil +} + +func NewMsgRegisterNextEpoch(args []interface{}, account string) (*dasignerstypes.MsgRegisterNextEpoch, error) { + if len(args) != 1 { + return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + + return &dasignerstypes.MsgRegisterNextEpoch{ + Account: account, + Signature: SerializeG1(args[0].(BN254G1Point)), + }, nil +} + +func NewMsgUpdateSocket(args []interface{}, account string) (*dasignerstypes.MsgUpdateSocket, error) { + if len(args) != 1 { + return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + + return &dasignerstypes.MsgUpdateSocket{ + Account: account, + Socket: args[0].(string), + }, nil +} diff --git a/proto/zgc/council/v1/genesis.proto b/proto/zgc/council/v1/genesis.proto index fbfcc07b..04bd2acc 100644 --- a/proto/zgc/council/v1/genesis.proto +++ b/proto/zgc/council/v1/genesis.proto @@ -28,7 +28,7 @@ message Council { uint64 voting_start_height = 2; uint64 start_height = 3; uint64 end_height = 4; - repeated Vote votes = 5 [(gogoproto.nullable) = false]; + repeated Vote votes = 5 [(gogoproto.nullable) = false]; repeated bytes members = 6 [ (cosmos_proto.scalar) = "cosmos.AddressBytes", (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress" diff --git a/proto/zgc/council/v1/tx.proto b/proto/zgc/council/v1/tx.proto index 323f6fde..70472762 100644 --- a/proto/zgc/council/v1/tx.proto +++ b/proto/zgc/council/v1/tx.proto @@ -11,21 +11,21 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the council Msg service service Msg { - rpc Register(MsgRegister) returns (MsgRegisterResponse); - rpc Vote(MsgVote) returns (MsgVoteResponse); + rpc Register(MsgRegister) returns (MsgRegisterResponse); + rpc Vote(MsgVote) returns (MsgVoteResponse); } message MsgRegister { - string voter = 1; - bytes key = 2; + string voter = 1; + bytes key = 2; } message MsgRegisterResponse {} message MsgVote { - uint64 council_id = 1 [(gogoproto.customname) = "CouncilID"]; - string voter = 2; - repeated Ballot ballots = 3; + uint64 council_id = 1 [(gogoproto.customname) = "CouncilID"]; + string voter = 2; + repeated Ballot ballots = 3; } message MsgVoteResponse {} diff --git a/proto/zgc/dasigners/v1/dasigners.proto b/proto/zgc/dasigners/v1/dasigners.proto new file mode 100644 index 00000000..91dc6dec --- /dev/null +++ b/proto/zgc/dasigners/v1/dasigners.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package zgc.dasigners.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types"; +option (gogoproto.goproto_getters_all) = false; + +message Signer { + // account defines the hex address of signer without 0x + string account = 1; + // socket defines the da node socket address + string socket = 2; + // pubkey_g1 defines the public key on bn254 G1 + bytes pubkey_g1 = 3; + // pubkey_g1 defines the public key on bn254 G2 + bytes pubkey_g2 = 4; +} + +message EpochSignerSet { + repeated string signers = 1; +} diff --git a/proto/zgc/dasigners/v1/genesis.proto b/proto/zgc/dasigners/v1/genesis.proto new file mode 100644 index 00000000..154cb987 --- /dev/null +++ b/proto/zgc/dasigners/v1/genesis.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package zgc.dasigners.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +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; +} + +// GenesisState defines the dasigners module's genesis state. +message GenesisState { + // params defines all the parameters of related to deposit. + Params params = 1 [(gogoproto.nullable) = false]; + // params epoch_number the epoch number + 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; +} diff --git a/proto/zgc/dasigners/v1/query.proto b/proto/zgc/dasigners/v1/query.proto new file mode 100644 index 00000000..b8811d26 --- /dev/null +++ b/proto/zgc/dasigners/v1/query.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; +package zgc.dasigners.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "zgc/dasigners/v1/dasigners.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types"; +option (gogoproto.goproto_getters_all) = false; + +// Query defines the gRPC querier service for the dasigners module +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 AggregatePubkeyG1(QueryAggregatePubkeyG1Request) returns (QueryAggregatePubkeyG1Response) { + option (google.api.http).get = "/0g/dasigners/v1/aggregate-pubkey-g1"; + } + rpc Signer(QuerySignerRequest) returns (QuerySignerResponse) { + option (google.api.http).get = "/0g/dasigners/v1/signer"; + } +} + +message QuerySignerRequest { + string account = 1; +} + +message QuerySignerResponse { + Signer signer = 1; +} + +message QueryEpochNumberRequest {} + +message QueryEpochNumberResponse { + uint64 epoch_number = 1; +} + +message QueryEpochSignerSetRequest { + uint64 epoch_number = 1; +} + +message QueryEpochSignerSetResponse { + repeated Signer signers = 1; +} + +message QueryAggregatePubkeyG1Request { + uint64 epoch_number = 1; + bytes signersBitmap = 2; +} + +message QueryAggregatePubkeyG1Response { + bytes aggregate_pubkey_g1 = 1; + uint64 total = 2; + uint64 hit = 3; +} diff --git a/proto/zgc/dasigners/v1/tx.proto b/proto/zgc/dasigners/v1/tx.proto new file mode 100644 index 00000000..9e5fd0e2 --- /dev/null +++ b/proto/zgc/dasigners/v1/tx.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +package zgc.dasigners.v1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "zgc/das/v1/genesis.proto"; +import "zgc/dasigners/v1/dasigners.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types"; +option (gogoproto.goproto_getters_all) = false; + +// Msg defines the dasigners Msg service +service Msg { + rpc RegisterSigner(MsgRegisterSigner) returns (MsgRegisterSignerResponse); + rpc UpdateSocket(MsgUpdateSocket) returns (MsgUpdateSocketResponse); + rpc RegisterNextEpoch(MsgRegisterNextEpoch) returns (MsgRegisterNextEpochResponse); +} + +message MsgRegisterSigner { + Signer signer = 1; + bytes signature = 2; +} + +message MsgRegisterSignerResponse {} + +message MsgUpdateSocket { + string account = 1; + string socket = 2; +} + +message MsgUpdateSocketResponse {} + +message MsgRegisterNextEpoch { + string account = 1; + bytes signature = 2; +} + +message MsgRegisterNextEpochResponse {} diff --git a/tests/e2e/runner/kvtool.go b/tests/e2e/runner/kvtool.go index a6f46096..a7a2e355 100644 --- a/tests/e2e/runner/kvtool.go +++ b/tests/e2e/runner/kvtool.go @@ -13,7 +13,7 @@ type KvtoolRunnerConfig struct { ImageTag string IncludeIBC bool - EnableAutomatedUpgrade bool + EnableAutomatedUpgrade bool ZgChainUpgradeName string ZgChainUpgradeHeight int64 ZgChainUpgradeBaseImageTag string diff --git a/tests/e2e/testutil/account.go b/tests/e2e/testutil/account.go index 65e8122e..95025afd 100644 --- a/tests/e2e/testutil/account.go +++ b/tests/e2e/testutil/account.go @@ -142,8 +142,8 @@ func (chain *Chain) AddNewSigningAccountFromPrivKey( evmResChan: evmResChan, zgChainSigner: zgChainSigner, - sdkReqChan: sdkReqChan, - sdkResChan: sdkResChan, + sdkReqChan: sdkReqChan, + sdkResChan: sdkResChan, EvmAuth: evmSigner.Auth, diff --git a/x/dasigners/v1/client/cli/query.go b/x/dasigners/v1/client/cli/query.go new file mode 100644 index 00000000..6561bb51 --- /dev/null +++ b/x/dasigners/v1/client/cli/query.go @@ -0,0 +1,57 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/0glabs/0g-chain/x/dasigners/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +// GetQueryCmd returns the cli query commands for the inflation module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the dasigners module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetEpochNumber(), + ) + + return cmd +} + +func GetEpochNumber() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch-number", + Short: "Query current epoch number", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryEpochNumberRequest{} + res, err := queryClient.EpochNumber(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%v\n", res.EpochNumber)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/dasigners/v1/client/cli/tx.go b/x/dasigners/v1/client/cli/tx.go new file mode 100644 index 00000000..0bfd045b --- /dev/null +++ b/x/dasigners/v1/client/cli/tx.go @@ -0,0 +1,22 @@ +package cli + +import ( + "fmt" + + "github.com/0glabs/0g-chain/x/das/v1/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand() + return cmd +} diff --git a/x/dasigners/v1/genesis.go b/x/dasigners/v1/genesis.go new file mode 100644 index 00000000..64354d00 --- /dev/null +++ b/x/dasigners/v1/genesis.go @@ -0,0 +1,50 @@ +package dasigners + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/0glabs/0g-chain/x/dasigners/v1/keeper" + "github.com/0glabs/0g-chain/x/dasigners/v1/types" +) + +// InitGenesis initializes the store state from a genesis state. +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) + } + keeper.SetEpochNumber(ctx, gs.EpochNumber) + for _, signer := range gs.Signers { + if err := keeper.SetSigner(ctx, *signer); err != nil { + panic(fmt.Sprintf("failed to write genesis state into store: %s", err)) + } + } + for epoch, signers := range gs.SignersByEpoch { + keeper.SetEpochSignerSet(ctx, uint64(epoch), *signers) + } + keeper.SetParams(ctx, gs.Params) +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + params := keeper.GetParams(ctx) + epochNumber, err := keeper.GetEpochNumber(ctx) + if err != nil { + panic(err) + } + signers := make([]*types.Signer, 0) + keeper.IterateSigners(ctx, func(_ int64, signer types.Signer) (stop bool) { + signers = append(signers, &signer) + return false + }) + epochSignerSets := make([]*types.EpochSignerSet, 0) + for i := 0; i < int(epochNumber); i += 1 { + epochSignerSet, found := keeper.GetEpochSignerSet(ctx, uint64(i)) + if !found { + panic("historical epoch signer set not found") + } + epochSignerSets = append(epochSignerSets, &epochSignerSet) + } + return types.NewGenesisState(params, epochNumber, signers, epochSignerSets) +} diff --git a/x/dasigners/v1/keeper/abci.go b/x/dasigners/v1/keeper/abci.go new file mode 100644 index 00000000..bff45f85 --- /dev/null +++ b/x/dasigners/v1/keeper/abci.go @@ -0,0 +1,88 @@ +package keeper + +import ( + "bytes" + "math/big" + "sort" + + "github.com/0glabs/0g-chain/x/dasigners/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/crypto" + abci "github.com/tendermint/tendermint/abci/types" +) + +type Ballot struct { + account string + content []byte +} + +func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + epochNumber, err := k.GetEpochNumber(ctx) + if err != nil { + k.Logger(ctx).Error("[BeginBlock] cannot get epoch number") + panic(err) + } + params := k.GetParams(ctx) + expectedEpoch := uint64(ctx.BlockHeight()) / params.EpochBlocks + if expectedEpoch == epochNumber { + return + } + if expectedEpoch > epochNumber+1 || expectedEpoch < epochNumber { + panic("block height is not continuous") + } + // new epoch + registrations := []Ballot{} + k.IterateRegistrations(ctx, expectedEpoch, func(account string, signature []byte) (stop bool) { + registrations = append(registrations, Ballot{ + account: account, + content: signature, + }) + return false + }) + ballots := []Ballot{} + tokensPerVote, ok := sdk.NewIntFromString(params.TokensPerVote) + if !ok { + panic("failed to load params tokens_per_vote") + } + for _, registration := range registrations { + // get validator + valAddr, err := sdk.ValAddressFromHex(registration.account) + if err != nil { + k.Logger(ctx).Error("[BeginBlock] invalid account") + continue + } + validator, found := k.stakingKeeper.GetValidator(ctx, valAddr) + if !found { + continue + } + num := validator.Tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000)).Quo(tokensPerVote).Abs().BigInt() + if num.Cmp(big.NewInt(int64(params.MaxVotes))) > 0 { + num = big.NewInt(int64(params.MaxVotes)) + } + content := registration.content + ballotNum := num.Int64() + for j := 0; j < int(ballotNum); j += 1 { + ballots = append(ballots, Ballot{ + account: registration.account, + content: content, + }) + content = crypto.Keccak256(content) + } + } + 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), + } + for _, ballot := range ballots { + if _, ok := chosen[ballot.account]; !ok { + chosen[ballot.account] = struct{}{} + epochSignerSet.Signers = append(epochSignerSet.Signers, ballot.account) + } + } + // save to store + k.SetEpochSignerSet(ctx, expectedEpoch, epochSignerSet) + k.SetEpochNumber(ctx, expectedEpoch) +} diff --git a/x/dasigners/v1/keeper/grpc_query.go b/x/dasigners/v1/keeper/grpc_query.go new file mode 100644 index 00000000..4dc1c749 --- /dev/null +++ b/x/dasigners/v1/keeper/grpc_query.go @@ -0,0 +1,92 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/crypto/bn254util" + "github.com/0glabs/0g-chain/x/dasigners/v1/types" + "github.com/consensys/gnark-crypto/ecc/bn254" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) Signer( + c context.Context, + req *types.QuerySignerRequest, +) (*types.QuerySignerResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signer, found, err := k.GetSigner(ctx, req.Account) + if err != nil { + return nil, err + } + if !found { + return nil, nil + } + return &types.QuerySignerResponse{Signer: &signer}, nil +} + +func (k Keeper) EpochNumber( + c context.Context, + _ *types.QueryEpochNumberRequest, +) (*types.QueryEpochNumberResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + epochNumber, err := k.GetEpochNumber(ctx) + if err != nil { + return nil, err + } + return &types.QueryEpochNumberResponse{EpochNumber: epochNumber}, nil +} + +func (k Keeper) EpochSignerSet(c context.Context, request *types.QueryEpochSignerSetRequest) (*types.QueryEpochSignerSetResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signers, found := k.GetEpochSignerSet(ctx, request.EpochNumber) + if !found { + return nil, types.ErrEpochSignerSetNotFound + } + 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) + } + return &types.QueryEpochSignerSetResponse{Signers: epochSignerSet}, 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) + if !found { + return nil, types.ErrEpochSignerSetNotFound + } + if len(request.SignersBitmap) != (len(signers.Signers)+7)/8 { + return nil, types.ErrSignerLengthNotMatch + } + aggPubkeyG1 := new(bn254.G1Affine) + hit := 0 + for i, account := range signers.Signers { + b := request.SignersBitmap[i/8] & (1 << (i % 8)) + if b == 0 { + continue + } + signer, found, err := k.GetSigner(ctx, account) + if err != nil { + return nil, err + } + if !found { + return nil, types.ErrSignerNotFound + } + hit += 1 + aggPubkeyG1.Add(aggPubkeyG1, bn254util.DeserializeG1(signer.PubkeyG1)) + } + return &types.QueryAggregatePubkeyG1Response{ + AggregatePubkeyG1: bn254util.SerializeG1(aggPubkeyG1), + Total: uint64(len(signers.Signers)), + Hit: uint64(hit), + }, nil +} diff --git a/x/dasigners/v1/keeper/keeper.go b/x/dasigners/v1/keeper/keeper.go new file mode 100644 index 00000000..44d437e5 --- /dev/null +++ b/x/dasigners/v1/keeper/keeper.go @@ -0,0 +1,183 @@ +package keeper + +import ( + "encoding/hex" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/0glabs/0g-chain/x/dasigners/v1/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + stakingKeeper types.StakingKeeper +} + +// NewKeeper creates a new das Keeper instance +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + stakingKeeper types.StakingKeeper, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + stakingKeeper: stakingKeeper, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + var params types.Params + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) +} + +func (k Keeper) GetEpochNumber(ctx sdk.Context) (uint64, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.EpochNumberKey) + if bz == nil { + return 0, types.ErrEpochNumberNotSet + } + return sdk.BigEndianToUint64(bz), nil +} + +func (k Keeper) SetEpochNumber(ctx sdk.Context, epoch uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.EpochNumberKey, sdk.Uint64ToBigEndian(epoch)) +} + +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) + if err != nil { + return types.Signer{}, false, err + } + bz := store.Get(key) + if bz == nil { + return types.Signer{}, false, nil + } + var signer types.Signer + k.cdc.MustUnmarshal(bz, &signer) + return signer, true, nil +} + +func (k Keeper) SetSigner(ctx sdk.Context, signer types.Signer) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix) + bz := k.cdc.MustMarshal(&signer) + key, err := types.GetSignerKeyFromAccount(signer.Account) + if err != nil { + return err + } + store.Set(key, bz) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeUpdateSigner, + sdk.NewAttribute(types.AttributeKeySigner, signer.Account), + sdk.NewAttribute(types.AttributeKeySocket, signer.Socket), + sdk.NewAttribute(types.AttributeKeyPublicKeyG1, hex.EncodeToString(signer.PubkeyG1)), + sdk.NewAttribute(types.AttributeKeyPublicKeyG2, hex.EncodeToString(signer.PubkeyG2)), + ), + ) + return nil +} + +// iterate through the signers set and perform the provided function +func (k Keeper) IterateSigners(ctx sdk.Context, fn func(index int64, signer types.Signer) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.SignerKeyPrefix + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + i := int64(0) + + for ; iterator.Valid(); iterator.Next() { + var signer types.Signer + k.cdc.MustUnmarshal(iterator.Value(), &signer) + stop := fn(i, signer) + + if stop { + break + } + i++ + } +} + +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)) + if bz == nil { + return types.EpochSignerSet{}, false + } + var signers types.EpochSignerSet + k.cdc.MustUnmarshal(bz, &signers) + return signers, 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) GetRegistration(ctx sdk.Context, epoch uint64, account string) ([]byte, bool, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetEpochRegistrationKeyPrefix(epoch)) + key, err := types.GetRegistrationKey(account) + if err != nil { + return nil, false, err + } + signature := store.Get(key) + if signature == nil { + return nil, false, nil + } + return signature, true, nil +} + +// iterate through the registrations set and perform the provided function +func (k Keeper) IterateRegistrations(ctx sdk.Context, epoch uint64, fn func(account string, signature []byte) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.GetEpochRegistrationKeyPrefix(epoch) + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + i := int64(0) + + for ; iterator.Valid(); iterator.Next() { + stop := fn(hex.EncodeToString((iterator.Key())[len(prefix):]), iterator.Value()) + + if stop { + break + } + i++ + } +} + +func (k Keeper) SetRegistration(ctx sdk.Context, epoch uint64, account string, signature []byte) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetEpochRegistrationKeyPrefix(epoch)) + key, err := types.GetRegistrationKey(account) + if err != nil { + return err + } + store.Set(key, signature) + return nil +} diff --git a/x/dasigners/v1/keeper/msg_server.go b/x/dasigners/v1/keeper/msg_server.go new file mode 100644 index 00000000..0c76fc28 --- /dev/null +++ b/x/dasigners/v1/keeper/msg_server.go @@ -0,0 +1,92 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/crypto/bn254util" + "github.com/0glabs/0g-chain/x/dasigners/v1/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + etherminttypes "github.com/evmos/ethermint/types" +) + +var _ types.MsgServer = &Keeper{} + +func (k Keeper) RegisterSigner(goCtx context.Context, msg *types.MsgRegisterSigner) (*types.MsgRegisterSignerResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // validate sender + valAddr, err := sdk.ValAddressFromHex(msg.Signer.Account) + if err != nil { + return nil, err + } + _, found := k.stakingKeeper.GetValidator(ctx, valAddr) + if !found { + return nil, stakingtypes.ErrNoValidatorFound + } + _, found, err = k.GetSigner(ctx, msg.Signer.Account) + if err != nil { + return nil, err + } + if found { + return nil, types.ErrSignerExists + } + // validate signature + chainID, err := etherminttypes.ParseChainID(ctx.ChainID()) + if err != nil { + return nil, err + } + hash := types.PubkeyRegistrationHash(common.HexToAddress(msg.Signer.Account), chainID) + if !msg.Signer.ValidateSignature(hash, bn254util.DeserializeG1(msg.Signature)) { + return nil, types.ErrInvalidSignature + } + // save signer + if err := k.SetSigner(ctx, *msg.Signer); err != nil { + return nil, err + } + return &types.MsgRegisterSignerResponse{}, nil +} + +func (k Keeper) UpdateSocket(goCtx context.Context, msg *types.MsgUpdateSocket) (*types.MsgUpdateSocketResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + signer, found, err := k.GetSigner(ctx, msg.Account) + if err != nil { + return nil, err + } + if !found { + return nil, types.ErrSignerNotFound + } + signer.Socket = msg.Socket + if err := k.SetSigner(ctx, signer); err != nil { + return nil, err + } + return &types.MsgUpdateSocketResponse{}, nil +} + +func (k Keeper) RegisterNextEpoch(goCtx context.Context, msg *types.MsgRegisterNextEpoch) (*types.MsgRegisterNextEpochResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // get signer + signer, found, err := k.GetSigner(ctx, msg.Account) + if err != nil { + return nil, err + } + if !found { + return nil, types.ErrSignerNotFound + } + // validate signature + epochNumber, err := k.GetEpochNumber(ctx) + if err != nil { + return nil, err + } + chainID, err := etherminttypes.ParseChainID(ctx.ChainID()) + if err != nil { + return nil, err + } + hash := types.EpochRegistrationHash(common.HexToAddress(msg.Account), epochNumber+1, chainID) + if !signer.ValidateSignature(hash, bn254util.DeserializeG1(msg.Signature)) { + return nil, types.ErrInvalidSignature + } + // save registration + k.SetRegistration(ctx, epochNumber+1, msg.Account, msg.Signature) + return &types.MsgRegisterNextEpochResponse{}, nil +} diff --git a/x/dasigners/v1/module.go b/x/dasigners/v1/module.go new file mode 100644 index 00000000..c5acc6e6 --- /dev/null +++ b/x/dasigners/v1/module.go @@ -0,0 +1,181 @@ +package dasigners + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/0glabs/0g-chain/x/dasigners/v1/client/cli" + "github.com/0glabs/0g-chain/x/dasigners/v1/keeper" + "github.com/0glabs/0g-chain/x/dasigners/v1/types" +) + +// consensusVersion defines the current x/council module consensus version. +const consensusVersion = 1 + +// type check to ensure the interface is properly implemented +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// app module Basics object +type AppModuleBasic struct{} + +// Name returns the inflation module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// ConsensusVersion returns the consensus state-breaking version for the module. +func (AppModuleBasic) ConsensusVersion() uint64 { + return consensusVersion +} + +// RegisterInterfaces registers interfaces and implementations of the incentives +// module. +func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(interfaceRegistry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the inflation module. +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genesisState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genesisState.Validate() +} + +// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST +// endpoints +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module. +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the inflation module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the inflation module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ___________________________________________________________________________ + +// AppModule implements an application module for the inflation module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper + sk stakingkeeper.Keeper +} + +// NewAppModule creates a new AppModule Object +func NewAppModule( + k keeper.Keeper, + sk stakingkeeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: k, + sk: sk, + } +} + +// Name returns the inflation module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// Route returns dasigners module's message route. +func (am AppModule) Route() sdk.Route { return sdk.Route{} } + +// QuerierRoute returns dasigners module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns dasigners module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterInvariants registers the inflation module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + am.keeper.BeginBlock(ctx, req) +} + +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + // am.keeper.EndBlock(ctx, req) + return []abci.ValidatorUpdate{} +} + +// InitGenesis performs genesis initialization for the inflation module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the inflation +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the inflation module. +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for inflation module's types. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +// WeightedOperations doesn't return any inflation module operation. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/dasigners/v1/types/codec.go b/x/dasigners/v1/types/codec.go new file mode 100644 index 00000000..778dc76b --- /dev/null +++ b/x/dasigners/v1/types/codec.go @@ -0,0 +1,44 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + // ModuleCdc references the global evm module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( +// Amino names +) + +// NOTE: This is required for the GetSignBytes function +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} + +// RegisterInterfaces register implementations +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgRegisterSigner{}, + &MsgUpdateSocket{}, + &MsgRegisterNextEpoch{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec required for EIP-712 +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} diff --git a/x/dasigners/v1/types/dasigners.pb.go b/x/dasigners/v1/types/dasigners.pb.go new file mode 100644 index 00000000..8310ff9c --- /dev/null +++ b/x/dasigners/v1/types/dasigners.pb.go @@ -0,0 +1,626 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/dasigners/v1/dasigners.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Signer struct { + // account defines the hex address of signer without 0x + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + // socket defines the da node socket address + Socket string `protobuf:"bytes,2,opt,name=socket,proto3" json:"socket,omitempty"` + // pubkey_g1 defines the public key on bn254 G1 + PubkeyG1 []byte `protobuf:"bytes,3,opt,name=pubkey_g1,json=pubkeyG1,proto3" json:"pubkey_g1,omitempty"` + // pubkey_g1 defines the public key on bn254 G2 + PubkeyG2 []byte `protobuf:"bytes,4,opt,name=pubkey_g2,json=pubkeyG2,proto3" json:"pubkey_g2,omitempty"` +} + +func (m *Signer) Reset() { *m = Signer{} } +func (m *Signer) String() string { return proto.CompactTextString(m) } +func (*Signer) ProtoMessage() {} +func (*Signer) Descriptor() ([]byte, []int) { + return fileDescriptor_b7328dc8ffac059e, []int{0} +} +func (m *Signer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Signer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Signer.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 *Signer) XXX_Merge(src proto.Message) { + xxx_messageInfo_Signer.Merge(m, src) +} +func (m *Signer) XXX_Size() int { + return m.Size() +} +func (m *Signer) XXX_DiscardUnknown() { + xxx_messageInfo_Signer.DiscardUnknown(m) +} + +var xxx_messageInfo_Signer proto.InternalMessageInfo + +type EpochSignerSet 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) { + return fileDescriptor_b7328dc8ffac059e, []int{1} +} +func (m *EpochSignerSet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochSignerSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EpochSignerSet.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 *EpochSignerSet) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochSignerSet.Merge(m, src) +} +func (m *EpochSignerSet) XXX_Size() int { + return m.Size() +} +func (m *EpochSignerSet) XXX_DiscardUnknown() { + xxx_messageInfo_EpochSignerSet.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochSignerSet proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Signer)(nil), "zgc.dasigners.v1.Signer") + proto.RegisterType((*EpochSignerSet)(nil), "zgc.dasigners.v1.EpochSignerSet") +} + +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, 0xb6, 0x9b, 0x97, 0x91, 0x66, 0x31, 0x2d, 0xdb, 0xfa, 0x2f, + 0x4d, 0x3a, 0xec, 0x9e, 0xc2, 0xc7, 0xda, 0x71, 0x47, 0x8f, 0xda, 0xbe, 0x88, 0xb4, 0xa9, 0xcc, + 0x79, 0xcb, 0xef, 0xfb, 0x05, 0x3e, 0xfe, 0x1f, 0xf6, 0xb6, 0x4a, 0xb0, 0x05, 0xd7, 0xb1, 0x4a, + 0x64, 0xa6, 0xd9, 0x26, 0x38, 0x80, 0x9f, 0x66, 0x60, 0xc0, 0xbd, 0xda, 0x2a, 0xe1, 0x1f, 0xc2, + 0x4d, 0x30, 0xe8, 0x0b, 0xd0, 0x6b, 0xd0, 0xf3, 0xc6, 0x33, 0x0b, 0xf6, 0xf3, 0xe0, 0x5a, 0x81, + 0x02, 0x9b, 0xd7, 0xaf, 0x36, 0xed, 0x2b, 0x00, 0xb5, 0x92, 0xac, 0xa1, 0x30, 0x7f, 0x63, 0x3c, + 0x29, 0x5a, 0x45, 0xff, 0xab, 0x45, 0x9e, 0x71, 0x13, 0x43, 0x62, 0xfd, 0xd0, 0xe0, 0xee, 0xac, + 0x69, 0x76, 0x09, 0x3e, 0xe3, 0x42, 0x40, 0x9e, 0x18, 0x82, 0x3c, 0x34, 0xea, 0x4d, 0x7f, 0xd1, + 0xbd, 0xc1, 0x5d, 0x0d, 0x62, 0x29, 0x0d, 0x39, 0x69, 0x44, 0x4b, 0xee, 0x2d, 0xee, 0xa5, 0x79, + 0xb8, 0x94, 0xc5, 0x5c, 0x05, 0xa4, 0xe3, 0xa1, 0xd1, 0xc5, 0xf4, 0xdc, 0x06, 0xcf, 0xc1, 0x5f, + 0x39, 0x21, 0xa7, 0x47, 0x72, 0x32, 0xbc, 0xc3, 0x97, 0x4f, 0x29, 0x88, 0xc8, 0x56, 0xcf, 0xa4, + 0xa9, 0xdb, 0xdb, 0x05, 0x08, 0xf2, 0x3a, 0x75, 0x7b, 0x8b, 0x8f, 0x2f, 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, +} + +func (m *Signer) 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 *Signer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Signer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PubkeyG2) > 0 { + i -= len(m.PubkeyG2) + copy(dAtA[i:], m.PubkeyG2) + i = encodeVarintDasigners(dAtA, i, uint64(len(m.PubkeyG2))) + i-- + dAtA[i] = 0x22 + } + if len(m.PubkeyG1) > 0 { + i -= len(m.PubkeyG1) + copy(dAtA[i:], m.PubkeyG1) + i = encodeVarintDasigners(dAtA, i, uint64(len(m.PubkeyG1))) + i-- + dAtA[i] = 0x1a + } + if len(m.Socket) > 0 { + i -= len(m.Socket) + copy(dAtA[i:], m.Socket) + i = encodeVarintDasigners(dAtA, i, uint64(len(m.Socket))) + i-- + dAtA[i] = 0x12 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintDasigners(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EpochSignerSet) 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 *EpochSignerSet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochSignerSet) 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-- { + i -= len(m.Signers[iNdEx]) + copy(dAtA[i:], m.Signers[iNdEx]) + i = encodeVarintDasigners(dAtA, i, uint64(len(m.Signers[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintDasigners(dAtA []byte, offset int, v uint64) int { + offset -= sovDasigners(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Signer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovDasigners(uint64(l)) + } + l = len(m.Socket) + if l > 0 { + n += 1 + l + sovDasigners(uint64(l)) + } + l = len(m.PubkeyG1) + if l > 0 { + n += 1 + l + sovDasigners(uint64(l)) + } + l = len(m.PubkeyG2) + if l > 0 { + n += 1 + l + sovDasigners(uint64(l)) + } + return n +} + +func (m *EpochSignerSet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Signers) > 0 { + for _, s := range m.Signers { + l = len(s) + n += 1 + l + sovDasigners(uint64(l)) + } + } + return n +} + +func sovDasigners(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDasigners(x uint64) (n int) { + return sovDasigners(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Signer) 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: Signer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Signer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDasigners + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDasigners + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDasigners + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Socket", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDasigners + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDasigners + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDasigners + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Socket = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubkeyG1", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDasigners + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDasigners + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDasigners + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PubkeyG1 = append(m.PubkeyG1[:0], dAtA[iNdEx:postIndex]...) + if m.PubkeyG1 == nil { + m.PubkeyG1 = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubkeyG2", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDasigners + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDasigners + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDasigners + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PubkeyG2 = append(m.PubkeyG2[:0], dAtA[iNdEx:postIndex]...) + if m.PubkeyG2 == nil { + m.PubkeyG2 = []byte{} + } + 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 (m *EpochSignerSet) 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: EpochSignerSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochSignerSet: 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) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDasigners + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDasigners + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDasigners + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex])) + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDasigners + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDasigners + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDasigners + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDasigners + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDasigners + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDasigners + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDasigners = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDasigners = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDasigners = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dasigners/v1/types/errors.go b/x/dasigners/v1/types/errors.go new file mode 100644 index 00000000..f2d5d88f --- /dev/null +++ b/x/dasigners/v1/types/errors.go @@ -0,0 +1,12 @@ +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") +) diff --git a/x/dasigners/v1/types/events.go b/x/dasigners/v1/types/events.go new file mode 100644 index 00000000..00927dae --- /dev/null +++ b/x/dasigners/v1/types/events.go @@ -0,0 +1,11 @@ +package types + +// Module event types +const ( + EventTypeUpdateSigner = "update_signer" + + AttributeKeySigner = "signer" + AttributeKeySocket = "socket" + AttributeKeyPublicKeyG1 = "pubkey_g1" + AttributeKeyPublicKeyG2 = "pubkey_g2" +) diff --git a/x/dasigners/v1/types/genesis.go b/x/dasigners/v1/types/genesis.go new file mode 100644 index 00000000..b3a4c651 --- /dev/null +++ b/x/dasigners/v1/types/genesis.go @@ -0,0 +1,48 @@ +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 { + return &GenesisState{ + Params: params, + EpochNumber: epoch, + Signers: signers, + SignersByEpoch: signersByEpoch, + } +} + +// 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)) +} + +// Validate performs basic validation of genesis data. +func (gs GenesisState) Validate() error { + registered := make(map[string]struct{}) + for _, signer := range gs.Signers { + if err := signer.Validate(); err != nil { + return err + } + registered[signer.Account] = struct{}{} + } + if len(gs.SignersByEpoch) != 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") + } + } + } + return nil +} diff --git a/x/dasigners/v1/types/genesis.pb.go b/x/dasigners/v1/types/genesis.pb.go new file mode 100644 index 00000000..0564b2c4 --- /dev/null +++ b/x/dasigners/v1/types/genesis.pb.go @@ -0,0 +1,775 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/dasigners/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +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"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_896efa766aaca3be, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +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 + } + return "" +} + +func (m *Params) GetMaxVotes() uint64 { + if m != nil { + return m.MaxVotes + } + return 0 +} + +func (m *Params) GetEpochBlocks() uint64 { + if m != nil { + return m.EpochBlocks + } + return 0 +} + +// GenesisState defines the dasigners module's genesis state. +type GenesisState struct { + // params defines all the parameters of related to deposit. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // params epoch_number the epoch number + 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"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_896efa766aaca3be, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetEpochNumber() uint64 { + if m != nil { + return m.EpochNumber + } + return 0 +} + +func (m *GenesisState) GetSigners() []*Signer { + if m != nil { + return m.Signers + } + return nil +} + +func (m *GenesisState) GetSignersByEpoch() []*EpochSignerSet { + if m != nil { + return m.SignersByEpoch + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "zgc.dasigners.v1.Params") + proto.RegisterType((*GenesisState)(nil), "zgc.dasigners.v1.GenesisState") +} + +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, 0xa0, 0x29, 0x91, 0x38, 0x70, 0x89, 0x9c, + 0xf0, 0xc7, 0x8d, 0x56, 0xc7, 0x21, 0x76, 0xaa, 0x26, 0x4f, 0x01, 0x6f, 0xb5, 0xe3, 0x8e, 0x9c, + 0x10, 0x6a, 0x4f, 0xbc, 0x05, 0xea, 0xdf, 0x19, 0x13, 0xeb, 0x6e, 0x7f, 0x7f, 0xbf, 0xcf, 0x9f, + 0x3f, 0xdb, 0x34, 0xe8, 0x65, 0xc1, 0xbf, 0x08, 0x53, 0xca, 0x0a, 0x1a, 0xc3, 0x97, 0x67, 0x5c, + 0x42, 0x05, 0xa6, 0x34, 0x51, 0xdd, 0x68, 0xab, 0xd9, 0x41, 0x2f, 0x8b, 0xe8, 0x1f, 0x8f, 0x96, + 0x67, 0x47, 0x87, 0x85, 0x36, 0x4a, 0x9b, 0x0c, 0x39, 0x77, 0x0b, 0x67, 0x3e, 0x7a, 0x26, 0xb5, + 0xd4, 0x4e, 0xdf, 0x4e, 0x83, 0x7a, 0x28, 0xb5, 0x96, 0x0b, 0xe0, 0xb8, 0xca, 0xdb, 0xaf, 0x5c, + 0x54, 0xdd, 0x80, 0x66, 0x77, 0x91, 0x2d, 0x15, 0x18, 0x2b, 0x54, 0x3d, 0x18, 0xc2, 0x9d, 0x7a, + 0xb7, 0x5d, 0xd0, 0x71, 0xfc, 0x83, 0xd0, 0xc9, 0x85, 0x68, 0x84, 0x32, 0x6c, 0x46, 0xa7, 0xdf, + 0x5a, 0xdd, 0xb4, 0x2a, 0x33, 0x65, 0x0f, 0x3e, 0x09, 0xc9, 0x89, 0x97, 0x50, 0x27, 0xa5, 0x65, + 0x0f, 0xec, 0x25, 0x7d, 0x6a, 0xf5, 0x25, 0x54, 0x26, 0xab, 0xa1, 0xc9, 0x96, 0xda, 0x82, 0xff, + 0x20, 0x24, 0x27, 0x7b, 0xc9, 0x63, 0x27, 0x5f, 0x40, 0xf3, 0x49, 0x5b, 0x60, 0xcf, 0xe9, 0x9e, + 0x12, 0x2b, 0x34, 0x18, 0x7f, 0x8c, 0x31, 0x8f, 0x94, 0x58, 0x6d, 0x99, 0x61, 0x2f, 0xe8, 0x3e, + 0xd4, 0xba, 0x98, 0x67, 0xf9, 0x42, 0x17, 0x97, 0xc6, 0xf7, 0x90, 0x4f, 0x51, 0x8b, 0x51, 0x3a, + 0xfe, 0x43, 0xe8, 0xfe, 0x3b, 0xf7, 0x8c, 0xa9, 0x15, 0x16, 0xd8, 0x1b, 0x3a, 0xa9, 0xb1, 0x23, + 0x96, 0x9a, 0x9e, 0xfb, 0xd1, 0xdd, 0x67, 0x8d, 0xdc, 0x1d, 0x62, 0xef, 0xea, 0xd7, 0x6c, 0x94, + 0x0c, 0xee, 0xdb, 0xb3, 0xaa, 0x56, 0xe5, 0xd0, 0x60, 0xdb, 0x9b, 0xb3, 0x3e, 0xa2, 0xc4, 0xce, + 0xe9, 0xc3, 0x21, 0xc5, 0x1f, 0x87, 0xe3, 0xfb, 0xb3, 0x53, 0x1c, 0x93, 0x1b, 0x23, 0xfb, 0x40, + 0x0f, 0x86, 0x31, 0xcb, 0xbb, 0x0c, 0xd3, 0x7c, 0x0f, 0x37, 0x87, 0xbb, 0x9b, 0xdf, 0x6e, 0xb1, + 0x4b, 0x48, 0xc1, 0x26, 0x4f, 0x06, 0x14, 0x77, 0x08, 0xe2, 0xf7, 0x57, 0xeb, 0x80, 0x5c, 0xaf, + 0x03, 0xf2, 0x7b, 0x1d, 0x90, 0xef, 0x9b, 0x60, 0x74, 0xbd, 0x09, 0x46, 0x3f, 0x37, 0xc1, 0xe8, + 0x33, 0x97, 0xa5, 0x9d, 0xb7, 0x79, 0x54, 0x68, 0xc5, 0x4f, 0xe5, 0x42, 0xe4, 0x86, 0x9f, 0xca, + 0x57, 0xc5, 0x5c, 0x94, 0x15, 0x5f, 0xfd, 0xff, 0xa9, 0xb6, 0xab, 0xc1, 0xe4, 0x13, 0xfc, 0xd1, + 0xd7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x84, 0xf4, 0xab, 0x94, 0x02, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochBlocks != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.EpochBlocks)) + i-- + dAtA[i] = 0x20 + } + if m.MaxVotes != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MaxVotes)) + i-- + dAtA[i] = 0x18 + } + 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 + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SignersByEpoch) > 0 { + for iNdEx := len(m.SignersByEpoch) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SignersByEpoch[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.EpochNumber != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + 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)) + } + if m.MaxVotes != 0 { + n += 1 + sovGenesis(uint64(m.MaxVotes)) + } + if m.EpochBlocks != 0 { + n += 1 + sovGenesis(uint64(m.EpochBlocks)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.EpochNumber != 0 { + n += 1 + sovGenesis(uint64(m.EpochNumber)) + } + if len(m.Signers) > 0 { + for _, e := range m.Signers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.SignersByEpoch) > 0 { + for _, e := range m.SignersByEpoch { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowGenesis + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + 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) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokensPerVote = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVotes", wireType) + } + m.MaxVotes = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxVotes |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochBlocks", wireType) + } + m.EpochBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochBlocks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignersByEpoch", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dasigners/v1/types/hash.go b/x/dasigners/v1/types/hash.go new file mode 100644 index 00000000..75e1cac8 --- /dev/null +++ b/x/dasigners/v1/types/hash.go @@ -0,0 +1,43 @@ +package types + +import ( + "math/big" + + "github.com/0glabs/0g-chain/crypto/bn254util" + "github.com/consensys/gnark-crypto/ecc/bn254" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func PubkeyRegistrationHash(operatorAddress common.Address, chainId *big.Int) *bn254.G1Affine { + toHash := make([]byte, 0) + toHash = append(toHash, operatorAddress.Bytes()...) + // make sure chainId is 32 bytes + toHash = append(toHash, common.LeftPadBytes(chainId.Bytes(), 32)...) + toHash = append(toHash, []byte("0G_BN254_Pubkey_Registration")...) + + msgHash := crypto.Keccak256(toHash) + // convert to [32]byte + var msgHash32 [32]byte + copy(msgHash32[:], msgHash) + + // hash to G1 + return bn254util.MapToCurve(msgHash32) +} + +func EpochRegistrationHash(operatorAddress common.Address, epoch uint64, chainId *big.Int) *bn254.G1Affine { + toHash := make([]byte, 0) + toHash = append(toHash, operatorAddress.Bytes()...) + toHash = append(toHash, sdk.Uint64ToBigEndian(epoch)...) + toHash = append(toHash, common.LeftPadBytes(chainId.Bytes(), 32)...) + + msgHash := crypto.Keccak256(toHash) + // convert to [32]byte + var msgHash32 [32]byte + copy(msgHash32[:], msgHash) + + // hash to G1 + return bn254util.MapToCurve(msgHash32) +} diff --git a/x/dasigners/v1/types/interfaces.go b/x/dasigners/v1/types/interfaces.go new file mode 100644 index 00000000..e7409261 --- /dev/null +++ b/x/dasigners/v1/types/interfaces.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type StakingKeeper interface { + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) +} diff --git a/x/dasigners/v1/types/keys.go b/x/dasigners/v1/types/keys.go new file mode 100644 index 00000000..d49436fc --- /dev/null +++ b/x/dasigners/v1/types/keys.go @@ -0,0 +1,45 @@ +package types + +import ( + "encoding/hex" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName The name that will be used throughout the module + ModuleName = "da-signers" + + // StoreKey Top level store key where all module items will be stored + StoreKey = ModuleName + + // QuerierRoute Top level query string + QuerierRoute = "dasigners" +) + +var ( + // prefix + SignerKeyPrefix = []byte{0x00} + EpochSignerSetKeyPrefix = []byte{0x01} + RegistrationKeyPrefix = []byte{0x02} + + // keys + ParamsKey = []byte{0x05} + EpochNumberKey = []byte{0x06} +) + +func GetSignerKeyFromAccount(account string) ([]byte, error) { + return hex.DecodeString(account) +} + +func GetEpochSignerSetKeyFromEpoch(epoch uint64) []byte { + return sdk.Uint64ToBigEndian(epoch) +} + +func GetEpochRegistrationKeyPrefix(epoch uint64) []byte { + return append(RegistrationKeyPrefix, sdk.Uint64ToBigEndian(epoch)...) +} + +func GetRegistrationKey(account string) ([]byte, error) { + return hex.DecodeString(account) +} diff --git a/x/dasigners/v1/types/msg.go b/x/dasigners/v1/types/msg.go new file mode 100644 index 00000000..6c234f3a --- /dev/null +++ b/x/dasigners/v1/types/msg.go @@ -0,0 +1,96 @@ +package types + +import ( + "encoding/hex" + fmt "fmt" + + "github.com/0glabs/0g-chain/crypto/bn254util" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _, _, _ sdk.Msg = &MsgRegisterSigner{}, &MsgUpdateSocket{}, &MsgRegisterNextEpoch{} + +// GetSigners returns the expected signers for a MsgRegister message. +func (msg *MsgRegisterSigner) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromHex(msg.Signer.Account) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic does a sanity check of the provided data +func (msg *MsgRegisterSigner) ValidateBasic() error { + if err := msg.Signer.Validate(); err != nil { + return err + } + if len(msg.Signature) != bn254util.G1PointSize { + return fmt.Errorf("invalid signature") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgRegisterSigner) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for a MsgVote message. +func (msg *MsgUpdateSocket) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromHex(msg.Account) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic does a sanity check of the provided data +func (msg *MsgUpdateSocket) ValidateBasic() error { + if err := ValidateHexAddress(msg.Account); err != nil { + return err + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgUpdateSocket) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for a MsgVote message. +func (msg *MsgRegisterNextEpoch) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromHex(msg.Account) + if err != nil { + panic(err) + } + accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic does a sanity check of the provided data +func (msg *MsgRegisterNextEpoch) ValidateBasic() error { + if err := ValidateHexAddress(msg.Account); err != nil { + return err + } + if len(msg.Signature) != bn254util.G1PointSize { + return fmt.Errorf("invalid signature") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgRegisterNextEpoch) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} diff --git a/x/dasigners/v1/types/query.pb.go b/x/dasigners/v1/types/query.pb.go new file mode 100644 index 00000000..fac6e645 --- /dev/null +++ b/x/dasigners/v1/types/query.pb.go @@ -0,0 +1,1706 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/dasigners/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QuerySignerRequest struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (m *QuerySignerRequest) Reset() { *m = QuerySignerRequest{} } +func (m *QuerySignerRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySignerRequest) ProtoMessage() {} +func (*QuerySignerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{0} +} +func (m *QuerySignerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySignerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySignerRequest.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 *QuerySignerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySignerRequest.Merge(m, src) +} +func (m *QuerySignerRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySignerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySignerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySignerRequest proto.InternalMessageInfo + +type QuerySignerResponse struct { + Signer *Signer `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *QuerySignerResponse) Reset() { *m = QuerySignerResponse{} } +func (m *QuerySignerResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySignerResponse) ProtoMessage() {} +func (*QuerySignerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{1} +} +func (m *QuerySignerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySignerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySignerResponse.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 *QuerySignerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySignerResponse.Merge(m, src) +} +func (m *QuerySignerResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySignerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySignerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySignerResponse proto.InternalMessageInfo + +type QueryEpochNumberRequest struct { +} + +func (m *QueryEpochNumberRequest) Reset() { *m = QueryEpochNumberRequest{} } +func (m *QueryEpochNumberRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEpochNumberRequest) ProtoMessage() {} +func (*QueryEpochNumberRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{2} +} +func (m *QueryEpochNumberRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochNumberRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochNumberRequest.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 *QueryEpochNumberRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochNumberRequest.Merge(m, src) +} +func (m *QueryEpochNumberRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochNumberRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochNumberRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochNumberRequest proto.InternalMessageInfo + +type QueryEpochNumberResponse struct { + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` +} + +func (m *QueryEpochNumberResponse) Reset() { *m = QueryEpochNumberResponse{} } +func (m *QueryEpochNumberResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochNumberResponse) ProtoMessage() {} +func (*QueryEpochNumberResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{3} +} +func (m *QueryEpochNumberResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochNumberResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochNumberResponse.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 *QueryEpochNumberResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochNumberResponse.Merge(m, src) +} +func (m *QueryEpochNumberResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochNumberResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochNumberResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochNumberResponse proto.InternalMessageInfo + +type QueryEpochSignerSetRequest 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) { + return fileDescriptor_991a610b84b5964c, []int{4} +} +func (m *QueryEpochSignerSetRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochSignerSetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochSignerSetRequest.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 *QueryEpochSignerSetRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochSignerSetRequest.Merge(m, src) +} +func (m *QueryEpochSignerSetRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochSignerSetRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochSignerSetRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochSignerSetRequest proto.InternalMessageInfo + +type QueryEpochSignerSetResponse struct { + Signers []*Signer `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` +} + +func (m *QueryEpochSignerSetResponse) Reset() { *m = QueryEpochSignerSetResponse{} } +func (m *QueryEpochSignerSetResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochSignerSetResponse) ProtoMessage() {} +func (*QueryEpochSignerSetResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{5} +} +func (m *QueryEpochSignerSetResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochSignerSetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochSignerSetResponse.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 *QueryEpochSignerSetResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochSignerSetResponse.Merge(m, src) +} +func (m *QueryEpochSignerSetResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochSignerSetResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochSignerSetResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochSignerSetResponse 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"` +} + +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} +} +func (m *QueryAggregatePubkeyG1Request) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAggregatePubkeyG1Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAggregatePubkeyG1Request.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 *QueryAggregatePubkeyG1Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAggregatePubkeyG1Request.Merge(m, src) +} +func (m *QueryAggregatePubkeyG1Request) XXX_Size() int { + return m.Size() +} +func (m *QueryAggregatePubkeyG1Request) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAggregatePubkeyG1Request.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAggregatePubkeyG1Request proto.InternalMessageInfo + +type QueryAggregatePubkeyG1Response struct { + AggregatePubkeyG1 []byte `protobuf:"bytes,1,opt,name=aggregate_pubkey_g1,json=aggregatePubkeyG1,proto3" json:"aggregate_pubkey_g1,omitempty"` + Total uint64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` + Hit uint64 `protobuf:"varint,3,opt,name=hit,proto3" json:"hit,omitempty"` +} + +func (m *QueryAggregatePubkeyG1Response) Reset() { *m = QueryAggregatePubkeyG1Response{} } +func (m *QueryAggregatePubkeyG1Response) String() string { return proto.CompactTextString(m) } +func (*QueryAggregatePubkeyG1Response) ProtoMessage() {} +func (*QueryAggregatePubkeyG1Response) Descriptor() ([]byte, []int) { + return fileDescriptor_991a610b84b5964c, []int{7} +} +func (m *QueryAggregatePubkeyG1Response) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAggregatePubkeyG1Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAggregatePubkeyG1Response.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 *QueryAggregatePubkeyG1Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAggregatePubkeyG1Response.Merge(m, src) +} +func (m *QueryAggregatePubkeyG1Response) XXX_Size() int { + return m.Size() +} +func (m *QueryAggregatePubkeyG1Response) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAggregatePubkeyG1Response.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAggregatePubkeyG1Response proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QuerySignerRequest)(nil), "zgc.dasigners.v1.QuerySignerRequest") + 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((*QueryAggregatePubkeyG1Request)(nil), "zgc.dasigners.v1.QueryAggregatePubkeyG1Request") + proto.RegisterType((*QueryAggregatePubkeyG1Response)(nil), "zgc.dasigners.v1.QueryAggregatePubkeyG1Response") +} + +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, 0x01, 0xc2, 0x51, 0xc4, 0x38, 0xe6, 0x01, 0x8b, 0x26, 0x39, 0x15, + 0x15, 0x15, 0x37, 0x2f, 0x7d, 0x8b, 0x70, 0xa4, 0xb4, 0x8d, 0xea, 0x7c, 0x88, 0x07, 0x21, 0x49, + 0x38, 0x0e, 0x63, 0x45, 0xa8, 0xe5, 0xac, 0xcf, 0x9c, 0x0a, 0x86, 0xe5, 0x00, 0x78, 0x3e, 0xee, + 0xe6, 0x42, 0xa0, 0x2e, 0xb9, 0x4c, 0x49, 0xc2, 0xa1, 0x0e, 0xd6, 0xb1, 0xef, 0xb3, 0x34, 0xe2, + 0xba, 0x56, 0xd3, 0x8e, 0xfe, 0x73, 0x27, 0x57, 0xeb, 0x0c, 0x6c, 0x67, 0xf8, 0x49, 0xcc, 0xa2, + 0x84, 0xc0, 0x06, 0x58, 0x93, 0x75, 0x05, 0x7f, 0xa3, 0xa5, 0x3b, 0xf3, 0xcf, 0xe2, 0xa8, 0x0c, + 0xc5, 0xb3, 0x2a, 0x60, 0x57, 0x14, 0x7a, 0x1e, 0x33, 0xbf, 0xf3, 0x32, 0x0d, 0xbd, 0xa9, 0xba, + 0xf5, 0x04, 0xe8, 0xf9, 0x90, 0x12, 0x3a, 0x00, 0x65, 0x32, 0x86, 0xdb, 0x91, 0xc0, 0x85, 0xdc, + 0x8a, 0xbb, 0x41, 0x66, 0x54, 0xeb, 0x29, 0x30, 0x66, 0xe9, 0x52, 0xf5, 0x82, 0xf0, 0x49, 0x6b, + 0x0b, 0x14, 0x38, 0x07, 0xf7, 0xff, 0x5a, 0x40, 0x59, 0x68, 0x81, 0x75, 0xd5, 0x96, 0xae, 0xd5, + 0x96, 0xef, 0x6c, 0x76, 0x42, 0xb4, 0x3a, 0x60, 0x5f, 0x94, 0x7c, 0x46, 0x69, 0x8f, 0x50, 0xcc, + 0xc9, 0xab, 0xd4, 0x7b, 0x47, 0x06, 0x67, 0xcd, 0xc5, 0x6d, 0xc1, 0x3a, 0xf8, 0x5f, 0x95, 0x3b, + 0x0d, 0x78, 0x88, 0x63, 0x7d, 0xa9, 0xa6, 0x1d, 0x95, 0xdd, 0x2c, 0x68, 0x5d, 0x01, 0xb3, 0x48, + 0x49, 0xf9, 0x77, 0xc0, 0x36, 0x9e, 0x04, 0xdb, 0xb1, 0x88, 0xb6, 0x69, 0x53, 0x28, 0x96, 0xdd, + 0x2d, 0x3c, 0x9f, 0x07, 0x77, 0xc0, 0x2a, 0x67, 0x1c, 0x77, 0x85, 0xde, 0x8a, 0x2b, 0x2f, 0x70, + 0x13, 0x2c, 0x77, 0x02, 0xae, 0x2f, 0x0b, 0x6c, 0x7c, 0x6c, 0x7d, 0x5d, 0x01, 0xab, 0x42, 0x1a, + 0x7e, 0xd0, 0xc0, 0xc6, 0x1f, 0xc3, 0x83, 0xc7, 0xf9, 0x07, 0x2a, 0x98, 0xbd, 0xf1, 0x68, 0x11, + 0xaa, 0x6c, 0xc4, 0x3a, 0x7c, 0xff, 0xed, 0xd7, 0xa7, 0xa5, 0x2a, 0xdc, 0x47, 0x0d, 0x9a, 0xdd, + 0x72, 0xf1, 0x6c, 0xb6, 0x7c, 0x4a, 0xf8, 0x59, 0x03, 0xf7, 0xb2, 0xa3, 0x84, 0x27, 0x77, 0xa9, + 0xcc, 0xaf, 0x8c, 0x61, 0x2f, 0xc8, 0x56, 0xb6, 0x8e, 0x85, 0xad, 0x07, 0xf0, 0xa0, 0xc0, 0x96, + 0x04, 0xec, 0x84, 0x70, 0xf8, 0x45, 0x03, 0x5b, 0xb9, 0x41, 0x41, 0x54, 0xa0, 0x57, 0xb4, 0x3c, + 0x46, 0x63, 0xf1, 0x04, 0xe5, 0xf1, 0x44, 0x78, 0x7c, 0x08, 0xeb, 0x39, 0x8f, 0xd3, 0xf9, 0xdb, + 0x72, 0x35, 0x6c, 0xda, 0x84, 0x7d, 0xb0, 0x26, 0xdb, 0x84, 0xf5, 0x02, 0xa5, 0xcc, 0xf7, 0x61, + 0x1c, 0xfe, 0x83, 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, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// 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) + AggregatePubkeyG1(ctx context.Context, in *QueryAggregatePubkeyG1Request, opts ...grpc.CallOption) (*QueryAggregatePubkeyG1Response, error) + Signer(ctx context.Context, in *QuerySignerRequest, opts ...grpc.CallOption) (*QuerySignerResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) EpochNumber(ctx context.Context, in *QueryEpochNumberRequest, opts ...grpc.CallOption) (*QueryEpochNumberResponse, error) { + out := new(QueryEpochNumberResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/EpochNumber", in, out, opts...) + if err != nil { + return nil, err + } + 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...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AggregatePubkeyG1(ctx context.Context, in *QueryAggregatePubkeyG1Request, opts ...grpc.CallOption) (*QueryAggregatePubkeyG1Response, error) { + out := new(QueryAggregatePubkeyG1Response) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/AggregatePubkeyG1", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Signer(ctx context.Context, in *QuerySignerRequest, opts ...grpc.CallOption) (*QuerySignerResponse, error) { + out := new(QuerySignerResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Query/Signer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + EpochNumber(context.Context, *QueryEpochNumberRequest) (*QueryEpochNumberResponse, error) + EpochSignerSet(context.Context, *QueryEpochSignerSetRequest) (*QueryEpochSignerSetResponse, error) + AggregatePubkeyG1(context.Context, *QueryAggregatePubkeyG1Request) (*QueryAggregatePubkeyG1Response, error) + Signer(context.Context, *QuerySignerRequest) (*QuerySignerResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +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) AggregatePubkeyG1(ctx context.Context, req *QueryAggregatePubkeyG1Request) (*QueryAggregatePubkeyG1Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method AggregatePubkeyG1 not implemented") +} +func (*UnimplementedQueryServer) Signer(ctx context.Context, req *QuerySignerRequest) (*QuerySignerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Signer not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_EpochNumber_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEpochNumberRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochNumber(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Query/EpochNumber", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochNumber(ctx, req.(*QueryEpochNumberRequest)) + } + 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) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochSignerSet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Query/EpochSignerSet", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochSignerSet(ctx, req.(*QueryEpochSignerSetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AggregatePubkeyG1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAggregatePubkeyG1Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AggregatePubkeyG1(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Query/AggregatePubkeyG1", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AggregatePubkeyG1(ctx, req.(*QueryAggregatePubkeyG1Request)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Signer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySignerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Signer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Query/Signer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Signer(ctx, req.(*QuerySignerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.dasigners.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "EpochNumber", + Handler: _Query_EpochNumber_Handler, + }, + { + MethodName: "EpochSignerSet", + Handler: _Query_EpochSignerSet_Handler, + }, + { + MethodName: "AggregatePubkeyG1", + Handler: _Query_AggregatePubkeyG1_Handler, + }, + { + MethodName: "Signer", + Handler: _Query_Signer_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/dasigners/v1/query.proto", +} + +func (m *QuerySignerRequest) 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 *QuerySignerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySignerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = 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 + } + return len(dAtA) - i, nil +} + +func (m *QuerySignerResponse) 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 *QuerySignerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySignerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Signer != nil { + { + size, err := m.Signer.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryEpochNumberRequest) 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 *QueryEpochNumberRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochNumberRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryEpochNumberResponse) 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 *QueryEpochNumberResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochNumberResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryEpochSignerSetRequest) 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 *QueryEpochSignerSetRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochSignerSetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryEpochSignerSetResponse) 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 *QueryEpochSignerSetResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochSignerSetResponse) 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)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryAggregatePubkeyG1Request) 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 *QueryAggregatePubkeyG1Request) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAggregatePubkeyG1Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = 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))) + i-- + dAtA[i] = 0x12 + } + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryAggregatePubkeyG1Response) 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 *QueryAggregatePubkeyG1Response) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAggregatePubkeyG1Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Hit != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Hit)) + i-- + dAtA[i] = 0x18 + } + if m.Total != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Total)) + i-- + dAtA[i] = 0x10 + } + if len(m.AggregatePubkeyG1) > 0 { + i -= len(m.AggregatePubkeyG1) + copy(dAtA[i:], m.AggregatePubkeyG1) + i = encodeVarintQuery(dAtA, i, uint64(len(m.AggregatePubkeyG1))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QuerySignerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySignerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Signer != nil { + l = m.Signer.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEpochNumberRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryEpochNumberResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + return n +} + +func (m *QueryEpochSignerSetRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + return n +} + +func (m *QueryEpochSignerSetResponse) 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)) + } + } + return n +} + +func (m *QueryAggregatePubkeyG1Request) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + l = len(m.SignersBitmap) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAggregatePubkeyG1Response) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AggregatePubkeyG1) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Total != 0 { + n += 1 + sovQuery(uint64(m.Total)) + } + if m.Hit != 0 { + n += 1 + sovQuery(uint64(m.Hit)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuerySignerRequest) 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: QuerySignerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySignerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 *QuerySignerResponse) 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: QuerySignerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySignerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Signer == nil { + m.Signer = &Signer{} + } + if err := m.Signer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *QueryEpochNumberRequest) 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: QueryEpochNumberRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochNumberRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryEpochNumberResponse) 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: QueryEpochNumberResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochNumberResponse: 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 + } + } + 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 *QueryEpochSignerSetRequest) 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: QueryEpochSignerSetRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochSignerSetRequest: 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 + } + } + 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 *QueryEpochSignerSetResponse) 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: QueryEpochSignerSetResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochSignerSetResponse: 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) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 { + return err + } + iNdEx = postIndex + 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 *QueryAggregatePubkeyG1Request) 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: QueryAggregatePubkeyG1Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAggregatePubkeyG1Request: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignersBitmap", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SignersBitmap = append(m.SignersBitmap[:0], dAtA[iNdEx:postIndex]...) + if m.SignersBitmap == nil { + m.SignersBitmap = []byte{} + } + iNdEx = postIndex + 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 *QueryAggregatePubkeyG1Response) 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: QueryAggregatePubkeyG1Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAggregatePubkeyG1Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AggregatePubkeyG1", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AggregatePubkeyG1 = append(m.AggregatePubkeyG1[:0], dAtA[iNdEx:postIndex]...) + if m.AggregatePubkeyG1 == nil { + m.AggregatePubkeyG1 = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) + } + m.Total = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Total |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Hit", wireType) + } + m.Hit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Hit |= 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 skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/dasigners/v1/types/query.pb.gw.go b/x/dasigners/v1/types/query.pb.gw.go new file mode 100644 index 00000000..362db812 --- /dev/null +++ b/x/dasigners/v1/types/query.pb.gw.go @@ -0,0 +1,402 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: zgc/dasigners/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_EpochNumber_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochNumberRequest + var metadata runtime.ServerMetadata + + msg, err := client.EpochNumber(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_EpochNumber_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryEpochNumberRequest + var metadata runtime.ServerMetadata + + msg, err := server.EpochNumber(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_EpochSignerSet_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 + 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 { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.EpochSignerSet(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 + 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 { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.EpochSignerSet(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AggregatePubkeyG1_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_AggregatePubkeyG1_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAggregatePubkeyG1Request + 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_AggregatePubkeyG1_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AggregatePubkeyG1(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AggregatePubkeyG1_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAggregatePubkeyG1Request + 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_AggregatePubkeyG1_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AggregatePubkeyG1(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Signer_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Signer_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySignerRequest + 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_Signer_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Signer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Signer_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySignerRequest + 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_Signer_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Signer(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_EpochNumber_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_EpochNumber_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_EpochNumber_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EpochSignerSet_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_EpochSignerSet_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_EpochSignerSet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AggregatePubkeyG1_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_AggregatePubkeyG1_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_AggregatePubkeyG1_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Signer_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_Signer_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_Signer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_EpochNumber_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_EpochNumber_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_EpochNumber_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_EpochSignerSet_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_EpochSignerSet_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()...) + + }) + + mux.Handle("GET", pattern_Query_AggregatePubkeyG1_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_AggregatePubkeyG1_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_AggregatePubkeyG1_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Signer_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_Signer_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_Signer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +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_AggregatePubkeyG1_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "aggregate-pubkey-g1"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Signer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0g", "dasigners", "v1", "signer"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_EpochNumber_0 = runtime.ForwardResponseMessage + + forward_Query_EpochSignerSet_0 = runtime.ForwardResponseMessage + + forward_Query_AggregatePubkeyG1_0 = runtime.ForwardResponseMessage + + forward_Query_Signer_0 = runtime.ForwardResponseMessage +) diff --git a/x/dasigners/v1/types/signer.go b/x/dasigners/v1/types/signer.go new file mode 100644 index 00000000..77c19b08 --- /dev/null +++ b/x/dasigners/v1/types/signer.go @@ -0,0 +1,55 @@ +package types + +import ( + "encoding/hex" + fmt "fmt" + + "github.com/0glabs/0g-chain/crypto/bn254util" + "github.com/consensys/gnark-crypto/ecc/bn254" +) + +func ValidateHexAddress(account string) error { + addr, err := hex.DecodeString(account) + if err != nil { + return err + } + if len(addr) != 20 { + return fmt.Errorf("invalid address length") + } + return nil +} + +func (s *Signer) Validate() error { + if len(s.PubkeyG1) != bn254util.G1PointSize { + return fmt.Errorf("invalid G1 pubkey length") + } + if len(s.PubkeyG2) != bn254util.G2PointSize { + return fmt.Errorf("invalid G2 pubkey length") + } + if err := ValidateHexAddress(s.Account); err != nil { + return err + } + return nil +} + +func (s *Signer) ValidateSignature(hash *bn254.G1Affine, signature *bn254.G1Affine) bool { + pubkeyG1 := bn254util.DeserializeG1(s.PubkeyG1) + pubkeyG2 := bn254util.DeserializeG2(s.PubkeyG2) + gamma := bn254util.Gamma(hash, signature, pubkeyG1, pubkeyG2) + + // pairing + P := [2]bn254.G1Affine{ + *new(bn254.G1Affine).Add(signature, new(bn254.G1Affine).ScalarMultiplication(pubkeyG1, gamma)), + *new(bn254.G1Affine).Add(hash, new(bn254.G1Affine).ScalarMultiplication(bn254util.GetG1Generator(), gamma)), + } + Q := [2]bn254.G2Affine{ + *new(bn254.G2Affine).Neg(bn254util.GetG2Generator()), + *pubkeyG2, + } + + ok, err := bn254.PairingCheck(P[:], Q[:]) + if err != nil { + return false + } + return ok +} diff --git a/x/dasigners/v1/types/tx.pb.go b/x/dasigners/v1/types/tx.pb.go new file mode 100644 index 00000000..66132018 --- /dev/null +++ b/x/dasigners/v1/types/tx.pb.go @@ -0,0 +1,1312 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/dasigners/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/0glabs/0g-chain/x/das/v1/types" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgRegisterSigner struct { + Signer *Signer `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *MsgRegisterSigner) Reset() { *m = MsgRegisterSigner{} } +func (m *MsgRegisterSigner) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterSigner) ProtoMessage() {} +func (*MsgRegisterSigner) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{0} +} +func (m *MsgRegisterSigner) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterSigner) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterSigner.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 *MsgRegisterSigner) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterSigner.Merge(m, src) +} +func (m *MsgRegisterSigner) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterSigner) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterSigner.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterSigner proto.InternalMessageInfo + +type MsgRegisterSignerResponse struct { +} + +func (m *MsgRegisterSignerResponse) Reset() { *m = MsgRegisterSignerResponse{} } +func (m *MsgRegisterSignerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterSignerResponse) ProtoMessage() {} +func (*MsgRegisterSignerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{1} +} +func (m *MsgRegisterSignerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterSignerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterSignerResponse.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 *MsgRegisterSignerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterSignerResponse.Merge(m, src) +} +func (m *MsgRegisterSignerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterSignerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterSignerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterSignerResponse proto.InternalMessageInfo + +type MsgUpdateSocket struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Socket string `protobuf:"bytes,2,opt,name=socket,proto3" json:"socket,omitempty"` +} + +func (m *MsgUpdateSocket) Reset() { *m = MsgUpdateSocket{} } +func (m *MsgUpdateSocket) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSocket) ProtoMessage() {} +func (*MsgUpdateSocket) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{2} +} +func (m *MsgUpdateSocket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSocket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSocket.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 *MsgUpdateSocket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSocket.Merge(m, src) +} +func (m *MsgUpdateSocket) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSocket) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSocket.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSocket proto.InternalMessageInfo + +type MsgUpdateSocketResponse struct { +} + +func (m *MsgUpdateSocketResponse) Reset() { *m = MsgUpdateSocketResponse{} } +func (m *MsgUpdateSocketResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSocketResponse) ProtoMessage() {} +func (*MsgUpdateSocketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{3} +} +func (m *MsgUpdateSocketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSocketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSocketResponse.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 *MsgUpdateSocketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSocketResponse.Merge(m, src) +} +func (m *MsgUpdateSocketResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSocketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSocketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSocketResponse proto.InternalMessageInfo + +type MsgRegisterNextEpoch struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *MsgRegisterNextEpoch) Reset() { *m = MsgRegisterNextEpoch{} } +func (m *MsgRegisterNextEpoch) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterNextEpoch) ProtoMessage() {} +func (*MsgRegisterNextEpoch) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{4} +} +func (m *MsgRegisterNextEpoch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterNextEpoch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterNextEpoch.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 *MsgRegisterNextEpoch) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterNextEpoch.Merge(m, src) +} +func (m *MsgRegisterNextEpoch) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterNextEpoch) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterNextEpoch.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterNextEpoch proto.InternalMessageInfo + +type MsgRegisterNextEpochResponse struct { +} + +func (m *MsgRegisterNextEpochResponse) Reset() { *m = MsgRegisterNextEpochResponse{} } +func (m *MsgRegisterNextEpochResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterNextEpochResponse) ProtoMessage() {} +func (*MsgRegisterNextEpochResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8bfa0cc0bd2f98e0, []int{5} +} +func (m *MsgRegisterNextEpochResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterNextEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterNextEpochResponse.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 *MsgRegisterNextEpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterNextEpochResponse.Merge(m, src) +} +func (m *MsgRegisterNextEpochResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterNextEpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterNextEpochResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterNextEpochResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgRegisterSigner)(nil), "zgc.dasigners.v1.MsgRegisterSigner") + proto.RegisterType((*MsgRegisterSignerResponse)(nil), "zgc.dasigners.v1.MsgRegisterSignerResponse") + proto.RegisterType((*MsgUpdateSocket)(nil), "zgc.dasigners.v1.MsgUpdateSocket") + proto.RegisterType((*MsgUpdateSocketResponse)(nil), "zgc.dasigners.v1.MsgUpdateSocketResponse") + proto.RegisterType((*MsgRegisterNextEpoch)(nil), "zgc.dasigners.v1.MsgRegisterNextEpoch") + proto.RegisterType((*MsgRegisterNextEpochResponse)(nil), "zgc.dasigners.v1.MsgRegisterNextEpochResponse") +} + +func init() { proto.RegisterFile("zgc/dasigners/v1/tx.proto", fileDescriptor_8bfa0cc0bd2f98e0) } + +var fileDescriptor_8bfa0cc0bd2f98e0 = []byte{ + // 410 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0xae, 0xd2, 0x40, + 0x18, 0xc5, 0x5b, 0x4c, 0x30, 0x8c, 0x44, 0xa5, 0x21, 0xda, 0x56, 0x32, 0xc1, 0x9a, 0x18, 0x8c, + 0xb1, 0x03, 0xf8, 0x06, 0x1a, 0x97, 0x65, 0x51, 0xe2, 0xc6, 0x98, 0x98, 0x76, 0x18, 0x87, 0x06, + 0xe8, 0x34, 0x9d, 0x29, 0x01, 0x9e, 0xc2, 0x87, 0xf1, 0x21, 0x58, 0xb2, 0x74, 0xe9, 0x85, 0x17, + 0xb9, 0x61, 0xfa, 0x07, 0x6e, 0x4b, 0xb8, 0xec, 0xe6, 0x9b, 0xef, 0xd7, 0x73, 0x4e, 0x4f, 0x5a, + 0x60, 0x6c, 0x28, 0x46, 0x13, 0x8f, 0x07, 0x34, 0x24, 0x31, 0x47, 0xcb, 0x01, 0x12, 0x2b, 0x3b, + 0x8a, 0x99, 0x60, 0xda, 0xcb, 0x0d, 0xc5, 0x76, 0xb1, 0xb2, 0x97, 0x03, 0xd3, 0xc0, 0x8c, 0x2f, + 0x18, 0xff, 0x25, 0xf7, 0x28, 0x1d, 0x52, 0xd8, 0x6c, 0x53, 0x46, 0x59, 0x7a, 0x7f, 0x3c, 0x65, + 0xb7, 0x06, 0x65, 0x8c, 0xce, 0x09, 0x92, 0x93, 0x9f, 0xfc, 0x46, 0x5e, 0xb8, 0xce, 0x56, 0x7a, + 0x66, 0x7c, 0xb4, 0xa4, 0x24, 0x24, 0x3c, 0xc8, 0xa5, 0xba, 0x95, 0x48, 0xa7, 0x10, 0x92, 0xb0, + 0x30, 0x68, 0x39, 0x9c, 0xba, 0x84, 0x06, 0x5c, 0x90, 0x78, 0x2c, 0x77, 0x5a, 0x1f, 0xd4, 0x53, + 0x4a, 0x57, 0xbb, 0x6a, 0xef, 0xd9, 0x50, 0xb7, 0xcb, 0xf9, 0xed, 0x94, 0x74, 0x33, 0x4e, 0xeb, + 0x80, 0xc6, 0xf1, 0xe4, 0x89, 0x24, 0x26, 0x7a, 0xad, 0xab, 0xf6, 0x9a, 0xee, 0xe9, 0xc2, 0x7a, + 0x03, 0x8c, 0x8a, 0x89, 0x4b, 0x78, 0xc4, 0x42, 0x4e, 0xac, 0xaf, 0xe0, 0x85, 0xc3, 0xe9, 0xf7, + 0x68, 0xe2, 0x09, 0x32, 0x66, 0x78, 0x46, 0x84, 0xa6, 0x83, 0xa7, 0x1e, 0xc6, 0x2c, 0x09, 0x85, + 0x0c, 0xd0, 0x70, 0xf3, 0x51, 0x7b, 0x05, 0xea, 0x5c, 0x32, 0xd2, 0xa4, 0xe1, 0x66, 0x93, 0x65, + 0x80, 0xd7, 0x25, 0x91, 0x42, 0x7f, 0x04, 0xda, 0x67, 0xe6, 0x23, 0xb2, 0x12, 0xdf, 0x22, 0x86, + 0xa7, 0x57, 0x4c, 0xae, 0xbf, 0x0c, 0x04, 0x9d, 0x4b, 0x7a, 0xb9, 0xdf, 0xf0, 0x6f, 0x0d, 0x3c, + 0x71, 0x38, 0xd5, 0x7c, 0xf0, 0xbc, 0x54, 0xeb, 0xbb, 0x6a, 0x8d, 0x95, 0x5a, 0xcc, 0x8f, 0x37, + 0x40, 0xb9, 0x97, 0xf6, 0x13, 0x34, 0x1f, 0x14, 0xf7, 0xf6, 0xe2, 0xc3, 0xe7, 0x88, 0xf9, 0xe1, + 0x51, 0xa4, 0x50, 0x9f, 0x81, 0x56, 0xb5, 0xb6, 0xf7, 0x57, 0xf3, 0x15, 0x9c, 0x69, 0xdf, 0xc6, + 0xe5, 0x66, 0x5f, 0x9c, 0xed, 0x1d, 0x54, 0xb6, 0x7b, 0xa8, 0xee, 0xf6, 0x50, 0xfd, 0xbf, 0x87, + 0xea, 0x9f, 0x03, 0x54, 0x76, 0x07, 0xa8, 0xfc, 0x3b, 0x40, 0xe5, 0x07, 0xa2, 0x81, 0x98, 0x26, + 0xbe, 0x8d, 0xd9, 0x02, 0xf5, 0xe9, 0xdc, 0xf3, 0x39, 0xea, 0xd3, 0x4f, 0x78, 0xea, 0x05, 0x21, + 0x5a, 0x95, 0x7e, 0xba, 0x75, 0x44, 0xb8, 0x5f, 0x97, 0x9f, 0xf7, 0xe7, 0xfb, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xa3, 0x4c, 0x19, 0x64, 0x95, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + RegisterSigner(ctx context.Context, in *MsgRegisterSigner, opts ...grpc.CallOption) (*MsgRegisterSignerResponse, error) + UpdateSocket(ctx context.Context, in *MsgUpdateSocket, opts ...grpc.CallOption) (*MsgUpdateSocketResponse, error) + RegisterNextEpoch(ctx context.Context, in *MsgRegisterNextEpoch, opts ...grpc.CallOption) (*MsgRegisterNextEpochResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) RegisterSigner(ctx context.Context, in *MsgRegisterSigner, opts ...grpc.CallOption) (*MsgRegisterSignerResponse, error) { + out := new(MsgRegisterSignerResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Msg/RegisterSigner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateSocket(ctx context.Context, in *MsgUpdateSocket, opts ...grpc.CallOption) (*MsgUpdateSocketResponse, error) { + out := new(MsgUpdateSocketResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Msg/UpdateSocket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RegisterNextEpoch(ctx context.Context, in *MsgRegisterNextEpoch, opts ...grpc.CallOption) (*MsgRegisterNextEpochResponse, error) { + out := new(MsgRegisterNextEpochResponse) + err := c.cc.Invoke(ctx, "/zgc.dasigners.v1.Msg/RegisterNextEpoch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + RegisterSigner(context.Context, *MsgRegisterSigner) (*MsgRegisterSignerResponse, error) + UpdateSocket(context.Context, *MsgUpdateSocket) (*MsgUpdateSocketResponse, error) + RegisterNextEpoch(context.Context, *MsgRegisterNextEpoch) (*MsgRegisterNextEpochResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) RegisterSigner(ctx context.Context, req *MsgRegisterSigner) (*MsgRegisterSignerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterSigner not implemented") +} +func (*UnimplementedMsgServer) UpdateSocket(ctx context.Context, req *MsgUpdateSocket) (*MsgUpdateSocketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSocket not implemented") +} +func (*UnimplementedMsgServer) RegisterNextEpoch(ctx context.Context, req *MsgRegisterNextEpoch) (*MsgRegisterNextEpochResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterNextEpoch not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_RegisterSigner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterSigner) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterSigner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Msg/RegisterSigner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterSigner(ctx, req.(*MsgRegisterSigner)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateSocket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateSocket) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSocket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Msg/UpdateSocket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSocket(ctx, req.(*MsgUpdateSocket)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RegisterNextEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterNextEpoch) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterNextEpoch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.dasigners.v1.Msg/RegisterNextEpoch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterNextEpoch(ctx, req.(*MsgRegisterNextEpoch)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.dasigners.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterSigner", + Handler: _Msg_RegisterSigner_Handler, + }, + { + MethodName: "UpdateSocket", + Handler: _Msg_UpdateSocket_Handler, + }, + { + MethodName: "RegisterNextEpoch", + Handler: _Msg_RegisterNextEpoch_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/dasigners/v1/tx.proto", +} + +func (m *MsgRegisterSigner) 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 *MsgRegisterSigner) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterSigner) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if m.Signer != nil { + { + size, err := m.Signer.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterSignerResponse) 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 *MsgRegisterSignerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterSignerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSocket) 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 *MsgUpdateSocket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSocket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Socket) > 0 { + i -= len(m.Socket) + copy(dAtA[i:], m.Socket) + i = encodeVarintTx(dAtA, i, uint64(len(m.Socket))) + i-- + dAtA[i] = 0x12 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintTx(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSocketResponse) 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 *MsgUpdateSocketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSocketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRegisterNextEpoch) 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 *MsgRegisterNextEpoch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterNextEpoch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintTx(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterNextEpochResponse) 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 *MsgRegisterNextEpochResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterNextEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterSigner) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Signer != nil { + l = m.Signer.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterSignerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateSocket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Socket) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateSocketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRegisterNextEpoch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterNextEpochResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegisterSigner) 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 ErrIntOverflowTx + } + 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: MsgRegisterSigner: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterSigner: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Signer == nil { + m.Signer = &Signer{} + } + if err := m.Signer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterSignerResponse) 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 ErrIntOverflowTx + } + 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: MsgRegisterSignerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterSignerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSocket) 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 ErrIntOverflowTx + } + 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: MsgUpdateSocket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSocket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Socket", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Socket = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSocketResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateSocketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSocketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterNextEpoch) 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 ErrIntOverflowTx + } + 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: MsgRegisterNextEpoch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterNextEpoch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterNextEpochResponse) 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 ErrIntOverflowTx + } + 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: MsgRegisterNextEpochResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterNextEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)