-
Notifications
You must be signed in to change notification settings - Fork 41
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
Move sanction module into the provenance repo (from our fork) #1758
Conversation
…1 (instead of v1beta1).
…ect app/network for tests.
… allRequestMsgs pattern for RegisterInterfaces.
…le other tests that were failing because a Msg type URL has changed.
…imilar to what the type url is now.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1758 +/- ##
==========================================
+ Coverage 74.01% 74.58% +0.56%
==========================================
Files 295 311 +16
Lines 44072 45467 +1395
==========================================
+ Hits 32622 33911 +1289
- Misses 10087 10165 +78
- Partials 1363 1391 +28
|
I'm not sure if it's possible to create a github link that shows the changes made in this PR, so I did the diffs locally, manually (from this branch to In all of these, ProtosCommand: $ diff -r --color --ignore-matching-lines='^package' --ignore-matching-lines='^option go_package ' --ignore-matching-lines='^import ' ../prov-cosmos-sdk/proto/cosmos/sanction/v1beta1 proto/provenance/sanction/v1
15c15
< option (google.api.http).get = "/cosmos/sanction/v1beta1/check/{address}";
---
> option (google.api.http).get = "/provenance/sanction/v1/check/{address}";
20c20
< option (google.api.http).get = "/cosmos/sanction/v1beta1/all";
---
> option (google.api.http).get = "/provenance/sanction/v1/all";
25c25
< option (google.api.http).get = "/cosmos/sanction/v1beta1/temp";
---
> option (google.api.http).get = "/provenance/sanction/v1/temp";
30c30
< option (google.api.http).get = "/cosmos/sanction/v1beta1/params";
---
> option (google.api.http).get = "/provenance/sanction/v1/params"; Go CodeCommand: $ diff -r --color -B --ignore-matching-lines='github.com' ../prov-cosmos-sdk/x/sanction x/sanction I then manually removed the spec-docs (see below) and auto-generated files. `client/cli/query.go`158c159
< if _, err := sdk.AccAddressFromBech32(args[0]); err != nil {
---
> if _, err = sdk.AccAddressFromBech32(args[0]); err != nil { `client/testutil/cli_test.go`32,34c35,39
< cfg := network.DefaultConfig()
< cfg.NumValidators = 5
< cfg.TimeoutCommit = 1 * time.Second
---
> pioconfig.SetProvenanceConfig("", 0)
> cfg := testutil.DefaultTestNetworkConfig()
> cfg.NumValidators = 2 // need at least 2 so that one can sanction the other.
> cfg.ChainID = antewrapper.SimAppChainID
> cfg.TimeoutCommit = 500 * time.Millisecond
92c97
< sanctionValI := 4
---
> sanctionValI := 1 `codec.go`13,20d10
< // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
< // governance module.
< func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
< legacy.RegisterAminoMsg(cdc, &MsgSanction{}, "cosmos-sdk/MsgSanction")
< legacy.RegisterAminoMsg(cdc, &MsgUnsanction{}, "cosmos-sdk/MsgUnsanction")
< legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/MsgUpdateParams")
< }
<
22,26c12,16
< registry.RegisterImplementations((*sdk.Msg)(nil),
< &MsgSanction{},
< &MsgUnsanction{},
< &MsgUpdateParams{},
< )
---
> messages := make([]proto.Message, len(allRequestMsgs))
> for i, msg := range allRequestMsgs {
> messages[i] = msg
> }
> registry.RegisterImplementations((*sdk.Msg)(nil), messages...)
29,50d18
< }
<
< var (
< amino = codec.NewLegacyAmino()
<
< // ModuleCdc references the global x/sanction module codec. Note, the codec should
< // ONLY be used in certain instances of tests and for JSON encoding as Amino is
< // still used for that purpose.
< //
< // The actual codec used for serialization should be provided to x/sanction and
< // defined at the application level.
< ModuleCdc = codec.NewAminoCodec(amino)
< )
<
< func init() {
< RegisterLegacyAminoCodec(amino)
< cryptocodec.RegisterCrypto(amino)
< sdk.RegisterLegacyAminoCodec(amino)
<
< // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
< // used to properly serialize MsgGrant and MsgExec instances
< RegisterLegacyAminoCodec(authzcodec.Amino) `errors/errors.go`3,8c3
< import (
< "cosmossdk.io/errors"
< )
<
< // sanctionCodespace is the codespace for all errors defined in sanction package
< const sanctionCodespace = "sanction"
---
> import sdkserrs "github.com/cosmos/cosmos-sdk/x/sanction/errors"
11,14c6,9
< ErrInvalidParams = errors.Register(sanctionCodespace, 2, "invalid params")
< ErrUnsanctionableAddr = errors.Register(sanctionCodespace, 3, "address cannot be sanctioned")
< ErrInvalidTempStatus = errors.Register(sanctionCodespace, 4, "invalid temp status")
< ErrSanctionedAccount = errors.Register(sanctionCodespace, 5, "account is sanctioned")
---
> ErrInvalidParams = sdkserrs.ErrInvalidParams
> ErrUnsanctionableAddr = sdkserrs.ErrUnsanctionableAddr
> ErrInvalidTempStatus = sdkserrs.ErrInvalidTempStatus
> ErrSanctionedAccount = sdkserrs.ErrSanctionedAccount
15a11,27
>
> // TODO: Once we have an official version of the SDK without the sanction module:
> // 1. Delete everything above this comment.
> // 2. Uncomment everything below this comment.
> // 3. Delete this comment.
>
> // import cerrs "cosmossdk.io/errors"
>
> // // sanctionCodespace is the codespace for all errors defined in sanction package
> // const sanctionCodespace = "sanction"
>
> // var (
> // ErrInvalidParams = cerrs.Register(sanctionCodespace, 2, "invalid params")
> // ErrUnsanctionableAddr = cerrs.Register(sanctionCodespace, 3, "address cannot be sanctioned")
> // ErrInvalidTempStatus = cerrs.Register(sanctionCodespace, 4, "invalid temp status")
> // ErrSanctionedAccount = cerrs.Register(sanctionCodespace, 5, "account is sanctioned")
> // ) `keeper/gov_hooks_test.go`1131,1135c1132,1136
< {exp: false, url: "cosmos.sanction.v1beta1.MsgSanction"},
< {exp: false, url: "/cosmos.sanction.v1beta1.MsgSanctio"},
< {exp: false, url: "/cosmos.sanction.v1beta1.MsgSanction "},
< {exp: false, url: " /cosmos.sanction.v1beta1.MsgSanction"},
< {exp: false, url: "/cosmos.sanction.v1beta1.MsgSanction2"},
---
> {exp: false, url: "provenance.sanction.v1.MsgSanction"},
> {exp: false, url: "/provenance.sanction.v1.MsgSanctio"},
> {exp: false, url: "/provenance.sanction.v1.MsgSanction "},
> {exp: false, url: " /provenance.sanction.v1.MsgSanction"},
> {exp: false, url: "/provenance.sanction.v1.MsgSanction2"}, `keeper/grpc_query.go`44c45
< store, _ := k.getSanctionedAddressPrefixStore(ctx)
---
> store := k.getSanctionedAddressPrefixStore(ctx)
80c81
< kAddr, propId := ParseTemporaryKey(ConcatBz(pre, key))
---
> kAddr, propID := ParseTemporaryKey(ConcatBz(pre, key))
83c84
< ProposalId: propId,
---
> ProposalId: propID, `keeper/keeper.go`201,202c202,203
< func (k Keeper) getSanctionedAddressPrefixStore(ctx sdk.Context) (sdk.KVStore, []byte) {
< return prefix.NewStore(ctx.KVStore(k.storeKey), SanctionedPrefix), SanctionedPrefix
---
> func (k Keeper) getSanctionedAddressPrefixStore(ctx sdk.Context) sdk.KVStore {
> return prefix.NewStore(ctx.KVStore(k.storeKey), SanctionedPrefix)
208c209
< store, _ := k.getSanctionedAddressPrefixStore(ctx)
---
> store := k.getSanctionedAddressPrefixStore(ctx) `keeper/keeper_test.go`32c33
< addrs := simapp.AddTestAddrsIncremental(s.App, s.SdkCtx, 5, sdk.NewInt(1_000_000_000))
---
> addrs := app.AddTestAddrsIncremental(s.App, s.SdkCtx, 5, sdk.NewInt(1_000_000_000))
53c54
< exp: "/cosmos.sanction.v1beta1.MsgSanction",
---
> exp: "/provenance.sanction.v1.MsgSanction",
58c59
< exp: "/cosmos.sanction.v1beta1.MsgUnsanction",
---
> exp: "/provenance.sanction.v1.MsgUnsanction", `keeper/suite_test.go`47c48
< App *simapp.SimApp
---
> App *app.App
58c59
< s.App = simapp.Setup(s.T(), false)
---
> s.App = app.Setup(s.T()) `module/module.go`96,98c98
< func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
< sanction.RegisterLegacyAminoCodec(cdc)
< }
---
> func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
101c101
< func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
---
> func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} `msgs.go`9c10,14
< var _ sdk.Msg = &MsgSanction{}
---
> var allRequestMsgs = []sdk.Msg{
> (*MsgSanction)(nil),
> (*MsgUnsanction)(nil),
> (*MsgUpdateParams)(nil),
> }
40,41d44
< var _ sdk.Msg = &MsgUnsanction{}
<
70,71d72
<
< var _ sdk.Msg = &MsgUpdateParams{} `sanction.go`11c11
< DefaultImmediateSanctionMinDeposit sdk.Coins = nil
---
> DefaultImmediateSanctionMinDeposit sdk.Coins
14c14
< DefaultImmediateUnsanctionMinDeposit sdk.Coins = nil
---
> DefaultImmediateUnsanctionMinDeposit sdk.Coins `simulation/decoder.go`12c13
< func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
---
> func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string { `simulation/genesis_test.go`309,310c311,312
< app := simapp.Setup(t, false)
< ctx := app.BaseApp.NewContext(false, tmproto.Header{})
---
> testApp := app.Setup(t)
> ctx := testApp.BaseApp.NewContext(false, tmproto.Header{})
314c316
< app.SanctionKeeper.InitGenesis(ctx, &randomGenState)
---
> testApp.SanctionKeeper.InitGenesis(ctx, &randomGenState)
321c323
< actualGenState = app.SanctionKeeper.ExportGenesis(ctx)
---
> actualGenState = testApp.SanctionKeeper.ExportGenesis(ctx) `simulation/operations_test.go`30c31
< app *simapp.SimApp
---
> app *app.App
38c39
< s.app = simapp.Setup(s.T(), false)
---
> s.app = app.Setup(s.T()) `testutil/test_helpers.go`53c53
< // AssertPanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
---
> // AssertPanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
83c83
< // RequirePanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
---
> // RequirePanicsWithMessage(t, "crazy error", func(){ GoCrazy() })
SpecCommand: $ diff -r --color ../prov-cosmos-sdk/x/sanction/spec x/sanction/spec `README.md`1,7d0
< <!--
< order: 0
< title: Sanction Overview
< parent:
< title: "sanction"
< -->
< `01_concepts.md`1,4d0
< <!--
< order: 1
< -->
< `02_state.md`1,4d0
< <!--
< order: 2
< -->
< `03_messages.md`1,4d0
< <!--
< order: 3
< -->
<
14c10
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/tx.proto#L22-L32
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/tx.proto#L22-L32
33c29
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/tx.proto#L37-L47
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/tx.proto#L37-L47
51c47
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/tx.proto#L52-L62
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/tx.proto#L52-L62 `04_events.md`1,4d0
< <!--
< order: 4
< -->
<
13c9
< `@Type`: `/cosmos.sanction.v1beta1.EventAddressSanctioned`
---
> `@Type`: `/provenance.sanction.v1.EventAddressSanctioned`
23c19
< `@Type`: `/cosmos.sanction.v1beta1.EventAddressUnsanctioned`
---
> `@Type`: `/provenance.sanction.v1.EventAddressUnsanctioned`
33c29
< `@Type`: `/cosmos.sanction.v1beta1.EventTempAddressSanctioned`
---
> `@Type`: `/provenance.sanction.v1.EventTempAddressSanctioned`
43c39
< `@Type`: `/cosmos.sanction.v1beta1.EventTempAddressUnsanctioned`
---
> `@Type`: `/provenance.sanction.v1.EventTempAddressUnsanctioned`
53c49
< `@Type`: `/cosmos.sanction.v1beta1.EventParamsUpdated`
---
> `@Type`: `/provenance.sanction.v1.EventParamsUpdated` `05_queries.md`1,4d0
< <!--
< order: 5
< -->
<
18c14
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L34-L37
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L34-L37
22c18
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L39-L43
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L39-L43
33c29
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L45-L49
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L45-L49
37c33
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L51-L58
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L51-L58
54c50
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L60-L67
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L60-L67
58c54
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L69-L75
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L69-L75
62c58
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/sanction.proto#L27-L35
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/sanction.proto#L27-L35
66c62
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/sanction.proto#L37-L47
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/sanction.proto#L37-L47
86c82
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L77-L78
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L77-L78
90c86
< +++ https://github.com/provenance-io/cosmos-sdk/blob/da2ea8a8139ae9e110de0776baffa1d0dd97db5e/proto/cosmos/sanction/v1beta1/query.proto#L80-L84
---
> +++ https://github.com/provenance-io/provenance/blob/06e6a215bce3f97a524013a821b88250d29d353c/proto/provenance/sanction/v1/query.proto#L80-L84 `06_client.md`1,4d0
< <!--
< order: 6
< -->
<
32c28
< $ simd query sanction is-sanctioned --help
---
> $ provenanced query sanction is-sanctioned --help
36,38c32,34
< $ simd query sanction is-sanctioned cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
< $ simd query sanction is cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
< $ simd query sanction check cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
---
> $ provenanced query sanction is-sanctioned pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
> $ provenanced query sanction is pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
> $ provenanced query sanction check pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
41c37
< simd query sanction is-sanctioned <address> [flags]
---
> provenanced query sanction is-sanctioned <address> [flags]
50c46
< $ simd query sanction sanctioned-addresses --help
---
> $ provenanced query sanction sanctioned-addresses --help
54,56c50,52
< $ simd query sanction sanctioned-addresses
< $ simd query sanction addresses
< $ simd query sanction all
---
> $ provenanced query sanction sanctioned-addresses
> $ provenanced query sanction addresses
> $ provenanced query sanction all
59c55
< simd query sanction sanctioned-addresses [flags]
---
> provenanced query sanction sanctioned-addresses [flags]
70c66
< simd query sanction temporary-entries --help
---
> $ provenanced query sanction temporary-entries --help
76,81c72,77
< $ simd query sanction temporary-entries
< $ simd query sanction temporary-entries cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
< $ simd query sanction temp-entries
< $ simd query sanction temp-entries cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
< $ simd query sanction temp
< $ simd query sanction temp cosmos1v4uxzmtsd3j4zat9wfu5zerywgc47h6luruvdf
---
> $ provenanced query sanction temporary-entries
> $ provenanced query sanction temporary-entries pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
> $ provenanced query sanction temp-entries
> $ provenanced query sanction temp-entries pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
> $ provenanced query sanction temp
> $ provenanced query sanction temp pb1v4uxzmtsd3j4zat9wfu5zerywgc47h6l4dhfq4
84c80
< simd query sanction temporary-entries [<address>] [flags]
---
> provenanced query sanction temporary-entries [<address>] [flags]
95c91
< $ simd query sanction params --help
---
> $ provenanced query sanction params --help
99c95
< $ simd query sanction params
---
> $ provenanced query sanction params
102c98
< simd query sanction params [flags]
---
> provenanced query sanction params [flags]
109,115c105,111
< | Name | URL |
< |-----------------------------|---------------------------------------------------|
< | IsSanctioned | `/cosmos/sanction/v1beta1/check/{address}` |
< | SanctionedAddresses | `/cosmos/sanction/v1beta1/all` |
< | TemporaryEntries - all | `/cosmos/sanction/v1beta1/temp` |
< | TemporaryEntries - specific | `/cosmos/sanction/v1beta1/temp?address={address}` |
< | Params | `/cosmos/sanction/v1beta1/params` |
---
> | Name | URL |
> |-----------------------------|--------------------------------------------------|
> | IsSanctioned | `/provenance/sanction/v1/check/{address}` |
> | SanctionedAddresses | `/provenance/sanction/v1/all` |
> | TemporaryEntries - all | `/provenance/sanction/v1/temp` |
> | TemporaryEntries - specific | `/provenance/sanction/v1/temp?address={address}` |
> | Params | `/provenance/sanction/v1/params` | |
…properly link to the module readmes.
# Conflicts: # x/README.md
After some discussion, we think it might be best to create a new repo to house these two modules (and maybe our own copy of the bank module). Ideally, that will let us keep the protos in the same package they're currently in. |
Description
closes: #1753
This copies the quarantine module stuff from our SDK fork into this repo. It also updates all references to the quarantine module to point to this new copy instead of the one from the SDK. The only exception is errors.go (more on that below).
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes