-
Notifications
You must be signed in to change notification settings - Fork 411
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
Change genesis preserving contract history #1076
Change genesis preserving contract history #1076
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1076 +/- ##
==========================================
+ Coverage 59.27% 59.42% +0.15%
==========================================
Files 53 53
Lines 6758 6783 +25
==========================================
+ Hits 4006 4031 +25
+ Misses 2456 2454 -2
- Partials 296 298 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work! Thanks a lot for the changes 👍
You addressed the created
date proper. Unfortunately this was only half of the original story. The other part is about the ContractHistory
. The history contains all the code changes for a contract. We don't export it but create a new start on import .
if you can add this to this PR, then #878 would be resolved. But also happy to merge this one and have a second to finish the issue. What you prefer.
@@ -107,8 +107,6 @@ func ExportGenesis(ctx sdk.Context, keeper *Keeper) *types.GenesisState { | |||
state = append(state, types.Model{Key: key, Value: value}) | |||
return false | |||
}) | |||
// redact contract info | |||
contract.Created = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -211,22 +212,6 @@ func TestAppImportExport(t *testing.T) { | |||
dropContractHistory(ctxA.KVStore(app.keys[wasm.StoreKey]), prefixes...) | |||
dropContractHistory(ctxB.KVStore(newApp.keys[wasm.StoreKey]), prefixes...) | |||
|
|||
normalizeContractInfo := func(ctx sdk.Context, app *WasmApp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Got it, I will continue with the Contract History. Tysm :3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks almost perfect now. Thanks a lot for your updates!
I have added some minor notes now but I need to do a deeper review tomorrow.
proto/cosmwasm/wasm/v1/genesis.proto
Outdated
@@ -53,6 +53,7 @@ message Contract { | |||
string contract_address = 1; | |||
ContractInfo contract_info = 2 [ (gogoproto.nullable) = false ]; | |||
repeated Model contract_state = 3 [ (gogoproto.nullable) = false ]; | |||
repeated ContractCodeHistoryEntry contract_code_history = 4 [ (gogoproto.nullable) = false ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
k.addToContractCodeSecondaryIndex(ctx, contractAddr, historyEntry) | ||
k.addToContractCreatorSecondaryIndex(ctx, creatorAddress, historyEntry.Updated, contractAddr) | ||
k.addToContractCodeSecondaryIndex(ctx, contractAddr, entries[len(entries)-1]) | ||
k.addToContractCreatorSecondaryIndex(ctx, creatorAddress, entries[0].Updated, contractAddr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice to use the history data to feed the indexes with proper dates! 👍
x/wasm/types/ibc.pb.go
Outdated
io "io" | ||
math "math" | ||
math_bits "math/bits" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run make proto-all
instead that includes the code formatters
@@ -41,7 +41,7 @@ func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState, staki | |||
if err != nil { | |||
return nil, sdkerrors.Wrapf(err, "address in contract number %d", i) | |||
} | |||
err = keeper.importContract(ctx, contractAddr, &contract.ContractInfo, contract.ContractState) | |||
err = keeper.importContract(ctx, contractAddr, &contract.ContractInfo, contract.ContractState, contract.ContractCodeHistory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some sanity checks for ContractCodeHistory
to the ValidateBacis()
Thank youuuuuuuuuuu sir :3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! 🌻
Thanks a lot for taking this task and the PR! Very well done! 🥇
I did some manual tests with state export/ import to confirm it is working as expected and it does. Only the wasmd q wasm contract-history
query does not return update data but I will provide a fix when this is merged to main.
* Add StoreAndInstantiateContract gov proposal * Add integration tests * Bump github.com/prometheus/client_golang from 1.13.0 to 1.14.0 Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Remove exposed functions * Add tests * Add Developer's guide and best practices (#1075) * Add Developer's guide and best practices * Fix comments * Change genesis preserving contract history (#1076) * preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]> * Return contract history updates * Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (#1082) Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](spf13/viper@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (#1082)" This reverts commit cf81eb8. * Add cli and refactor code * Contract authz - redesign (#1077) * Add contract authz proto * Implement contract autorization * Register contract authz * Add contract-authz tests * Consume gas for contract authz * Add contract authz cli * Update cli usage * Model spike * Add max funds limit * Redesign authz model * Start e2e test * Full e2e test * Test filter and limits * Test accept * Fix description * No linter warning Co-authored-by: Giancarlos Salas <[email protected]> * Add StoreAndInstantiateContract gov proposal * Add integration tests * Remove exposed functions * Add tests * Add cli and refactor code * Fix comments Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GNaD13 <[email protected]> Co-authored-by: Alex Peters <[email protected]> Co-authored-by: Giancarlos Salas <[email protected]>
* preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]>
* Add StoreAndInstantiateContract gov proposal * Add integration tests * Bump github.com/prometheus/client_golang from 1.13.0 to 1.14.0 Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Remove exposed functions * Add tests * Add Developer's guide and best practices (CosmWasm#1075) * Add Developer's guide and best practices * Fix comments * Change genesis preserving contract history (CosmWasm#1076) * preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]> * Return contract history updates * Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082) Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](spf13/viper@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082)" This reverts commit cf81eb8. * Add cli and refactor code * Contract authz - redesign (CosmWasm#1077) * Add contract authz proto * Implement contract autorization * Register contract authz * Add contract-authz tests * Consume gas for contract authz * Add contract authz cli * Update cli usage * Model spike * Add max funds limit * Redesign authz model * Start e2e test * Full e2e test * Test filter and limits * Test accept * Fix description * No linter warning Co-authored-by: Giancarlos Salas <[email protected]> * Add StoreAndInstantiateContract gov proposal * Add integration tests * Remove exposed functions * Add tests * Add cli and refactor code * Fix comments Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GNaD13 <[email protected]> Co-authored-by: Alex Peters <[email protected]> Co-authored-by: Giancarlos Salas <[email protected]>
* preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]>
* Add StoreAndInstantiateContract gov proposal * Add integration tests * Bump github.com/prometheus/client_golang from 1.13.0 to 1.14.0 Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Remove exposed functions * Add tests * Add Developer's guide and best practices (CosmWasm#1075) * Add Developer's guide and best practices * Fix comments * Change genesis preserving contract history (CosmWasm#1076) * preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]> * Return contract history updates * Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082) Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](spf13/viper@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082)" This reverts commit cf81eb8. * Add cli and refactor code * Contract authz - redesign (CosmWasm#1077) * Add contract authz proto * Implement contract autorization * Register contract authz * Add contract-authz tests * Consume gas for contract authz * Add contract authz cli * Update cli usage * Model spike * Add max funds limit * Redesign authz model * Start e2e test * Full e2e test * Test filter and limits * Test accept * Fix description * No linter warning Co-authored-by: Giancarlos Salas <[email protected]> * Add StoreAndInstantiateContract gov proposal * Add integration tests * Remove exposed functions * Add tests * Add cli and refactor code * Fix comments Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GNaD13 <[email protected]> Co-authored-by: Alex Peters <[email protected]> Co-authored-by: Giancarlos Salas <[email protected]>
* preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]>
* Add StoreAndInstantiateContract gov proposal * Add integration tests * Bump github.com/prometheus/client_golang from 1.13.0 to 1.14.0 Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Remove exposed functions * Add tests * Add Developer's guide and best practices (CosmWasm#1075) * Add Developer's guide and best practices * Fix comments * Change genesis preserving contract history (CosmWasm#1076) * preserve contract created date on genesis import and add query contract created date * add validate created * fix sims test app import export * add preserve contract history * Make proto-all only * Remove ResetFromGenesis * Add validation Co-authored-by: Alex Peters <[email protected]> * Return contract history updates * Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082) Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.13.0 to 1.14.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](spf13/viper@v1.13.0...v1.14.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Bump github.com/spf13/viper from 1.13.0 to 1.14.0 (CosmWasm#1082)" This reverts commit cf81eb8. * Add cli and refactor code * Contract authz - redesign (CosmWasm#1077) * Add contract authz proto * Implement contract autorization * Register contract authz * Add contract-authz tests * Consume gas for contract authz * Add contract authz cli * Update cli usage * Model spike * Add max funds limit * Redesign authz model * Start e2e test * Full e2e test * Test filter and limits * Test accept * Fix description * No linter warning Co-authored-by: Giancarlos Salas <[email protected]> * Add StoreAndInstantiateContract gov proposal * Add integration tests * Remove exposed functions * Add tests * Add cli and refactor code * Fix comments Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GNaD13 <[email protected]> Co-authored-by: Alex Peters <[email protected]> Co-authored-by: Giancarlos Salas <[email protected]>
Close #878