diff --git a/proto/zetachain/zetacore/emissions/params.proto b/proto/zetachain/zetacore/emissions/params.proto index 01958fb556..148e5239a5 100644 --- a/proto/zetachain/zetacore/emissions/params.proto +++ b/proto/zetachain/zetacore/emissions/params.proto @@ -26,20 +26,21 @@ message Params { reserved 8; } -//// Deprecated: Do not use. Use Params. -// message ParamsLegacy { -// option (gogoproto.goproto_stringer) = false; -// string max_bond_factor = 1; -// string min_bond_factor = 2; -// string avg_block_time = 3; -// string target_bond_ratio = 4; -// string validator_emission_percentage = 5; -// string observer_emission_percentage = 6; -// string tss_signer_emission_percentage = 7; -// string duration_factor_constant = 8; -// string observer_slash_amount = 9 [ -// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", -// (gogoproto.nullable) = false -// ]; -// int64 ballot_maturity_blocks = 10; -// } +// Deprecated: Do not use. Use Params. +// TODO: Add release version when this change is going to be applied. (v20?) +message LegacyParams { + option (gogoproto.goproto_stringer) = false; + string max_bond_factor = 1; + string min_bond_factor = 2; + string avg_block_time = 3; + string target_bond_ratio = 4; + string validator_emission_percentage = 5; + string observer_emission_percentage = 6; + string tss_signer_emission_percentage = 7; + string duration_factor_constant = 8; + string observer_slash_amount = 9 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 ballot_maturity_blocks = 10; +} diff --git a/x/emissions/keeper/keeper.go b/x/emissions/keeper/keeper.go index 39c1f19a22..46df10d4fa 100644 --- a/x/emissions/keeper/keeper.go +++ b/x/emissions/keeper/keeper.go @@ -55,6 +55,11 @@ func NewKeeper( } } +func (k Keeper) GetCodec() codec.BinaryCodec { + return k.cdc + +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/emissions/migrations/v3/migrate_test.go b/x/emissions/migrations/v3/migrate_test.go index 13439e8120..1ea65b8acf 100644 --- a/x/emissions/migrations/v3/migrate_test.go +++ b/x/emissions/migrations/v3/migrate_test.go @@ -9,8 +9,9 @@ import ( keepertest "github.com/zeta-chain/node/testutil/keeper" "github.com/zeta-chain/node/x/emissions/exported" - v3 "github.com/zeta-chain/node/x/emissions/migrations/v3" "github.com/zeta-chain/node/x/emissions/types" + + v3 "github.com/zeta-chain/node/x/emissions/migrations/v3" ) type mockSubspace struct { diff --git a/x/emissions/migrations/v4/migrate.go b/x/emissions/migrations/v4/migrate.go new file mode 100644 index 0000000000..e9132466f9 --- /dev/null +++ b/x/emissions/migrations/v4/migrate.go @@ -0,0 +1,66 @@ +package v4 + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/zeta-chain/node/x/emissions/types" +) + +type EmissionsKeeper interface { + SetParams(ctx sdk.Context, params types.Params) error +} + +// Migrate migrates the x/emissions module state from the consensus version 2 to +// version 3. Specifically, it takes the parameters that are currently stored +// and managed by the x/params modules and stores them directly into the x/emissions +// module state. +func MigrateStore( + ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.Codec, + emissionsKeeper EmissionsKeeper, +) error { + currentParams, found := GetParamsLegacy(ctx, storeKey, cdc) + if !found { + err := fmt.Errorf("failed to get legacy params") + ctx.Logger().Error("error :", err.Error()) + return err + } + + defaultParams := types.NewParams() + if currentParams.ValidatorEmissionPercentage != "" { + defaultParams.ValidatorEmissionPercentage = currentParams.ValidatorEmissionPercentage + } + if currentParams.ObserverEmissionPercentage != "" { + defaultParams.ObserverEmissionPercentage = currentParams.ObserverEmissionPercentage + } + if currentParams.TssSignerEmissionPercentage != "" { + defaultParams.TssSignerEmissionPercentage = currentParams.TssSignerEmissionPercentage + } + defaultParams.ObserverSlashAmount = currentParams.ObserverSlashAmount + defaultParams.BallotMaturityBlocks = currentParams.BallotMaturityBlocks + + err := emissionsKeeper.SetParams(ctx, defaultParams) + if err != nil { + return err + } + return nil +} + +func GetParamsLegacy(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec) (params types.LegacyParams, found bool) { + store := ctx.KVStore(storeKey) + bz := store.Get(types.KeyPrefix(types.ParamsKey)) + if bz == nil { + return types.LegacyParams{}, false + } + err := cdc.Unmarshal(bz, ¶ms) + if err != nil { + return types.LegacyParams{}, false + } + + return params, true +} diff --git a/x/emissions/migrations/v4/migrate_test.go b/x/emissions/migrations/v4/migrate_test.go new file mode 100644 index 0000000000..9a228007be --- /dev/null +++ b/x/emissions/migrations/v4/migrate_test.go @@ -0,0 +1,53 @@ +package v4_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/node/testutil/keeper" + "github.com/zeta-chain/node/x/emissions/types" +) + +func TestMigrateStore(t *testing.T) { + t.Run("should successfully migrate to new params", func(t *testing.T) { + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + + cdc := k.GetCodec() + emissionsStoreKey := sdk.NewKVStoreKey(types.StoreKey) + + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, LegacyMainnetParams()) + require.NoError(t, err) + + }) +} + +func SetLegacyParams(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, params types.LegacyParams) error { + store := ctx.KVStore(storeKey) + bz, err := cdc.Marshal(¶ms) + if err != nil { + return err + } + + store.Set(types.KeyPrefix(types.ParamsKey), bz) + return nil +} + +// https://zetachain-api.lavenderfive.com/zeta-chain/emissions/params +func LegacyMainnetParams() types.LegacyParams { + return types.LegacyParams{ + MaxBondFactor: "1.25", + MinBondFactor: "0.75", + AvgBlockTime: "6.00", + TargetBondRatio: "0.67", + ObserverEmissionPercentage: "0.125", + ValidatorEmissionPercentage: "0.75", + TssSignerEmissionPercentage: "0.125", + DurationFactorConstant: "0.001877876953694702", + ObserverSlashAmount: sdkmath.NewIntFromUint64(100000000000000000), + BallotMaturityBlocks: 100, + } +} diff --git a/x/emissions/types/legacy_params.go b/x/emissions/types/legacy_params.go new file mode 100644 index 0000000000..3e9f52629c --- /dev/null +++ b/x/emissions/types/legacy_params.go @@ -0,0 +1,11 @@ +package types + +import "gopkg.in/yaml.v2" + +func (m *LegacyParams) String() string { + out, err := yaml.Marshal(m) + if err != nil { + return "" + } + return string(out) +} diff --git a/x/emissions/types/legacy_params_test.go b/x/emissions/types/legacy_params_test.go new file mode 100644 index 0000000000..2af05e9507 --- /dev/null +++ b/x/emissions/types/legacy_params_test.go @@ -0,0 +1,28 @@ +package types_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/x/emissions/types" + "gopkg.in/yaml.v2" +) + +func TestLegacyString(t *testing.T) { + params := types.LegacyParams{ + MaxBondFactor: "1.25", + MinBondFactor: "0.75", + AvgBlockTime: "6.00", + TargetBondRatio: "0.67", + ObserverEmissionPercentage: "0.125", + ValidatorEmissionPercentage: "0.75", + TssSignerEmissionPercentage: "0.125", + DurationFactorConstant: "0.001877876953694702", + ObserverSlashAmount: sdkmath.NewIntFromUint64(100000000000000000), + BallotMaturityBlocks: 100, + } + out, err := yaml.Marshal(params) + require.NoError(t, err) + require.Equal(t, string(out), params.String()) +} diff --git a/x/emissions/types/params.pb.go b/x/emissions/types/params.pb.go index bcd6ada699..1372e11cea 100644 --- a/x/emissions/types/params.pb.go +++ b/x/emissions/types/params.pb.go @@ -94,8 +94,119 @@ func (m *Params) GetBallotMaturityBlocks() int64 { return 0 } +// Deprecated: Do not use. Use Params. +// TODO: Add release version when this change is going to be applied. (v20?) +type LegacyParams struct { + MaxBondFactor string `protobuf:"bytes,1,opt,name=max_bond_factor,json=maxBondFactor,proto3" json:"max_bond_factor,omitempty"` + MinBondFactor string `protobuf:"bytes,2,opt,name=min_bond_factor,json=minBondFactor,proto3" json:"min_bond_factor,omitempty"` + AvgBlockTime string `protobuf:"bytes,3,opt,name=avg_block_time,json=avgBlockTime,proto3" json:"avg_block_time,omitempty"` + TargetBondRatio string `protobuf:"bytes,4,opt,name=target_bond_ratio,json=targetBondRatio,proto3" json:"target_bond_ratio,omitempty"` + ValidatorEmissionPercentage string `protobuf:"bytes,5,opt,name=validator_emission_percentage,json=validatorEmissionPercentage,proto3" json:"validator_emission_percentage,omitempty"` + ObserverEmissionPercentage string `protobuf:"bytes,6,opt,name=observer_emission_percentage,json=observerEmissionPercentage,proto3" json:"observer_emission_percentage,omitempty"` + TssSignerEmissionPercentage string `protobuf:"bytes,7,opt,name=tss_signer_emission_percentage,json=tssSignerEmissionPercentage,proto3" json:"tss_signer_emission_percentage,omitempty"` + DurationFactorConstant string `protobuf:"bytes,8,opt,name=duration_factor_constant,json=durationFactorConstant,proto3" json:"duration_factor_constant,omitempty"` + ObserverSlashAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=observer_slash_amount,json=observerSlashAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"observer_slash_amount"` + BallotMaturityBlocks int64 `protobuf:"varint,10,opt,name=ballot_maturity_blocks,json=ballotMaturityBlocks,proto3" json:"ballot_maturity_blocks,omitempty"` +} + +func (m *LegacyParams) Reset() { *m = LegacyParams{} } +func (*LegacyParams) ProtoMessage() {} +func (*LegacyParams) Descriptor() ([]byte, []int) { + return fileDescriptor_259272924aec0acf, []int{1} +} +func (m *LegacyParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LegacyParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyParams.Merge(m, src) +} +func (m *LegacyParams) XXX_Size() int { + return m.Size() +} +func (m *LegacyParams) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyParams.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyParams proto.InternalMessageInfo + +func (m *LegacyParams) GetMaxBondFactor() string { + if m != nil { + return m.MaxBondFactor + } + return "" +} + +func (m *LegacyParams) GetMinBondFactor() string { + if m != nil { + return m.MinBondFactor + } + return "" +} + +func (m *LegacyParams) GetAvgBlockTime() string { + if m != nil { + return m.AvgBlockTime + } + return "" +} + +func (m *LegacyParams) GetTargetBondRatio() string { + if m != nil { + return m.TargetBondRatio + } + return "" +} + +func (m *LegacyParams) GetValidatorEmissionPercentage() string { + if m != nil { + return m.ValidatorEmissionPercentage + } + return "" +} + +func (m *LegacyParams) GetObserverEmissionPercentage() string { + if m != nil { + return m.ObserverEmissionPercentage + } + return "" +} + +func (m *LegacyParams) GetTssSignerEmissionPercentage() string { + if m != nil { + return m.TssSignerEmissionPercentage + } + return "" +} + +func (m *LegacyParams) GetDurationFactorConstant() string { + if m != nil { + return m.DurationFactorConstant + } + return "" +} + +func (m *LegacyParams) GetBallotMaturityBlocks() int64 { + if m != nil { + return m.BallotMaturityBlocks + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "zetachain.zetacore.emissions.Params") + proto.RegisterType((*LegacyParams)(nil), "zetachain.zetacore.emissions.LegacyParams") } func init() { @@ -103,32 +214,40 @@ func init() { } var fileDescriptor_259272924aec0acf = []byte{ - // 393 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xbb, 0x6e, 0xe2, 0x40, - 0x14, 0x86, 0x6d, 0x71, 0x59, 0x98, 0x6d, 0x58, 0xc3, 0xae, 0x10, 0xcb, 0x1a, 0xb4, 0xc5, 0x8a, - 0x95, 0x82, 0x5d, 0x24, 0x55, 0xaa, 0xc4, 0xb9, 0x48, 0x41, 0x8a, 0x84, 0x4c, 0x97, 0x22, 0xd6, - 0xd8, 0x1e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7, 0x53, 0x5b, 0x73, 0x68, 0xa8, 0x3b, 0x14, - 0x42, 0x0a, 0xdb, 0xa7, 0x0f, 0xee, 0x44, 0xe7, 0xf3, 0x98, 0x80, 0x76, 0x15, 0x71, 0xb3, 0x9e, - 0xc9, 0x46, 0x89, 0xeb, 0x54, 0xa8, 0x94, 0x23, 0xf4, 0xcb, 0xc6, 0x41, 0x40, 0xb9, 0x15, 0x62, - 0x3e, 0x65, 0x3e, 0x9f, 0x5b, 0x76, 0x40, 0x9d, 0x09, 0x34, 0x51, 0x57, 0xee, 0x15, 0xcc, 0x46, - 0x3a, 0xbd, 0xde, 0x0e, 0x0d, 0x31, 0x53, 0x6e, 0x51, 0x5d, 0x50, 0x16, 0x23, 0x77, 0x98, 0xb9, - 0x59, 0xae, 0xef, 0x5f, 0xce, 0x75, 0x4e, 0x1c, 0xf3, 0x87, 0x50, 0x99, 0xc2, 0x94, 0xa6, 0x3a, - 0x2e, 0x3e, 0x3d, 0x77, 0xa4, 0x41, 0xb1, 0x22, 0xd7, 0x4a, 0x83, 0x62, 0xa5, 0x52, 0xab, 0x1a, - 0x97, 0x8b, 0xb5, 0x2a, 0x2f, 0xd7, 0xaa, 0xfc, 0xbe, 0x56, 0xe5, 0xc7, 0x8d, 0x2a, 0x2d, 0x37, - 0xaa, 0xf4, 0xb2, 0x51, 0xa5, 0x9b, 0x83, 0x9d, 0x33, 0x49, 0x61, 0xfa, 0x69, 0xcd, 0x22, 0xea, - 0x12, 0xfd, 0x7e, 0xa7, 0x64, 0xe2, 0xa0, 0x5d, 0x16, 0x85, 0x39, 0xfc, 0x08, 0x00, 0x00, 0xff, - 0xff, 0xfa, 0xc0, 0x3f, 0x91, 0x91, 0x02, 0x00, 0x00, + // 528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x94, 0xcf, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x1b, 0xda, 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 0x07, 0x77, 0xad, 0xe0, 0xb8, 0x98, 0xe3, 0xee, 0x91, 0x5b, 0x30, 0x4a, 0xf2, 0xc3, 0x53, 0xc3, + 0x53, 0xe6, 0xd4, 0x11, 0x5b, 0x86, 0x51, 0x82, 0xa7, 0x7e, 0xcb, 0x53, 0x66, 0x3f, 0x20, 0x6b, + 0x06, 0x54, 0xc2, 0x4c, 0x2e, 0x54, 0x60, 0xb8, 0x74, 0x1a, 0x08, 0xae, 0xe4, 0x85, 0x4c, 0x19, + 0x64, 0xdb, 0x57, 0xe9, 0x25, 0x3e, 0x21, 0x4e, 0x3c, 0xc4, 0xc3, 0x8a, 0xe2, 0x12, 0x69, 0x24, + 0x85, 0x36, 0x20, 0x8c, 0xd3, 0xc2, 0xf6, 0xcd, 0xb2, 0x9e, 0x5f, 0xe7, 0x61, 0x51, 0xfd, 0x7f, + 0xdf, 0x70, 0xfe, 0xc6, 0xba, 0x47, 0xe7, 0x53, 0xd7, 0xba, 0x98, 0xba, 0xd6, 0xaf, 0xa9, 0x6b, + 0x7d, 0x9e, 0xb9, 0xb5, 0x8b, 0x99, 0x5b, 0xfb, 0x3e, 0x73, 0x6b, 0xef, 0x1e, 0xce, 0x45, 0xca, + 0x06, 0xd1, 0x41, 0x3e, 0xbe, 0x84, 0x8c, 0x99, 0x3f, 0x9e, 0x1b, 0x5e, 0x18, 0x2e, 0x6c, 0xe2, + 0x20, 0x7a, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xea, 0x36, 0x06, 0xa1, 0xe9, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -200,6 +319,100 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LegacyParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LegacyParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BallotMaturityBlocks != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BallotMaturityBlocks)) + i-- + dAtA[i] = 0x50 + } + { + size := m.ObserverSlashAmount.Size() + i -= size + if _, err := m.ObserverSlashAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + if len(m.DurationFactorConstant) > 0 { + i -= len(m.DurationFactorConstant) + copy(dAtA[i:], m.DurationFactorConstant) + i = encodeVarintParams(dAtA, i, uint64(len(m.DurationFactorConstant))) + i-- + dAtA[i] = 0x42 + } + if len(m.TssSignerEmissionPercentage) > 0 { + i -= len(m.TssSignerEmissionPercentage) + copy(dAtA[i:], m.TssSignerEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.TssSignerEmissionPercentage))) + i-- + dAtA[i] = 0x3a + } + if len(m.ObserverEmissionPercentage) > 0 { + i -= len(m.ObserverEmissionPercentage) + copy(dAtA[i:], m.ObserverEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.ObserverEmissionPercentage))) + i-- + dAtA[i] = 0x32 + } + if len(m.ValidatorEmissionPercentage) > 0 { + i -= len(m.ValidatorEmissionPercentage) + copy(dAtA[i:], m.ValidatorEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.ValidatorEmissionPercentage))) + i-- + dAtA[i] = 0x2a + } + if len(m.TargetBondRatio) > 0 { + i -= len(m.TargetBondRatio) + copy(dAtA[i:], m.TargetBondRatio) + i = encodeVarintParams(dAtA, i, uint64(len(m.TargetBondRatio))) + i-- + dAtA[i] = 0x22 + } + if len(m.AvgBlockTime) > 0 { + i -= len(m.AvgBlockTime) + copy(dAtA[i:], m.AvgBlockTime) + i = encodeVarintParams(dAtA, i, uint64(len(m.AvgBlockTime))) + i-- + dAtA[i] = 0x1a + } + if len(m.MinBondFactor) > 0 { + i -= len(m.MinBondFactor) + copy(dAtA[i:], m.MinBondFactor) + i = encodeVarintParams(dAtA, i, uint64(len(m.MinBondFactor))) + i-- + dAtA[i] = 0x12 + } + if len(m.MaxBondFactor) > 0 { + i -= len(m.MaxBondFactor) + copy(dAtA[i:], m.MaxBondFactor) + i = encodeVarintParams(dAtA, i, uint64(len(m.MaxBondFactor))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -239,6 +452,52 @@ func (m *Params) Size() (n int) { return n } +func (m *LegacyParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MaxBondFactor) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.MinBondFactor) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.AvgBlockTime) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.TargetBondRatio) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.ValidatorEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.ObserverEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.TssSignerEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.DurationFactorConstant) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.ObserverSlashAmount.Size() + n += 1 + l + sovParams(uint64(l)) + if m.BallotMaturityBlocks != 0 { + n += 1 + sovParams(uint64(m.BallotMaturityBlocks)) + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -478,6 +737,365 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *LegacyParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBondFactor", 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 + } + m.MaxBondFactor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBondFactor", 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 + } + m.MinBondFactor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvgBlockTime", 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 + } + m.AvgBlockTime = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetBondRatio", 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 + } + m.TargetBondRatio = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorEmissionPercentage", 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 + } + m.ValidatorEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObserverEmissionPercentage", 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 + } + m.ObserverEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TssSignerEmissionPercentage", 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 + } + m.TssSignerEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DurationFactorConstant", 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 + } + m.DurationFactorConstant = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObserverSlashAmount", 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.ObserverSlashAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BallotMaturityBlocks", wireType) + } + m.BallotMaturityBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BallotMaturityBlocks |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0