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: add inactive contract management in wasm #655

Merged
merged 18 commits into from
Sep 5, 2022

Conversation

zemyblue
Copy link
Member

@zemyblue zemyblue commented Aug 29, 2022

Main changes

  • add contract blacklist as inactive_contract_addresses of genesisStatue
  • add deactivate and activate contract proposal
  • define custom tx and query in proto/lbm/wasm/v1 directory.

Description

related: #623

This PR is the function that replacing previous contract blacklist management.
The previous contract blacklist management function was managed in the contract status of wasm genesisStatus I
But in order that we added this function in the contract status, we needed to customize original genesis proto.

So I add new lbm's genesis proto and add inactive contract list in lbm's genesisStatus without modifying original genesisStatus.

Add custom lbm protos

  • proto/lbm/wasm/v1/event.proto
  • proto/lbm/wasm/v1/proposal.proto
  • proto/lbm/wasm/v1/query.proto
  • proto/lbm/wasm/v1/tx.proto

Added Msg.StoreCodeAndInstantiateContract tx, InactiveContracts query and DeactivateContractProposal, ActivateContractProposal proposals. And added EventDeactivateContractProposal and EventActivateContractProposal events

These proto is converted in x/wasm/lbmtypes directory
To avoide import cycle problems, lbmtypes is not imported from types.

Change cosmwasm's protos

I didn't want to modify original proto file of cosmwasm/wasmd. But I needed to apply for the changes of our WasmGasRegister architecture in the wasm Keeper. Our WasmGasRegister architecture use genesisStatus instead of default configure of cosmwasm/wasmd. And WasmGasRegister is defined in wasm Keeper structure as private property. So we can't transfer as param or wrap the keeper. Therefore I had no choice but to correct it.

The following list is modified proto list

  • proto/cosmwasm/v1/genesis.proto
    • add inactive_contract_addresses field
  • proto/cosmwasm/v1/types.proto
    • add gas_multiplier, instance_cost and compile_cost in Params

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
 - add inactive_contract_addresses in genesisStatus
 - modify Params of wasm
 - add custom tx and queries

Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
@zemyblue zemyblue marked this pull request as draft August 29, 2022 13:08
…asm.Keeper.

And change to proper gas data in unittest.

Signed-off-by: zemyblue <zemyblue@gmail.com>
@zemyblue zemyblue self-assigned this Aug 29, 2022
@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

❗ No coverage uploaded for pull request base (feat/wasm_refactor@0f5056f). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                  Coverage Diff                  @@
##             feat/wasm_refactor     #655   +/-   ##
=====================================================
  Coverage                      ?   60.41%           
=====================================================
  Files                         ?      826           
  Lines                         ?    96088           
  Branches                      ?        0           
=====================================================
  Hits                          ?    58048           
  Misses                        ?    34563           
  Partials                      ?     3477           

Signed-off-by: zemyblue <zemyblue@gmail.com>
@zemyblue zemyblue marked this pull request as ready for review August 29, 2022 15:24
proto/cosmwasm/wasm/v1/types.proto Outdated Show resolved Hide resolved
proto/lbm/wasm/v1/event.proto Outdated Show resolved Hide resolved
proto/lbm/wasm/v1/event.proto Outdated Show resolved Hide resolved
proto/lbm/wasm/v1/query.proto Show resolved Hide resolved
x/wasm/keeper/keeper_extension.go Outdated Show resolved Hide resolved
x/wasm/lbmtypes/proposal.go Outdated Show resolved Hide resolved
x/wasm/lbmtypes/proposal.go Outdated Show resolved Hide resolved
x/wasm/types/params.go Outdated Show resolved Hide resolved
Signed-off-by: zemyblue <zemyblue@gmail.com>
@zemyblue zemyblue requested a review from 0Tech September 1, 2022 01:21
x/wasm/keeper/keeper_extension.go Show resolved Hide resolved
x/wasm/types/events.go Show resolved Hide resolved
x/wasm/lbmtypes/proposal.go Show resolved Hide resolved
x/wasm/lbmtypes/proposal.go Show resolved Hide resolved
x/wasm/client/cli/query.go Outdated Show resolved Hide resolved
x/wasm/client/cli/gov_tx.go Outdated Show resolved Hide resolved
 - response error if there isn't contract address in chain

Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
proto/lbm/wasm/v1/proposal.proto Show resolved Hide resolved
proto/lbm/wasm/v1/event.proto Outdated Show resolved Hide resolved
proto/lbm/wasm/v1/query.proto Outdated Show resolved Hide resolved
x/wasm/client/testutil/gov.go Show resolved Hide resolved
x/wasm/keeper/keeper.go Outdated Show resolved Hide resolved
x/wasm/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/wasm/keeper/keeper_test.go Show resolved Hide resolved
x/wasm/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/wasm/keeper/querier.go Show resolved Hide resolved
x/wasm/keeper/querier.go Show resolved Hide resolved
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants