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

feat!: store proposed chainID before voting finishes #1289

Merged
merged 38 commits into from
Oct 2, 2023

Conversation

yaruwangway
Copy link
Contributor

@yaruwangway yaruwangway commented Sep 12, 2023

Description

Closes: #1282

The proposed chainID in consumerAddition proposal is saved as key: prefix | proposalID value: ChainID
Manually tested:

 curl http://localhost:1317/interchain_security/ccv/provider/proposed_consumer_chainids
{"proposedChains":[{"chainID":"foochain","proposalID":"1"},{"chainID":"foochain","proposalID":"2"},{"chainID":"standalone-1","proposalID":"3"}]}%
 interchain-security-pd query provider proposed-consumer-chains --home test -o json
{"proposedChains":[{"chainID":"foochain","proposalID":"1"},{"chainID":"foochain","proposalID":"2"},{"chainID":"standalone-1","proposalID":"3"}]}

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • Included the correct type prefix in the PR title
  • Added ! to the type prefix if state-machine breaking change (i.e., requires coordinated upgrade)
  • Confirmed this PR does not introduce changes requiring state migrations, OR migration code has been added to consumer and/or provider modules
  • Targeted the correct branch (see PR Targeting)
  • Provided a link to the relevant issue or specification
  • Followed the guidelines for building SDK modules
  • Included the necessary unit and integration tests
  • Added a changelog entry to CHANGELOG.md
  • Included comments for documenting Go code
  • Updated the relevant documentation or specification
  • Reviewed "Files changed" and left comments if necessary
  • Confirmed all CI checks have passed
  • If this PR is library API breaking, bump the go.mod version string of the repo, and follow through on a new major release for both the consumer and provider

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed this PR does not introduce changes requiring state migrations, OR confirmed migration code has been added to consumer and/or provider modules
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage

@github-actions github-actions bot added the C:x/provider Assigned automatically by the PR labeler label Sep 12, 2023
@yaruwangway yaruwangway changed the title feat: store chain in proposal feat !: store chain in proposal Sep 12, 2023
@yaruwangway yaruwangway changed the title feat !: store chain in proposal feat!: store chain in proposal Sep 12, 2023
@yaruwangway yaruwangway changed the title feat!: store chain in proposal feat!: store chainID in proposal Sep 12, 2023
@github-actions github-actions bot added the C:Testing Assigned automatically by the PR labeler label Sep 19, 2023
tests/e2e/state.go Outdated Show resolved Hide resolved
tests/e2e/steps_start_chains.go Outdated Show resolved Hide resolved
tests/e2e/state.go Outdated Show resolved Hide resolved
tests/e2e/steps_start_chains.go Outdated Show resolved Hide resolved
@yaruwangway
Copy link
Contributor Author

yaruwangway commented Sep 20, 2023

Hi, @MSalopek , this PR is not state breaking right ? even though there is a new type of kv.
key is prefix | len(chainID) | chainID | propsalID value: chainID
thanks!

@yaruwangway yaruwangway changed the title feat!: store chainID in proposal feat: store chainID in proposal Sep 21, 2023
@yaruwangway yaruwangway marked this pull request as ready for review September 21, 2023 09:33
@yaruwangway yaruwangway requested a review from a team as a code owner September 21, 2023 09:33
x/ccv/provider/keeper/gov_hook.go Outdated Show resolved Hide resolved
x/ccv/provider/keeper/keeper.go Show resolved Hide resolved
x/ccv/provider/keeper/keeper.go Outdated Show resolved Hide resolved
x/ccv/provider/keeper/keeper.go Outdated Show resolved Hide resolved
@yaruwangway
Copy link
Contributor Author

Requested some changes. Will add more context

EDIT: Also, the e2e test that checks this value is failing. Can you address that?

in the voteGovProposalAction, the state of proposal status is PROPOSAL_STATUS_PASSED, so the proposedConsumerChain state cannot be added here as nonempty. I moved proposedConsumerChain to submit proposal action.

FAILED action voteGovProposalAction
"actual state"
{provi: {ValBalances:                    {alice: 9500000000,
                                          bob:   9500000000},
         Proposals:                      {1: {Deposit:       10000001,
                                              Chain:         "consu",
                                              SpawnTime:     0,
                                              InitialHeight: {RevisionNumber: 0,
                                                              RevisionHeight: 1},
                                              Status:        "PROPOSAL_STATUS_PASSED"}},
         ProposedConsumerChains:         [],
         ValPowers:                      nil,
         RepresentativePowers:           nil,
         Params:                         nil,
         Rewards:                        nil,
         ConsumerChains:                 nil,
         AssignedKeys:                   nil,
         ProviderKeys:                   nil,
         ConsumerChainQueueSizes:        nil,
         GlobalSlashQueueSize:           nil,
         RegisteredConsumerRewardDenoms: nil}}
"model state"

@yaruwangway
Copy link
Contributor Author

Nice work @yaruwangway. I approve the overall logic. See my comments below.

Also, the PR doesn't fix #1282. For that you need to add an if condition when handling a key assignment message.

Hi @marius, if you meant to check key in use when assigning keys ? (need chainIDs from providerKeeper.GetAllPendingConsumerAdditionProps, providerKeeper.GetAllConsumerChains(ctx) and providerKeeper.GetProposedChains ) it will be in this PR. #1279

