diff --git a/proto/dex/params.proto b/proto/dex/params.proto index 64754c02be..ff44257e54 100644 --- a/proto/dex/params.proto +++ b/proto/dex/params.proto @@ -14,4 +14,9 @@ message Params { (gogoproto.moretags) = "yaml:\"price_snapshot_retention\"", (gogoproto.jsontag) = "price_snapshot_retention" ]; -} \ No newline at end of file + string sudo_call_gas_price = 2 [ + (gogoproto.jsontag) = "sudo_call_gas_price", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/utils/slice.go b/utils/slice.go index 23bf8126a2..cf2a37cbcc 100644 --- a/utils/slice.go +++ b/utils/slice.go @@ -28,3 +28,13 @@ func Reduce[I, O any](input []I, reducer func(I, O) O, initial O) O { } return initial } + +func Filter[T any](slice []T, lambda func(t T) bool) []T { + res := []T{} + for _, t := range slice { + if lambda(t) { + res = append(res, t) + } + } + return res +} diff --git a/x/dex/contract/abci.go b/x/dex/contract/abci.go index bfddb00cd5..235b333f39 100644 --- a/x/dex/contract/abci.go +++ b/x/dex/contract/abci.go @@ -103,7 +103,7 @@ func cacheAndDecorateContext(ctx sdk.Context, env *environment) (sdk.Context, sd cachedCtx, msCached := store.GetCachedContext(ctx) goCtx := context.WithValue(cachedCtx.Context(), dexcache.CtxKeyExecTermSignal, env.executionTerminationSignals) cachedCtx = cachedCtx.WithContext(goCtx) - decoratedCtx := cachedCtx.WithGasMeter(seisync.NewGasWrapper(cachedCtx.GasMeter())).WithBlockGasMeter( + decoratedCtx := cachedCtx.WithGasMeter(seisync.NewGasWrapper(sdk.NewInfiniteGasMeter())).WithBlockGasMeter( seisync.NewGasWrapper(cachedCtx.BlockGasMeter()), ) return decoratedCtx, msCached diff --git a/x/dex/contract/whitelist.go b/x/dex/contract/whitelist.go index 0f70aad100..5e62948014 100644 --- a/x/dex/contract/whitelist.go +++ b/x/dex/contract/whitelist.go @@ -5,6 +5,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sei-protocol/sei-chain/utils" + "github.com/sei-protocol/sei-chain/x/dex/keeper" "github.com/sei-protocol/sei-chain/x/dex/types" ) @@ -19,6 +20,7 @@ var DexWhitelistedKeys = []string{ types.SettlementEntryKey, types.NextOrderIDKey, types.MatchResultKey, + keeper.ContractPrefixKey, } var WasmWhitelistedKeys = []string{ diff --git a/x/dex/keeper/contract.go b/x/dex/keeper/contract.go index 752380aa3b..86862e0c0d 100644 --- a/x/dex/keeper/contract.go +++ b/x/dex/keeper/contract.go @@ -67,6 +67,24 @@ func (k Keeper) GetAllContractInfo(ctx sdk.Context) []types.ContractInfoV2 { return list } +func (k Keeper) ChargeRentForGas(ctx sdk.Context, contractAddr string, gasUsed uint64) error { + contract, err := k.GetContract(ctx, contractAddr) + if err != nil { + return err + } + params := k.GetParams(ctx) + gasPrice := sdk.NewDec(int64(gasUsed)).Mul(params.SudoCallGasPrice).RoundInt().Int64() + if gasPrice > int64(contract.RentBalance) { + contract.RentBalance = 0 + if err := k.SetContract(ctx, &contract); err != nil { + return err + } + return errors.New("insufficient rent") + } + contract.RentBalance -= uint64(gasPrice) + return k.SetContract(ctx, &contract) +} + func contractKey(contractAddr string) []byte { return []byte(contractAddr) } diff --git a/x/dex/keeper/contract_test.go b/x/dex/keeper/contract_test.go new file mode 100644 index 0000000000..2a0d7dae9e --- /dev/null +++ b/x/dex/keeper/contract_test.go @@ -0,0 +1,30 @@ +package keeper_test + +import ( + "testing" + + keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/sei-protocol/sei-chain/x/dex/types" + "github.com/stretchr/testify/require" +) + +func TestChargeRentForGas(t *testing.T) { + keeper, ctx := keepertest.DexKeeper(t) + err := keeper.SetContract(ctx, &types.ContractInfoV2{ + Creator: keepertest.TestAccount, + ContractAddr: keepertest.TestContract, + CodeId: 1, + RentBalance: 1000000, + }) + require.Nil(t, err) + err = keeper.ChargeRentForGas(ctx, keepertest.TestContract, 5000000) + require.Nil(t, err) + contract, err := keeper.GetContract(ctx, keepertest.TestContract) + require.Nil(t, err) + require.Equal(t, uint64(500000), contract.RentBalance) + err = keeper.ChargeRentForGas(ctx, keepertest.TestContract, 6000000) + require.NotNil(t, err) + contract, err = keeper.GetContract(ctx, keepertest.TestContract) + require.Nil(t, err) + require.Equal(t, uint64(0), contract.RentBalance) +} diff --git a/x/dex/keeper/utils/wasm.go b/x/dex/keeper/utils/wasm.go index 82d1556699..c5127120f3 100644 --- a/x/dex/keeper/utils/wasm.go +++ b/x/dex/keeper/utils/wasm.go @@ -35,16 +35,18 @@ func getMsgType(msg interface{}) string { } } -func sudo(sdkCtx sdk.Context, k *keeper.Keeper, contractAddress []byte, wasmMsg []byte, msgType string) ([]byte, error) { +func sudo(sdkCtx sdk.Context, k *keeper.Keeper, contractAddress []byte, wasmMsg []byte, msgType string) ([]byte, uint64, error) { // Measure the time it takes to execute the contract in WASM defer metrics.MeasureSudoExecutionDuration(time.Now(), msgType) + gasConsumedBefore := sdkCtx.GasMeter().GasConsumed() data, err := k.WasmKeeper.Sudo( sdkCtx, contractAddress, wasmMsg, ) + gasConsumedAfter := sdkCtx.GasMeter().GasConsumed() if hasErrInstantiatingWasmModuleDueToCPUFeature(err) { panic(utils.DecorateHardFailError(err)) } - return data, err + return data, gasConsumedAfter - gasConsumedBefore, err } func hasErrInstantiatingWasmModuleDueToCPUFeature(err error) bool { @@ -66,11 +68,16 @@ func CallContractSudo(sdkCtx sdk.Context, k *keeper.Keeper, contractAddr string, return []byte{}, err } msgType := getMsgType(msg) - data, err := sudo(sdkCtx, k, contractAddress, wasmMsg, msgType) + data, gasUsed, err := sudo(sdkCtx, k, contractAddress, wasmMsg, msgType) if err != nil { metrics.IncrementSudoFailCount(msgType) sdkCtx.Logger().Error(err.Error()) return []byte{}, err } + if err := k.ChargeRentForGas(sdkCtx, contractAddr, gasUsed); err != nil { + metrics.IncrementSudoFailCount(msgType) + sdkCtx.Logger().Error(err.Error()) + return []byte{}, err + } return data, nil } diff --git a/x/dex/migrations/v8_to_v9.go b/x/dex/migrations/v8_to_v9.go index 493069c222..cb0e6095d3 100644 --- a/x/dex/migrations/v8_to_v9.go +++ b/x/dex/migrations/v8_to_v9.go @@ -33,5 +33,6 @@ func V8ToV9(ctx sdk.Context, dexkeeper keeper.Keeper) error { } contractStore.Set(iterator.Key(), bz) } + return nil } diff --git a/x/dex/module.go b/x/dex/module.go index 586d87e450..acee7de30f 100644 --- a/x/dex/module.go +++ b/x/dex/module.go @@ -211,7 +211,8 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 9 } func (am AppModule) getAllContractInfo(ctx sdk.Context) []types.ContractInfoV2 { - return am.keeper.GetAllContractInfo(ctx) + // Do not process any contract that has a non-zero rent balance + return utils.Filter(am.keeper.GetAllContractInfo(ctx), func(c types.ContractInfoV2) bool { return c.RentBalance > 0 }) } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. diff --git a/x/dex/module_test.go b/x/dex/module_test.go index b96402e574..a327618fd7 100644 --- a/x/dex/module_test.go +++ b/x/dex/module_test.go @@ -74,7 +74,7 @@ func TestEndBlockMarketOrder(t *testing.T) { if err != nil { panic(err) } - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, contractAddr.String(), pair) dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(contractAddr.String()), utils.GetPairString(&pair)).Add( &types.Order{ @@ -202,7 +202,7 @@ func TestEndBlockLimitOrder(t *testing.T) { panic(err) } - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, contractAddr.String(), pair) dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(contractAddr.String()), utils.GetPairString(&pair)).Add( &types.Order{ @@ -347,7 +347,7 @@ func TestEndBlockRollback(t *testing.T) { dexkeeper := testApp.DexKeeper pair := TEST_PAIR() // register contract and pair - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: keepertest.TestContract, NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: keepertest.TestContract, NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, keepertest.TestContract, pair) // place one order to a nonexistent contract dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(keepertest.TestContract), utils.GetPairString(&pair)).Add( @@ -378,7 +378,7 @@ func TestEndBlockPartialRollback(t *testing.T) { dexkeeper := testApp.DexKeeper pair := TEST_PAIR() // register contract and pair - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: keepertest.TestContract, NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: keepertest.TestContract, NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, keepertest.TestContract, pair) // place one order to a nonexistent contract dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(keepertest.TestContract), utils.GetPairString(&pair)).Add( @@ -416,7 +416,7 @@ func TestEndBlockPartialRollback(t *testing.T) { if err != nil { panic(err) } - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, contractAddr.String(), pair) // place one order to a nonexistent contract dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(contractAddr.String()), utils.GetPairString(&pair)).Add( @@ -480,7 +480,7 @@ func TestBeginBlock(t *testing.T) { if err != nil { panic(err) } - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) // right now just make sure it doesn't crash since it doesn't register any state to be checked against testApp.BeginBlocker(ctx, abci.RequestBeginBlock{}) @@ -520,7 +520,7 @@ func TestEndBlockPanicHandling(t *testing.T) { if err != nil { panic(err) } - dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true}) + dexkeeper.SetContract(ctx, &types.ContractInfoV2{CodeId: 123, ContractAddr: contractAddr.String(), NeedHook: false, NeedOrderMatching: true, RentBalance: 100000000}) dexkeeper.AddRegisteredPair(ctx, contractAddr.String(), pair) dexutils.GetMemState(ctx.Context()).GetBlockOrders(ctx, utils.ContractAddress(contractAddr.String()), utils.GetPairString(&pair)).Add( &types.Order{ diff --git a/x/dex/types/params.go b/x/dex/types/params.go index 20aa00d193..3fb55143ce 100644 --- a/x/dex/types/params.go +++ b/x/dex/types/params.go @@ -3,16 +3,22 @@ package types import ( fmt "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) -var KeyPriceSnapshotRetention = []byte("PriceSnapshotRetention") // number of epochs to retain price snapshots for +var ( + KeyPriceSnapshotRetention = []byte("PriceSnapshotRetention") // number of epochs to retain price snapshots for + KeySudoCallGasPrice = []byte("KeySudoCallGasPrice") // gas price for sudo calls from endblock +) const ( DefaultPriceSnapshotRetention = 24 * 3600 // default to one day ) +var DefaultSudoCallGasPrice = sdk.NewDecWithPrec(1, 1) // 0.1 + var _ paramtypes.ParamSet = (*Params)(nil) // ParamKeyTable the param key table for launch module @@ -29,6 +35,7 @@ func NewParams() Params { func DefaultParams() Params { return Params{ PriceSnapshotRetention: DefaultPriceSnapshotRetention, + SudoCallGasPrice: DefaultSudoCallGasPrice, } } @@ -36,6 +43,7 @@ func DefaultParams() Params { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPriceSnapshotRetention, &p.PriceSnapshotRetention, validatePriceSnapshotRetention), + paramtypes.NewParamSetPair(KeySudoCallGasPrice, &p.SudoCallGasPrice, validateSudoCallGasPrice), } } @@ -62,3 +70,7 @@ func validatePriceSnapshotRetention(i interface{}) error { return nil } + +func validateSudoCallGasPrice(i interface{}) error { + return nil +} diff --git a/x/dex/types/params.pb.go b/x/dex/types/params.pb.go index d10563e263..35befdc34a 100644 --- a/x/dex/types/params.pb.go +++ b/x/dex/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -25,7 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - PriceSnapshotRetention uint64 `protobuf:"varint,1,opt,name=price_snapshot_retention,json=priceSnapshotRetention,proto3" json:"price_snapshot_retention" yaml:"price_snapshot_retention"` + PriceSnapshotRetention uint64 `protobuf:"varint,1,opt,name=price_snapshot_retention,json=priceSnapshotRetention,proto3" json:"price_snapshot_retention" yaml:"price_snapshot_retention"` + SudoCallGasPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=sudo_call_gas_price,json=sudoCallGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sudo_call_gas_price"` } func (m *Params) Reset() { *m = Params{} } @@ -74,22 +76,26 @@ func init() { func init() { proto.RegisterFile("dex/params.proto", fileDescriptor_e49286500ccff43e) } var fileDescriptor_e49286500ccff43e = []byte{ - // 227 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x48, 0x49, 0xad, 0xd0, - 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, 0x4e, - 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, - 0x52, 0x52, 0x2b, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0xbd, - 0x52, 0x2f, 0x23, 0x17, 0x5b, 0x00, 0xd8, 0x00, 0xa1, 0x4a, 0x2e, 0x89, 0x82, 0xa2, 0xcc, 0xe4, - 0xd4, 0xf8, 0xe2, 0xbc, 0xc4, 0x82, 0xe2, 0x8c, 0xfc, 0x92, 0xf8, 0xa2, 0xd4, 0x92, 0xd4, 0xbc, - 0x92, 0xcc, 0xfc, 0x3c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, 0x27, 0xfb, 0x57, 0xf7, 0xe4, 0x71, - 0xaa, 0xf9, 0x74, 0x4f, 0x5e, 0xbe, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x97, 0x0a, 0xa5, 0x20, - 0x31, 0xb0, 0x54, 0x30, 0x54, 0x26, 0x08, 0x26, 0x61, 0xc5, 0x31, 0x63, 0x81, 0x3c, 0xc3, 0x8b, - 0x05, 0xf2, 0x8c, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, - 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, - 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, - 0xf3, 0x25, 0x98, 0x03, 0xf6, 0xa6, 0x7e, 0x85, 0x3e, 0x28, 0x3c, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, - 0x93, 0xd8, 0xc0, 0xf2, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0x2a, 0x03, 0x6c, 0x23, - 0x01, 0x00, 0x00, + // 303 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0xc7, 0x73, 0x45, 0x8a, 0x66, 0x2a, 0x55, 0x24, 0x38, 0xdc, 0x95, 0x0e, 0xd2, 0xa5, 0xb9, + 0xc1, 0xad, 0x8b, 0x50, 0x95, 0xae, 0xa5, 0x6e, 0x2e, 0xe1, 0x7a, 0x39, 0x92, 0xc3, 0x4b, 0x2e, + 0xe4, 0x5d, 0x21, 0x99, 0xfd, 0x02, 0x8e, 0x8e, 0xfd, 0x38, 0x1d, 0x3b, 0x8a, 0x43, 0x90, 0x64, + 0x91, 0x8e, 0x7e, 0x02, 0xc9, 0xd9, 0x82, 0x83, 0x9d, 0xee, 0xdd, 0xfb, 0xfd, 0x78, 0x0f, 0xfe, + 0xcf, 0xed, 0x85, 0xa2, 0xa0, 0x19, 0xcb, 0x59, 0x02, 0x7e, 0x96, 0x6b, 0xa3, 0xfb, 0x1e, 0x08, + 0x69, 0x2b, 0xae, 0x95, 0x0f, 0x42, 0xf2, 0x98, 0xc9, 0xd4, 0x0f, 0x45, 0x71, 0x75, 0x11, 0xe9, + 0x48, 0x5b, 0x44, 0xdb, 0xea, 0xd7, 0x1f, 0xbe, 0x74, 0xdc, 0xee, 0xdc, 0x0e, 0xe8, 0x97, 0xae, + 0x97, 0xe5, 0x92, 0x8b, 0x00, 0x52, 0x96, 0x41, 0xac, 0x4d, 0x90, 0x0b, 0x23, 0x52, 0x23, 0x75, + 0xea, 0xa1, 0x01, 0x1a, 0x9d, 0x4c, 0x6f, 0x77, 0x15, 0x39, 0xea, 0x7c, 0x57, 0x84, 0x94, 0x2c, + 0x51, 0x93, 0xe1, 0x31, 0x63, 0xb8, 0xb8, 0xb4, 0xe8, 0x71, 0x4f, 0x16, 0x07, 0xd0, 0x37, 0xee, + 0x39, 0xac, 0x42, 0x1d, 0x70, 0xa6, 0x54, 0x10, 0x31, 0x08, 0xac, 0xe7, 0x75, 0x06, 0x68, 0x74, + 0x36, 0x7d, 0xd8, 0x54, 0xc4, 0xf9, 0xa8, 0xc8, 0x75, 0x24, 0x4d, 0xbc, 0x5a, 0xfa, 0x5c, 0x27, + 0x94, 0x6b, 0x48, 0x34, 0xec, 0x9f, 0x31, 0x84, 0xcf, 0xd4, 0x94, 0x99, 0x00, 0xff, 0x5e, 0xf0, + 0x5d, 0x45, 0xfe, 0x1b, 0xb6, 0xe8, 0xb5, 0xcd, 0x3b, 0xa6, 0xd4, 0x8c, 0xc1, 0xbc, 0xed, 0x4c, + 0x4e, 0xdf, 0xd6, 0xc4, 0xf9, 0x5a, 0x13, 0x34, 0x9d, 0x6d, 0x6a, 0x8c, 0xb6, 0x35, 0x46, 0x9f, + 0x35, 0x46, 0xaf, 0x0d, 0x76, 0xb6, 0x0d, 0x76, 0xde, 0x1b, 0xec, 0x3c, 0x8d, 0xff, 0x2c, 0x05, + 0x21, 0xc7, 0x87, 0x6c, 0xed, 0xc7, 0x86, 0x4b, 0x0b, 0xda, 0x5e, 0xc1, 0xee, 0x5f, 0x76, 0x2d, + 0xbf, 0xf9, 0x09, 0x00, 0x00, 0xff, 0xff, 0x19, 0xbd, 0xa8, 0x1c, 0x99, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -114,6 +120,9 @@ func (this *Params) Equal(that interface{}) bool { if this.PriceSnapshotRetention != that1.PriceSnapshotRetention { return false } + if !this.SudoCallGasPrice.Equal(that1.SudoCallGasPrice) { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -136,6 +145,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.SudoCallGasPrice.Size() + i -= size + if _, err := m.SudoCallGasPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if m.PriceSnapshotRetention != 0 { i = encodeVarintParams(dAtA, i, uint64(m.PriceSnapshotRetention)) i-- @@ -164,6 +183,8 @@ func (m *Params) Size() (n int) { if m.PriceSnapshotRetention != 0 { n += 1 + sovParams(uint64(m.PriceSnapshotRetention)) } + l = m.SudoCallGasPrice.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -221,6 +242,40 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SudoCallGasPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SudoCallGasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])