Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cosmwasm support #106

Merged
merged 28 commits into from
Mar 5, 2024
Merged

add cosmwasm support #106

merged 28 commits into from
Mar 5, 2024

Conversation

bowenyou
Copy link
Member

No description provided.

@p0p3yee
Copy link
Contributor

p0p3yee commented Feb 15, 2024

Error when building fairyring:

go install -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=fairyring -X github.com/cosmos/cosmos-sdk/version.AppName=fairyringd -X github.com/cosmos/cosmos-sdk/version.Version=v0.3.1-49-g1c99c9c -X github.com/cosmos/cosmos-sdk/version.Commit=1c99c9cea9238c55d74859d69e59d852b300c92e -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -X github.com/cometbft/cometbft/version.TMCoreSemVer=v0.37.2 -w -s' -trimpath  ./...
# fairyring/testutil/keeper
testutil/keeper/keyshare.go:132:3: not enough arguments in call to keeper.NewKeeper
	have (*"github.com/cosmos/cosmos-sdk/codec".ProtoCodec, *"github.com/cosmos/cosmos-sdk/store/types".KVStoreKey, *"github.com/cosmos/cosmos-sdk/store/types".MemoryStoreKey, "github.com/cosmos/cosmos-sdk/x/params/types".Subspace, keyshareChannelKeeper, keysharePortKeeper, "github.com/cosmos/cosmos-sdk/x/capability/keeper".ScopedKeeper, keyshareconnectionKeeper, "fairyring/x/pep/keeper".Keeper, *"github.com/cosmos/cosmos-sdk/x/staking/keeper".Keeper)
	want ("github.com/cosmos/cosmos-sdk/codec".BinaryCodec, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/x/params/types".Subspace, "fairyring/x/keyshare/types".ChannelKeeper, "fairyring/x/keyshare/types".PortKeeper, "fairyring/x/keyshare/types".ScopedKeeper, "fairyring/x/keyshare/types".ConnectionKeeper, "fairyring/x/keyshare/types".PepKeeper, "fairyring/x/keyshare/types".StakingKeeper, "fairyring/x/keyshare/types".GovKeeper)
# github.com/CosmWasm/wasmd/x/wasm/keeper
../../go/pkg/mod/github.com/!cosm!wasm/wasmd@v0.45.0/x/wasm/keeper/test_common.go:461:3: not enough arguments in call to govkeeper.NewKeeper
	have ("github.com/cosmos/cosmos-sdk/codec".Codec, *"github.com/cosmos/cosmos-sdk/store/types".KVStoreKey, "github.com/cosmos/cosmos-sdk/x/auth/keeper".AccountKeeper, "github.com/cosmos/cosmos-sdk/x/bank/keeper".BaseKeeper, *"github.com/cosmos/cosmos-sdk/x/staking/keeper".Keeper, *baseapp.MsgServiceRouter, "github.com/cosmos/cosmos-sdk/x/gov/types".Config, string)
	want ("github.com/cosmos/cosmos-sdk/codec".BinaryCodec, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/x/gov/types".AccountKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".BankKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".StakingKeeper, *baseapp.MsgServiceRouter, "github.com/cosmos/cosmos-sdk/x/gov/types".Config, string, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ChannelKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".PortKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ScopedKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ConnectionKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".KeyshareKeeper)
make: *** [install] Error 1

keyshare keeper in testutil is not updated

@p0p3yee
Copy link
Contributor

p0p3yee commented Feb 15, 2024

fairyring/app/app.go, line 578

Cannot use 'keyshareKeeper' (type keysharemodulekeeper.Keeper) as the type types.KeyshareKeeper Type does not implement 'types.KeyshareKeeper' need the method: ProcessKeyshareRequest(ctx sdk.Context, msg MsgRequestAggrKeyshare) (rsp MsgRequestAggrKeyshareResponse, err error) have the method: ProcessKeyshareRequest(ctx sdk.Context, msg types.MsgRequestAggrKeyshare) (rsp types.MsgRequestAggrKeyshareResponse, err error)

Using the latest commit of github.com/Fairblock/cosmos-sdk, private-gov-47.3 branch, commit hash: 2f9d94a0d06f1f4cc9d80debf0e29a90b538e7a5 (put in ../cosmos-sdk)

@bowenyou
Copy link
Member Author

think we should also remove the vue/ autogenerated stuff from Ignite.

@ap0calypse644
Copy link
Contributor

Error when building fairyring:

go install -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=fairyring -X github.com/cosmos/cosmos-sdk/version.AppName=fairyringd -X github.com/cosmos/cosmos-sdk/version.Version=v0.3.1-49-g1c99c9c -X github.com/cosmos/cosmos-sdk/version.Commit=1c99c9cea9238c55d74859d69e59d852b300c92e -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -X github.com/cometbft/cometbft/version.TMCoreSemVer=v0.37.2 -w -s' -trimpath  ./...
# fairyring/testutil/keeper
testutil/keeper/keyshare.go:132:3: not enough arguments in call to keeper.NewKeeper
	have (*"github.com/cosmos/cosmos-sdk/codec".ProtoCodec, *"github.com/cosmos/cosmos-sdk/store/types".KVStoreKey, *"github.com/cosmos/cosmos-sdk/store/types".MemoryStoreKey, "github.com/cosmos/cosmos-sdk/x/params/types".Subspace, keyshareChannelKeeper, keysharePortKeeper, "github.com/cosmos/cosmos-sdk/x/capability/keeper".ScopedKeeper, keyshareconnectionKeeper, "fairyring/x/pep/keeper".Keeper, *"github.com/cosmos/cosmos-sdk/x/staking/keeper".Keeper)
	want ("github.com/cosmos/cosmos-sdk/codec".BinaryCodec, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/x/params/types".Subspace, "fairyring/x/keyshare/types".ChannelKeeper, "fairyring/x/keyshare/types".PortKeeper, "fairyring/x/keyshare/types".ScopedKeeper, "fairyring/x/keyshare/types".ConnectionKeeper, "fairyring/x/keyshare/types".PepKeeper, "fairyring/x/keyshare/types".StakingKeeper, "fairyring/x/keyshare/types".GovKeeper)
# github.com/CosmWasm/wasmd/x/wasm/keeper
../../go/pkg/mod/github.com/!cosm!wasm/wasmd@v0.45.0/x/wasm/keeper/test_common.go:461:3: not enough arguments in call to govkeeper.NewKeeper
	have ("github.com/cosmos/cosmos-sdk/codec".Codec, *"github.com/cosmos/cosmos-sdk/store/types".KVStoreKey, "github.com/cosmos/cosmos-sdk/x/auth/keeper".AccountKeeper, "github.com/cosmos/cosmos-sdk/x/bank/keeper".BaseKeeper, *"github.com/cosmos/cosmos-sdk/x/staking/keeper".Keeper, *baseapp.MsgServiceRouter, "github.com/cosmos/cosmos-sdk/x/gov/types".Config, string)
	want ("github.com/cosmos/cosmos-sdk/codec".BinaryCodec, "github.com/cosmos/cosmos-sdk/store/types".StoreKey, "github.com/cosmos/cosmos-sdk/x/gov/types".AccountKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".BankKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".StakingKeeper, *baseapp.MsgServiceRouter, "github.com/cosmos/cosmos-sdk/x/gov/types".Config, string, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ChannelKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".PortKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ScopedKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types/v1".ConnectionKeeper, "github.com/cosmos/cosmos-sdk/x/gov/types".KeyshareKeeper)
make: *** [install] Error 1

keyshare keeper in testutil is not updated

fixed

@ap0calypse644
Copy link
Contributor

fairyring/app/app.go, line 578

Cannot use 'keyshareKeeper' (type keysharemodulekeeper.Keeper) as the type types.KeyshareKeeper Type does not implement 'types.KeyshareKeeper' need the method: ProcessKeyshareRequest(ctx sdk.Context, msg MsgRequestAggrKeyshare) (rsp MsgRequestAggrKeyshareResponse, err error) have the method: ProcessKeyshareRequest(ctx sdk.Context, msg types.MsgRequestAggrKeyshare) (rsp types.MsgRequestAggrKeyshareResponse, err error)

Using the latest commit of github.com/Fairblock/cosmos-sdk, private-gov-47.3 branch, commit hash: 2f9d94a0d06f1f4cc9d80debf0e29a90b538e7a5 (put in ../cosmos-sdk)

fixed

@ap0calypse644
Copy link
Contributor

think we should also remove the vue/ autogenerated stuff from Ignite.

we can add to git ignore

@ap0calypse644 ap0calypse644 marked this pull request as ready for review February 15, 2024 15:28
@p0p3yee
Copy link
Contributor

p0p3yee commented Feb 16, 2024

Build error after your latest commit cc9a53b, the previous commit works fine

go mod tidy error:

go mod tidy
go: github.com/Fairblock/fairyring/testutil/keeper imports
	fairyring/x/keyshare/keeper: malformed module path "fairyring": missing dot in first path element
go: github.com/Fairblock/fairyring/testutil/keeper imports
	fairyring/x/keyshare/types: malformed module path "fairyring": missing dot in first path element
go: github.com/Fairblock/fairyring/x/keyshare/keeper imports
	fairyring/x/common/types: malformed module path "fairyring": missing dot in first path element
go: github.com/Fairblock/fairyring/x/pep/client/cli imports
	fairyring/x/pep/types: malformed module path "fairyring": missing dot in first path element
go: github.com/Fairblock/fairyring/x/pep/simulation imports
	fairyring/x/pep/keeper: malformed module path "fairyring": missing dot in first path element
go: github.com/Fairblock/fairyring/x/pep/types tested by
	github.com/Fairblock/fairyring/x/pep/types.test imports
	fairyring/testutil/sample: malformed module path "fairyring": missing dot in first path element

make install error:

go install -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=fairyring -X github.com/cosmos/cosmos-sdk/version.AppName=fairyringd -X github.com/cosmos/cosmos-sdk/version.Version=v0.3.2-9-gcc9a53b -X github.com/cosmos/cosmos-sdk/version.Commit=cc9a53b3c64395a4159c50a240e7b0fab4a42773 -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -X github.com/cometbft/cometbft/version.TMCoreSemVer=v0.37.2 -w -s' -trimpath  ./...
../../go/pkg/mod/github.com/!fairblock/wasmd@v0.45.1-0.20240214145549-25fcd10bf244/x/wasm/keeper/test_common.go:29:2: missing go.sum entry for module providing package fairyring/x/keyshare/keeper (imported by github.com/Fairblock/fairyring/testutil/keeper); to add:
	go get github.com/Fairblock/fairyring/testutil/keeper
../cosmos-sdk/x/gov/types/expected_keepers.go:4:2: missing go.sum entry for module providing package fairyring/x/common/types (imported by github.com/Fairblock/fairyring/x/keyshare/keeper); to add:
	go get github.com/Fairblock/fairyring/x/keyshare/keeper
../cosmos-sdk/x/gov/abci.go:8:2: missing go.sum entry for module providing package fairyring/x/keyshare/types (imported by github.com/Fairblock/fairyring/testutil/keeper); to add:
	go get github.com/Fairblock/fairyring/testutil/keeper
x/pep/client/cli/tx_get_general_keyshare.go:6:2: missing go.sum entry for module providing package fairyring/x/pep/types (imported by github.com/Fairblock/fairyring/x/pep/client/cli); to add:
	go get github.com/Fairblock/fairyring/x/pep/client/cli
x/pep/simulation/get_general_keyshare.go:6:2: missing go.sum entry for module providing package fairyring/x/pep/keeper (imported by github.com/Fairblock/fairyring/x/pep/simulation); to add:
	go get github.com/Fairblock/fairyring/x/pep/simulation
make: *** [install] Error 1

@p0p3yee
Copy link
Contributor

p0p3yee commented Feb 18, 2024

Error log after "Proposal has encrypted votes" log:

{"level":"info","module":"server","module":"x/gov","proposal":1,"error":"module does not own channel capability: channel capability not found","time":"2024-02-18T10:43:29-05:00","message":"IBC Request to fetch aggr. Keyshare failed"}

Steps to reproduce the error:

  1. Create draft_proposal.json in root directory of fairyring
{
 "metadata": "ipfs://CID",
 "deposit": "100000000stake",
 "title": "dummy",
 "summary": "blahblahblah"
}
  1. Create test_proposal.sh script in root directory of fairyring
#!/bin/bash

fairyringd tx gov submit-proposal draft_proposal.json --from val2 -o json --home ./data/fairyring_test_2/ -y --keyring-backend test --gas-prices 1ufairy

sleep 6

TOTAL_PROPOSALS=$(fairyringd q gov proposals --home ./data/fairyring_test_2/ -o json | jq '.proposals | length')

fairyringd tx gov vote-encrypted $TOTAL_PROPOSALS no --from val2 --home ./data/fairyring_test_2/ --keyring-backend test --gas-prices 1ufairy -o json -y
  1. Run ./scripts/tests/start.sh
  2. Run ./test_proposal.sh after both chain running
  3. Search for "Proposal has encrypted votes" from the fairyring_test_2 log

@ap0calypse644
Copy link
Contributor

Error log after "Proposal has encrypted votes" log:

{"level":"info","module":"server","module":"x/gov","proposal":1,"error":"module does not own channel capability: channel capability not found","time":"2024-02-18T10:43:29-05:00","message":"IBC Request to fetch aggr. Keyshare failed"}

Steps to reproduce the error:

1. Create `draft_proposal.json` in root directory of fairyring
{
 "metadata": "ipfs://CID",
 "deposit": "100000000stake",
 "title": "dummy",
 "summary": "blahblahblah"
}
2. Create `test_proposal.sh` script in root directory of fairyring
#!/bin/bash

fairyringd tx gov submit-proposal draft_proposal.json --from val2 -o json --home ./data/fairyring_test_2/ -y --keyring-backend test --gas-prices 1ufairy

sleep 6

TOTAL_PROPOSALS=$(fairyringd q gov proposals --home ./data/fairyring_test_2/ -o json | jq '.proposals | length')

fairyringd tx gov vote-encrypted $TOTAL_PROPOSALS no --from val2 --home ./data/fairyring_test_2/ --keyring-backend test --gas-prices 1ufairy -o json -y
3. Run `./scripts/tests/start.sh`

4. Run `./test_proposal.sh` after both chain running

5. Search for `"Proposal has encrypted votes"` from the `fairyring_test_2` log

I committed a small change for the ibc issue. But the script needs to be updated a bit too.

  1. The hermes relayer attempts to start without creating a channel first. I commented the last line and ran the following command manually:
    hermes --config hermes_config.toml create channel --new-client-connection --a-chain fairyring_test_2 --b-chain fairyring_test_1 --a-port gov --b-port keyshare --channel-version keyshare-1 --yes

This should create the channel with channel-id 0

  1. I added a couple of lines in the script to update the params of the chains

  2. I increased the voting time to 100 seconds for manual testing.

However, the enc vote will still not work because the source chain does not have a pubkey. @p0p3yee

@p0p3yee
Copy link
Contributor

p0p3yee commented Feb 22, 2024

Error log after "Proposal has encrypted votes" log:

{"level":"info","module":"server","module":"x/gov","proposal":1,"error":"module does not own channel capability: channel capability not found","time":"2024-02-18T10:43:29-05:00","message":"IBC Request to fetch aggr. Keyshare failed"}

Steps to reproduce the error:

1. Create `draft_proposal.json` in root directory of fairyring
{
 "metadata": "ipfs://CID",
 "deposit": "100000000stake",
 "title": "dummy",
 "summary": "blahblahblah"
}
2. Create `test_proposal.sh` script in root directory of fairyring
#!/bin/bash

fairyringd tx gov submit-proposal draft_proposal.json --from val2 -o json --home ./data/fairyring_test_2/ -y --keyring-backend test --gas-prices 1ufairy

sleep 6

TOTAL_PROPOSALS=$(fairyringd q gov proposals --home ./data/fairyring_test_2/ -o json | jq '.proposals | length')

fairyringd tx gov vote-encrypted $TOTAL_PROPOSALS no --from val2 --home ./data/fairyring_test_2/ --keyring-backend test --gas-prices 1ufairy -o json -y
3. Run `./scripts/tests/start.sh`

4. Run `./test_proposal.sh` after both chain running

5. Search for `"Proposal has encrypted votes"` from the `fairyring_test_2` log

I committed a small change for the ibc issue. But the script needs to be updated a bit too.

  1. The hermes relayer attempts to start without creating a channel first. I commented the last line and ran the following command manually:
    hermes --config hermes_config.toml create channel --new-client-connection --a-chain fairyring_test_2 --b-chain fairyring_test_1 --a-port gov --b-port keyshare --channel-version keyshare-1 --yes

This should create the channel with channel-id 0

  1. I added a couple of lines in the script to update the params of the chains
  2. I increased the voting time to 100 seconds for manual testing.

However, the enc vote will still not work because the source chain does not have a pubkey. @p0p3yee


Updated the code according to the changes you mentioned, error on the pep module after running make integration-test-all:

Submit valid aggregated key to pep module on chain fairyring_test_2 from address: fairy1qnk2n4nlkpw9xfqntladh74w6ujtulwnsgww3g
ERROR: Pep module submit aggregated key error. Expected tx action to be MsgCreateAggregatedKeyShare,  got 'null'
ERROR MESSAGE: failed to execute message; message index: 0: active key not found
make: *** [test-pep-module] Error

Active public key found in keyshare module but not pep module and it causes the error mentioned above.

For the encrypted voting part, seems to be working fine without error, However it didn't emit the StartSendGeneralKeyShareEventType event:

Voting period ended for Proposal:  2
Proposal aggr keyshare:  


 Proposal has encrypted votes


 Proposal tally period is over
{"level":"info","module":"server","module":"x/gov","proposal":2,"results":"failed","time":"2024-02-21T21:20:27-05:00","message":"proposal tallied"}

Steps to reproduce it:

  1. git pull to the latest commit in wasm branch
  2. checkout to test/wasm-branch in fairyringclient repo & go install
  3. Add one of the private key in fairyring_test_2 chain by: fairyringclient keys add PRIVATE_KEY, can send you the private key in discord if you want.
  4. Run make integration-test-all
  5. After both chain running, run the fairyringclient by fairyringclient start
  6. Run ./test_proposal.sh
  7. If the client catches the event it will show in the log, but it didn't
  8. The pep module test script error will show up in the console


params := k.GetParams(ctx)
if params.IsSourceChain {
//TODO: process for fairyring
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for general encryption. I am making the changes in another branch for this. This is separate from priv gov

@ap0calypse644
Copy link
Contributor

@p0p3yee fixed the issue of pubkey not being updated in destination chain

@ap0calypse644 ap0calypse644 merged commit 7d37fb9 into main Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants