diff --git a/Makefile b/Makefile index d79dd92..6983ab9 100644 --- a/Makefile +++ b/Makefile @@ -494,19 +494,19 @@ generate-zk-keys: .PHONY: generate-zk-keys ###################################################################### -####### Relayer ############ +####### dispatcher ############ ###################################################################### -run-alice-relayer: - zkappd tx zk-gov run-relayer --from alice --keyring-backend test --chain-id demo -y -run-bob-relayer: - zkappd tx zk-gov run-relayer --from bob --keyring-backend test --chain-id demo -run-sai-relayer: - zkappd tx zk-gov run-relayer --from sai --keyring-backend test --chain-id demo -run-teja-relayer: - zkappd tx zk-gov run-relayer --from teja --keyring-backend test --chain-id demo +run-alice-dispatcher: + zkappd tx zk-gov run-dispatcher --from alice --keyring-backend test --chain-id demo -y +run-bob-dispatcher: + zkappd tx zk-gov run-dispatcher --from bob --keyring-backend test --chain-id demo +run-charlie-dispatcher: + zkappd tx zk-gov run-dispatcher --from charlie --keyring-backend test --chain-id demo +run-david-dispatcher: + zkappd tx zk-gov run-dispatcher --from david --keyring-backend test --chain-id demo -.PHONY: run-alice-relayer run-bob-relayer run-sai-relayer run-teja-relayer +.PHONY: run-alice-dispatcher run-bob-dispatcher run-charlie-dispatcher run-david-dispatcher ###################################################################### ####### Transactions ############ @@ -521,28 +521,28 @@ register-alice-vote: zkappd tx zk-gov register-vote 1 "NO" --from alice --keyring-backend test --chain-id demo register-bob-vote: zkappd tx zk-gov register-vote 1 "YES" --from bob --keyring-backend test --chain-id demo -register-sai-vote: - zkappd tx zk-gov register-vote 1 "NO" --from sai --keyring-backend test --chain-id demo -register-teja-vote: - zkappd tx zk-gov register-vote 1 "YES" --from teja --keyring-backend test --chain-id demo +register-charlie-vote: + zkappd tx zk-gov register-vote 1 "NO" --from charlie --keyring-backend test --chain-id demo +register-david-vote: + zkappd tx zk-gov register-vote 1 "YES" --from david --keyring-backend test --chain-id demo broadcast-alice-vote: zkappd tx zk-gov vote 1 cosmos1ux2hl3y42nz6vtdl8k7t7f05k9p3r2k62zfvtv --from unknown --keyring-backend test --chain-id demo broadcast-bob-vote: zkappd tx zk-gov vote 1 cosmos13j3mn8n2d3scd2yy3urmw5vqhn53rej6p050np --from unknown --keyring-backend test --chain-id demo -broadcast-sai-vote: +broadcast-charlie-vote: zkappd tx zk-gov vote 1 cosmos1mg4t0l2nc98vhjdmg6kzee5wh6uhx9jlfrgfu9 --from unknown --keyring-backend test --chain-id demo -broadcast-teja-vote: +broadcast-david-vote: zkappd tx zk-gov vote 1 cosmos1pf0m5ch2673r6lv5lwm2mkyw433xapzx7nuemu --from unknown --keyring-backend test --chain-id demo -broadcast-alice-vote-via-relayer: - zkappd tx zk-gov vote 1 cosmos1ux2hl3y42nz6vtdl8k7t7f05k9p3r2k62zfvtv --relayer "http://localhost:8080" -broadcast-bob-vote-via-relayer: - zkappd tx zk-gov vote 1 cosmos13j3mn8n2d3scd2yy3urmw5vqhn53rej6p050np --relayer "http://localhost:8080" -broadcast-sai-vote-via-relayer: - zkappd tx zk-gov vote 1 cosmos1mg4t0l2nc98vhjdmg6kzee5wh6uhx9jlfrgfu9 --relayer "http://localhost:8080" -broadcast-teja-vote-via-relayer: - zkappd tx zk-gov vote 1 cosmos1pf0m5ch2673r6lv5lwm2mkyw433xapzx7nuemu --relayer "http://localhost:8080" +broadcast-alice-vote-via-dispatcher: + zkappd tx zk-gov vote 1 cosmos1ux2hl3y42nz6vtdl8k7t7f05k9p3r2k62zfvtv --dispatcher "http://localhost:8080" +broadcast-bob-vote-via-dispatcher: + zkappd tx zk-gov vote 1 cosmos13j3mn8n2d3scd2yy3urmw5vqhn53rej6p050np --dispatcher "http://localhost:8080" +broadcast-charlie-vote-via-dispatcher: + zkappd tx zk-gov vote 1 cosmos1mg4t0l2nc98vhjdmg6kzee5wh6uhx9jlfrgfu9 --dispatcher "http://localhost:8080" +broadcast-david-vote-via-dispatcher: + zkappd tx zk-gov vote 1 cosmos1pf0m5ch2673r6lv5lwm2mkyw433xapzx7nuemu --dispatcher "http://localhost:8080" -.PHONY: create-proposal-a create-proposal-b broadcast-alice-vote broadcast-bob-vote broadcast-sai-vote broadcast-teja-vote broadcast-alice-vote-via-relayer broadcast-bob-vote-via-relayer broadcast-sai-vote-via-relayer broadcast-teja-vote-via-relayer \ No newline at end of file +.PHONY: create-proposal-a create-proposal-b broadcast-alice-vote broadcast-bob-vote broadcast-charlie-vote broadcast-david-vote broadcast-alice-vote-via-dispatcher broadcast-bob-vote-via-dispatcher broadcast-charlie-vote-via-dispatcher broadcast-david-vote-via-dispatcher \ No newline at end of file diff --git a/README.md b/README.md index 31f1691..c00eb22 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Cosmos ZK Voting is a governance voting system designed to ensure voter anonymit * **Anonymous Voting:** Protects voter identities using Zero-Knowledge proofs. * **Decentralized:** Built on the Cosmos blockchain for enhanced security and scalability. * **Secure Key Management:** Ensures the safety of prover and verifier keys. -* **Relayer Support:** Facilitates seamless vote transactions through a dedicated relayer service. +* **dispatcher Support:** Facilitates seamless vote transactions through a dedicated dispatcher service. * **Flexible Proposal Management:** Create and manage governance proposals with ease. ## **Getting Started** @@ -25,10 +25,13 @@ Follow the steps below to set up and run Cosmos ZK Voting locally. * [Git](https://git-scm.com/downloads) ### **Clone the Repository** + ```bash -git clone https://github.com/your-username/cosmos-zk-voting -cd cosmos-zk-voting + +git clone https://github.com/vitwit/cosmos-zk-gov + git fetch + git checkout main ``` @@ -44,18 +47,15 @@ make install Initialize and start a local testnet. -**Initialize the Chain:** +1. **Initialize and Start the Chain:** Modify the `scripts/init-simapp.sh` script according to your requirements. -```bash +`make init-simapp` will the run chain. +```bash make init-simapp ``` -1. **Start the Testnet:** -```bash -zkappd start -``` -2. ## **ZK Prover and Verifier Keys** +## **ZK Prover and Verifier Keys** Before setting up the chain, generate the ZK prover and verifier keys. @@ -76,34 +76,28 @@ make generate-zk-keys * **Optimize Merkle Implementation:** Aim for a constant Merkle tree size of 2^31 and improve update operations from O(n) to O(log n). -## **Relayer** - -The Relayer is an HTTP server that listens for vote transactions, signs them with a valid chain address, and broadcasts them on-chain. - -### **Why Use a Relayer?** +## **Dispatcher** -Vote transactions must be sent from a different, unlinkable address than the registered address. Since most users may not have multiple unlinkable addresses, the Relayer serves as an intermediary to handle this securely. +The Dispatcher is an HTTP server that listens for vote transactions, signs them with a valid chain address, and broadcasts them on-chain. -**Security Assurance:** The Relayer cannot manipulate transactions because the ZK proof guarantees transaction validity without exposing user secrets. +### **Why Use a Dispatcher?** -### **Running the Relayer** +Vote transactions must be sent from a different, unlinkable address than the registered address. Since most users may not have multiple unlinkable addresses, the dispatcher serves as an intermediary to handle this securely. -**Navigate to the Relayer Directory:** -```bash -cd /x/zkgov/client/relayer -``` +**Security Assurance:** The Dispatcher cannot manipulate transactions because the ZK proof guarantees transaction validity without exposing user secrets. -1. **Start the Relayer:** -```bash -zkappd tx zk-gov run-relayer --from {key} --keyring-backend test --chain-id {chain-id} -y +### **Running the Dispatcher** +1.**Start the dispatcher:** +```bash +zkappd tx zk-gov run-dispatcher --from {key} --keyring-backend test --chain-id {chain-id} -y ``` -Alternatively, you can run a predefined relayer (e.g., Alice): -```bash -make run-alice-relayer +Alternatively, you can run a predefined dispatcher (e.g., alice): +```bash +make run-alice-dispatcher ``` -2. This command starts an HTTP server on port `8080` by default. You can change the port using the `--relayerPort {port}` flag. +2. This command starts an HTTP server on port `8080` by default. You can change the port using the `--dispatcherPort {port}` flag. ## **Transactions** @@ -125,6 +119,12 @@ Or use a make command for convenience: make create-proposal-a ``` +**Create Commitments Directory:** +```bash +mkdir commitments +``` + + ### **Register a Vote** Register a vote commitment, which will be used later to anonymize the actual vote. @@ -136,20 +136,22 @@ zkappd tx zk-gov register-vote [proposal-id] {"YES"/"NO"} --from [actual-voter- Alternatively, use predefined make commands: ```bash -mkdir commitments make register-alice-vote + make register-bob-vote -make register-sai-vote -make register-teja-vote + +make register-charlie-vote + +make register-david-vote ``` ### **Cast a Vote** After registering a vote commitment, generate a ZK proof to cast the actual vote. This proof verifies that you know the valid commitment without revealing your identity. -**Important:** The vote transaction must be signed by a different, unlinkable address from the one used to register the vote commitment. Use the Relayer to facilitate this process. +**Important:** The vote transaction must be signed by a different, unlinkable address from the one used to register the vote commitment. Use the dispatcher to facilitate this process. -#### **Without Relayer** +#### **Without dispatcher** ```bash zkappd tx zk-gov vote [proposal-id] [register-vote-address] --from [different-unlinkable-address] --keyring-backend test --chain-id [chain-id] @@ -162,17 +164,18 @@ make broadcast-alice-vote make broadcast-bob-vote ``` -#### **With Relayer** +#### **With Dispatcher** ```bash -zkappd tx zk-gov vote [proposal-id] [register-vote-address] --relayer [relayer-address] +zkappd tx zk-gov vote [proposal-id] [register-vote-address] --dispatcher [dispatcher-address] ``` Or use make commands: ```bash -make broadcast-sai-vote-via-relayer -make broadcast-teja-vote-via-relayer +make broadcast-charlie-vote-via-dispatcher + +make broadcast-david-vote-via-dispatcher ``` ### **Query a Proposal** diff --git a/app/app.go b/app/app.go index 3e34f2c..683d17e 100644 --- a/app/app.go +++ b/app/app.go @@ -99,9 +99,9 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" "github.com/spf13/cast" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov" - zkgovKeeper "github.com/vishal-kanna/zk/zk-gov/x/zkgov/keeper" - zktypes "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov" + zkgovKeeper "github.com/vitwit/cosmos-zk-gov/x/zkgov/keeper" + zktypes "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) const AppName = "App" diff --git a/app/sim_bench_test.go b/app/sim_bench_test.go index 851b742..b7d62c7 100644 --- a/app/sim_bench_test.go +++ b/app/sim_bench_test.go @@ -14,7 +14,7 @@ package app_test // simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" // "github.com/stretchr/testify/require" -// "github.com/vishal-kanna/zk/zk-gov/app" +// "github.com/vitwit/cosmos-zk-gov/app" // ) // // Profile with: diff --git a/app/zkappd/cmd/commands.go b/app/zkappd/cmd/commands.go index e05fb11..2e134b4 100644 --- a/app/zkappd/cmd/commands.go +++ b/app/zkappd/cmd/commands.go @@ -12,7 +12,7 @@ import ( "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" - simapp "github.com/vishal-kanna/zk/zk-gov/app" + simapp "github.com/vitwit/cosmos-zk-gov/app" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/debug" diff --git a/app/zkappd/cmd/root.go b/app/zkappd/cmd/root.go index 6a08677..2b2e684 100644 --- a/app/zkappd/cmd/root.go +++ b/app/zkappd/cmd/root.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/log" dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cobra" - simapp "github.com/vishal-kanna/zk/zk-gov/app" + simapp "github.com/vitwit/cosmos-zk-gov/app" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" diff --git a/app/zkappd/cmd/root_test.go b/app/zkappd/cmd/root_test.go index c66ce86..2336eb1 100644 --- a/app/zkappd/cmd/root_test.go +++ b/app/zkappd/cmd/root_test.go @@ -6,8 +6,8 @@ package cmd_test // "github.com/stretchr/testify/require" -// simapp "github.com/vishal-kanna/zk/zk-gov/app" -// "github.com/vishal-kanna/zk/zk-gov/app/zkappd/cmd" +// simapp "github.com/vitwit/cosmos-zk-gov/app" +// "github.com/vitwit/cosmos-zk-gov/app/zkappd/cmd" // "github.com/cosmos/cosmos-sdk/client/flags" // svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" diff --git a/app/zkappd/cmd/testnet.go b/app/zkappd/cmd/testnet.go index f12caf4..53d062a 100644 --- a/app/zkappd/cmd/testnet.go +++ b/app/zkappd/cmd/testnet.go @@ -15,7 +15,7 @@ import ( "cosmossdk.io/math" "cosmossdk.io/math/unsafe" - simapp "github.com/vishal-kanna/zk/zk-gov/app" + simapp "github.com/vitwit/cosmos-zk-gov/app" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/app/zkappd/main.go b/app/zkappd/main.go index 1ddf4d7..65b77f1 100644 --- a/app/zkappd/main.go +++ b/app/zkappd/main.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - simapp "github.com/vishal-kanna/zk/zk-gov/app" - "github.com/vishal-kanna/zk/zk-gov/app/zkappd/cmd" + simapp "github.com/vitwit/cosmos-zk-gov/app" + "github.com/vitwit/cosmos-zk-gov/app/zkappd/cmd" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" ) diff --git a/x/zkgov/client/relayer/client/client.go b/dispatcher/client/client.go similarity index 73% rename from x/zkgov/client/relayer/client/client.go rename to dispatcher/client/client.go index 7362137..05d23b5 100644 --- a/x/zkgov/client/relayer/client/client.go +++ b/dispatcher/client/client.go @@ -6,20 +6,20 @@ import ( "net/http" "time" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) -type RelayerClient struct { +type DispatcherClient struct { Address string } -func NewRelayerClient(address string) *RelayerClient { - return &RelayerClient{ +func NewdispatcherClient(address string) *DispatcherClient { + return &DispatcherClient{ Address: address, } } -func (relayerClient *RelayerClient) BroadCastTx(msg types.MsgVoteProposal) error { +func (dispatcherClient *DispatcherClient) BroadCastTx(msg types.MsgVoteProposal) error { // Marshal the message to JSON msgBytes, err := msg.Marshal() if err != nil { @@ -27,7 +27,7 @@ func (relayerClient *RelayerClient) BroadCastTx(msg types.MsgVoteProposal) error } // Create a new POST request - url := relayerClient.Address + "/broadCastTransaction" + url := dispatcherClient.Address + "/broadCastTransaction" req, err := http.NewRequest("POST", url, bytes.NewBuffer(msgBytes)) if err != nil { return fmt.Errorf("failed to create HTTP request: %w", err) diff --git a/x/zkgov/client/relayer/server/server.go b/dispatcher/server/server.go similarity index 68% rename from x/zkgov/client/relayer/server/server.go rename to dispatcher/server/server.go index a9f9d5a..624c4ae 100644 --- a/x/zkgov/client/relayer/server/server.go +++ b/dispatcher/server/server.go @@ -10,22 +10,22 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) -type RelayerServer struct { +type DispatcherServer struct { ClientCtx *client.Context Cmd *cobra.Command } -func NewRelayer(ctx *client.Context, cmd *cobra.Command) RelayerServer { - return RelayerServer{ +func NewDispatcher(ctx *client.Context, cmd *cobra.Command) DispatcherServer { + return DispatcherServer{ ClientCtx: ctx, Cmd: cmd, } } -func (relayer *RelayerServer) broadCastTransactionHandler(w http.ResponseWriter, r *http.Request) { +func (dispatcher *DispatcherServer) broadCastTransactionHandler(w http.ResponseWriter, r *http.Request) { if r.Method == http.MethodPost { body, err := io.ReadAll(r.Body) if err != nil { @@ -34,11 +34,11 @@ func (relayer *RelayerServer) broadCastTransactionHandler(w http.ResponseWriter, } defer r.Body.Close() - relayerAddress := relayer.ClientCtx.GetFromAddress().String() + dispatcherAddress := dispatcher.ClientCtx.GetFromAddress().String() var msg types.MsgVoteProposal err = msg.Unmarshal(body) - msg.Sender = relayerAddress + msg.Sender = dispatcherAddress if err != nil { slog.Error("unable to unmarshal transaction") @@ -51,7 +51,7 @@ func (relayer *RelayerServer) broadCastTransactionHandler(w http.ResponseWriter, fmt.Sprintf("Received vote transaction: proposal_ID=%d, vote_option=%d\n", msg.ProposalId, msg.VoteOption), ) - err = tx.GenerateOrBroadcastTxCLI(*relayer.ClientCtx, relayer.Cmd.Flags(), &msg) + err = tx.GenerateOrBroadcastTxCLI(*dispatcher.ClientCtx, dispatcher.Cmd.Flags(), &msg) if err != nil { slog.Error("Error while broadcasting vote proposal", err.Error()) http.Error(w, "Broadcast error ", http.StatusInternalServerError) @@ -74,11 +74,11 @@ func (relayer *RelayerServer) broadCastTransactionHandler(w http.ResponseWriter, } } -func (relayer *RelayerServer) Run(port string) error { - http.HandleFunc("/broadCastTransaction", relayer.broadCastTransactionHandler) - slog.Info("Starting Relayer server on :" + port) +func (dispatcher *DispatcherServer) Run(port string) error { + http.HandleFunc("/broadCastTransaction", dispatcher.broadCastTransactionHandler) + slog.Info("Starting dispatcher server on :" + port) if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil { - return fmt.Errorf("Could not start relayer: %s\n", err) + return fmt.Errorf("Could not start dispatcher: %s\n", err) } return nil } diff --git a/go.mod b/go.mod index 7fca476..5ca6320 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/vishal-kanna/zk/zk-gov +module github.com/vitwit/cosmos-zk-gov go 1.22.4 diff --git a/proto/sdk/zkgov/v1beta1/query.proto b/proto/sdk/zkgov/v1beta1/query.proto index 9920bab..ffdac85 100644 --- a/proto/sdk/zkgov/v1beta1/query.proto +++ b/proto/sdk/zkgov/v1beta1/query.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "sdk/zkgov/v1beta1/zkgov.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types"; +option go_package = "github.com/vitwit/cosmos-zk-gov/x/zkgov/types"; // Query service Query { diff --git a/proto/sdk/zkgov/v1beta1/tx.proto b/proto/sdk/zkgov/v1beta1/tx.proto index 10657f3..47412cc 100644 --- a/proto/sdk/zkgov/v1beta1/tx.proto +++ b/proto/sdk/zkgov/v1beta1/tx.proto @@ -5,7 +5,7 @@ import "cosmos/msg/v1/msg.proto"; import "sdk/zkgov/v1beta1/zkgov.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types"; +option go_package = "github.com/vitwit/cosmos-zk-gov/x/zkgov/types"; // Msg service for the zk-giv service service Msg { diff --git a/proto/sdk/zkgov/v1beta1/zkgov.proto b/proto/sdk/zkgov/v1beta1/zkgov.proto index 93995cb..88e2315 100644 --- a/proto/sdk/zkgov/v1beta1/zkgov.proto +++ b/proto/sdk/zkgov/v1beta1/zkgov.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package sdk.zkgov.v1beta1; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types"; +option go_package = "github.com/vitwit/cosmos-zk-gov/x/zkgov/types"; // commitment message Commitment { string commitment = 1; diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh index 1db5d99..512b248 100644 --- a/scripts/init-simapp.sh +++ b/scripts/init-simapp.sh @@ -2,9 +2,9 @@ SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} ALICE_MNEMONIC="all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic" -BOB_MNEMONIC="remain then chuckle hockey protect sausage govern curve hobby aisle clinic decline rotate judge this sail broom debris minute buddy buffalo desk pizza invite" -SAI_MNEMONIC="festival borrow upon ritual remind song execute chase toward fan neck subway canal throw nothing ticket frown leave thank become extend balcony strike fame" -TEJA_MNEMONIC="claim infant gather cereal sentence general cheese float hero dwarf miracle oven tide virus question choice say relax similar rice surround deal smooth rival" +BOB_MNEMONIC="remain then chuckle hockey protect sausage govern curve hobby aisle clinic decline rotate judge this charliel broom debris minute buddy buffalo desk pizza invite" +CHARLIE_MNEMONIC="festival borrow upon ritual remind song execute chase toward fan neck subway canal throw nothing ticket frown leave thank become extend balcony strike fame" +DAVID_MNEMONIC="claim infant gather cereal sentence general cheese float hero dwarf miracle oven tide virus question choice say relax similar rice surround deal smooth rival" UNKNOWN_MNOMONIC="purpose clutch ill track skate syrup cost among piano elegant close chaos come quit orchard acquire plunge hockey swift tongue salt supreme sting night" if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi @@ -16,15 +16,15 @@ $SIMD_BIN config set app api.enable true echo $ALICE_MNEMONIC | $SIMD_BIN keys add alice --recover echo $BOB_MNEMONIC | $SIMD_BIN keys add bob --recover -echo $SAI_MNEMONIC | $SIMD_BIN keys add sai --recover -echo $TEJA_MNEMONIC | $SIMD_BIN keys add teja --recover +echo $CHARLIE_MNEMONIC | $SIMD_BIN keys add charlie --recover +echo $DAVID_MNEMONIC | $SIMD_BIN keys add david --recover echo $UNKNOWN_MNOMONIC | $SIMD_BIN keys add unknown --recover $SIMD_BIN init test --chain-id demo $SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test $SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test -$SIMD_BIN genesis add-genesis-account sai 5000000000stake --keyring-backend test -$SIMD_BIN genesis add-genesis-account teja 5000000000stake --keyring-backend test +$SIMD_BIN genesis add-genesis-account charlie 5000000000stake --keyring-backend test +$SIMD_BIN genesis add-genesis-account david 5000000000stake --keyring-backend test $SIMD_BIN genesis add-genesis-account unknown 5000000000stake --keyring-backend test $SIMD_BIN genesis gentx alice 1000000stake --chain-id demo diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index a7c6849..37bebe3 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -32,7 +32,7 @@ cd .. # (cd tests/integration/tx/internal; make codegen) # move proto files to the right places -cp -r github.com/vishal-kanna/zk/zk-gov/* ./ +cp -r github.com/vitwit/cosmos-zk-gov/* ./ rm -rf github.com go mod tidy diff --git a/x/zkgov/autocli.go b/x/zkgov/autocli.go index 1c051f0..6a03367 100644 --- a/x/zkgov/autocli.go +++ b/x/zkgov/autocli.go @@ -2,7 +2,7 @@ package zkgov // import ( // autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" -// zkgovv1beta1 "github.com/vishal-kanna/zk/zk-gov/api/sdk/zkgov/v1beta1" +// zkgovv1beta1 "github.com/vitwit/cosmos-zk-gov/api/sdk/zkgov/v1beta1" // ) // func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { diff --git a/x/zkgov/circuit/circuit.go b/x/zkgov/circuit/circuit.go index 98a542c..481afa1 100644 --- a/x/zkgov/circuit/circuit.go +++ b/x/zkgov/circuit/circuit.go @@ -10,7 +10,7 @@ import ( "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/std/accumulator/merkle" "github.com/consensys/gnark/std/hash/mimc" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) // Define the circuit diff --git a/x/zkgov/circuit/circuit_test.go b/x/zkgov/circuit/circuit_test.go index 72fe998..e350128 100644 --- a/x/zkgov/circuit/circuit_test.go +++ b/x/zkgov/circuit/circuit_test.go @@ -14,7 +14,7 @@ import ( "github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc" "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/test" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/store" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/store" ) func GetRandomCommitmentList(size uint64, hFunc hash.Hash) []byte { diff --git a/x/zkgov/circuit/localStorage.go b/x/zkgov/circuit/localStorage.go index cce929c..031d26d 100644 --- a/x/zkgov/circuit/localStorage.go +++ b/x/zkgov/circuit/localStorage.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) type VoterInfo struct { diff --git a/x/zkgov/circuit/read_keys_test.go b/x/zkgov/circuit/read_keys_test.go index 12dbb77..ec057f6 100644 --- a/x/zkgov/circuit/read_keys_test.go +++ b/x/zkgov/circuit/read_keys_test.go @@ -12,7 +12,7 @@ import ( "github.com/consensys/gnark/backend/groth16" "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/test" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/store" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/store" ) func TestReadingKeys(t *testing.T) { diff --git a/x/zkgov/client/cli/query.go b/x/zkgov/client/cli/query.go index 895b281..0d99700 100644 --- a/x/zkgov/client/cli/query.go +++ b/x/zkgov/client/cli/query.go @@ -3,7 +3,7 @@ package cli import ( "strconv" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/x/zkgov/client/cli/tx.go b/x/zkgov/client/cli/tx.go index 2d3cc62..7e142e3 100644 --- a/x/zkgov/client/cli/tx.go +++ b/x/zkgov/client/cli/tx.go @@ -14,16 +14,16 @@ import ( "github.com/spf13/cobra" "golang.org/x/exp/slog" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/circuit" - relayerCLient "github.com/vishal-kanna/zk/zk-gov/x/zkgov/client/relayer/client" - relayerServer "github.com/vishal-kanna/zk/zk-gov/x/zkgov/client/relayer/server" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + dispatcherCLient "github.com/vitwit/cosmos-zk-gov/dispatcher/client" + dispatcherServer "github.com/vitwit/cosmos-zk-gov/dispatcher/server" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/circuit" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/store" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) var FlagSplit = "split" -var FlagRelayer = "relayer" -var FlagRelayerPort = "relayerPort" +var Flagdispatcher = "dispatcher" +var FlagdispatcherPort = "dispatcherPort" // NewTxCmd returns a root CLI command handler for all x/bank transaction commands. func NewTxCmd() *cobra.Command { @@ -39,7 +39,7 @@ func NewTxCmd() *cobra.Command { NewRegisterVoteCmd(), NewCreateProposalCmd(), NewVote(), - Relayer(), + Dispatcher(), ) return txCmd @@ -208,14 +208,14 @@ func NewVote() *cobra.Command { MerkleproofSize: uint64(merkleproofSize), } - relayerFlag := cmd.Flag(FlagRelayer) - relayerAddress := relayerFlag.Value.String() - if relayerAddress == "" { + dispatcherFlag := cmd.Flag(Flagdispatcher) + dispatcherAddress := dispatcherFlag.Value.String() + if dispatcherAddress == "" { return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) } - relayerClient := relayerCLient.NewRelayerClient(relayerAddress) - err = relayerClient.BroadCastTx(msg) + dispatcherClient := dispatcherCLient.NewdispatcherClient(dispatcherAddress) + err = dispatcherClient.BroadCastTx(msg) if err != nil { return err } @@ -225,30 +225,30 @@ func NewVote() *cobra.Command { }, } - cmd.Flags().String(FlagRelayer, "", "Broadcast the transaction Relayer end point") + cmd.Flags().String(Flagdispatcher, "", "Broadcast the transaction dispatcher end point") flags.AddTxFlagsToCmd(cmd) return cmd } -func Relayer() *cobra.Command { +func Dispatcher() *cobra.Command { cmd := &cobra.Command{ - Use: "run-relayer", - Short: "relayer will listen to transactions from users, signs them and broadcast them to network", + Use: "run-dispatcher", + Short: "dispatcher will listen to transactions from users, signs them and broadcast them to network", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - relayer := relayerServer.NewRelayer(&clientCtx, cmd) - port := cmd.Flag(FlagRelayerPort).Value.String() + dispatcher := dispatcherServer.NewDispatcher(&clientCtx, cmd) + port := cmd.Flag(FlagdispatcherPort).Value.String() - return relayer.Run(port) + return dispatcher.Run(port) }, } - cmd.Flags().Uint64(FlagRelayerPort, 8080, "port on which relayer runs") + cmd.Flags().Uint64(FlagdispatcherPort, 8080, "port on which dispatcher runs") flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/zkgov/client/zk/keys.go b/x/zkgov/client/zk/keys.go index feb0d71..da373aa 100644 --- a/x/zkgov/client/zk/keys.go +++ b/x/zkgov/client/zk/keys.go @@ -12,7 +12,7 @@ import ( "github.com/consensys/gnark/backend/groth16" "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/frontend/cs/r1cs" - zkcircuit "github.com/vishal-kanna/zk/zk-gov/x/zkgov/circuit" + zkcircuit "github.com/vitwit/cosmos-zk-gov/x/zkgov/circuit" ) func GenerateZKKeys(merkleProofSize int) { diff --git a/x/zkgov/keeper/keeper.go b/x/zkgov/keeper/keeper.go index a5ceb40..18131dd 100644 --- a/x/zkgov/keeper/keeper.go +++ b/x/zkgov/keeper/keeper.go @@ -6,9 +6,9 @@ import ( cosmosstore "cosmossdk.io/core/store" "github.com/consensys/gnark/backend/groth16" "github.com/cosmos/cosmos-sdk/codec" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/circuit" - storeImpl "github.com/vishal-kanna/zk/zk-gov/x/zkgov/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/circuit" + storeImpl "github.com/vitwit/cosmos-zk-gov/x/zkgov/store" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/runtime" diff --git a/x/zkgov/keeper/keeper_test.go b/x/zkgov/keeper/keeper_test.go index ca25843..9006d5e 100644 --- a/x/zkgov/keeper/keeper_test.go +++ b/x/zkgov/keeper/keeper_test.go @@ -18,9 +18,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/stretchr/testify/suite" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/keeper" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/keeper" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) type TestSuite struct { diff --git a/x/zkgov/keeper/msg_server.go b/x/zkgov/keeper/msg_server.go index 0ea794e..b5a14b3 100644 --- a/x/zkgov/keeper/msg_server.go +++ b/x/zkgov/keeper/msg_server.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) var _ types.MsgServer = msgServer{} diff --git a/x/zkgov/keeper/query_server.go b/x/zkgov/keeper/query_server.go index 26fa6e8..6c58eb8 100644 --- a/x/zkgov/keeper/query_server.go +++ b/x/zkgov/keeper/query_server.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/zkgov/keeper/query_server_test.go b/x/zkgov/keeper/query_server_test.go index ccf286d..a4ef72d 100644 --- a/x/zkgov/keeper/query_server_test.go +++ b/x/zkgov/keeper/query_server_test.go @@ -3,7 +3,7 @@ package keeper_test // import ( // "fmt" -// "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" +// "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" // ) // func (s *TestSuite) TestPlanByID() { diff --git a/x/zkgov/module.go b/x/zkgov/module.go index 31ae113..1d35b56 100644 --- a/x/zkgov/module.go +++ b/x/zkgov/module.go @@ -5,8 +5,8 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/client/cli" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/keeper" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/client/cli" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/keeper" "cosmossdk.io/core/appmodule" @@ -15,7 +15,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - zktypes "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + zktypes "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) var ( diff --git a/x/zkgov/store/commitment.go b/x/zkgov/store/commitment.go index 464c7fa..5ae0865 100644 --- a/x/zkgov/store/commitment.go +++ b/x/zkgov/store/commitment.go @@ -5,7 +5,7 @@ import ( "context" cosmosstore "cosmossdk.io/core/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func StoreCommitment(ctx context.Context, store cosmosstore.KVStore, proposalID uint64, commitment string) error { diff --git a/x/zkgov/store/merkle.go b/x/zkgov/store/merkle.go index 24fcd4c..22d5cba 100644 --- a/x/zkgov/store/merkle.go +++ b/x/zkgov/store/merkle.go @@ -10,7 +10,7 @@ import ( "github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc" "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/std/accumulator/merkle" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func InitMerkleRoot(ctx context.Context, store cosmosstore.KVStore, proposalID uint64) error { diff --git a/x/zkgov/store/nullifier.go b/x/zkgov/store/nullifier.go index 5a30418..b9ea036 100644 --- a/x/zkgov/store/nullifier.go +++ b/x/zkgov/store/nullifier.go @@ -6,7 +6,7 @@ import ( "errors" cosmosstore "cosmossdk.io/core/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func InitNullifiers(ctx context.Context, store cosmosstore.KVStore, proposalID uint64) error { diff --git a/x/zkgov/store/proposal.go b/x/zkgov/store/proposal.go index 8611a81..138e1dd 100644 --- a/x/zkgov/store/proposal.go +++ b/x/zkgov/store/proposal.go @@ -5,7 +5,7 @@ import ( "encoding/binary" cosmosstore "cosmossdk.io/core/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func StoreProposal(ctx context.Context, store cosmosstore.KVStore, req types.MsgCreateProposal) (uint64, error) { diff --git a/x/zkgov/store/user.go b/x/zkgov/store/user.go index d126c95..57c79e2 100644 --- a/x/zkgov/store/user.go +++ b/x/zkgov/store/user.go @@ -6,7 +6,7 @@ import ( "errors" cosmosstore "cosmossdk.io/core/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func InitUsers(ctx context.Context, store cosmosstore.KVStore, proposalID uint64) error { diff --git a/x/zkgov/store/vote.go b/x/zkgov/store/vote.go index abce22d..27c1752 100644 --- a/x/zkgov/store/vote.go +++ b/x/zkgov/store/vote.go @@ -4,7 +4,7 @@ import ( "context" cosmosstore "cosmossdk.io/core/store" - "github.com/vishal-kanna/zk/zk-gov/x/zkgov/types" + "github.com/vitwit/cosmos-zk-gov/x/zkgov/types" ) func InitVotes(ctx context.Context, store cosmosstore.KVStore, proposalID uint64) error {