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 migration for new params #1840

Merged
merged 4 commits into from
Aug 30, 2024
Merged

Add migration for new params #1840

merged 4 commits into from
Aug 30, 2024

Conversation

blindchaser
Copy link
Contributor

Describe your changes and provide context

Testing performed to validate your change

x/evm/module.go Outdated
@@ -208,6 +208,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
_ = cfg.RegisterMigration(types.ModuleName, 10, func(ctx sdk.Context) error {
return migrations.MigrateCastAddressBalances(ctx, am.keeper)
})

_ = cfg.RegisterMigration(types.ModuleName, 11, func(ctx sdk.Context) error {
return migrations.AddNewParamsAndSetAllToDefaults(ctx, am.keeper)
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not use this migration handler because it will reset params which we don't want to do, instead we should initialize the param value for the new param being introduced. And lets add tests for that

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's a valid concern, let's only change for the new param

defaultParams := types.DefaultParams()
defaultDeliverTxHookWasmGasLimit := defaultParams.DeliverTxHookWasmGasLimit
defaultParams.DeliverTxHookWasmGasLimit = defaultDeliverTxHookWasmGasLimit
k.SetParams(ctx, defaultParams)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will still override the other existing params, instead of starting from default params, we need to load the existing params, and set these two values in that struct


keeperParams := k.GetParams(ctx)

require.Equal(t, keeperParams.GetDeliverTxHookWasmGasLimit(), types.DefaultParams().DeliverTxHookWasmGasLimit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

For good measure we can start by setting some other value for a non new param and verify that it doesn't get overwritten

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i relized that too. working on it

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 60.69%. Comparing base (942e73d) to head (45eed45).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/evm/module.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1840      +/-   ##
==========================================
+ Coverage   60.51%   60.69%   +0.18%     
==========================================
  Files         258      259       +1     
  Lines       22734    22748      +14     
==========================================
+ Hits        13758    13808      +50     
+ Misses       7995     7956      -39     
- Partials      981      984       +3     
Files with missing lines Coverage Δ
x/evm/migrations/migrate_deliver_tx_gas_limit.go 100.00% <100.00%> (ø)
x/evm/module.go 40.10% <25.00%> (-0.66%) ⬇️

... and 2 files with indirect coverage changes

@blindchaser blindchaser enabled auto-merge (squash) August 30, 2024 22:38
@blindchaser blindchaser merged commit c2a0d85 into main Aug 30, 2024
49 checks passed
@blindchaser blindchaser deleted the yiren/param-fix branch August 30, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants