Skip to content

Commit

Permalink
V5.8.0 hotfix 3 (#1862)
Browse files Browse the repository at this point in the history
* Release oom hotfix

* Revert showing wasm transactions in EVM rpc (#1861)

* fix: add V580Params specific functions

* chore: update variable name ParamsPreV580

---------

Co-authored-by: yzang2019 <[email protected]>
Co-authored-by: codchen <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent fa620f1 commit fa43819
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 46 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ require (
github.com/fzipp/gocyclo v0.5.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-critic/go-critic v0.6.3 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand Down Expand Up @@ -172,6 +173,7 @@ require (
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down Expand Up @@ -765,6 +766,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/guptarohit/asciigraph v0.5.5/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag=
Expand Down
45 changes: 44 additions & 1 deletion proto/evm/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,50 @@ string minimum_fee_per_gas = 4 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "minimum_fee_per_gas"
];
uint64 deliver_tx_hook_wasm_gas_limit = 5;
// ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// string chain_id = 6 [
// (gogoproto.moretags) = "yaml:\"chain_id\"",
// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
// (gogoproto.nullable) = false,
// (gogoproto.jsontag) = "chain_id"
// ];
// repeated string whitelisted_codehashes_bank_send = 7 [
// (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"",
// (gogoproto.jsontag) = "whitelisted_codehashes_bank_send"
// ];
repeated bytes whitelisted_cw_code_hashes_for_delegate_call = 8 [
(gogoproto.moretags) = "yaml:\"whitelisted_cw_code_hashes_for_delegate_call\"",
(gogoproto.jsontag) = "whitelisted_cw_code_hashes_for_delegate_call"
];

uint64 deliver_tx_hook_wasm_gas_limit = 9;
}

message ParamsPreV580 {
option (gogoproto.goproto_stringer) = false;

// string base_denom = 1 [
// (gogoproto.moretags) = "yaml:\"base_denom\"",
// (gogoproto.jsontag) = "base_denom"
// ];
string priority_normalizer = 2 [
(gogoproto.moretags) = "yaml:\"priority_normalizer\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "priority_normalizer"
];
string base_fee_per_gas = 3 [
(gogoproto.moretags) = "yaml:\"base_fee_per_gas\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "base_fee_per_gas"
];
string minimum_fee_per_gas = 4 [
(gogoproto.moretags) = "yaml:\"minimum_fee_per_gas\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "minimum_fee_per_gas"
];
// ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// string chain_id = 6 [
// (gogoproto.moretags) = "yaml:\"chain_id\"",
Expand Down
23 changes: 21 additions & 2 deletions x/evm/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,31 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.Paramstore.SetParamSet(ctx, &params)
}

func (k *Keeper) GetParams(ctx sdk.Context) types.Params {
params := types.Params{}
func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params) {
params = types.Params{}
defer func() {
if r := recover(); r != nil {
// If panic occurs, try to get paramsPreV580
params = k.GetParamsPreV580(ctx)
}
}()
k.Paramstore.GetParamSet(ctx, &params)
return params
}

func (k *Keeper) GetParamsPreV580(ctx sdk.Context) types.Params {
paramsPreV580 := types.ParamsPreV580{}
k.Paramstore.GetParamSet(ctx, &paramsPreV580)
// Convert paramsPreV580 to params
return types.Params{
PriorityNormalizer: paramsPreV580.PriorityNormalizer,
BaseFeePerGas: paramsPreV580.BaseFeePerGas,
MinimumFeePerGas: paramsPreV580.MinimumFeePerGas,
WhitelistedCwCodeHashesForDelegateCall: paramsPreV580.WhitelistedCwCodeHashesForDelegateCall,
DeliverTxHookWasmGasLimit: uint64(300000),
}
}

func (k *Keeper) GetParamsIfExists(ctx sdk.Context) types.Params {
params := types.Params{}
k.Paramstore.GetParamSetIfExists(ctx, &params)
Expand Down
2 changes: 1 addition & 1 deletion x/evm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestModuleExportGenesis(t *testing.T) {
module := evm.NewAppModule(nil, k)
jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc)
jsonStr := string(jsonMsg)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"deliver_tx_hook_wasm_gas_limit\":\"300000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[],\"deliver_tx_hook_wasm_gas_limit\":\"300000\"},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr)
}

func TestConsensusVersion(t *testing.T) {
Expand Down
16 changes: 15 additions & 1 deletion x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyPriorityNormalizer, &p.PriorityNormalizer, validatePriorityNormalizer),
paramtypes.NewParamSetPair(KeyBaseFeePerGas, &p.BaseFeePerGas, validateBaseFeePerGas),
paramtypes.NewParamSetPair(KeyMinFeePerGas, &p.MinimumFeePerGas, validateMinFeePerGas),
paramtypes.NewParamSetPair(KeyDeliverTxHookWasmGasLimit, &p.DeliverTxHookWasmGasLimit, validateDeliverTxHookWasmGasLimit),
paramtypes.NewParamSetPair(KeyWhitelistedCwCodeHashesForDelegateCall, &p.WhitelistedCwCodeHashesForDelegateCall, validateWhitelistedCwHashesForDelegateCall),
paramtypes.NewParamSetPair(KeyDeliverTxHookWasmGasLimit, &p.DeliverTxHookWasmGasLimit, validateDeliverTxHookWasmGasLimit),
}
}

Expand Down Expand Up @@ -79,6 +79,20 @@ func (p Params) String() string {
return string(out)
}

func (p *ParamsPreV580) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyPriorityNormalizer, &p.PriorityNormalizer, validatePriorityNormalizer),
paramtypes.NewParamSetPair(KeyBaseFeePerGas, &p.BaseFeePerGas, validateBaseFeePerGas),
paramtypes.NewParamSetPair(KeyMinFeePerGas, &p.MinimumFeePerGas, validateMinFeePerGas),
paramtypes.NewParamSetPair(KeyWhitelistedCwCodeHashesForDelegateCall, &p.WhitelistedCwCodeHashesForDelegateCall, validateWhitelistedCwHashesForDelegateCall),
}
}

func (p ParamsPreV580) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}

func validatePriorityNormalizer(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
Expand Down
Loading

0 comments on commit fa43819

Please sign in to comment.