diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc11ad0f..5728ffa4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: args: chain build --release --release.prefix ${{ steps.vars.outputs.tarball_prefix }} -t linux:amd64 -t darwin:amd64 -t darwin:arm64 - name: Delete the "latest" Release - uses: dev-drprasad/delete-tag-and-release@v0.2.0 + uses: dev-drprasad/delete-tag-and-release@v0.2.1 if: ${{ steps.vars.outputs.is_release_type_latest == 'true' }} with: tag_name: ${{ steps.vars.outputs.tag_name }} diff --git a/.gitignore b/.gitignore index 27649c1d..8f6c3c66 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build/ gentx/ DistributedIBE/ *.json +encrypter \ No newline at end of file diff --git a/app/app.go b/app/app.go index be750b5b..a12f2aa3 100644 --- a/app/app.go +++ b/app/app.go @@ -514,8 +514,14 @@ func New( keys[fairyringmoduletypes.StoreKey], keys[fairyringmoduletypes.MemStoreKey], app.GetSubspace(fairyringmoduletypes.ModuleName), + app.StakingKeeper, + ) + fairyringModule := fairyringmodule.NewAppModule( + appCodec, + app.FairyringKeeper, + app.AccountKeeper, + app.BankKeeper, ) - fairyringModule := fairyringmodule.NewAppModule(appCodec, app.FairyringKeeper, app.AccountKeeper, app.BankKeeper) scopedFairblockKeeper := app.CapabilityKeeper.ScopeToModule(fairblockmoduletypes.ModuleName) app.ScopedFairblockKeeper = scopedFairblockKeeper diff --git a/create_multi_sign_account.sh b/create_multi_sign_account.sh new file mode 100755 index 00000000..0f0bb79f --- /dev/null +++ b/create_multi_sign_account.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +die () { + echo >&2 "$@" + exit 1 +} + +[ "$#" -eq 3 ] || die "3 argument required, $# provided, Usage: ./create_multi_sign_account {acc1,acc2...} {multi sig account name} {threshold}" + +echo $3 | grep -E -q '^[0-9]+$' || die "Numeric argument required, $3 provided" + +IFS=',' read -ra ACCOUNTS_ARR <<< "$1" + +[ $3 -le ${#ACCOUNTS_ARR[@]} ] || die "Invalid threshold, threshold must be less or equals to the number of accounts. $3 provided as threshold but ${#ACCOUNTS_ARR[@]} accounts provided." + +ALICE_ADDRESS=`fairyringd keys show alice | grep "address:" | sed 's/^.*: //'` + +for EACH_ACCOUNT in "${ACCOUNTS_ARR[@]}" +do + fairyringd keys add $EACH_ACCOUNT + EACH_ADDRESS=`fairyringd keys show $EACH_ACCOUNT | grep "address:" | sed 's/^.*: //'` + fairyringd tx bank send $ALICE_ADDRESS $EACH_ADDRESS 100frt --from alice --yes +done + +fairyringd keys add $2 --multisig $1 --multisig-threshold $3 + +MULTI_SIGN_ADDRESS=`fairyringd keys show $2 | grep "address:" | sed 's/^.*: //'` + +fairyringd tx bank send $ALICE_ADDRESS $MULTI_SIGN_ADDRESS 100frt --from alice --yes \ No newline at end of file diff --git a/fairyring.yml b/fairyring.yml index 15288ddc..471b905d 100644 --- a/fairyring.yml +++ b/fairyring.yml @@ -8,16 +8,16 @@ build: accounts: - name: alice coins: - - 1000token + - 100000000frt - 100000000stake - name: bob coins: - - 500token + - 100000000frt - 100000000stake faucet: name: bob coins: - - 5token + - 100000frt - 100000stake host: 0.0.0.0:4500 genesis: diff --git a/go.mod b/go.mod index b914f655..48227239 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( DistributedIBE v0.0.0 - cosmossdk.io/math v1.0.0-beta.3 + cosmossdk.io/math v1.0.0 github.com/cosmos/cosmos-sdk v0.46.3 github.com/cosmos/ibc-go/v5 v5.0.0 github.com/drand/kyber v1.1.17 @@ -16,7 +16,7 @@ require ( github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.2 github.com/tendermint/tendermint v0.34.22 github.com/tendermint/tm-db v0.6.7 google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 @@ -190,7 +190,7 @@ require ( go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.5.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect + golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect diff --git a/go.sum b/go.sum index 9b29e97d..7cc05851 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= -cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= +cosmossdk.io/math v1.0.0 h1:ro9w7eKx23om2tZz/VM2Pf+z2WAbGX1yDQQOJ6iGeJw= +cosmossdk.io/math v1.0.0/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/age v1.1.1 h1:pIpO7l151hCnQ4BdyBujnGP2YlUo0uj6sAVNHGBvXHg= filippo.io/age v1.1.1/go.mod h1:l03SrzDUrBkdBx8+IILdnn2KZysqQdbEBUQ4p3sqEQE= @@ -923,7 +923,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -1327,8 +1327,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1491,8 +1492,8 @@ 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-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o= +golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= diff --git a/proto/fairyring/fairblock/fairblock_executed_nonce.proto b/proto/fairyring/fairblock/fairblock_executed_nonce.proto deleted file mode 100644 index ad0bdcff..00000000 --- a/proto/fairyring/fairblock/fairblock_executed_nonce.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package fairyring.fairblock; - -option go_package = "fairyring/x/fairblock/types"; - -message FairblockExecutedNonce { - string address = 1; - uint64 nonce = 2; - -} - diff --git a/proto/fairyring/fairblock/genesis.proto b/proto/fairyring/fairblock/genesis.proto index 252f5411..b78c40fe 100644 --- a/proto/fairyring/fairblock/genesis.proto +++ b/proto/fairyring/fairblock/genesis.proto @@ -6,7 +6,6 @@ import "gogoproto/gogo.proto"; import "fairyring/fairblock/params.proto"; import "fairyring/fairblock/encrypted_tx.proto"; import "fairyring/fairblock/fairblock_nonce.proto"; -import "fairyring/fairblock/fairblock_executed_nonce.proto"; import "fairyring/fairblock/aggregated_key_share.proto"; // this line is used by starport scaffolding # genesis/proto/import @@ -19,9 +18,8 @@ message GenesisState { string port_id = 2; repeated EncryptedTxArray encryptedTxArray = 3 [(gogoproto.nullable) = false]; repeated FairblockNonce fairblockNonceList = 4 [(gogoproto.nullable) = false]; - repeated FairblockExecutedNonce fairblockExecutedNonceList = 5 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state - repeated AggregatedKeyShare aggregatedKeyShareList = 6 [(gogoproto.nullable) = false]; + repeated AggregatedKeyShare aggregatedKeyShareList = 5 [(gogoproto.nullable) = false]; } diff --git a/proto/fairyring/fairblock/query.proto b/proto/fairyring/fairblock/query.proto index cff1be18..14e0be49 100644 --- a/proto/fairyring/fairblock/query.proto +++ b/proto/fairyring/fairblock/query.proto @@ -8,7 +8,6 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "fairyring/fairblock/params.proto"; import "fairyring/fairblock/encrypted_tx.proto"; import "fairyring/fairblock/fairblock_nonce.proto"; -import "fairyring/fairblock/fairblock_executed_nonce.proto"; import "fairyring/fairblock/aggregated_key_share.proto"; // this line is used by starport scaffolding # 1 @@ -59,18 +58,6 @@ service Query { option (google.api.http).get = "/fairyring/fairblock/fairblock_nonce"; } - - // Queries a FairblockExecutedNonce by index. - rpc FairblockExecutedNonce (QueryGetFairblockExecutedNonceRequest) returns (QueryGetFairblockExecutedNonceResponse) { - option (google.api.http).get = "/fairyring/fairblock/fairblock_executed_nonce/{address}"; - - } - - // Queries a list of FairblockExecutedNonce items. - rpc FairblockExecutedNonceAll (QueryAllFairblockExecutedNonceRequest) returns (QueryAllFairblockExecutedNonceResponse) { - option (google.api.http).get = "/fairyring/fairblock/fairblock_executed_nonce"; - - } // this line is used by starport scaffolding # 2 } @@ -133,21 +120,4 @@ message QueryAllFairblockNonceResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryGetFairblockExecutedNonceRequest { - string address = 1; -} - -message QueryGetFairblockExecutedNonceResponse { - FairblockExecutedNonce fairblockExecutedNonce = 1 [(gogoproto.nullable) = false]; -} - -message QueryAllFairblockExecutedNonceRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -message QueryAllFairblockExecutedNonceResponse { - repeated FairblockExecutedNonce fairblockExecutedNonce = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - // this line is used by starport scaffolding # 3 \ No newline at end of file diff --git a/proto/fairyring/fairyring/validator_set.proto b/proto/fairyring/fairyring/validator_set.proto index 6799540f..e6a79343 100644 --- a/proto/fairyring/fairyring/validator_set.proto +++ b/proto/fairyring/fairyring/validator_set.proto @@ -5,8 +5,8 @@ option go_package = "fairyring/x/fairyring/types"; message ValidatorSet { string index = 1; - string validator = 2; - bool isActive = 3; - + string validator = 2; + string consAddr = 3; + bool isActive = 4; } diff --git a/test_submit_multi_sig_tx.sh b/test_submit_multi_sig_tx.sh new file mode 100755 index 00000000..6140c3c8 --- /dev/null +++ b/test_submit_multi_sig_tx.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +die () { + echo >&2 "$@" + exit 1 +} + +[ "$#" -eq 6 ] || die "5 argument required, $# provided, Usage: ./test_submit_multi_sig_tx {acc1,acc2...} {multi sig account} {sender account} {tx_target_height} {to_address} {amount}" + +echo $4 | grep -E -q '^[0-9]+$' || die "Numeric argument required, $4 provided" + +ACCOUNT_NAME=$2 +CHAIN_ID="fairyring" +UNSIGNED_TX_FILE_NAME="script_multi_sig_unsigned.json" +SIGNED_TX_FILE_NAME="script_multi_sig_signed.json" + +# Get the address of target account name +MULTI_SIG_ADDRESS=`fairyringd keys show $ACCOUNT_NAME -a` + +# Create the unsigned tx data +fairyringd tx bank send $MULTI_SIG_ADDRESS $5 $6 --chain-id $CHAIN_ID --generate-only --yes > $UNSIGNED_TX_FILE_NAME + +SIGNED_TX_FILE_LIST="" + +IFS=',' read -ra ACCOUNTS_ARR <<< "$1" + +MULTI_SIG_ACCOUNT_NUMBER=`fairyringd q account $MULTI_SIG_ADDRESS | grep "account_number: " | sed 's/^.*: //'` +MULTI_SIG_ACCOUNT_NUMBER=`sed -e 's/^"//' -e 's/"$//' <<< "$MULTI_SIG_ACCOUNT_NUMBER"` + +ACCOUNT_FAIRBLOCK_NONCE=`fairyringd query fairblock show-fairblock-nonce $MULTI_SIG_ADDRESS | grep "nonce:" | sed 's/^.*: //'` + +if [ -z "${ACCOUNT_FAIRBLOCK_NONCE}" ]; then + die "Fairblock Nonce not found" +else # else, remove the string quote from the result + ACCOUNT_FAIRBLOCK_NONCE=`sed -e 's/^"//' -e 's/"$//' <<< "$ACCOUNT_FAIRBLOCK_NONCE"` +fi + +for EACH_ACCOUNT in "${ACCOUNTS_ARR[@]}" +do + EACH_ADDRESS=`fairyringd keys show $EACH_ACCOUNT -a` + + #EACH_SIGNED_DATA=`fairyringd tx sign $UNSIGNED_TX_FILE_NAME --multisig $ACCOUNT_NAME --from $EACH_ACCOUNT --offline --account-number $MULTI_SIG_ACCOUNT_NUMBER --sequence $ACCOUNT_FAIRBLOCK_NONCE --chain-id $CHAIN_ID --yes --output-document $EACH_ACCOUNT$SIGNED_TX_FILE_NAME` + EACH_SIGNED_DATA=`fairyringd tx sign $UNSIGNED_TX_FILE_NAME --multisig $ACCOUNT_NAME --from $EACH_ACCOUNT --chain-id $CHAIN_ID --yes --output-document $EACH_ACCOUNT$SIGNED_TX_FILE_NAME` + + SIGNED_TX_FILE_LIST="$SIGNED_TX_FILE_LIST $EACH_ACCOUNT$SIGNED_TX_FILE_NAME" +done + +#FINAL_SIGNED_DATA=`fairyringd tx multisign $UNSIGNED_TX_FILE_NAME $ACCOUNT_NAME $SIGNED_TX_FILE_LIST --offline --account-number $MULTI_SIG_ACCOUNT_NUMBER --sequence $ACCOUNT_FAIRBLOCK_NONCE --chain-id $CHAIN_ID --yes` +FINAL_SIGNED_DATA=`fairyringd tx multisign $UNSIGNED_TX_FILE_NAME $ACCOUNT_NAME $SIGNED_TX_FILE_LIST --chain-id $CHAIN_ID --yes` +echo $FINAL_SIGNED_DATA +PUB_KEY=`fairyringd q fairyring show-latest-pub-key | grep "publicKey: " | sed 's/^.*: //'` + +CIPHER=`./encrypter $4 $PUB_KEY $FINAL_SIGNED_DATA` + +# Submit encrypted tx with the signed data +fairyringd tx fairblock submit-encrypted-tx $CIPHER $4 --from $3 --yes + +rm $SIGNED_TX_FILE_LIST $UNSIGNED_TX_FILE_NAME + +printf "\nRun 'fairyringd query bank balances $5' to check target account balance later\n" \ No newline at end of file diff --git a/test_submit_tx.sh b/test_submit_tx.sh index 8a802fef..0c0381b5 100755 --- a/test_submit_tx.sh +++ b/test_submit_tx.sh @@ -5,7 +5,7 @@ die () { exit 1 } -[ "$#" -eq 1 ] || die "1 argument required, $# provided, Usage: ./test_tx_execution {tx_target_height}" +[ "$#" -eq 3 ] || die "3 argument required, $# provided, Usage: ./test_tx_execution {tx_target_height} {to_address} {amount}" echo $1 | grep -E -q '^[0-9]+$' || die "Numeric argument required, $1 provided" @@ -20,10 +20,9 @@ ADDRESS=`fairyringd keys show $ACCOUNT_NAME | grep "address:" | sed 's/^.*: //'` # Get the fairblock nonce of target account address FairblockNonce=`fairyringd query fairblock show-fairblock-nonce $ADDRESS | grep "nonce:" | sed 's/^.*: //'` -# Check if get nonce is success, if not assign 1 to the nonce +# Check if get nonce is success, if not assign 0 to the nonce if [ -z "${FairblockNonce}" ]; then - echo "$ACCOUNT_NAME nonce not found, init nonce as 1" - FairblockNonce=1 + die "Fairblock Nonce not found" else # else, remove the string quote from the result FairblockNonce=`sed -e 's/^"//' -e 's/"$//' <<< "$FairblockNonce"` fi @@ -33,13 +32,18 @@ printf "Got $ACCOUNT_NAME's FairblockNonce: $FairblockNonce Account Balance:\n\n fairyringd query bank balances $ADDRESS # Create the unsigned tx data -fairyringd tx fairyring register-validator --from $ACCOUNT_NAME --generate-only --yes > $UNSIGNED_TX_FILE_NAME +fairyringd tx bank send $ADDRESS $2 $3 --from $ACCOUNT_NAME --generate-only --yes > $UNSIGNED_TX_FILE_NAME # Sign the unsigned tx that just created SIGNED_DATA=`fairyringd tx sign $UNSIGNED_TX_FILE_NAME --from $ACCOUNT_NAME --offline --account-number $ACCOUNT_NUMBER --sequence $FairblockNonce --chain-id $CHAIN_ID --yes` +# SIGNED_DATA=`fairyringd tx sign $UNSIGNED_TX_FILE_NAME --from $ACCOUNT_NAME --chain-id $CHAIN_ID --yes` + +PUB_KEY=`fairyringd q fairyring show-latest-pub-key | grep "publicKey: " | sed 's/^.*: //'` + +CIPHER=`./encrypter $1 $PUB_KEY $SIGNED_DATA` # Submit encrypted tx with the signed data -fairyringd tx fairblock submit-encrypted-tx $SIGNED_DATA $1 --from $ACCOUNT_NAME --yes +fairyringd tx fairblock submit-encrypted-tx $CIPHER $1 --from $ACCOUNT_NAME --yes # List all the encrypted txs printf "\n\nList encrypted Txs:\n\n" @@ -52,7 +56,7 @@ printf "\nUnsigned TX JSON File Removed\n" printf "\nAccount Balance after submitting Encrypted Tx" fairyringd query bank balances $ADDRESS -printf "\nValidator Set After submitting Encrypted Tx:" -fairyringd query fairyring list-validator-set +printf "\nTarget To Account Balance after submitting Encrypted Tx" +fairyringd query bank balances $2 -printf "\nRun 'fairyringd query fairyring list-validator-set' to check validator set later\n" \ No newline at end of file +printf "\nRun 'fairyringd query bank balances $2' to check target account balance later\n" \ No newline at end of file diff --git a/x/fairblock/client/cli/query.go b/x/fairblock/client/cli/query.go index b51f0461..5a8dd8b9 100644 --- a/x/fairblock/client/cli/query.go +++ b/x/fairblock/client/cli/query.go @@ -32,8 +32,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListFairblockNonce()) cmd.AddCommand(CmdShowFairblockNonce()) - cmd.AddCommand(CmdListFairblockExecutedNonce()) - cmd.AddCommand(CmdShowFairblockExecutedNonce()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/fairblock/client/cli/query_fairblock_executed_nonce.go b/x/fairblock/client/cli/query_fairblock_executed_nonce.go deleted file mode 100644 index 0ce78587..00000000 --- a/x/fairblock/client/cli/query_fairblock_executed_nonce.go +++ /dev/null @@ -1,73 +0,0 @@ -package cli - -import ( - "context" - - "fairyring/x/fairblock/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" -) - -func CmdListFairblockExecutedNonce() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-fairblock-executed-nonce", - Short: "list all FairblockExecutedNonce", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryAllFairblockExecutedNonceRequest{ - Pagination: pageReq, - } - - res, err := queryClient.FairblockExecutedNonceAll(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddPaginationFlagsToCmd(cmd, cmd.Use) - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdShowFairblockExecutedNonce() *cobra.Command { - cmd := &cobra.Command{ - Use: "show-fairblock-executed-nonce [address]", - Short: "shows a FairblockExecutedNonce", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - argAddress := args[0] - - params := &types.QueryGetFairblockExecutedNonceRequest{ - Address: argAddress, - } - - res, err := queryClient.FairblockExecutedNonce(context.Background(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/fairblock/client/cli/query_fairblock_executed_nonce_test.go b/x/fairblock/client/cli/query_fairblock_executed_nonce_test.go deleted file mode 100644 index 33988403..00000000 --- a/x/fairblock/client/cli/query_fairblock_executed_nonce_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package cli_test - -import ( - "fmt" - "strconv" - "testing" - - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/stretchr/testify/require" - tmcli "github.com/tendermint/tendermint/libs/cli" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "fairyring/testutil/network" - "fairyring/testutil/nullify" - "fairyring/x/fairblock/client/cli" - "fairyring/x/fairblock/types" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func networkWithFairblockExecutedNonceObjects(t *testing.T, n int) (*network.Network, []types.FairblockExecutedNonce) { - t.Helper() - cfg := network.DefaultConfig() - state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) - - for i := 0; i < n; i++ { - fairblockExecutedNonce := types.FairblockExecutedNonce{ - Address: strconv.Itoa(i), - } - nullify.Fill(&fairblockExecutedNonce) - state.FairblockExecutedNonceList = append(state.FairblockExecutedNonceList, fairblockExecutedNonce) - } - buf, err := cfg.Codec.MarshalJSON(&state) - require.NoError(t, err) - cfg.GenesisState[types.ModuleName] = buf - return network.New(t, cfg), state.FairblockExecutedNonceList -} - -func TestShowFairblockExecutedNonce(t *testing.T) { - net, objs := networkWithFairblockExecutedNonceObjects(t, 2) - - ctx := net.Validators[0].ClientCtx - common := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - for _, tc := range []struct { - desc string - idAddress string - - args []string - err error - obj types.FairblockExecutedNonce - }{ - { - desc: "found", - idAddress: objs[0].Address, - - args: common, - obj: objs[0], - }, - { - desc: "not found", - idAddress: strconv.Itoa(100000), - - args: common, - err: status.Error(codes.NotFound, "not found"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idAddress, - } - args = append(args, tc.args...) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowFairblockExecutedNonce(), args) - if tc.err != nil { - stat, ok := status.FromError(tc.err) - require.True(t, ok) - require.ErrorIs(t, stat.Err(), tc.err) - } else { - require.NoError(t, err) - var resp types.QueryGetFairblockExecutedNonceResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NotNil(t, resp.FairblockExecutedNonce) - require.Equal(t, - nullify.Fill(&tc.obj), - nullify.Fill(&resp.FairblockExecutedNonce), - ) - } - }) - } -} - -func TestListFairblockExecutedNonce(t *testing.T) { - net, objs := networkWithFairblockExecutedNonceObjects(t, 5) - - ctx := net.Validators[0].ClientCtx - request := func(next []byte, offset, limit uint64, total bool) []string { - args := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - if next == nil { - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) - } else { - args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) - } - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) - if total { - args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) - } - return args - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(objs); i += step { - args := request(nil, uint64(i), uint64(step), false) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFairblockExecutedNonce(), args) - require.NoError(t, err) - var resp types.QueryAllFairblockExecutedNonceResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.FairblockExecutedNonce), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(objs); i += step { - args := request(next, 0, uint64(step), false) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFairblockExecutedNonce(), args) - require.NoError(t, err) - var resp types.QueryAllFairblockExecutedNonceResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.FairblockExecutedNonce), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - args := request(nil, 0, uint64(len(objs)), true) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListFairblockExecutedNonce(), args) - require.NoError(t, err) - var resp types.QueryAllFairblockExecutedNonceResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NoError(t, err) - require.Equal(t, len(objs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(objs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - }) -} diff --git a/x/fairblock/genesis.go b/x/fairblock/genesis.go index 90a0b60e..4fada0a9 100644 --- a/x/fairblock/genesis.go +++ b/x/fairblock/genesis.go @@ -19,10 +19,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.FairblockNonceList { k.SetFairblockNonce(ctx, elem) } - // Set all the fairblockExecutedNonce - for _, elem := range genState.FairblockExecutedNonceList { - k.SetFairblockExecutedNonce(ctx, elem) - } // Set all the aggregatedKeyShare for _, elem := range genState.AggregatedKeyShareList { k.SetAggregatedKeyShare(ctx, elem) @@ -36,10 +32,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - + genesis.EncryptedTxArray = k.GetAllEncryptedArray(ctx) genesis.FairblockNonceList = k.GetAllFairblockNonce(ctx) - genesis.FairblockExecutedNonceList = k.GetAllFairblockExecutedNonce(ctx) genesis.AggregatedKeyShareList = k.GetAllAggregatedKeyShare(ctx) // this line is used by starport scaffolding # genesis/module/export diff --git a/x/fairblock/genesis_test.go b/x/fairblock/genesis_test.go index 53d17263..01275c60 100644 --- a/x/fairblock/genesis_test.go +++ b/x/fairblock/genesis_test.go @@ -47,14 +47,6 @@ func TestGenesis(t *testing.T) { Address: "1", }, }, - FairblockExecutedNonceList: []types.FairblockExecutedNonce{ - { - Address: "0", - }, - { - Address: "1", - }, - }, AggregatedKeyShareList: []types.AggregatedKeyShare{ { Height: 0, @@ -78,7 +70,6 @@ func TestGenesis(t *testing.T) { require.ElementsMatch(t, genesisState.EncryptedTxArray, got.EncryptedTxArray) require.ElementsMatch(t, genesisState.FairblockNonceList, got.FairblockNonceList) - require.ElementsMatch(t, genesisState.FairblockExecutedNonceList, got.FairblockExecutedNonceList) require.ElementsMatch(t, genesisState.AggregatedKeyShareList, got.AggregatedKeyShareList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/fairblock/keeper/encrypted_tx.go b/x/fairblock/keeper/encrypted_tx.go index 920742de..91e1c1fc 100644 --- a/x/fairblock/keeper/encrypted_tx.go +++ b/x/fairblock/keeper/encrypted_tx.go @@ -25,8 +25,6 @@ func (k Keeper) AppendEncryptedTx( parsedEncryptedTxArr := k.cdc.MustMarshal(&allTxsFromHeight) - k.IncreaseFairblockNonce(ctx, encryptedTx.Creator) - store.Set(types.EncryptedTxAllFromHeightKey( encryptedTx.TargetHeight, ), parsedEncryptedTxArr) diff --git a/x/fairblock/keeper/fairblock_executed_nonce.go b/x/fairblock/keeper/fairblock_executed_nonce.go deleted file mode 100644 index 67ee9c24..00000000 --- a/x/fairblock/keeper/fairblock_executed_nonce.go +++ /dev/null @@ -1,94 +0,0 @@ -package keeper - -import ( - "fairyring/x/fairblock/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// SetFairblockExecutedNonce set a specific fairblockExecutedNonce in the store from its index -func (k Keeper) SetFairblockExecutedNonce(ctx sdk.Context, fairblockExecutedNonce types.FairblockExecutedNonce) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - b := k.cdc.MustMarshal(&fairblockExecutedNonce) - store.Set(types.FairblockExecutedNonceKey( - fairblockExecutedNonce.Address, - ), b) -} - -// IncreaseFairblockExecutedNonce increase specific fairblockExecutedNonce by 1 and returns the new nonce -func (k Keeper) IncreaseFairblockExecutedNonce( - ctx sdk.Context, - address string, -) uint64 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - - b := store.Get(types.FairblockExecutedNonceKey( - address, - )) - - var nonce types.FairblockExecutedNonce - var newNonce uint64 - if b == nil { - // New address ? - nonce = types.FairblockExecutedNonce{ - Address: address, - Nonce: 2, - } - newNonce = 2 - } else { - k.cdc.MustUnmarshal(b, &nonce) - nonce.Nonce = nonce.Nonce + 1 - newNonce = nonce.Nonce - } - - k.SetFairblockExecutedNonce(ctx, nonce) - - return newNonce -} - -// GetFairblockExecutedNonce returns a fairblockExecutedNonce from its index -func (k Keeper) GetFairblockExecutedNonce( - ctx sdk.Context, - address string, - -) (val types.FairblockExecutedNonce, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - - b := store.Get(types.FairblockExecutedNonceKey( - address, - )) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} - -// RemoveFairblockExecutedNonce removes a fairblockExecutedNonce from the store -func (k Keeper) RemoveFairblockExecutedNonce( - ctx sdk.Context, - address string, - -) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - store.Delete(types.FairblockExecutedNonceKey( - address, - )) -} - -// GetAllFairblockExecutedNonce returns all fairblockExecutedNonce -func (k Keeper) GetAllFairblockExecutedNonce(ctx sdk.Context) (list []types.FairblockExecutedNonce) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var val types.FairblockExecutedNonce - k.cdc.MustUnmarshal(iterator.Value(), &val) - list = append(list, val) - } - - return -} diff --git a/x/fairblock/keeper/fairblock_executed_nonce_test.go b/x/fairblock/keeper/fairblock_executed_nonce_test.go deleted file mode 100644 index b6135880..00000000 --- a/x/fairblock/keeper/fairblock_executed_nonce_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package keeper_test - -import ( - "strconv" - "testing" - - keepertest "fairyring/testutil/keeper" - "fairyring/testutil/nullify" - "fairyring/x/fairblock/keeper" - "fairyring/x/fairblock/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func createNFairblockExecutedNonce(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.FairblockExecutedNonce { - items := make([]types.FairblockExecutedNonce, n) - for i := range items { - items[i].Address = strconv.Itoa(i) - - keeper.SetFairblockExecutedNonce(ctx, items[i]) - } - return items -} - -func TestFairblockExecutedNonceGet(t *testing.T) { - keeper, ctx := keepertest.FairblockKeeper(t) - items := createNFairblockExecutedNonce(keeper, ctx, 10) - for _, item := range items { - rst, found := keeper.GetFairblockExecutedNonce(ctx, - item.Address, - ) - require.True(t, found) - require.Equal(t, - nullify.Fill(&item), - nullify.Fill(&rst), - ) - } -} -func TestFairblockExecutedNonceRemove(t *testing.T) { - keeper, ctx := keepertest.FairblockKeeper(t) - items := createNFairblockExecutedNonce(keeper, ctx, 10) - for _, item := range items { - keeper.RemoveFairblockExecutedNonce(ctx, - item.Address, - ) - _, found := keeper.GetFairblockExecutedNonce(ctx, - item.Address, - ) - require.False(t, found) - } -} - -func TestFairblockExecutedNonceGetAll(t *testing.T) { - keeper, ctx := keepertest.FairblockKeeper(t) - items := createNFairblockExecutedNonce(keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(items), - nullify.Fill(keeper.GetAllFairblockExecutedNonce(ctx)), - ) -} diff --git a/x/fairblock/keeper/fairblock_nonce.go b/x/fairblock/keeper/fairblock_nonce.go index 338c47cd..ed6fa2e0 100644 --- a/x/fairblock/keeper/fairblock_nonce.go +++ b/x/fairblock/keeper/fairblock_nonce.go @@ -27,14 +27,13 @@ func (k Keeper) IncreaseFairblockNonce( )) var nonce types.FairblockNonce - var newNonce uint64 + var newNonce uint64 = 1 if b == nil { // New address ? nonce = types.FairblockNonce{ Address: address, - Nonce: 2, + Nonce: 1, } - newNonce = 2 } else { k.cdc.MustUnmarshal(b, &nonce) nonce.Nonce = nonce.Nonce + 1 @@ -58,7 +57,12 @@ func (k Keeper) GetFairblockNonce( address, )) if b == nil { - return val, false + initNonce := types.FairblockNonce{ + Address: address, + Nonce: 0, + } + k.SetFairblockNonce(ctx, initNonce) + return initNonce, true } k.cdc.MustUnmarshal(b, &val) diff --git a/x/fairblock/keeper/grpc_query_fairblock_executed_nonce.go b/x/fairblock/keeper/grpc_query_fairblock_executed_nonce.go deleted file mode 100644 index d32663af..00000000 --- a/x/fairblock/keeper/grpc_query_fairblock_executed_nonce.go +++ /dev/null @@ -1,57 +0,0 @@ -package keeper - -import ( - "context" - - "fairyring/x/fairblock/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) FairblockExecutedNonceAll(c context.Context, req *types.QueryAllFairblockExecutedNonceRequest) (*types.QueryAllFairblockExecutedNonceResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - var fairblockExecutedNonces []types.FairblockExecutedNonce - ctx := sdk.UnwrapSDKContext(c) - - store := ctx.KVStore(k.storeKey) - fairblockExecutedNonceStore := prefix.NewStore(store, types.KeyPrefix(types.FairblockExecutedNonceKeyPrefix)) - - pageRes, err := query.Paginate(fairblockExecutedNonceStore, req.Pagination, func(key []byte, value []byte) error { - var fairblockExecutedNonce types.FairblockExecutedNonce - if err := k.cdc.Unmarshal(value, &fairblockExecutedNonce); err != nil { - return err - } - - fairblockExecutedNonces = append(fairblockExecutedNonces, fairblockExecutedNonce) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryAllFairblockExecutedNonceResponse{FairblockExecutedNonce: fairblockExecutedNonces, Pagination: pageRes}, nil -} - -func (k Keeper) FairblockExecutedNonce(c context.Context, req *types.QueryGetFairblockExecutedNonceRequest) (*types.QueryGetFairblockExecutedNonceResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(c) - - val, found := k.GetFairblockExecutedNonce( - ctx, - req.Address, - ) - if !found { - return nil, status.Error(codes.NotFound, "not found") - } - - return &types.QueryGetFairblockExecutedNonceResponse{FairblockExecutedNonce: val}, nil -} diff --git a/x/fairblock/keeper/grpc_query_fairblock_executed_nonce_test.go b/x/fairblock/keeper/grpc_query_fairblock_executed_nonce_test.go deleted file mode 100644 index f858b934..00000000 --- a/x/fairblock/keeper/grpc_query_fairblock_executed_nonce_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package keeper_test - -import ( - "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - keepertest "fairyring/testutil/keeper" - "fairyring/testutil/nullify" - "fairyring/x/fairblock/types" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func TestFairblockExecutedNonceQuerySingle(t *testing.T) { - keeper, ctx := keepertest.FairblockKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNFairblockExecutedNonce(keeper, ctx, 2) - for _, tc := range []struct { - desc string - request *types.QueryGetFairblockExecutedNonceRequest - response *types.QueryGetFairblockExecutedNonceResponse - err error - }{ - { - desc: "First", - request: &types.QueryGetFairblockExecutedNonceRequest{ - Address: msgs[0].Address, - }, - response: &types.QueryGetFairblockExecutedNonceResponse{FairblockExecutedNonce: msgs[0]}, - }, - { - desc: "Second", - request: &types.QueryGetFairblockExecutedNonceRequest{ - Address: msgs[1].Address, - }, - response: &types.QueryGetFairblockExecutedNonceResponse{FairblockExecutedNonce: msgs[1]}, - }, - { - desc: "KeyNotFound", - request: &types.QueryGetFairblockExecutedNonceRequest{ - Address: strconv.Itoa(100000), - }, - err: status.Error(codes.NotFound, "not found"), - }, - { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.FairblockExecutedNonce(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - require.Equal(t, - nullify.Fill(tc.response), - nullify.Fill(response), - ) - } - }) - } -} - -func TestFairblockExecutedNonceQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.FairblockKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNFairblockExecutedNonce(keeper, ctx, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllFairblockExecutedNonceRequest { - return &types.QueryAllFairblockExecutedNonceRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(msgs); i += step { - resp, err := keeper.FairblockExecutedNonceAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.FairblockExecutedNonce), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(msgs); i += step { - resp, err := keeper.FairblockExecutedNonceAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.FairblockExecutedNonce), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := keeper.FairblockExecutedNonceAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(msgs), - nullify.Fill(resp.FairblockExecutedNonce), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.FairblockExecutedNonceAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} diff --git a/x/fairblock/keeper/msg_server_aggregated_key_share.go b/x/fairblock/keeper/msg_server_aggregated_key_share.go index 3889efe9..10268132 100644 --- a/x/fairblock/keeper/msg_server_aggregated_key_share.go +++ b/x/fairblock/keeper/msg_server_aggregated_key_share.go @@ -2,24 +2,13 @@ package keeper import ( "context" - "fairyring/x/fairblock/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) func (k msgServer) CreateAggregatedKeyShare(goCtx context.Context, msg *types.MsgCreateAggregatedKeyShare) (*types.MsgCreateAggregatedKeyShareResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check if the value already exists - _, isFound := k.GetAggregatedKeyShare( - ctx, - msg.Height, - ) - if isFound { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "index already set") - } - var aggregatedKeyShare = types.AggregatedKeyShare{ Creator: msg.Creator, Height: msg.Height, diff --git a/x/fairblock/keeper/unconfirmed_txs.go b/x/fairblock/keeper/unconfirmed_txs.go index 9d42ae7f..7c387dcf 100644 --- a/x/fairblock/keeper/unconfirmed_txs.go +++ b/x/fairblock/keeper/unconfirmed_txs.go @@ -90,13 +90,14 @@ func (k Keeper) processMessage(ctx sdk.Context, msg types.MsgCreateAggregatedKey } k.SetAggregatedKeyShare(ctx, types.AggregatedKeyShare{ - Height: msg.Height, - Data: msg.Data, - Creator: msg.Creator, + Height: msg.Height, + Data: msg.Data, + Creator: msg.Creator, + PublicKey: msg.PublicKey, }) latestHeight, err := strconv.ParseUint(k.GetLatestHeight(ctx), 10, 64) - if err != nil { // latest height is empty, set it to 0 + if err != nil { latestHeight = 0 } diff --git a/x/fairblock/module.go b/x/fairblock/module.go index b2498b94..e85b888e 100644 --- a/x/fairblock/module.go +++ b/x/fairblock/module.go @@ -7,6 +7,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "math" "strconv" "github.com/cosmos/cosmos-sdk/baseapp" @@ -184,17 +185,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { lastExecutedHeight = 0 } - //========================================// - // Replaced with reading Txs from MemPool // - //========================================// - - // err = am.keeper.QueryFairyringCurrentHeight(ctx) - // if err != nil { - // am.keeper.Logger(ctx).Error("Beginblocker get height err", err) - // am.keeper.Logger(ctx).Error(err.Error()) - // return - // } - utxs, _ := tmcore.UnconfirmedTxs(nil, nil) am.keeper.ProcessUnconfirmedTxs(ctx, utxs) @@ -213,9 +203,67 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { arr := am.keeper.GetEncryptedTxAllFromHeight(ctx, h) am.keeper.SetLastExecutedHeight(ctx, strconv.FormatUint(h, 10)) + key, found := am.keeper.GetAggregatedKeyShare(ctx, h) + if !found { + am.keeper.Logger(ctx).Error(fmt.Sprintf("Decryption key not found for block height: %d", h)) + continue + } + + publicKeyByte, err := hex.DecodeString(key.GetPublicKey()) + if err != nil { + am.keeper.Logger(ctx).Error("Error decoding public key") + am.keeper.Logger(ctx).Error(err.Error()) + return + } + + suite := bls.NewBLS12381Suite() + + publicKeyPoint := suite.G1().Point() + err = publicKeyPoint.UnmarshalBinary(publicKeyByte) + if err != nil { + am.keeper.Logger(ctx).Error("Error unmarshalling public key") + am.keeper.Logger(ctx).Error(err.Error()) + return + } + + am.keeper.Logger(ctx).Info("Unmarshal public key successfully") + am.keeper.Logger(ctx).Info(publicKeyPoint.String()) + + keyByte, err := hex.DecodeString(key.Data) + if err != nil { + am.keeper.Logger(ctx).Error("Error decoding aggregated key") + am.keeper.Logger(ctx).Error(err.Error()) + continue + } + + skPoint := suite.G2().Point() + err = skPoint.UnmarshalBinary(keyByte) + if err != nil { + am.keeper.Logger(ctx).Error("Error unmarshalling aggregated key") + am.keeper.Logger(ctx).Error(err.Error()) + continue + } + + am.keeper.Logger(ctx).Info("Unmarshal decryption key successfully") + am.keeper.Logger(ctx).Info(skPoint.String()) + for _, eachTx := range arr.EncryptedTx { am.keeper.RemoveEncryptedTx(ctx, eachTx.TargetHeight, eachTx.Index) - newExecutedNonce := am.keeper.IncreaseFairblockExecutedNonce(ctx, eachTx.Creator) + + if currentNonce, found := am.keeper.GetFairblockNonce(ctx, eachTx.Creator); found && currentNonce.Nonce >= math.MaxUint64 { + am.keeper.Logger(ctx).Error("Invalid Fairblock Nonce") + ctx.EventManager().EmitEvent( + sdk.NewEvent(types.EncryptedTxRevertedEventType, + sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), + sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Invalid fairblock nonce"), + sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), + ), + ) + continue + } + + newExecutedNonce := am.keeper.IncreaseFairblockNonce(ctx, eachTx.Creator) creatorAddr, err := sdk.AccAddressFromBech32(eachTx.Creator) if err != nil { @@ -229,28 +277,31 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } creatorAccount := am.accountKeeper.GetAccount(ctx, creatorAddr) - key, found := am.keeper.GetAggregatedKeyShare(ctx, h) - if !found { - am.keeper.Logger(ctx).Error(fmt.Sprintf("Decryption key not found for block height: %d", h)) + txBytes, err := hex.DecodeString(eachTx.Data) + if err != nil { + am.keeper.Logger(ctx).Error("Error decoding tx data to bytes") + am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Decryption key not found"), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - keyByte, err := hex.DecodeString(key.Data) + var decryptedTx bytes.Buffer + var txBuffer bytes.Buffer + _, err = txBuffer.Write(txBytes) if err != nil { - am.keeper.Logger(ctx).Error("Error decoding aggregated key") + am.keeper.Logger(ctx).Error("Error write byte to tx buffer") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, @@ -260,14 +311,12 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - suite := bls.NewBLS12381Suite() - skPoint := suite.G2().Point() - err = skPoint.UnmarshalBinary(keyByte) + err = enc.Decrypt(publicKeyPoint, skPoint, &decryptedTx, &txBuffer) if err != nil { - am.keeper.Logger(ctx).Error("Error unmarshalling aggregated key") + am.keeper.Logger(ctx).Error("Error decrypting tx data") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, @@ -277,246 +326,186 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - am.keeper.Logger(ctx).Info("Unmarshal decryption key successfully") - am.keeper.Logger(ctx).Info(skPoint.String()) + am.keeper.Logger(ctx).Info(fmt.Sprintf("Decrypt TX Successfully: %s", decryptedTx.String())) + + var signed tx.Tx + err = am.cdcJson.UnmarshalJSON(decryptedTx.Bytes(), &signed) - publicKeyByte, err := hex.DecodeString(key.PublicKey) if err != nil { - am.keeper.Logger(ctx).Error("Error decoding public key") + am.keeper.Logger(ctx).Error("UnmarshalJson to Tx Error in BeginBlock") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to unmarshal data to FairblockTx"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - publicKeyPoint := suite.G1().Point() - err = publicKeyPoint.UnmarshalBinary(publicKeyByte) + decodedTxJson, err := am.txConfig.TxJSONDecoder()(decryptedTx.Bytes()) if err != nil { - am.keeper.Logger(ctx).Error("Error unmarshalling public key") + am.keeper.Logger(ctx).Error("TXJson Decoding error in Beginblock") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to decode tx data to Cosmos Tx"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - am.keeper.Logger(ctx).Info("Unmarshal public key successfully") - am.keeper.Logger(ctx).Info(publicKeyPoint.String()) - - txBytes, err := hex.DecodeString(eachTx.Data) + wrappedTx, err := am.txConfig.WrapTxBuilder(decodedTxJson) if err != nil { - am.keeper.Logger(ctx).Error("Error decoding tx data to bytes") + am.keeper.Logger(ctx).Error("Error in wrapping tx to TxBuilder") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to wrap tx to TxBuilder"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - var decryptedTx bytes.Buffer - var txBuffer bytes.Buffer - _, err = txBuffer.Write(txBytes) + sigs, err := wrappedTx.GetTx().GetSignaturesV2() if err != nil { - am.keeper.Logger(ctx).Error("Error write byte to tx buffer") + am.keeper.Logger(ctx).Error("Error in getting tx signature") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to get tx signature"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - err = enc.Decrypt(publicKeyPoint, skPoint, &decryptedTx, &txBuffer) - if err != nil { - am.keeper.Logger(ctx).Error("Error decrypting tx data") - am.keeper.Logger(ctx).Error(err.Error()) + if len(sigs) != 1 { + am.keeper.Logger(ctx).Error("Number of signatures provided is more than 1") ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Number of signatures provided is more than 1"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - am.keeper.Logger(ctx).Info(fmt.Sprintf("Decrypt TX Successfully: %s", decryptedTx.String())) + txMsgs := wrappedTx.GetTx().GetMsgs() - var signed tx.Tx - err = am.cdcJson.UnmarshalJSON(decryptedTx.Bytes(), &signed) - - if err != nil { - am.keeper.Logger(ctx).Error("UnmarshalJson to Tx Error in BeginBlock") - am.keeper.Logger(ctx).Error(err.Error()) + if len(sigs) != len(txMsgs) { + am.keeper.Logger(ctx).Error("Number of signature is not equals to number of messages") ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to unmarshal data to FairblockTx"), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Number of signature is not equals to number of messages"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - decodedTxJson, err := am.txConfig.TxJSONDecoder()(decryptedTx.Bytes()) - if err != nil { - am.keeper.Logger(ctx).Error("TXJson Decoding error in Beginblock") - am.keeper.Logger(ctx).Error(err.Error()) + if !sigs[0].PubKey.Equals(creatorAccount.GetPubKey()) { + am.keeper.Logger(ctx).Error("Signer is not sender") ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to decode tx data to Cosmos Tx"), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "signer public key does not match sender public key"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - wrappedTx, err := am.txConfig.WrapTxBuilder(decodedTxJson) - if err != nil { - am.keeper.Logger(ctx).Error("Error in wrapping tx to TxBuilder") - am.keeper.Logger(ctx).Error(err.Error()) + expectingNonce := newExecutedNonce - 1 + + if sigs[0].Sequence < expectingNonce { + am.keeper.Logger(ctx).Error(fmt.Sprintf("Incorrect Nonce sequence, Provided: %d, Expecting: %d", sigs[0].Sequence, expectingNonce)) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to wrap tx to TxBuilder"), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, fmt.Sprintf("Incorrect nonce sequence, provided: %d, expecting: %d", sigs[0].Sequence, expectingNonce)), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - sigs, err := wrappedTx.GetTx().GetSignaturesV2() + if sigs[0].Sequence > expectingNonce { + am.keeper.SetFairblockNonce(ctx, types.FairblockNonce{ + Address: eachTx.Creator, + Nonce: sigs[0].Sequence, + }) + } + + verifiableTx := wrappedTx.GetTx().(authsigning.SigVerifiableTx) + + signingData := authsigning.SignerData{ + Address: creatorAddr.String(), + ChainID: ctx.ChainID(), + AccountNumber: creatorAccount.GetAccountNumber(), + Sequence: sigs[0].Sequence, + PubKey: creatorAccount.GetPubKey(), + } + + err = authsigning.VerifySignature( + creatorAccount.GetPubKey(), + signingData, + sigs[0].Data, + am.txConfig.SignModeHandler(), + verifiableTx, + ) + if err != nil { - am.keeper.Logger(ctx).Error("Error in getting tx signature") + am.keeper.Logger(ctx).Error("Invalid Signature in BeginBlock") am.keeper.Logger(ctx).Error(err.Error()) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxRevertedEventType, sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Unable to get tx signature"), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Invalid signature"), sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), ), ) - return + continue } - for index, eachSig := range sigs { - if index > 0 { - newExecutedNonce = am.keeper.IncreaseFairblockExecutedNonce(ctx, eachTx.Creator) - } - - // For now only support User submitting their own signed tx - if !eachSig.PubKey.Equals(creatorAccount.GetPubKey()) { - am.keeper.Logger(ctx).Error("Signer is not sender") - am.keeper.Logger(ctx).Error(err.Error()) - ctx.EventManager().EmitEvent( - sdk.NewEvent(types.EncryptedTxRevertedEventType, - sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), - sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "signer public key does not match sender public key"), - sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), - ), - ) - return - } - - if eachSig.Sequence != newExecutedNonce-1 { - am.keeper.Logger(ctx).Error("Incorrect Nonce sequence") - ctx.EventManager().EmitEvent( - sdk.NewEvent(types.EncryptedTxRevertedEventType, - sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), - sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Incorrect nonce sequence"), - sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), - ), - ) - return - } - - verifiableTx := wrappedTx.GetTx().(authsigning.SigVerifiableTx) - - signingData := authsigning.SignerData{ - Address: creatorAddr.String(), - ChainID: ctx.ChainID(), - AccountNumber: creatorAccount.GetAccountNumber(), - Sequence: sigs[0].Sequence, - PubKey: creatorAccount.GetPubKey(), - } - - err = authsigning.VerifySignature( - creatorAccount.GetPubKey(), - signingData, - sigs[0].Data, - am.txConfig.SignModeHandler(), - verifiableTx, + handler := am.msgServiceRouter.Handler(txMsgs[0]) + _, err = handler(ctx, txMsgs[0]) + if err != nil { + am.keeper.Logger(ctx).Error("Handle Tx Msg Error") + am.keeper.Logger(ctx).Error(err.Error()) + ctx.EventManager().EmitEvent( + sdk.NewEvent(types.EncryptedTxRevertedEventType, + sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), + sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), + sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), + sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), + ), ) - - if err != nil { - am.keeper.Logger(ctx).Error("Invalid Signature in BeginBlock") - ctx.EventManager().EmitEvent( - sdk.NewEvent(types.EncryptedTxRevertedEventType, - sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), - sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, "Invalid signature"), - sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), - ), - ) - continue - } - - } - - for _, eachMsg := range wrappedTx.GetTx().GetMsgs() { - handler := am.msgServiceRouter.Handler(eachMsg) - _, err := handler(ctx, eachMsg) - if err != nil { - am.keeper.Logger(ctx).Error("!!!Handle Tx Msg Error") - ctx.EventManager().EmitEvent( - sdk.NewEvent(types.EncryptedTxRevertedEventType, - sdk.NewAttribute(types.EncryptedTxRevertedEventCreator, eachTx.Creator), - sdk.NewAttribute(types.EncryptedTxRevertedEventHeight, strconv.FormatUint(eachTx.TargetHeight, 10)), - sdk.NewAttribute(types.EncryptedTxRevertedEventReason, err.Error()), - sdk.NewAttribute(types.EncryptedTxRevertedEventIndex, strconv.FormatUint(eachTx.Index, 10)), - ), - ) - continue - } - am.keeper.Logger(ctx).Info("!Executed successfully!") + continue } - /// For now, after removal, the encrypted tx will become an empty array - /// Or Remove the entire tx array of current height - /// instead removing it one by one ? + am.keeper.Logger(ctx).Info("!Executed successfully!") - // Emit event for tx execution ctx.EventManager().EmitEvent( sdk.NewEvent(types.EncryptedTxExecutedEventType, sdk.NewAttribute(types.EncryptedTxExecutedEventCreator, eachTx.Creator), diff --git a/x/fairblock/types/fairblock_executed_nonce.pb.go b/x/fairblock/types/fairblock_executed_nonce.pb.go deleted file mode 100644 index 22c18e45..00000000 --- a/x/fairblock/types/fairblock_executed_nonce.pb.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fairyring/fairblock/fairblock_executed_nonce.proto - -package types - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - 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 FairblockExecutedNonce struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` -} - -func (m *FairblockExecutedNonce) Reset() { *m = FairblockExecutedNonce{} } -func (m *FairblockExecutedNonce) String() string { return proto.CompactTextString(m) } -func (*FairblockExecutedNonce) ProtoMessage() {} -func (*FairblockExecutedNonce) Descriptor() ([]byte, []int) { - return fileDescriptor_bf7f4ea8f30ec4b7, []int{0} -} -func (m *FairblockExecutedNonce) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FairblockExecutedNonce) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FairblockExecutedNonce.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 *FairblockExecutedNonce) XXX_Merge(src proto.Message) { - xxx_messageInfo_FairblockExecutedNonce.Merge(m, src) -} -func (m *FairblockExecutedNonce) XXX_Size() int { - return m.Size() -} -func (m *FairblockExecutedNonce) XXX_DiscardUnknown() { - xxx_messageInfo_FairblockExecutedNonce.DiscardUnknown(m) -} - -var xxx_messageInfo_FairblockExecutedNonce proto.InternalMessageInfo - -func (m *FairblockExecutedNonce) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *FairblockExecutedNonce) GetNonce() uint64 { - if m != nil { - return m.Nonce - } - return 0 -} - -func init() { - proto.RegisterType((*FairblockExecutedNonce)(nil), "fairyring.fairblock.FairblockExecutedNonce") -} - -func init() { - proto.RegisterFile("fairyring/fairblock/fairblock_executed_nonce.proto", fileDescriptor_bf7f4ea8f30ec4b7) -} - -var fileDescriptor_bf7f4ea8f30ec4b7 = []byte{ - // 165 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4a, 0x4b, 0xcc, 0x2c, - 0xaa, 0x2c, 0xca, 0xcc, 0x4b, 0xd7, 0x07, 0xb1, 0x92, 0x72, 0xf2, 0x93, 0xb3, 0x11, 0xac, 0xf8, - 0xd4, 0x8a, 0xd4, 0xe4, 0xd2, 0x92, 0xd4, 0x94, 0xf8, 0xbc, 0xfc, 0xbc, 0xe4, 0x54, 0xbd, 0x82, - 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x61, 0xb8, 0x1e, 0x3d, 0xb8, 0x4a, 0x25, 0x0f, 0x2e, 0x31, 0x37, - 0x18, 0xc7, 0x15, 0xaa, 0xcb, 0x0f, 0xa4, 0x49, 0x48, 0x82, 0x8b, 0x3d, 0x31, 0x25, 0xa5, 0x28, - 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x15, 0x12, 0xe1, 0x62, 0x05, - 0x9b, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0xe1, 0x38, 0x99, 0x9e, 0x78, 0x24, 0xc7, - 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, - 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x34, 0xc2, 0xb1, 0x15, 0x48, 0xce, 0x2d, 0xa9, 0x2c, - 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x3b, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x5d, 0x3b, - 0x82, 0xd2, 0x00, 0x00, 0x00, -} - -func (m *FairblockExecutedNonce) 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 *FairblockExecutedNonce) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FairblockExecutedNonce) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Nonce != 0 { - i = encodeVarintFairblockExecutedNonce(dAtA, i, uint64(m.Nonce)) - i-- - dAtA[i] = 0x10 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintFairblockExecutedNonce(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintFairblockExecutedNonce(dAtA []byte, offset int, v uint64) int { - offset -= sovFairblockExecutedNonce(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *FairblockExecutedNonce) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovFairblockExecutedNonce(uint64(l)) - } - if m.Nonce != 0 { - n += 1 + sovFairblockExecutedNonce(uint64(m.Nonce)) - } - return n -} - -func sovFairblockExecutedNonce(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozFairblockExecutedNonce(x uint64) (n int) { - return sovFairblockExecutedNonce(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *FairblockExecutedNonce) 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 ErrIntOverflowFairblockExecutedNonce - } - 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: FairblockExecutedNonce: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FairblockExecutedNonce: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFairblockExecutedNonce - } - 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 ErrInvalidLengthFairblockExecutedNonce - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthFairblockExecutedNonce - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - m.Nonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFairblockExecutedNonce - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipFairblockExecutedNonce(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthFairblockExecutedNonce - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipFairblockExecutedNonce(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, ErrIntOverflowFairblockExecutedNonce - } - 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, ErrIntOverflowFairblockExecutedNonce - } - 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, ErrIntOverflowFairblockExecutedNonce - } - 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, ErrInvalidLengthFairblockExecutedNonce - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupFairblockExecutedNonce - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthFairblockExecutedNonce - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthFairblockExecutedNonce = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowFairblockExecutedNonce = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupFairblockExecutedNonce = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/fairblock/types/genesis.go b/x/fairblock/types/genesis.go index aabe45b3..760c1fbc 100644 --- a/x/fairblock/types/genesis.go +++ b/x/fairblock/types/genesis.go @@ -10,9 +10,8 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - EncryptedTxArray: []EncryptedTxArray{}, - FairblockExecutedNonceList: []FairblockExecutedNonce{}, - AggregatedKeyShareList: []AggregatedKeyShare{}, + EncryptedTxArray: []EncryptedTxArray{}, + AggregatedKeyShareList: []AggregatedKeyShare{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -39,16 +38,6 @@ func (gs GenesisState) Validate() error { encryptedTxArrIndexMap[index] = struct{}{} } - // Check for duplicated index in fairblockExecutedNonce - fairblockExecutedNonceIndexMap := make(map[string]struct{}) - - for _, elem := range gs.FairblockExecutedNonceList { - index := string(FairblockExecutedNonceKey(elem.Address)) - if _, ok := fairblockExecutedNonceIndexMap[index]; ok { - return fmt.Errorf("duplicated index for fairblockExecutedNonce") - } - fairblockExecutedNonceIndexMap[index] = struct{}{} - } // Check for duplicated index in aggregatedKeyShare aggregatedKeyShareIndexMap := make(map[string]struct{}) diff --git a/x/fairblock/types/genesis.pb.go b/x/fairblock/types/genesis.pb.go index c72b00d0..ad1936f4 100644 --- a/x/fairblock/types/genesis.pb.go +++ b/x/fairblock/types/genesis.pb.go @@ -25,13 +25,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fairblock module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` - EncryptedTxArray []EncryptedTxArray `protobuf:"bytes,3,rep,name=encryptedTxArray,proto3" json:"encryptedTxArray"` - FairblockNonceList []FairblockNonce `protobuf:"bytes,4,rep,name=fairblockNonceList,proto3" json:"fairblockNonceList"` - FairblockExecutedNonceList []FairblockExecutedNonce `protobuf:"bytes,5,rep,name=fairblockExecutedNonceList,proto3" json:"fairblockExecutedNonceList"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + EncryptedTxArray []EncryptedTxArray `protobuf:"bytes,3,rep,name=encryptedTxArray,proto3" json:"encryptedTxArray"` + FairblockNonceList []FairblockNonce `protobuf:"bytes,4,rep,name=fairblockNonceList,proto3" json:"fairblockNonceList"` // this line is used by starport scaffolding # genesis/proto/state - AggregatedKeyShareList []AggregatedKeyShare `protobuf:"bytes,6,rep,name=aggregatedKeyShareList,proto3" json:"aggregatedKeyShareList"` + AggregatedKeyShareList []AggregatedKeyShare `protobuf:"bytes,5,rep,name=aggregatedKeyShareList,proto3" json:"aggregatedKeyShareList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -95,13 +94,6 @@ func (m *GenesisState) GetFairblockNonceList() []FairblockNonce { return nil } -func (m *GenesisState) GetFairblockExecutedNonceList() []FairblockExecutedNonce { - if m != nil { - return m.FairblockExecutedNonceList - } - return nil -} - func (m *GenesisState) GetAggregatedKeyShareList() []AggregatedKeyShare { if m != nil { return m.AggregatedKeyShareList @@ -116,31 +108,29 @@ func init() { func init() { proto.RegisterFile("fairyring/fairblock/genesis.proto", fileDescriptor_b53796bdf37ea997) } var fileDescriptor_b53796bdf37ea997 = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xfb, 0x30, - 0x1c, 0xc7, 0xdb, 0xff, 0xf6, 0xaf, 0x98, 0x79, 0x90, 0x28, 0x5a, 0x3a, 0xa8, 0x55, 0x51, 0x27, - 0x42, 0x07, 0x13, 0x0f, 0x1e, 0x37, 0x98, 0x22, 0x8a, 0xc8, 0x26, 0x88, 0x5e, 0x4a, 0xd6, 0xc5, - 0x5a, 0xa6, 0x4d, 0x4d, 0x23, 0xb4, 0x6f, 0xe1, 0x63, 0xed, 0xb8, 0xa3, 0x27, 0x91, 0xed, 0x05, - 0x7c, 0x04, 0x49, 0x16, 0xba, 0xcd, 0xc5, 0xdd, 0xd2, 0xf6, 0xf3, 0xfd, 0x7c, 0xe9, 0x2f, 0x3f, - 0xb0, 0xfd, 0x88, 0x42, 0x9a, 0xd1, 0x30, 0x0a, 0xaa, 0xfc, 0xd4, 0x79, 0x26, 0x7e, 0xaf, 0x1a, - 0xe0, 0x08, 0x27, 0x61, 0xe2, 0xc6, 0x94, 0x30, 0x02, 0xd7, 0x72, 0xc4, 0xcd, 0x11, 0x6b, 0x3d, - 0x20, 0x01, 0x11, 0xdf, 0xab, 0xfc, 0x34, 0x46, 0x2d, 0x47, 0x65, 0x8b, 0x11, 0x45, 0x2f, 0x52, - 0x66, 0xed, 0xab, 0x08, 0x1c, 0xf9, 0x34, 0x8b, 0x19, 0xee, 0x7a, 0x2c, 0x95, 0xdc, 0xa1, 0x8a, - 0xcb, 0x4f, 0x5e, 0x44, 0x22, 0x1f, 0x4b, 0xb4, 0xb6, 0x18, 0xc5, 0x29, 0xf6, 0xdf, 0xb8, 0x7b, - 0x3a, 0xe3, 0xaa, 0x32, 0x28, 0x08, 0x28, 0x0e, 0x10, 0x67, 0x7b, 0x38, 0xf3, 0x92, 0x27, 0x44, - 0x25, 0xbf, 0xf3, 0x5d, 0x00, 0x2b, 0xe7, 0xe3, 0xa9, 0xb4, 0x19, 0x62, 0x18, 0x9e, 0x02, 0x63, - 0xfc, 0x5f, 0xa6, 0xee, 0xe8, 0x95, 0x52, 0xad, 0xec, 0x2a, 0xa6, 0xe4, 0xde, 0x08, 0xa4, 0x51, - 0xec, 0x7f, 0x6e, 0x69, 0x2d, 0x19, 0x80, 0x9b, 0x60, 0x29, 0x26, 0x94, 0x79, 0x61, 0xd7, 0xfc, - 0xe7, 0xe8, 0x95, 0xe5, 0x96, 0xc1, 0x1f, 0x2f, 0xba, 0xf0, 0x0e, 0xac, 0xe6, 0x93, 0xb8, 0x4d, - 0xeb, 0x94, 0xa2, 0xcc, 0x2c, 0x38, 0x85, 0x4a, 0xa9, 0xb6, 0xa7, 0xb4, 0x37, 0x7f, 0xc1, 0xb2, - 0x67, 0x4e, 0x02, 0xef, 0x01, 0xcc, 0x53, 0xd7, 0x7c, 0x0a, 0x57, 0x61, 0xc2, 0xcc, 0xa2, 0x50, - 0xef, 0x2a, 0xd5, 0x67, 0x33, 0xb8, 0x14, 0x2b, 0x24, 0xf0, 0x15, 0x58, 0xf9, 0xdb, 0xa6, 0x9c, - 0xf4, 0xa4, 0xe2, 0xbf, 0xa8, 0x38, 0x5a, 0x5c, 0x31, 0x13, 0x93, 0x55, 0x0b, 0xa4, 0x10, 0x83, - 0x8d, 0xc9, 0x4d, 0x5d, 0xe2, 0xac, 0xcd, 0xef, 0x49, 0xd4, 0x19, 0xa2, 0xee, 0x40, 0x59, 0x57, - 0x9f, 0x8b, 0xc8, 0xaa, 0x3f, 0x64, 0x8d, 0x93, 0xfe, 0xd0, 0xd6, 0x07, 0x43, 0x5b, 0xff, 0x1a, - 0xda, 0xfa, 0xfb, 0xc8, 0xd6, 0x06, 0x23, 0x5b, 0xfb, 0x18, 0xd9, 0xda, 0x43, 0x79, 0xb2, 0x3c, - 0xe9, 0xd4, 0xfa, 0xb0, 0x2c, 0xc6, 0x49, 0xc7, 0x10, 0x0b, 0x73, 0xfc, 0x13, 0x00, 0x00, 0xff, - 0xff, 0xc2, 0xb4, 0xbb, 0xfb, 0x59, 0x03, 0x00, 0x00, + // 341 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x4b, 0xc3, 0x30, + 0x14, 0xc7, 0xdb, 0x6d, 0x4e, 0xcc, 0x3c, 0x48, 0x14, 0x2d, 0x1b, 0xc4, 0xaa, 0xa8, 0xf3, 0xd2, + 0xc1, 0xc4, 0x83, 0xc7, 0x0d, 0x54, 0x44, 0x11, 0xd9, 0x04, 0xd1, 0x4b, 0xc9, 0xb6, 0x18, 0xcb, + 0xb4, 0x29, 0x69, 0x0e, 0xcb, 0xb7, 0xf0, 0x63, 0xed, 0xb8, 0xa3, 0x27, 0x91, 0xed, 0x73, 0x08, + 0x92, 0x34, 0x74, 0xea, 0xe2, 0xed, 0x95, 0xfe, 0xde, 0xef, 0xe5, 0xbd, 0x3f, 0xd8, 0x79, 0xc2, + 0x11, 0x97, 0x3c, 0x8a, 0x69, 0x43, 0x55, 0xbd, 0x17, 0xd6, 0x1f, 0x36, 0x28, 0x89, 0x49, 0x1a, + 0xa5, 0x41, 0xc2, 0x99, 0x60, 0x70, 0x3d, 0x47, 0x82, 0x1c, 0xa9, 0x6e, 0x50, 0x46, 0x99, 0xfe, + 0xdf, 0x50, 0x55, 0x86, 0x56, 0x7d, 0x9b, 0x2d, 0xc1, 0x1c, 0xbf, 0x1a, 0x59, 0xf5, 0xc0, 0x46, + 0x90, 0xb8, 0xcf, 0x65, 0x22, 0xc8, 0x20, 0x14, 0x23, 0xc3, 0x1d, 0xd9, 0xb8, 0xbc, 0x0a, 0x63, + 0x16, 0xf7, 0x89, 0x41, 0x03, 0x1b, 0x8a, 0x29, 0xe5, 0x84, 0x62, 0xe5, 0x1c, 0x12, 0x19, 0xa6, + 0xcf, 0x98, 0x1b, 0x7e, 0xf7, 0xab, 0x00, 0x56, 0x2f, 0xb2, 0x0d, 0xbb, 0x02, 0x0b, 0x02, 0x4f, + 0x41, 0x39, 0x7b, 0xa3, 0xe7, 0xfa, 0x6e, 0xbd, 0xd2, 0xac, 0x05, 0x96, 0x8d, 0x83, 0x5b, 0x8d, + 0xb4, 0x4b, 0xe3, 0x8f, 0x6d, 0xa7, 0x63, 0x1a, 0xe0, 0x16, 0x58, 0x4e, 0x18, 0x17, 0x61, 0x34, + 0xf0, 0x0a, 0xbe, 0x5b, 0x5f, 0xe9, 0x94, 0xd5, 0xe7, 0xe5, 0x00, 0xde, 0x83, 0xb5, 0x7c, 0xab, + 0xbb, 0x51, 0x8b, 0x73, 0x2c, 0xbd, 0xa2, 0x5f, 0xac, 0x57, 0x9a, 0xfb, 0x56, 0xfb, 0xd9, 0x1f, + 0xd8, 0xcc, 0x59, 0x90, 0xc0, 0x07, 0x00, 0xf3, 0xae, 0x1b, 0x75, 0x85, 0xeb, 0x28, 0x15, 0x5e, + 0x49, 0xab, 0xf7, 0xac, 0xea, 0xf3, 0x5f, 0xb8, 0x11, 0x5b, 0x24, 0x90, 0x80, 0xcd, 0xf9, 0xd9, + 0xae, 0x88, 0xec, 0xaa, 0xa3, 0x69, 0xfd, 0x92, 0xd6, 0x1f, 0x5a, 0xf5, 0xad, 0x85, 0x16, 0x33, + 0xe2, 0x1f, 0x59, 0xfb, 0x64, 0x3c, 0x45, 0xee, 0x64, 0x8a, 0xdc, 0xcf, 0x29, 0x72, 0xdf, 0x66, + 0xc8, 0x99, 0xcc, 0x90, 0xf3, 0x3e, 0x43, 0xce, 0x63, 0x6d, 0x9e, 0xe4, 0xe8, 0x47, 0x96, 0x42, + 0x26, 0x24, 0xed, 0x95, 0x75, 0x7a, 0xc7, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xac, 0x19, + 0x30, 0xb2, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -174,20 +164,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 - } - } - if len(m.FairblockExecutedNonceList) > 0 { - for iNdEx := len(m.FairblockExecutedNonceList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FairblockExecutedNonceList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x2a } } @@ -274,12 +250,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.FairblockExecutedNonceList) > 0 { - for _, e := range m.FairblockExecutedNonceList { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } if len(m.AggregatedKeyShareList) > 0 { for _, e := range m.AggregatedKeyShareList { l = e.Size() @@ -458,40 +428,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FairblockExecutedNonceList", 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.FairblockExecutedNonceList = append(m.FairblockExecutedNonceList, FairblockExecutedNonce{}) - if err := m.FairblockExecutedNonceList[len(m.FairblockExecutedNonceList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AggregatedKeyShareList", wireType) } diff --git a/x/fairblock/types/genesis_test.go b/x/fairblock/types/genesis_test.go index f3716493..667caba9 100644 --- a/x/fairblock/types/genesis_test.go +++ b/x/fairblock/types/genesis_test.go @@ -55,14 +55,6 @@ func TestGenesisState_Validate(t *testing.T) { Address: "1", }, }, - FairblockExecutedNonceList: []types.FairblockExecutedNonce{ - { - Address: "0", - }, - { - Address: "1", - }, - }, AggregatedKeyShareList: []types.AggregatedKeyShare{ { Height: 0, @@ -121,20 +113,6 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, - { - desc: "duplicated fairblockExecutedNonce", - genState: &types.GenesisState{ - FairblockExecutedNonceList: []types.FairblockExecutedNonce{ - { - Address: "0", - }, - { - Address: "0", - }, - }, - }, - valid: false, - }, { desc: "duplicated aggregatedKeyShare", genState: &types.GenesisState{ diff --git a/x/fairblock/types/key_fairblock_executed_nonce.go b/x/fairblock/types/key_fairblock_executed_nonce.go deleted file mode 100644 index 11664869..00000000 --- a/x/fairblock/types/key_fairblock_executed_nonce.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import "encoding/binary" - -var _ binary.ByteOrder - -const ( - // FairblockExecutedNonceKeyPrefix is the prefix to retrieve all FairblockExecutedNonce - FairblockExecutedNonceKeyPrefix = "FairblockExecutedNonce/value/" -) - -// FairblockExecutedNonceKey returns the store key to retrieve a FairblockExecutedNonce from the index fields -func FairblockExecutedNonceKey( - address string, -) []byte { - var key []byte - - addressBytes := []byte(address) - key = append(key, addressBytes...) - key = append(key, []byte("/")...) - - return key -} diff --git a/x/fairblock/types/query.pb.go b/x/fairblock/types/query.pb.go index 6d911f48..9c6db97c 100644 --- a/x/fairblock/types/query.pb.go +++ b/x/fairblock/types/query.pb.go @@ -657,194 +657,6 @@ func (m *QueryAllFairblockNonceResponse) GetPagination() *query.PageResponse { return nil } -type QueryGetFairblockExecutedNonceRequest struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` -} - -func (m *QueryGetFairblockExecutedNonceRequest) Reset() { *m = QueryGetFairblockExecutedNonceRequest{} } -func (m *QueryGetFairblockExecutedNonceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetFairblockExecutedNonceRequest) ProtoMessage() {} -func (*QueryGetFairblockExecutedNonceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_af70b057edf32872, []int{14} -} -func (m *QueryGetFairblockExecutedNonceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetFairblockExecutedNonceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetFairblockExecutedNonceRequest.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 *QueryGetFairblockExecutedNonceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetFairblockExecutedNonceRequest.Merge(m, src) -} -func (m *QueryGetFairblockExecutedNonceRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryGetFairblockExecutedNonceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetFairblockExecutedNonceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetFairblockExecutedNonceRequest proto.InternalMessageInfo - -func (m *QueryGetFairblockExecutedNonceRequest) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -type QueryGetFairblockExecutedNonceResponse struct { - FairblockExecutedNonce FairblockExecutedNonce `protobuf:"bytes,1,opt,name=fairblockExecutedNonce,proto3" json:"fairblockExecutedNonce"` -} - -func (m *QueryGetFairblockExecutedNonceResponse) Reset() { - *m = QueryGetFairblockExecutedNonceResponse{} -} -func (m *QueryGetFairblockExecutedNonceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetFairblockExecutedNonceResponse) ProtoMessage() {} -func (*QueryGetFairblockExecutedNonceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_af70b057edf32872, []int{15} -} -func (m *QueryGetFairblockExecutedNonceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetFairblockExecutedNonceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetFairblockExecutedNonceResponse.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 *QueryGetFairblockExecutedNonceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetFairblockExecutedNonceResponse.Merge(m, src) -} -func (m *QueryGetFairblockExecutedNonceResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGetFairblockExecutedNonceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetFairblockExecutedNonceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetFairblockExecutedNonceResponse proto.InternalMessageInfo - -func (m *QueryGetFairblockExecutedNonceResponse) GetFairblockExecutedNonce() FairblockExecutedNonce { - if m != nil { - return m.FairblockExecutedNonce - } - return FairblockExecutedNonce{} -} - -type QueryAllFairblockExecutedNonceRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllFairblockExecutedNonceRequest) Reset() { *m = QueryAllFairblockExecutedNonceRequest{} } -func (m *QueryAllFairblockExecutedNonceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllFairblockExecutedNonceRequest) ProtoMessage() {} -func (*QueryAllFairblockExecutedNonceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_af70b057edf32872, []int{16} -} -func (m *QueryAllFairblockExecutedNonceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllFairblockExecutedNonceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllFairblockExecutedNonceRequest.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 *QueryAllFairblockExecutedNonceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllFairblockExecutedNonceRequest.Merge(m, src) -} -func (m *QueryAllFairblockExecutedNonceRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAllFairblockExecutedNonceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllFairblockExecutedNonceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllFairblockExecutedNonceRequest proto.InternalMessageInfo - -func (m *QueryAllFairblockExecutedNonceRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -type QueryAllFairblockExecutedNonceResponse struct { - FairblockExecutedNonce []FairblockExecutedNonce `protobuf:"bytes,1,rep,name=fairblockExecutedNonce,proto3" json:"fairblockExecutedNonce"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllFairblockExecutedNonceResponse) Reset() { - *m = QueryAllFairblockExecutedNonceResponse{} -} -func (m *QueryAllFairblockExecutedNonceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllFairblockExecutedNonceResponse) ProtoMessage() {} -func (*QueryAllFairblockExecutedNonceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_af70b057edf32872, []int{17} -} -func (m *QueryAllFairblockExecutedNonceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllFairblockExecutedNonceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllFairblockExecutedNonceResponse.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 *QueryAllFairblockExecutedNonceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllFairblockExecutedNonceResponse.Merge(m, src) -} -func (m *QueryAllFairblockExecutedNonceResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAllFairblockExecutedNonceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllFairblockExecutedNonceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllFairblockExecutedNonceResponse proto.InternalMessageInfo - -func (m *QueryAllFairblockExecutedNonceResponse) GetFairblockExecutedNonce() []FairblockExecutedNonce { - if m != nil { - return m.FairblockExecutedNonce - } - return nil -} - -func (m *QueryAllFairblockExecutedNonceResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - func init() { proto.RegisterType((*QueryParamsRequest)(nil), "fairyring.fairblock.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "fairyring.fairblock.QueryParamsResponse") @@ -860,77 +672,64 @@ func init() { proto.RegisterType((*QueryGetFairblockNonceResponse)(nil), "fairyring.fairblock.QueryGetFairblockNonceResponse") proto.RegisterType((*QueryAllFairblockNonceRequest)(nil), "fairyring.fairblock.QueryAllFairblockNonceRequest") proto.RegisterType((*QueryAllFairblockNonceResponse)(nil), "fairyring.fairblock.QueryAllFairblockNonceResponse") - proto.RegisterType((*QueryGetFairblockExecutedNonceRequest)(nil), "fairyring.fairblock.QueryGetFairblockExecutedNonceRequest") - proto.RegisterType((*QueryGetFairblockExecutedNonceResponse)(nil), "fairyring.fairblock.QueryGetFairblockExecutedNonceResponse") - proto.RegisterType((*QueryAllFairblockExecutedNonceRequest)(nil), "fairyring.fairblock.QueryAllFairblockExecutedNonceRequest") - proto.RegisterType((*QueryAllFairblockExecutedNonceResponse)(nil), "fairyring.fairblock.QueryAllFairblockExecutedNonceResponse") } func init() { proto.RegisterFile("fairyring/fairblock/query.proto", fileDescriptor_af70b057edf32872) } var fileDescriptor_af70b057edf32872 = []byte{ - // 965 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xce, 0x24, 0x6d, 0x10, 0x2f, 0x51, 0x04, 0xd3, 0x28, 0xda, 0x3a, 0x74, 0x1b, 0x26, 0x69, - 0x9a, 0x16, 0xea, 0x49, 0x37, 0x2a, 0x74, 0x97, 0x03, 0x6c, 0xa5, 0xa6, 0x15, 0x42, 0x28, 0x5d, - 0x21, 0x90, 0xb8, 0xac, 0x66, 0x77, 0x27, 0x8e, 0x55, 0xc7, 0xde, 0xda, 0x0e, 0xda, 0x55, 0x14, - 0xa9, 0xe2, 0x2f, 0x40, 0xea, 0x89, 0x0b, 0x7f, 0x00, 0x37, 0x38, 0x23, 0x71, 0xad, 0x54, 0x09, - 0x55, 0x70, 0xe1, 0x80, 0x10, 0x4a, 0xf8, 0x43, 0x2a, 0x8f, 0xdf, 0x66, 0xed, 0x66, 0xd6, 0xf6, - 0x36, 0x7b, 0xb3, 0x3d, 0xef, 0xc7, 0xf7, 0x7d, 0xf3, 0x3c, 0x9f, 0x0d, 0x57, 0x77, 0x85, 0xed, - 0xf7, 0x7d, 0xdb, 0xb5, 0x78, 0x74, 0xd5, 0x72, 0xbc, 0xf6, 0x63, 0xfe, 0xe4, 0x40, 0xfa, 0x7d, - 0xb3, 0xeb, 0x7b, 0xa1, 0x47, 0x2f, 0x9d, 0x06, 0x98, 0xa7, 0x01, 0xc6, 0xa2, 0xe5, 0x59, 0x9e, - 0x5a, 0xe7, 0xd1, 0x55, 0x1c, 0x6a, 0xbc, 0x67, 0x79, 0x9e, 0xe5, 0x48, 0x2e, 0xba, 0x36, 0x17, - 0xae, 0xeb, 0x85, 0x22, 0xb4, 0x3d, 0x37, 0xc0, 0xd5, 0x9b, 0x6d, 0x2f, 0xd8, 0xf7, 0x02, 0xde, - 0x12, 0x81, 0x8c, 0x3b, 0xf0, 0xef, 0x6e, 0xb7, 0x64, 0x28, 0x6e, 0xf3, 0xae, 0xb0, 0x6c, 0x57, - 0x05, 0x63, 0xec, 0x8a, 0x0e, 0x55, 0x57, 0xf8, 0x62, 0x7f, 0x50, 0x6d, 0x5d, 0x17, 0x21, 0xdd, - 0xb6, 0xdf, 0xef, 0x86, 0xb2, 0xd3, 0x0c, 0x7b, 0x18, 0x77, 0x43, 0x17, 0x77, 0x7a, 0xd5, 0x74, - 0x3d, 0xb7, 0x2d, 0x31, 0xb4, 0x92, 0x1d, 0x2a, 0x7b, 0xb2, 0x7d, 0x10, 0xd5, 0x4e, 0xe6, 0x98, - 0xba, 0x1c, 0x61, 0x59, 0xbe, 0xb4, 0x44, 0x14, 0xfb, 0x58, 0xf6, 0x9b, 0xc1, 0x9e, 0xf0, 0x31, - 0x9e, 0x2d, 0x02, 0x7d, 0x14, 0x51, 0xdf, 0x51, 0x5c, 0x1a, 0xf2, 0xc9, 0x81, 0x0c, 0x42, 0xb6, - 0x03, 0x97, 0x52, 0x4f, 0x83, 0xae, 0xe7, 0x06, 0x92, 0x56, 0x61, 0x36, 0xe6, 0x5c, 0x22, 0x2b, - 0x64, 0x63, 0xae, 0xb2, 0x6c, 0x6a, 0xf6, 0xc2, 0x8c, 0x93, 0xee, 0x5d, 0x78, 0xfe, 0xef, 0xd5, - 0xa9, 0x06, 0x26, 0xb0, 0xaf, 0xc1, 0x50, 0x15, 0x1f, 0xc8, 0xf0, 0xfe, 0x40, 0x94, 0xaf, 0x7a, - 0xd8, 0x8f, 0x32, 0x98, 0x0f, 0x85, 0x6f, 0xc9, 0xf0, 0xa1, 0xb4, 0xad, 0xbd, 0x50, 0x95, 0xbf, - 0xd0, 0x48, 0x3d, 0xa3, 0x8b, 0x70, 0xd1, 0x76, 0x3b, 0xb2, 0x57, 0x9a, 0x56, 0x8b, 0xf1, 0x0d, - 0xb3, 0x60, 0x59, 0x5b, 0x17, 0x11, 0x3f, 0x84, 0x39, 0x39, 0x7c, 0x8c, 0xb0, 0x57, 0xb4, 0xb0, - 0x13, 0xe9, 0x88, 0x3d, 0x99, 0xca, 0x3a, 0x48, 0xa0, 0xee, 0x38, 0x1a, 0x02, 0xdb, 0x00, 0xc3, - 0x99, 0xc1, 0x36, 0xeb, 0x66, 0x3c, 0x60, 0x66, 0x34, 0x60, 0x66, 0x3c, 0xc2, 0x38, 0x60, 0xe6, - 0x8e, 0xb0, 0x24, 0xe6, 0x36, 0x12, 0x99, 0xec, 0x77, 0x82, 0x7c, 0x5e, 0x6f, 0x83, 0x7c, 0xbe, - 0x81, 0x77, 0x12, 0xa0, 0xea, 0xbe, 0x2f, 0xfa, 0x25, 0xb2, 0x32, 0xb3, 0x31, 0x57, 0xb9, 0x96, - 0x47, 0x4a, 0x05, 0x23, 0xb3, 0x33, 0x45, 0xe8, 0x83, 0x14, 0x81, 0x69, 0x45, 0xe0, 0x7a, 0x2e, - 0x81, 0x18, 0x55, 0x8a, 0xc1, 0xe7, 0xb0, 0xa6, 0x21, 0xb0, 0xed, 0x7b, 0xfb, 0xf1, 0x3e, 0x8e, - 0xb1, 0xe5, 0xec, 0x29, 0x81, 0x6b, 0x39, 0xc5, 0x32, 0x75, 0x21, 0xe7, 0xd6, 0x85, 0x19, 0x50, - 0x52, 0x08, 0xbe, 0x10, 0xa1, 0x0c, 0xc2, 0x14, 0x05, 0xb6, 0x05, 0x97, 0x35, 0x6b, 0x88, 0x68, - 0x09, 0x66, 0xf7, 0x92, 0xcc, 0xf0, 0x8e, 0x55, 0xe1, 0xca, 0x60, 0x60, 0xb7, 0x07, 0x70, 0xbe, - 0x8c, 0x5e, 0xe0, 0x81, 0x30, 0x25, 0x78, 0x4b, 0x74, 0x3a, 0xbe, 0x0c, 0xe2, 0xb7, 0xec, 0xed, - 0xc6, 0xe0, 0x96, 0x05, 0x50, 0x1e, 0x95, 0x8a, 0x4d, 0x1f, 0xc1, 0xc2, 0x6e, 0x6a, 0x05, 0x45, - 0x58, 0xd5, 0x8a, 0x90, 0x2e, 0x82, 0x12, 0xbc, 0x56, 0x80, 0x59, 0x88, 0xb7, 0xee, 0x38, 0x7a, - 0xbc, 0x93, 0x1a, 0xfd, 0xdf, 0x08, 0xd2, 0xd3, 0x74, 0xca, 0xa0, 0x37, 0x73, 0x2e, 0x7a, 0x93, - 0x9b, 0xfb, 0x3a, 0x8e, 0x6a, 0x72, 0x73, 0xee, 0xe3, 0x09, 0x5d, 0x70, 0x7f, 0x9f, 0x11, 0x58, - 0xcf, 0xab, 0x81, 0x4a, 0xd8, 0xb0, 0xb4, 0xab, 0x8d, 0xc0, 0x0d, 0xf8, 0x20, 0x5b, 0x91, 0x54, - 0x0a, 0x2a, 0x33, 0xa2, 0x20, 0xf3, 0x86, 0xef, 0x60, 0x36, 0xb1, 0x49, 0x0d, 0xc2, 0x3f, 0x03, - 0x19, 0x32, 0x3a, 0x16, 0x90, 0x61, 0x66, 0xa2, 0x32, 0x4c, 0x6c, 0x50, 0x2a, 0x7f, 0xcc, 0xc3, - 0x45, 0x45, 0x8f, 0x3e, 0x25, 0x30, 0x1b, 0x9b, 0x25, 0xbd, 0xae, 0x05, 0x7a, 0xd6, 0x99, 0x8d, - 0x8d, 0xfc, 0xc0, 0xb8, 0x27, 0x5b, 0xfd, 0xfe, 0xaf, 0xff, 0x9f, 0x4d, 0x5f, 0xa1, 0xcb, 0x7c, - 0xf4, 0xb7, 0x0b, 0xfd, 0x95, 0xc0, 0x5c, 0xe2, 0x2c, 0xa4, 0x7c, 0x74, 0x79, 0xad, 0x73, 0x1b, - 0x9b, 0xc5, 0x13, 0x10, 0xd7, 0x67, 0x0a, 0x57, 0x8d, 0xde, 0xe5, 0x79, 0x5f, 0x4c, 0xfc, 0x30, - 0xe9, 0x06, 0x47, 0xfc, 0x50, 0x59, 0xfe, 0x11, 0xfd, 0x89, 0xc0, 0x42, 0xf2, 0x00, 0x77, 0x9c, - 0x2c, 0xdc, 0x5a, 0xc3, 0xce, 0xc2, 0xad, 0xb7, 0x5e, 0x76, 0x43, 0xe1, 0x5e, 0xa5, 0xef, 0xe7, - 0xe2, 0xa6, 0x2f, 0x08, 0x94, 0xd2, 0x00, 0x87, 0x96, 0x45, 0xab, 0x45, 0x3b, 0x9f, 0xf1, 0x4c, - 0xa3, 0xf6, 0x26, 0xa9, 0x08, 0xff, 0xae, 0x82, 0x5f, 0xa1, 0x9b, 0xe3, 0xca, 0x4e, 0x7f, 0x24, - 0x30, 0x9f, 0xb4, 0x38, 0x7a, 0x6b, 0x34, 0x0c, 0x8d, 0x4d, 0x1a, 0x66, 0xd1, 0x70, 0x44, 0x7a, - 0x53, 0x21, 0x5d, 0xa3, 0x4c, 0x8b, 0xd4, 0x51, 0x29, 0xcd, 0xd8, 0x4d, 0xe9, 0x2f, 0x04, 0x16, - 0xd2, 0xe7, 0x3c, 0xad, 0x64, 0x4e, 0xa4, 0xd6, 0xc3, 0x8c, 0xad, 0xb1, 0x72, 0x10, 0xe7, 0x47, - 0x0a, 0xe7, 0x26, 0x35, 0x79, 0x81, 0x4f, 0x7a, 0x7e, 0x88, 0xa7, 0xfc, 0x11, 0xfd, 0x99, 0xc0, - 0xbb, 0xe9, 0x92, 0xd1, 0x04, 0x57, 0x32, 0xf7, 0x76, 0x6c, 0xd8, 0x23, 0x4d, 0x94, 0x7d, 0xa8, - 0x60, 0xaf, 0xd3, 0xb5, 0x22, 0xb0, 0xe9, 0x9f, 0x04, 0x96, 0xf4, 0xe7, 0x25, 0xad, 0x15, 0x13, - 0x4d, 0xe7, 0x15, 0xc6, 0x27, 0x6f, 0x94, 0x8b, 0x0c, 0x3e, 0x55, 0x0c, 0xaa, 0xf4, 0x63, 0x3e, - 0xce, 0x0f, 0x52, 0x62, 0x07, 0x5e, 0x10, 0xb8, 0xac, 0xef, 0x11, 0xed, 0x44, 0xad, 0x98, 0xaa, - 0xe3, 0xf2, 0xca, 0x75, 0x33, 0x76, 0x47, 0xf1, 0xe2, 0xf4, 0xd6, 0x58, 0xbc, 0xee, 0xdd, 0x79, - 0x7e, 0x5c, 0x26, 0x2f, 0x8f, 0xcb, 0xe4, 0xbf, 0xe3, 0x32, 0xf9, 0xe1, 0xa4, 0x3c, 0xf5, 0xf2, - 0xa4, 0x3c, 0xf5, 0xf7, 0x49, 0x79, 0xea, 0xdb, 0xe5, 0x61, 0x9d, 0x5e, 0xa2, 0x52, 0xd8, 0xef, - 0xca, 0xa0, 0x35, 0xab, 0x7e, 0x00, 0xb7, 0x5e, 0x05, 0x00, 0x00, 0xff, 0xff, 0x39, 0xc7, 0xa5, - 0xc2, 0x71, 0x0f, 0x00, 0x00, + // 826 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4d, 0x4f, 0x13, 0x41, + 0x18, 0xc7, 0x3b, 0xbc, 0xd4, 0x30, 0x25, 0x44, 0x07, 0x62, 0xea, 0x56, 0x4a, 0x1d, 0xde, 0x89, + 0xee, 0x40, 0x89, 0x06, 0x38, 0x09, 0x89, 0x40, 0x8c, 0x31, 0xd0, 0x18, 0x4d, 0xbc, 0x34, 0xd3, + 0x76, 0x58, 0x1a, 0x96, 0xdd, 0xb2, 0xbb, 0x98, 0x36, 0x84, 0x84, 0xf8, 0x09, 0x4c, 0x3c, 0x79, + 0xf1, 0x03, 0xe8, 0x49, 0xcf, 0x26, 0x5e, 0x49, 0xbc, 0x90, 0x78, 0xf1, 0x64, 0x0c, 0xf8, 0x41, + 0x4c, 0x67, 0x9f, 0xd2, 0x5d, 0x98, 0xbe, 0x09, 0xb7, 0xdd, 0x99, 0xe7, 0xe5, 0xf7, 0x7f, 0xe6, + 0x99, 0x67, 0x17, 0x8f, 0x6c, 0xf1, 0xa2, 0x53, 0x71, 0x8a, 0x96, 0xc1, 0xaa, 0x4f, 0x39, 0xd3, + 0xce, 0xef, 0xb0, 0xbd, 0x7d, 0xe1, 0x54, 0xf4, 0x92, 0x63, 0x7b, 0x36, 0x19, 0x3c, 0x37, 0xd0, + 0xcf, 0x0d, 0xb4, 0x21, 0xc3, 0x36, 0x6c, 0xb9, 0xcf, 0xaa, 0x4f, 0xbe, 0xa9, 0x76, 0xd7, 0xb0, + 0x6d, 0xc3, 0x14, 0x8c, 0x97, 0x8a, 0x8c, 0x5b, 0x96, 0xed, 0x71, 0xaf, 0x68, 0x5b, 0x2e, 0xec, + 0xce, 0xe4, 0x6d, 0x77, 0xd7, 0x76, 0x59, 0x8e, 0xbb, 0xc2, 0xcf, 0xc0, 0xde, 0xcc, 0xe5, 0x84, + 0xc7, 0xe7, 0x58, 0x89, 0x1b, 0x45, 0x4b, 0x1a, 0x83, 0x6d, 0x4a, 0x45, 0x55, 0xe2, 0x0e, 0xdf, + 0xad, 0x45, 0x9b, 0x50, 0x59, 0x08, 0x2b, 0xef, 0x54, 0x4a, 0x9e, 0x28, 0x64, 0xbd, 0x32, 0xd8, + 0x4d, 0xab, 0xec, 0xce, 0x9f, 0xb2, 0x96, 0x6d, 0xe5, 0x05, 0x98, 0xea, 0x2a, 0x53, 0x6e, 0x18, + 0x8e, 0x30, 0x78, 0x35, 0xe6, 0x8e, 0xa8, 0x64, 0xdd, 0x6d, 0xee, 0x80, 0x3d, 0x1d, 0xc2, 0x64, + 0xb3, 0x2a, 0x63, 0x43, 0x72, 0x65, 0xc4, 0xde, 0xbe, 0x70, 0x3d, 0xba, 0x81, 0x07, 0x43, 0xab, + 0x6e, 0xc9, 0xb6, 0x5c, 0x41, 0x16, 0x71, 0xd4, 0xe7, 0x8f, 0xa3, 0x14, 0x9a, 0x8a, 0xa5, 0x13, + 0xba, 0xa2, 0xae, 0xba, 0xef, 0xb4, 0xd2, 0x73, 0xfc, 0x7b, 0x24, 0x92, 0x01, 0x07, 0xfa, 0x12, + 0x6b, 0x32, 0xe2, 0x9a, 0xf0, 0x9e, 0xd4, 0x04, 0xbe, 0x28, 0x43, 0x3e, 0x42, 0x71, 0xbf, 0xc7, + 0x1d, 0x43, 0x78, 0xeb, 0xa2, 0x68, 0x6c, 0x7b, 0x32, 0x7c, 0x4f, 0x26, 0xb4, 0x46, 0x86, 0x70, + 0x6f, 0xd1, 0x2a, 0x88, 0x72, 0xbc, 0x4b, 0x6e, 0xfa, 0x2f, 0xd4, 0xc0, 0x09, 0x65, 0x5c, 0x20, + 0x5e, 0xc7, 0x31, 0x51, 0x5f, 0x06, 0xec, 0x94, 0x12, 0x3b, 0xe0, 0x0e, 0xec, 0x41, 0x57, 0x5a, + 0x00, 0x01, 0xcb, 0xa6, 0xa9, 0x10, 0xb0, 0x8a, 0x71, 0xfd, 0xfc, 0x21, 0xcd, 0x84, 0xee, 0x37, + 0x8b, 0x5e, 0x6d, 0x16, 0xdd, 0x6f, 0x47, 0x68, 0x16, 0x7d, 0x83, 0x1b, 0x02, 0x7c, 0x33, 0x01, + 0x4f, 0xfa, 0x1d, 0x81, 0x9e, 0x8b, 0x69, 0x40, 0xcf, 0x2b, 0x7c, 0x33, 0x00, 0xb5, 0xec, 0x38, + 0xbc, 0x12, 0x47, 0xa9, 0xee, 0xa9, 0x58, 0x7a, 0xbc, 0x95, 0x28, 0x69, 0x0c, 0xca, 0x2e, 0x05, + 0x21, 0x6b, 0x21, 0x01, 0x5d, 0x52, 0xc0, 0x64, 0x4b, 0x01, 0x3e, 0x55, 0x48, 0xc1, 0x53, 0x3c, + 0xa6, 0x10, 0xb0, 0xea, 0xd8, 0xbb, 0xfe, 0x39, 0x76, 0x70, 0xe4, 0xf4, 0x08, 0xe1, 0xf1, 0x16, + 0xc1, 0x9a, 0xd6, 0x05, 0x5d, 0xb9, 0x2e, 0x54, 0xc3, 0x71, 0x49, 0xf0, 0x8c, 0x7b, 0xc2, 0xf5, + 0x42, 0x12, 0xe8, 0x3c, 0xbe, 0xa3, 0xd8, 0x03, 0xa2, 0xdb, 0x38, 0xba, 0x1d, 0x54, 0x06, 0x6f, + 0x74, 0x11, 0x0f, 0xd7, 0x1a, 0x76, 0xb5, 0x86, 0xf3, 0xbc, 0x7a, 0x81, 0x6b, 0x85, 0x89, 0xe3, + 0x1b, 0xbc, 0x50, 0x70, 0x84, 0xeb, 0xdf, 0xb2, 0xbe, 0x4c, 0xed, 0x95, 0xba, 0x38, 0xd9, 0xc8, + 0x15, 0x92, 0x6e, 0xe2, 0x81, 0xad, 0xd0, 0x0e, 0x14, 0x61, 0x54, 0x59, 0x84, 0x70, 0x10, 0x28, + 0xc1, 0x85, 0x00, 0xd4, 0x00, 0xde, 0x65, 0xd3, 0x54, 0xf3, 0x5e, 0x57, 0xeb, 0x7f, 0x43, 0x20, + 0x4f, 0x91, 0xa9, 0x89, 0xbc, 0xee, 0x2b, 0xc9, 0xbb, 0xb6, 0xbe, 0x4f, 0x7f, 0xee, 0xc3, 0xbd, + 0x12, 0x9f, 0x1c, 0x21, 0x1c, 0xf5, 0x67, 0x20, 0x99, 0x54, 0x82, 0x5d, 0x1e, 0xb8, 0xda, 0x54, + 0x6b, 0x43, 0x3f, 0x27, 0x1d, 0x7d, 0xfb, 0xf3, 0xef, 0xfb, 0xae, 0x61, 0x92, 0x60, 0x8d, 0x3f, + 0x2f, 0xe4, 0x2b, 0xc2, 0xb1, 0x40, 0x8b, 0x13, 0xd6, 0x38, 0xbc, 0x72, 0x20, 0x6b, 0xb3, 0xed, + 0x3b, 0x00, 0xd7, 0x63, 0xc9, 0xb5, 0x44, 0x16, 0x58, 0xab, 0x8f, 0x1a, 0x3b, 0x08, 0x5e, 0xf2, + 0x43, 0x76, 0x20, 0x27, 0xf9, 0x21, 0xf9, 0x88, 0xf0, 0x40, 0xf0, 0x5e, 0x9a, 0x66, 0x33, 0x6e, + 0xe5, 0x1c, 0x6e, 0xc6, 0xad, 0x9e, 0xa8, 0x74, 0x5a, 0x72, 0x8f, 0x92, 0x7b, 0x2d, 0xb9, 0xc9, + 0x0f, 0x84, 0xe3, 0x61, 0xc0, 0xfa, 0x24, 0x22, 0x8b, 0xed, 0x66, 0xbe, 0x34, 0x0a, 0xb5, 0xa5, + 0xff, 0x71, 0x05, 0xfc, 0x05, 0x89, 0x9f, 0x26, 0xb3, 0x9d, 0x96, 0x9d, 0x7c, 0x40, 0xb8, 0x3f, + 0x38, 0xb9, 0xc8, 0x83, 0xc6, 0x18, 0x8a, 0xe9, 0xa7, 0xe9, 0xed, 0x9a, 0x03, 0xe9, 0x8c, 0x24, + 0x1d, 0x23, 0x54, 0x49, 0x6a, 0x4a, 0x97, 0xac, 0x3f, 0x24, 0xc9, 0x17, 0x84, 0x07, 0xc2, 0xd7, + 0x97, 0xa4, 0x9b, 0x76, 0xa4, 0x72, 0x34, 0x69, 0xf3, 0x1d, 0xf9, 0x00, 0xe7, 0x23, 0xc9, 0x39, + 0x4b, 0x74, 0xd6, 0xc6, 0x5f, 0x17, 0x3b, 0x80, 0xe1, 0x7c, 0x48, 0x3e, 0x21, 0x7c, 0x2b, 0x1c, + 0xb2, 0xda, 0xc1, 0xe9, 0xa6, 0x67, 0xdb, 0x31, 0x76, 0xc3, 0xd9, 0x48, 0xef, 0x4b, 0xec, 0x09, + 0x32, 0xd6, 0x0e, 0xf6, 0xca, 0xc3, 0xe3, 0xd3, 0x24, 0x3a, 0x39, 0x4d, 0xa2, 0x3f, 0xa7, 0x49, + 0xf4, 0xee, 0x2c, 0x19, 0x39, 0x39, 0x4b, 0x46, 0x7e, 0x9d, 0x25, 0x23, 0xaf, 0x13, 0x75, 0xf7, + 0x72, 0x20, 0x80, 0x57, 0x29, 0x09, 0x37, 0x17, 0x95, 0x3f, 0x8d, 0xf3, 0xff, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x3f, 0x26, 0x65, 0xf0, 0x71, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -959,10 +758,6 @@ type QueryClient interface { FairblockNonce(ctx context.Context, in *QueryGetFairblockNonceRequest, opts ...grpc.CallOption) (*QueryGetFairblockNonceResponse, error) // Queries a list of FairblockNonce items. FairblockNonceAll(ctx context.Context, in *QueryAllFairblockNonceRequest, opts ...grpc.CallOption) (*QueryAllFairblockNonceResponse, error) - // Queries a FairblockExecutedNonce by index. - FairblockExecutedNonce(ctx context.Context, in *QueryGetFairblockExecutedNonceRequest, opts ...grpc.CallOption) (*QueryGetFairblockExecutedNonceResponse, error) - // Queries a list of FairblockExecutedNonce items. - FairblockExecutedNonceAll(ctx context.Context, in *QueryAllFairblockExecutedNonceRequest, opts ...grpc.CallOption) (*QueryAllFairblockExecutedNonceResponse, error) } type queryClient struct { @@ -1036,24 +831,6 @@ func (c *queryClient) FairblockNonceAll(ctx context.Context, in *QueryAllFairblo return out, nil } -func (c *queryClient) FairblockExecutedNonce(ctx context.Context, in *QueryGetFairblockExecutedNonceRequest, opts ...grpc.CallOption) (*QueryGetFairblockExecutedNonceResponse, error) { - out := new(QueryGetFairblockExecutedNonceResponse) - err := c.cc.Invoke(ctx, "/fairyring.fairblock.Query/FairblockExecutedNonce", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FairblockExecutedNonceAll(ctx context.Context, in *QueryAllFairblockExecutedNonceRequest, opts ...grpc.CallOption) (*QueryAllFairblockExecutedNonceResponse, error) { - out := new(QueryAllFairblockExecutedNonceResponse) - err := c.cc.Invoke(ctx, "/fairyring.fairblock.Query/FairblockExecutedNonceAll", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1070,10 +847,6 @@ type QueryServer interface { FairblockNonce(context.Context, *QueryGetFairblockNonceRequest) (*QueryGetFairblockNonceResponse, error) // Queries a list of FairblockNonce items. FairblockNonceAll(context.Context, *QueryAllFairblockNonceRequest) (*QueryAllFairblockNonceResponse, error) - // Queries a FairblockExecutedNonce by index. - FairblockExecutedNonce(context.Context, *QueryGetFairblockExecutedNonceRequest) (*QueryGetFairblockExecutedNonceResponse, error) - // Queries a list of FairblockExecutedNonce items. - FairblockExecutedNonceAll(context.Context, *QueryAllFairblockExecutedNonceRequest) (*QueryAllFairblockExecutedNonceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1101,12 +874,6 @@ func (*UnimplementedQueryServer) FairblockNonce(ctx context.Context, req *QueryG func (*UnimplementedQueryServer) FairblockNonceAll(ctx context.Context, req *QueryAllFairblockNonceRequest) (*QueryAllFairblockNonceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FairblockNonceAll not implemented") } -func (*UnimplementedQueryServer) FairblockExecutedNonce(ctx context.Context, req *QueryGetFairblockExecutedNonceRequest) (*QueryGetFairblockExecutedNonceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FairblockExecutedNonce not implemented") -} -func (*UnimplementedQueryServer) FairblockExecutedNonceAll(ctx context.Context, req *QueryAllFairblockExecutedNonceRequest) (*QueryAllFairblockExecutedNonceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FairblockExecutedNonceAll not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1238,42 +1005,6 @@ func _Query_FairblockNonceAll_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Query_FairblockExecutedNonce_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetFairblockExecutedNonceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FairblockExecutedNonce(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/fairyring.fairblock.Query/FairblockExecutedNonce", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FairblockExecutedNonce(ctx, req.(*QueryGetFairblockExecutedNonceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_FairblockExecutedNonceAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllFairblockExecutedNonceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FairblockExecutedNonceAll(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/fairyring.fairblock.Query/FairblockExecutedNonceAll", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FairblockExecutedNonceAll(ctx, req.(*QueryAllFairblockExecutedNonceRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "fairyring.fairblock.Query", HandlerType: (*QueryServer)(nil), @@ -1306,14 +1037,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "FairblockNonceAll", Handler: _Query_FairblockNonceAll_Handler, }, - { - MethodName: "FairblockExecutedNonce", - Handler: _Query_FairblockExecutedNonce_Handler, - }, - { - MethodName: "FairblockExecutedNonceAll", - Handler: _Query_FairblockExecutedNonceAll_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "fairyring/fairblock/query.proto", @@ -1784,233 +1507,86 @@ func (m *QueryAllFairblockNonceResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryGetFairblockExecutedNonceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +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++ } - return dAtA[:n], nil + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n } -func (m *QueryGetFairblockExecutedNonceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryGetFairblockExecutedNonceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryGetEncryptedTxRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa + if m.TargetHeight != 0 { + n += 1 + sovQuery(uint64(m.TargetHeight)) } - return len(dAtA) - i, nil + if m.Index != 0 { + n += 1 + sovQuery(uint64(m.Index)) + } + return n } -func (m *QueryGetFairblockExecutedNonceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryGetEncryptedTxResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.EncryptedTx.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryGetFairblockExecutedNonceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryAllEncryptedTxRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryGetFairblockExecutedNonceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryAllEncryptedTxResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size, err := m.FairblockExecutedNonce.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 *QueryAllFairblockExecutedNonceRequest) 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 *QueryAllFairblockExecutedNonceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllFairblockExecutedNonceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.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 *QueryAllFairblockExecutedNonceResponse) 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 *QueryAllFairblockExecutedNonceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllFairblockExecutedNonceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.FairblockExecutedNonce) > 0 { - for iNdEx := len(m.FairblockExecutedNonce) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FairblockExecutedNonce[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 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 *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryGetEncryptedTxRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TargetHeight != 0 { - n += 1 + sovQuery(uint64(m.TargetHeight)) - } - if m.Index != 0 { - n += 1 + sovQuery(uint64(m.Index)) - } - return n -} - -func (m *QueryGetEncryptedTxResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.EncryptedTx.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAllEncryptedTxRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAllEncryptedTxResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.EncryptedTxArray) > 0 { - for _, e := range m.EncryptedTxArray { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.EncryptedTxArray) > 0 { + for _, e := range m.EncryptedTxArray { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } if m.Pagination != nil { @@ -2120,62 +1696,6 @@ func (m *QueryAllFairblockNonceResponse) Size() (n int) { return n } -func (m *QueryGetFairblockExecutedNonceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryGetFairblockExecutedNonceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.FairblockExecutedNonce.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAllFairblockExecutedNonceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAllFairblockExecutedNonceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.FairblockExecutedNonce) > 0 { - for _, e := range m.FairblockExecutedNonce { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3334,377 +2854,6 @@ func (m *QueryAllFairblockNonceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetFairblockExecutedNonceRequest) 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: QueryGetFairblockExecutedNonceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetFairblockExecutedNonceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *QueryGetFairblockExecutedNonceResponse) 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: QueryGetFairblockExecutedNonceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetFairblockExecutedNonceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FairblockExecutedNonce", 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 err := m.FairblockExecutedNonce.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 *QueryAllFairblockExecutedNonceRequest) 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: QueryAllFairblockExecutedNonceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllFairblockExecutedNonceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 *QueryAllFairblockExecutedNonceResponse) 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: QueryAllFairblockExecutedNonceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllFairblockExecutedNonceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FairblockExecutedNonce", 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.FairblockExecutedNonce = append(m.FairblockExecutedNonce, FairblockExecutedNonce{}) - if err := m.FairblockExecutedNonce[len(m.FairblockExecutedNonce)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/fairblock/types/query.pb.gw.go b/x/fairblock/types/query.pb.gw.go index dff98343..826da68b 100644 --- a/x/fairblock/types/query.pb.gw.go +++ b/x/fairblock/types/query.pb.gw.go @@ -325,96 +325,6 @@ func local_request_Query_FairblockNonceAll_0(ctx context.Context, marshaler runt } -func request_Query_FairblockExecutedNonce_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetFairblockExecutedNonceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") - } - - protoReq.Address, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) - } - - msg, err := client.FairblockExecutedNonce(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FairblockExecutedNonce_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetFairblockExecutedNonceRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") - } - - protoReq.Address, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) - } - - msg, err := server.FairblockExecutedNonce(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_FairblockExecutedNonceAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_FairblockExecutedNonceAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllFairblockExecutedNonceRequest - 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_FairblockExecutedNonceAll_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.FairblockExecutedNonceAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FairblockExecutedNonceAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllFairblockExecutedNonceRequest - 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_FairblockExecutedNonceAll_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.FairblockExecutedNonceAll(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. @@ -582,52 +492,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_FairblockExecutedNonce_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_FairblockExecutedNonce_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_FairblockExecutedNonce_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FairblockExecutedNonceAll_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_FairblockExecutedNonceAll_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_FairblockExecutedNonceAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -809,46 +673,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_FairblockExecutedNonce_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_FairblockExecutedNonce_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_FairblockExecutedNonce_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FairblockExecutedNonceAll_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_FairblockExecutedNonceAll_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_FairblockExecutedNonceAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -866,10 +690,6 @@ var ( pattern_Query_FairblockNonce_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"fairyring", "fairblock", "fairblock_nonce", "address"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_FairblockNonceAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"fairyring", "fairblock", "fairblock_nonce"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_FairblockExecutedNonce_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"fairyring", "fairblock", "fairblock_executed_nonce", "address"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_FairblockExecutedNonceAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"fairyring", "fairblock", "fairblock_executed_nonce"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -886,8 +706,4 @@ var ( forward_Query_FairblockNonce_0 = runtime.ForwardResponseMessage forward_Query_FairblockNonceAll_0 = runtime.ForwardResponseMessage - - forward_Query_FairblockExecutedNonce_0 = runtime.ForwardResponseMessage - - forward_Query_FairblockExecutedNonceAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/fairyring/keeper/keeper.go b/x/fairyring/keeper/keeper.go index dbde5fc7..cf9f4f64 100644 --- a/x/fairyring/keeper/keeper.go +++ b/x/fairyring/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "fairyring/x/fairyring/types" "github.com/cosmos/cosmos-sdk/codec" @@ -13,10 +14,11 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + stakingKeeper stakingkeeper.Keeper } ) @@ -25,7 +27,7 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, - + stakingKeeper stakingkeeper.Keeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -33,14 +35,18 @@ func NewKeeper( } return &Keeper{ - - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + stakingKeeper: stakingKeeper, } } +func (k Keeper) StakingKeeper() stakingkeeper.Keeper { + return k.stakingKeeper +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/fairyring/keeper/msg_server_register_validator.go b/x/fairyring/keeper/msg_server_register_validator.go index b86f4307..bf7c8464 100644 --- a/x/fairyring/keeper/msg_server_register_validator.go +++ b/x/fairyring/keeper/msg_server_register_validator.go @@ -2,25 +2,46 @@ package keeper import ( "context" + "encoding/hex" "fairyring/x/fairyring/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) func (k msgServer) RegisterValidator(goCtx context.Context, msg *types.MsgRegisterValidator) (*types.MsgRegisterValidatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: Handling the message - _, found := k.GetValidatorSet(ctx, msg.Creator) if found { return nil, types.ErrValidatorAlreadyRegistered.Wrap(msg.Creator) } + isStaking := false + var senderConsAddr string + + allStakingValidators := k.stakingKeeper.GetAllValidators(ctx) + for _, eachV := range allStakingValidators { + valAddr, _ := sdk.ValAddressFromBech32(eachV.OperatorAddress) + valAccAddr := sdk.AccAddress(valAddr) + consAddr, _ := eachV.GetConsAddr() + + if valAccAddr.String() == msg.Creator { + isStaking = true + consByte := consAddr.Bytes() + consHex := hex.EncodeToString(consByte) + senderConsAddr = consHex + break + } + } + + if !isStaking { + return nil, types.ErrAccountNotStaking.Wrap(msg.Creator) + } + validator := types.ValidatorSet{ Index: msg.Creator, Validator: msg.Creator, + ConsAddr: senderConsAddr, IsActive: true, } diff --git a/x/fairyring/keeper/msg_server_send_keyshare.go b/x/fairyring/keeper/msg_server_send_keyshare.go index 542afea2..e83af8f5 100644 --- a/x/fairyring/keeper/msg_server_send_keyshare.go +++ b/x/fairyring/keeper/msg_server_send_keyshare.go @@ -73,16 +73,12 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar ctx := sdk.UnwrapSDKContext(goCtx) // check if validator is registered - _, found := k.GetValidatorSet(ctx, msg.Creator) + validatorInfo, found := k.GetValidatorSet(ctx, msg.Creator) if !found { return nil, types.ErrValidatorNotRegistered.Wrap(msg.Creator) } - //if msg.BlockHeight < uint64(ctx.BlockHeight()) { - // return nil, types.ErrInvalidBlockHeight - //} - // Setup suite := bls.NewBLS12381Suite() ibeID := strconv.FormatUint(msg.BlockHeight, 10) @@ -90,7 +86,30 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar // Parse the keyshare & commitment then verify it _, _, err := parseKeyShareCommitment(suite, msg.Message, msg.Commitment, uint32(msg.KeyShareIndex), ibeID) if err != nil { - return nil, err + k.Logger(ctx).Error(fmt.Sprintf("Error in parsing & verifying keyshare & commitment: %s", err.Error())) + // Invalid Share, slash validator + var consAddr sdk.ConsAddress + + savedConsAddrByte, err := hex.DecodeString(validatorInfo.ConsAddr) + if err != nil { + return nil, err + } + + err = consAddr.Unmarshal(savedConsAddrByte) + if err != nil { + return nil, err + } + + k.stakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight()-1, 100, sdk.NewDecWithPrec(5, 1)) + + return &types.MsgSendKeyshareResponse{ + Creator: msg.Creator, + Keyshare: msg.Message, + Commitment: msg.Commitment, + KeyshareIndex: msg.KeyShareIndex, + ReceivedBlockHeight: uint64(ctx.BlockHeight()), + BlockHeight: msg.BlockHeight, + }, nil } keyShare := types.KeyShare{ diff --git a/x/fairyring/module.go b/x/fairyring/module.go index 923e4dc1..37989777 100644 --- a/x/fairyring/module.go +++ b/x/fairyring/module.go @@ -151,74 +151,15 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) { - //validatorList := am.keeper.GetAllValidatorSet(ctx) - // - //suite := bls.NewBLS12381Suite() - // - //var listOfShares []distIBE.ExtractedKey - //var listOfCommitment []distIBE.Commitment - // - //for _, eachValidator := range validatorList { - // eachKeyShare, found := am.keeper.GetKeyShare(ctx, eachValidator.Validator, uint64(ctx.BlockHeight())) - // if !found { - // am.keeper.Logger(ctx).Info( - // fmt.Sprintf( - // "Can not find key share from validator: %s for height: %d", - // eachValidator.Validator, - // ctx.BlockHeight(), - // ), - // ) - // continue - // } - // - // byteKey, err := hex.DecodeString(eachKeyShare.KeyShare) - // if err != nil { - // am.keeper.Logger(ctx).Error(fmt.Sprintf("Error in decoding hex key: %s", err.Error())) - // continue - // } - // - // kp := suite.G2().Point() - // err = kp.UnmarshalBinary(byteKey) - // if err != nil { - // am.keeper.Logger(ctx).Error(fmt.Sprintf("Error in unmarshal point: %s", err.Error())) - // continue - // } - // - // am.keeper.Logger(ctx).Info(eachKeyShare.Commitment) - // byteCommitment, err := hex.DecodeString(eachKeyShare.Commitment) - // if err != nil { - // am.keeper.Logger(ctx).Error(fmt.Sprintf("Error in decoding hex commitment: %s", err.Error())) - // continue - // } - // - // commitmentKp := suite.G1().Point() - // err = commitmentKp.UnmarshalBinary(byteCommitment) - // if err != nil { - // am.keeper.Logger(ctx).Error(fmt.Sprintf("Error in unmarshal commitment point: %s", err.Error())) - // continue - // } - // - // listOfShares = append( - // listOfShares, - // distIBE.ExtractedKey{ - // Sk: kp, - // Index: uint32(eachKeyShare.KeyShareIndex), - // }, - // ) - // listOfCommitment = append( - // listOfCommitment, - // distIBE.Commitment{ - // Sp: commitmentKp, - // Index: uint32(eachKeyShare.KeyShareIndex), - // }, - // ) - //} - // - //if len(listOfCommitment) > 0 && len(listOfShares) > 0 { - // SK, _ := distIBE.AggregateSK(suite, listOfShares, listOfCommitment, []byte(types.IBEId)) - // am.keeper.Logger(ctx).Info(fmt.Sprintf("Aggregated Decryption Key: %s", SK.String())) - //} +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + validators := am.keeper.StakingKeeper().GetAllValidators(ctx) + for _, eachValidator := range validators { + if !eachValidator.IsBonded() { + valAddr, _ := sdk.ValAddressFromBech32(eachValidator.OperatorAddress) + valAccAddr := sdk.AccAddress(valAddr) + am.keeper.RemoveValidatorSet(ctx, valAccAddr.String()) + } + } } // EndBlock contains the logic that is automatically triggered at the end of each block diff --git a/x/fairyring/types/errors.go b/x/fairyring/types/errors.go index d56c1863..edda338e 100644 --- a/x/fairyring/types/errors.go +++ b/x/fairyring/types/errors.go @@ -19,4 +19,5 @@ var ( ErrUnableToVerifyShare = sdkerrors.Register(ModuleName, 1108, "unable to verify share") ErrInvalidShare = sdkerrors.Register(ModuleName, 1109, "invalid share / commitment") ErrPubKeyNotFound = sdkerrors.Register(ModuleName, 1110, "Public key does not exists now") + ErrAccountNotStaking = sdkerrors.Register(ModuleName, 1111, "account is not staking") ) diff --git a/x/fairyring/types/validator_set.pb.go b/x/fairyring/types/validator_set.pb.go index 8aeb9b02..6919840d 100644 --- a/x/fairyring/types/validator_set.pb.go +++ b/x/fairyring/types/validator_set.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ValidatorSet struct { Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` Validator string `protobuf:"bytes,2,opt,name=validator,proto3" json:"validator,omitempty"` - IsActive bool `protobuf:"varint,3,opt,name=isActive,proto3" json:"isActive,omitempty"` + ConsAddr string `protobuf:"bytes,3,opt,name=consAddr,proto3" json:"consAddr,omitempty"` + IsActive bool `protobuf:"varint,4,opt,name=isActive,proto3" json:"isActive,omitempty"` } func (m *ValidatorSet) Reset() { *m = ValidatorSet{} } @@ -75,6 +76,13 @@ func (m *ValidatorSet) GetValidator() string { return "" } +func (m *ValidatorSet) GetConsAddr() string { + if m != nil { + return m.ConsAddr + } + return "" +} + func (m *ValidatorSet) GetIsActive() bool { if m != nil { return m.IsActive @@ -91,18 +99,19 @@ func init() { } var fileDescriptor_92e1027f2189f291 = []byte{ - // 169 bytes of a gzipped FileDescriptorProto + // 185 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0x4b, 0xcc, 0x2c, 0xaa, 0x2c, 0xca, 0xcc, 0x4b, 0xd7, 0x47, 0xb0, 0xca, 0x12, 0x73, 0x32, 0x53, 0x12, 0x4b, 0xf2, 0x8b, 0xe2, 0x8b, 0x53, 0x4b, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x84, 0xe1, 0xd2, 0x7a, - 0x70, 0x96, 0x52, 0x1c, 0x17, 0x4f, 0x18, 0x4c, 0x6d, 0x70, 0x6a, 0x89, 0x90, 0x08, 0x17, 0x6b, + 0x70, 0x96, 0x52, 0x15, 0x17, 0x4f, 0x18, 0x4c, 0x6d, 0x70, 0x6a, 0x89, 0x90, 0x08, 0x17, 0x6b, 0x66, 0x5e, 0x4a, 0x6a, 0x85, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x84, 0x23, 0x24, 0xc3, - 0xc5, 0x09, 0x37, 0x51, 0x82, 0x09, 0x2c, 0x83, 0x10, 0x10, 0x92, 0xe2, 0xe2, 0xc8, 0x2c, 0x76, - 0x4c, 0x2e, 0xc9, 0x2c, 0x4b, 0x95, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x08, 0x82, 0xf3, 0x9d, 0x4c, - 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, - 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x1a, 0xe1, 0xda, 0x0a, 0x24, - 0x97, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x9d, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, - 0xff, 0x67, 0x7b, 0xe3, 0x95, 0xdd, 0x00, 0x00, 0x00, + 0xc5, 0x09, 0x37, 0x51, 0x82, 0x09, 0x2c, 0x83, 0x10, 0x10, 0x92, 0xe2, 0xe2, 0x48, 0xce, 0xcf, + 0x2b, 0x76, 0x4c, 0x49, 0x29, 0x92, 0x60, 0x06, 0x4b, 0xc2, 0xf9, 0x20, 0xb9, 0xcc, 0x62, 0xc7, + 0xe4, 0x92, 0xcc, 0xb2, 0x54, 0x09, 0x16, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x38, 0xdf, 0xc9, 0xf4, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, + 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xa4, 0x11, 0x3e, 0xa9, 0x40, 0xf2, + 0x55, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x3b, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xea, 0x25, 0x18, 0xd1, 0xf9, 0x00, 0x00, 0x00, } func (m *ValidatorSet) Marshal() (dAtA []byte, err error) { @@ -133,7 +142,14 @@ func (m *ValidatorSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 + } + if len(m.ConsAddr) > 0 { + i -= len(m.ConsAddr) + copy(dAtA[i:], m.ConsAddr) + i = encodeVarintValidatorSet(dAtA, i, uint64(len(m.ConsAddr))) + i-- + dAtA[i] = 0x1a } if len(m.Validator) > 0 { i -= len(m.Validator) @@ -177,6 +193,10 @@ func (m *ValidatorSet) Size() (n int) { if l > 0 { n += 1 + l + sovValidatorSet(uint64(l)) } + l = len(m.ConsAddr) + if l > 0 { + n += 1 + l + sovValidatorSet(uint64(l)) + } if m.IsActive { n += 2 } @@ -283,6 +303,38 @@ func (m *ValidatorSet) Unmarshal(dAtA []byte) error { m.Validator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowValidatorSet + } + 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 ErrInvalidLengthValidatorSet + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthValidatorSet + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IsActive", wireType) }