@MSalopek MSalopek changed the title feat: store proposed chainID before voting finishes feat!: store proposed chainID before voting finishes Sep 28, 2023
x/ccv/provider/keeper/keeper.go Show resolved Hide resolved
x/ccv/provider/keeper/keeper.go Outdated Show resolved Hide resolved
x/ccv/provider/keeper/gov_hook.go Outdated Show resolved Hide resolved
x/ccv/provider/keeper/gov_hook.go Outdated Show resolved Hide resolved
@yaruwangway yaruwangway changed the base branch from main to feat/refactor-key-assignment October 2, 2023 09:17
@yaruwangway yaruwangway merged commit 67ec715 into feat/refactor-key-assignment Oct 2, 2023
5 of 12 checks passed
@yaruwangway yaruwangway deleted the chain-in-proposal branch October 2, 2023 15:09
MSalopek added a commit that referenced this pull request Nov 28, 2023
* feat!: store proposed chainID before voting finishes (#1289)

* feat: store chain in proposal

* add govHook

* delete GetChainsInProposal

* check proposal type

* update key

* feat: add query proposed chainIDs

* feat: set govhook

* feat: parse key

* refactor: names

* feat: add list proposed consumer chains

* test: add e2e test

* add e2e test

* update comments

* update ProposeConsumerChains in e2e test

* remove wait for block

* docs: update changelog

* fix: lint

* add  TestParseProposedConsumerChainKey

* refactor gov hook

* Update proto/interchain_security/ccv/provider/v1/query.proto

Co-authored-by: MSalopek <[email protected]>

* update proto

* add test for set kv

* refactor key to be prefix_proposalID

* formatting

* update e2e test

* format

* Update x/ccv/provider/keeper/gov_hook.go

Co-authored-by: Shawn <[email protected]>

* Update x/ccv/provider/keeper/keeper.go

Co-authored-by: Shawn <[email protected]>

* Update x/ccv/provider/keeper/keeper.go

Co-authored-by: Shawn <[email protected]>

* fix e2e test

* fix gosec

* remove type url check

* test: add unit test

* lint

* fix lint

* fix err

---------

Co-authored-by: MSalopek <[email protected]>
Co-authored-by: Shawn <[email protected]>

* fix test

* feat: update GetAllValidatorsByConsumerAddr for fast find consensus key in use  (#1279)

* update GetAllValidatorsByConsumerAddr

* fix test

* update ValidatorConsensusKeyInUse

* update changelog

* Update proto/interchain_security/ccv/provider/v1/query.proto

* Update x/ccv/provider/keeper/gov_hook.go

* Update x/ccv/provider/keeper/keeper.go

* Update x/ccv/provider/keeper/keeper.go

* Update x/ccv/provider/keeper/keeper.go

* fix gov hooks

* fix bug and add tests

* finish unit testing of consu addition legacy prop getter

* nit

* update changelog

* lint

* update changelog entry

* Update .changelog/unreleased/features/provider/1339-check-key-assignment-in-use.md

Co-authored-by: Marius Poke <[email protected]>

* fix #1282

* remove todos and update doc

* tests: fix broken unit tests

* tests: fix broken integration test consumer registration

* tests: update names

---------

Co-authored-by: MSalopek <[email protected]>
Co-authored-by: Shawn <[email protected]>
Co-authored-by: Simon Noetzlin <[email protected]>
Co-authored-by: Marius Poke <[email protected]>
MSalopek added a commit that referenced this pull request Dec 1, 2023
* feat!: store proposed chainID before voting finishes (#1289)

* feat: store chain in proposal

* add govHook

* delete GetChainsInProposal

* check proposal type

* update key

* feat: add query proposed chainIDs

* feat: set govhook

* feat: parse key

* refactor: names

* feat: add list proposed consumer chains

* test: add e2e test

* add e2e test

* update comments

* update ProposeConsumerChains in e2e test

* remove wait for block

* docs: update changelog

* fix: lint

* add  TestParseProposedConsumerChainKey

* refactor gov hook

* Update proto/interchain_security/ccv/provider/v1/query.proto

Co-authored-by: MSalopek <[email protected]>

* update proto

* add test for set kv

* refactor key to be prefix_proposalID

* formatting

* update e2e test

* format

* Update x/ccv/provider/keeper/gov_hook.go

Co-authored-by: Shawn <[email protected]>

* Update x/ccv/provider/keeper/keeper.go

Co-authored-by: Shawn <[email protected]>

* Update x/ccv/provider/keeper/keeper.go

Co-authored-by: Shawn <[email protected]>

* fix e2e test

* fix gosec

* remove type url check

* test: add unit test

* lint

* fix lint

* fix err

---------

Co-authored-by: MSalopek <[email protected]>
Co-authored-by: Shawn <[email protected]>

* fix test

* feat: update GetAllValidatorsByConsumerAddr for fast find consensus key in use  (#1279)

* update GetAllValidatorsByConsumerAddr

* fix test

* update ValidatorConsensusKeyInUse

* update changelog

* Update proto/interchain_security/ccv/provider/v1/query.proto

* Update x/ccv/provider/keeper/gov_hook.go

* Update x/ccv/provider/keeper/keeper.go

* Update x/ccv/provider/keeper/keeper.go

* Update x/ccv/provider/keeper/keeper.go

* fix gov hooks

* fix bug and add tests

* finish unit testing of consu addition legacy prop getter

* nit

* update changelog

* lint

* update changelog entry

* Update .changelog/unreleased/features/provider/1339-check-key-assignment-in-use.md

Co-authored-by: Marius Poke <[email protected]>

* fix #1282

* remove todos and update doc

* tests: fix broken unit tests

* tests: fix broken integration test consumer registration

* tests: update names

---------

Co-authored-by: MSalopek <[email protected]>
Co-authored-by: Shawn <[email protected]>
Co-authored-by: Simon Noetzlin <[email protected]>
Co-authored-by: Marius Poke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Testing Assigned automatically by the PR labeler C:x/provider Assigned automatically by the PR labeler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow key assignment on registered consumers and chains with proposals in voting period
4 participants