diff --git a/proto/umee/oracle/v1/genesis.proto b/proto/umee/oracle/v1/genesis.proto index e0c6cd1b64..ae08880bc1 100644 --- a/proto/umee/oracle/v1/genesis.proto +++ b/proto/umee/oracle/v1/genesis.proto @@ -25,6 +25,11 @@ message GenesisState { repeated Price medians = 7 [(gogoproto.nullable) = false]; repeated Price historic_prices = 8 [(gogoproto.nullable) = false]; repeated Price medianDeviations = 9 [(gogoproto.nullable) = false]; + // Historic Avg Counter params + AvgCounterParams avg_counter_params = 10 [ + (gogoproto.moretags) = "yaml:\"avg_counter_params\"", + (gogoproto.nullable) = false + ]; } // FeederDelegation is the address for where oracle feeder authority are diff --git a/proto/umee/oracle/v1/oracle.proto b/proto/umee/oracle/v1/oracle.proto index 3899d1f206..14bf477911 100644 --- a/proto/umee/oracle/v1/oracle.proto +++ b/proto/umee/oracle/v1/oracle.proto @@ -56,11 +56,6 @@ message Params { // Maximum Median Stamps represents the maximum amount of medians the // oracle module will store before pruning via FIFO. uint64 maximum_median_stamps = 12; - // Historic Avg Counter params - AvgCounterParams avg_counter_params = 13 [ - (gogoproto.moretags) = "yaml:\"avg_counter_params\"", - (gogoproto.nullable) = false - ]; } // AvgCounterParams - Historic avg counter params diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go index f686dcae52..386cb5c1a0 100644 --- a/x/oracle/genesis.go +++ b/x/oracle/genesis.go @@ -71,6 +71,10 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, genState types.GenesisSt if moduleAcc == nil { panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) } + + // set historic avg counter params (avgPeriod and avgShift) + err := keeper.SetHistoricAvgCounterParams(ctx, genState.AvgCounterParams) + util.Panic(err) } // ExportGenesis returns the x/oracle module's exported genesis. @@ -128,6 +132,8 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { historicPrices := keeper.AllHistoricPrices(ctx) medianPrices := keeper.AllMedianPrices(ctx) medianDeviationPrices := keeper.AllMedianDeviationPrices(ctx) + hacp, err := keeper.GetHistoricAvgCounterParams(ctx) + util.Panic(err) return types.NewGenesisState( params, @@ -139,5 +145,6 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { historicPrices, medianPrices, medianDeviationPrices, + hacp, ) } diff --git a/x/oracle/genesis_test.go b/x/oracle/genesis_test.go index d458f6ea83..be773d655b 100644 --- a/x/oracle/genesis_test.go +++ b/x/oracle/genesis_test.go @@ -200,6 +200,7 @@ func (s *IntegrationTestSuite) TestGenesis_ExportGenesis() { BlockNum: 0, }, } + hacp := types.DefaultAvgCounterParams() genesisState := types.GenesisState{ Params: params, @@ -211,6 +212,7 @@ func (s *IntegrationTestSuite) TestGenesis_ExportGenesis() { Medians: medians, HistoricPrices: historicPrices, MedianDeviations: medianDeviations, + AvgCounterParams: hacp, } oracle.InitGenesis(ctx, keeper, genesisState) @@ -225,4 +227,5 @@ func (s *IntegrationTestSuite) TestGenesis_ExportGenesis() { assert.DeepEqual(s.T(), medians, result.Medians) assert.DeepEqual(s.T(), historicPrices, result.HistoricPrices) assert.DeepEqual(s.T(), medianDeviations, result.MedianDeviations) + assert.DeepEqual(s.T(), hacp, result.AvgCounterParams) } diff --git a/x/oracle/keeper/genesis.go b/x/oracle/keeper/genesis.go index 4017ccf753..c6e5b1fd5b 100644 --- a/x/oracle/keeper/genesis.go +++ b/x/oracle/keeper/genesis.go @@ -111,3 +111,26 @@ func (k Keeper) AllMedianDeviationPrices(ctx sdk.Context) types.Prices { }) return prices } + +// SetAvgPeSetHistoricAvgCounterParams sets avg period and avg shift time duration +func (k Keeper) SetHistoricAvgCounterParams(ctx sdk.Context, acp types.AvgCounterParams) error { + store := ctx.KVStore(k.storeKey) + bz, err := acp.Marshal() + if err != nil { + return err + } + store.Set(types.KeyHistoricAvgCounterParams, bz) + return nil +} + +// GetHistoricAvgCounterParams gets the avg period and avg shift time duration from store +func (k Keeper) GetHistoricAvgCounterParams(ctx sdk.Context) (types.AvgCounterParams, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyHistoricAvgCounterParams) + var acp types.AvgCounterParams + err := acp.Unmarshal(bz) + if err != nil { + return types.AvgCounterParams{}, err + } + return acp, nil +} diff --git a/x/oracle/keeper/historic_avg.go b/x/oracle/keeper/historic_avg.go index 30ea49b8cf..3a9d8ff2c9 100644 --- a/x/oracle/keeper/historic_avg.go +++ b/x/oracle/keeper/historic_avg.go @@ -17,7 +17,8 @@ type AvgKeeper struct { } func (k Keeper) AvgKeeper(ctx sdk.Context) AvgKeeper { - p := k.GetParams(ctx).AvgCounterParams + p, err := k.GetHistoricAvgCounterParams(ctx) + util.Panic(err) return AvgKeeper{store: ctx.KVStore(k.storeKey), period: p.AvgPeriod, shift: p.AvgShift} } diff --git a/x/oracle/keeper/migrations.go b/x/oracle/keeper/migrations.go index bdb513a394..4169429c97 100644 --- a/x/oracle/keeper/migrations.go +++ b/x/oracle/keeper/migrations.go @@ -38,8 +38,7 @@ func (m Migrator) HistoracleParams3x4(ctx sdk.Context) error { // SetAvgPeriodAndShift updates the avg shift and period params func (m Migrator) SetAvgPeriodAndShift(ctx sdk.Context) error { p := types.DefaultAvgCounterParams() - m.keeper.SetHistoricAvgCounterParams(ctx, *p) - return nil + return m.keeper.SetHistoricAvgCounterParams(ctx, p) } // MigrateBNB fixes the BNB base denom for the 4.1 upgrade without using leverage hooks diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 71e3390df9..426d21d461 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -136,8 +136,3 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } - -// SetAvgPeSetHistoricAvgCounterParams sets avg period and avg shift time duration -func (k Keeper) SetHistoricAvgCounterParams(ctx sdk.Context, acp types.AvgCounterParams) { - k.paramSpace.Set(ctx, types.KeyHistoricAvgCounterParams, &acp) -} diff --git a/x/oracle/simulations/genesis.go b/x/oracle/simulations/genesis.go index 7f40327415..107f4b03e8 100644 --- a/x/oracle/simulations/genesis.go +++ b/x/oracle/simulations/genesis.go @@ -175,6 +175,10 @@ func RandomizedGenState(simState *module.SimulationState) { ) oracleGenesis := types.DefaultGenesisState() + oracleGenesis.AvgCounterParams = types.AvgCounterParams{ + AvgPeriod: avgPeriod, + AvgShift: avgShift, + } oracleGenesis.Params = types.Params{ VotePeriod: votePeriod, VoteThreshold: voteThreshold, @@ -190,10 +194,6 @@ func RandomizedGenState(simState *module.SimulationState) { MedianStampPeriod: medianStampPeriod, MaximumPriceStamps: historicStampPeriod, MaximumMedianStamps: historicStampPeriod, - AvgCounterParams: types.AvgCounterParams{ - AvgPeriod: avgPeriod, - AvgShift: avgShift, - }, } bz, err := json.MarshalIndent(&oracleGenesis.Params, "", " ") diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 6c72b6dc4c..946a0fb220 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -2,6 +2,7 @@ package types import ( "encoding/json" + "fmt" "github.com/cosmos/cosmos-sdk/codec" ) @@ -17,6 +18,7 @@ func NewGenesisState( historicPrices []Price, medianPrices []Price, medianDeviationPrices []Price, + acp AvgCounterParams, ) *GenesisState { return &GenesisState{ Params: params, @@ -28,6 +30,7 @@ func NewGenesisState( HistoricPrices: historicPrices, Medians: medianPrices, MedianDeviations: medianDeviationPrices, + AvgCounterParams: acp, } } @@ -44,12 +47,17 @@ func DefaultGenesisState() *GenesisState { HistoricPrices: []Price{}, Medians: []Price{}, MedianDeviations: []Price{}, + AvgCounterParams: DefaultAvgCounterParams(), } } // ValidateGenesis validates the oracle genesis state. func ValidateGenesis(data *GenesisState) error { - return data.Params.Validate() + if err := data.Params.Validate(); err != nil { + return err + } + + return data.AvgCounterParams.Validate() } // GetGenesisStateFromAppState returns x/oracle GenesisState given raw application @@ -63,3 +71,26 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R return &genesisState } + +func DefaultAvgCounterParams() AvgCounterParams { + return AvgCounterParams{ + AvgPeriod: DefaultAvgPeriod, // 16 hours + AvgShift: DefaultAvgShift, // 12 hours + } +} + +func (acp AvgCounterParams) Equal(other *AvgCounterParams) bool { + return acp.AvgPeriod == other.AvgPeriod && acp.AvgShift == other.AvgShift +} + +func (acp AvgCounterParams) Validate() error { + if acp.AvgPeriod.Seconds() <= 0 { + return fmt.Errorf("avg period must be positive: %d", acp.AvgPeriod) + } + + if acp.AvgShift.Seconds() <= 0 { + return fmt.Errorf("avg shift must be positive: %d", acp.AvgShift) + } + + return nil +} diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 5267e9542b..e7a88fd7b3 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -34,6 +34,8 @@ type GenesisState struct { Medians []Price `protobuf:"bytes,7,rep,name=medians,proto3" json:"medians"` HistoricPrices []Price `protobuf:"bytes,8,rep,name=historic_prices,json=historicPrices,proto3" json:"historic_prices"` MedianDeviations []Price `protobuf:"bytes,9,rep,name=medianDeviations,proto3" json:"medianDeviations"` + // Historic Avg Counter params + AvgCounterParams AvgCounterParams `protobuf:"bytes,10,opt,name=avg_counter_params,json=avgCounterParams,proto3" json:"avg_counter_params" yaml:"avg_counter_params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -199,44 +201,46 @@ func init() { func init() { proto.RegisterFile("umee/oracle/v1/genesis.proto", fileDescriptor_c99b4af40468acc1) } var fileDescriptor_c99b4af40468acc1 = []byte{ - // 577 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xdd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8c, 0xfb, 0x93, 0xb6, 0x9b, 0x36, 0x5f, 0xba, 0x1f, 0x20, 0x2b, 0xa1, 0x6e, 0x1a, 0x09, - 0x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ipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xdd, 0x4e, 0xd4, 0x4e, + 0x14, 0xdf, 0xf2, 0xb1, 0xc0, 0x2c, 0xec, 0x7f, 0x99, 0xbf, 0x9a, 0xba, 0x48, 0x59, 0x9a, 0x98, + 0x60, 0xd4, 0x36, 0xa0, 0xdc, 0x78, 0x07, 0x22, 0xdc, 0xa8, 0x21, 0xf5, 0x2b, 0x31, 0x31, 0xcd, + 0xd0, 0x1e, 0x4a, 0x43, 0xdb, 0xa9, 0x33, 0xd3, 0x0a, 0x31, 0xbe, 0x83, 0xcf, 0xe1, 0x93, 0x70, + 0xc9, 0xa5, 0x57, 0xa8, 0xf0, 0x06, 0xfa, 0x02, 0xa6, 0xd3, 0x29, 0x2c, 0x5d, 0x10, 0xee, 0x76, + 0xcf, 0xf9, 0x7d, 0x9c, 0x74, 0x7e, 0xe7, 0xa0, 0x3b, 0x59, 0x0c, 0x60, 0x53, 0x46, 0xbc, 0x08, + 0xec, 0x7c, 0xd1, 0x0e, 0x20, 0x01, 0x1e, 0x72, 0x2b, 0x65, 0x54, 0x50, 0xdc, 0x2e, 0xba, 0x56, + 0xd9, 0xb5, 0xf2, 0xc5, 0xee, 0x8d, 0x80, 0x06, 0x54, 0xb6, 0xec, 0xe2, 0x57, 0x89, 0xea, 0xce, + 0xd4, 0x34, 0x14, 0x5e, 0x36, 0xcd, 0x3f, 0x4d, 0x34, 0xb9, 0x51, 0x8a, 0xbe, 0x12, 0x44, 0x00, + 0x7e, 0x8c, 0x9a, 0x29, 0x61, 0x24, 0xe6, 0xba, 0xd6, 0xd3, 0x16, 0x5a, 0x4b, 0xb7, 0xac, 0xf3, + 0x26, 0xd6, 0xa6, 0xec, 0xae, 0x8e, 0x1c, 0x1c, 0xcd, 0x35, 0x1c, 0x85, 0xc5, 0x6f, 0x10, 0xde, + 0x06, 0xf0, 0x81, 0xb9, 0x3e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, 0x46, 0xe3, 0xe0, 0xd8, 0xd0, 0x0e, 0x8f, 0x0d, 0xed, 0xe7, 0xb1, 0xa1, 0x7d, 0x3d, + 0x31, 0x1a, 0x87, 0x27, 0x46, 0xe3, 0xfb, 0x89, 0xd1, 0x78, 0x6f, 0x05, 0xa1, 0xd8, 0xc9, 0xb6, + 0x2c, 0x8f, 0xc6, 0x76, 0x31, 0xc0, 0xc3, 0x04, 0xc4, 0x27, 0xca, 0x76, 0xe5, 0x1f, 0x3b, 0x5f, + 0xb6, 0xf7, 0xaa, 0x9b, 0x28, 0xf6, 0x53, 0xe0, 0x5b, 0x4d, 0x79, 0x10, 0x1f, 0xfd, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x5a, 0x0e, 0x46, 0xe0, 0x73, 0x05, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -259,6 +263,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.AvgCounterParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 if len(m.MedianDeviations) > 0 { for iNdEx := len(m.MedianDeviations) - 1; iNdEx >= 0; iNdEx-- { { @@ -561,6 +575,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.AvgCounterParams.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -951,6 +967,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvgCounterParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvgCounterParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index 9bf05614f6..9067fbcce2 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -67,6 +67,7 @@ func TestGetGenesisStateFromAppState(t *testing.T) { MissCounters: []MissCounter{}, AggregateExchangeRatePrevotes: []AggregateExchangeRatePrevote{}, AggregateExchangeRateVotes: []AggregateExchangeRateVote{}, + AvgCounterParams: AvgCounterParams{}, } bz, err := json.Marshal(emptyGenesis) diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 969b763397..d64fe7b271 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -52,8 +52,6 @@ type Params struct { // Maximum Median Stamps represents the maximum amount of medians the // oracle module will store before pruning via FIFO. MaximumMedianStamps uint64 `protobuf:"varint,12,opt,name=maximum_median_stamps,json=maximumMedianStamps,proto3" json:"maximum_median_stamps,omitempty"` - // Historic Avg Counter params - AvgCounterParams AvgCounterParams `protobuf:"bytes,13,opt,name=avg_counter_params,json=avgCounterParams,proto3" json:"avg_counter_params" yaml:"avg_counter_params"` } func (m *Params) Reset() { *m = Params{} } @@ -345,76 +343,73 @@ func init() { func init() { proto.RegisterFile("umee/oracle/v1/oracle.proto", fileDescriptor_8893c9e0e94ceb54) } var fileDescriptor_8893c9e0e94ceb54 = []byte{ - // 1092 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 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 0xe4, 0xcf, - 0x06, 0x58, 0x99, 0x21, 0x10, 0xb9, 0xca, 0xed, 0x55, 0xca, 0xa5, 0xfb, 0x43, 0xc1, 0xf0, 0x08, - 0x34, 0x26, 0x64, 0x6b, 0xee, 0x47, 0x37, 0x5e, 0xa4, 0xcd, 0x6b, 0x6a, 0x60, 0x7b, 0x4b, 0xe5, - 0x6b, 0x4e, 0x09, 0xff, 0xc1, 0x00, 0x60, 0xbc, 0x03, 0xe0, 0xe7, 0x60, 0x8e, 0x65, 0x85, 0x5e, - 0xe7, 0x66, 0xfc, 0x9e, 0x08, 0x85, 0xcb, 0x60, 0x2e, 0xcd, 0xd4, 0x60, 0x34, 0x3c, 0xf1, 0x09, - 0x3b, 0x60, 0x81, 0x71, 0x44, 0x55, 0xd3, 0xd7, 0x77, 0x37, 0x66, 0x86, 0xfb, 0xa0, 0xf8, 0x2d, - 0xe4, 0x56, 0x05, 0xe3, 0x0b, 0x31, 0xb2, 0x2a, 0xa4, 0x53, 0x7d, 0xae, 0x85, 0xba, 0x8f, 0xcf, - 0xff, 0x6c, 0x55, 0xce, 0x2f, 0x5a, 0xc6, 0xab, 0x8b, 0x96, 0xf1, 0xc7, 0x45, 0xcb, 0x78, 0x71, - 0xd9, 0xaa, 0xbc, 0xba, 0x6c, 0x55, 0x7e, 0xbb, 0x6c, 0x55, 0xbe, 0x71, 0x4a, 0x12, 0x45, 0xc7, - 0xdc, 0x4d, 0x31, 0x3f, 0x26, 0xf4, 0x48, 0x1a, 0xed, 0xe1, 0x83, 0xf6, 0x49, 0xf1, 0xfb, 0x4d, - 0xca, 0xed, 0x2e, 0x4a, 0xf2, 0xfb, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x41, 0x05, 0xe7, 0x97, - 0xdb, 0x09, 0x00, 0x00, + // 1052 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcf, 0x6f,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0xde, 0x7f, 0x9c, 0x24, 0x14, 0x25, 0x90, 0xa3, + 0xaf, 0x8e, 0xa2, 0x01, 0xcc, 0x13, 0x14, 0x40, 0x8e, 0x76, 0x29, 0x12, 0x4b, 0xd0, 0xfc, 0x00, + 0xdc, 0x18, 0x40, 0x36, 0xd0, 0xb5, 0xdc, 0x1e, 0x97, 0x76, 0x5b, 0xe5, 0x16, 0xa7, 0x4e, 0x20, + 0x41, 0xf3, 0x1e, 0x98, 0x17, 0xce, 0x54, 0x2b, 0x5f, 0x1e, 0x97, 0xf6, 0xe2, 0x64, 0xb3, 0x52, + 0x27, 0x50, 0xb0, 0x2c, 0xb4, 0xe8, 0x67, 0x98, 0x87, 0xfd, 0x94, 0x44, 0x07, 0x52, 0xf0, 0xf4, + 0x5b, 0xad, 0xa1, 0xa2, 0x50, 0x69, 0xfa, 0xc2, 0xba, 0xa4, 0xfb, 0xcc, 0x00, 0x77, 0xae, 0xd4, + 0xfd, 0x42, 0x88, 0xfe, 0xde, 0x00, 0x1d, 0xa4, 0x0f, 0x43, 0x0a, 0xc5, 0x72, 0x2f, 0x86, 0x29, + 0x62, 0x96, 0x21, 0xd7, 0xdd, 0xdd, 0xcb, 0xeb, 0xae, 0x9e, 0x60, 0x4f, 0x78, 0xfa, 0x9f, 0xeb, + 0xd5, 0xb7, 0x51, 0x35, 0x72, 0x36, 0x99, 0xd8, 0x81, 0xe6, 0x4c, 0x24, 0x0b, 0x4c, 0x34, 0x73, + 0xf6, 0x5f, 0x1b, 0x74, 0xa9, 0xc8, 0x9f, 0x0d, 0xb0, 0x32, 0x43, 0x20, 0x72, 0xd5, 0xc7, 0xab, + 0x96, 0x4b, 0xcf, 0x87, 0x82, 0xcd, 0x03, 0xb0, 0x34, 0x25, 0x5b, 0x73, 0x3f, 0xb9, 0xf6, 0x56, + 0xeb, 0x5c, 0xd1, 0x03, 0x27, 0x58, 0xac, 0x97, 0x79, 0x49, 0xf8, 0x0f, 0x06, 0x00, 0x93, 0x1d, + 0x60, 0x7e, 0x01, 0xe6, 0x58, 0x51, 0xe9, 0x75, 0xaf, 0xc7, 0x1f, 0x88, 0x50, 0x73, 0x19, 0xcc, + 0xe5, 0x85, 0x7a, 0x18, 0x4b, 0x81, 0xf8, 0x34, 0x7b, 0x60, 0x9e, 0x71, 0x48, 0xd5, 0xd0, 0xb7, + 0xb7, 0xd7, 0x67, 0x1e, 0xf7, 0x5e, 0xf5, 0xc7, 0xc4, 0x6f, 0x0a, 0xc6, 0x57, 0xe2, 0xc9, 0xaa, + 0x90, 0x5e, 0xf3, 0xa5, 0x16, 0xea, 0x3f, 0x3d, 0xfd, 0xa3, 0xdb, 0x38, 0x3d, 0xeb, 0x1a, 0x6f, + 0xce, 0xba, 0xc6, 0xef, 0x67, 0x5d, 0xe3, 0xd5, 0x79, 0xb7, 0xf1, 0xe6, 0xbc, 0xdb, 0xf8, 0xf5, + 0xbc, 0xdb, 0xf8, 0xd6, 0xad, 0x49, 0x14, 0x13, 0x73, 0x3f, 0x47, 0xfc, 0x90, 0xd0, 0x03, 0x69, + 0x78, 0xa3, 0x47, 0xde, 0x51, 0xf5, 0x67, 0x4a, 0xca, 0xed, 0x2f, 0x48, 0xf2, 0x87, 0xff, 0x04, + 0x00, 0x00, 0xff, 0xff, 0x50, 0x13, 0x1a, 0x2e, 0x68, 0x09, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -477,9 +472,6 @@ func (this *Params) Equal(that interface{}) bool { if this.MaximumMedianStamps != that1.MaximumMedianStamps { return false } - if !this.AvgCounterParams.Equal(&that1.AvgCounterParams) { - return false - } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -502,16 +494,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.AvgCounterParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintOracle(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a if m.MaximumMedianStamps != 0 { i = encodeVarintOracle(dAtA, i, uint64(m.MaximumMedianStamps)) i-- @@ -624,21 +606,21 @@ func (m *AvgCounterParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.AvgShift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.AvgShift):]) + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.AvgShift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.AvgShift):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintOracle(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x12 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.AvgPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.AvgPeriod):]) if err2 != nil { return 0, err2 } i -= n2 i = encodeVarintOracle(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x12 - n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.AvgPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.AvgPeriod):]) - if err3 != nil { - return 0, err3 - } - i -= n3 - i = encodeVarintOracle(dAtA, i, uint64(n3)) - i-- dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -831,12 +813,12 @@ func (m *AvgCounter) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Start):]) - if err4 != nil { - return 0, err4 + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Start):]) + if err3 != nil { + return 0, err3 } - i -= n4 - i = encodeVarintOracle(dAtA, i, uint64(n4)) + i -= n3 + i = encodeVarintOracle(dAtA, i, uint64(n3)) i-- dAtA[i] = 0x1a if m.Num != 0 { @@ -909,8 +891,6 @@ func (m *Params) Size() (n int) { if m.MaximumMedianStamps != 0 { n += 1 + sovOracle(uint64(m.MaximumMedianStamps)) } - l = m.AvgCounterParams.Size() - n += 1 + l + sovOracle(uint64(l)) return n } @@ -1355,39 +1335,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AvgCounterParams", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOracle - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthOracle - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthOracle - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.AvgCounterParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOracle(dAtA[iNdEx:]) diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index e3cd86f729..69fad2c690 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -65,7 +65,6 @@ func DefaultParams() Params { MedianStampPeriod: BlocksPerHour * 3, // 3h MaximumPriceStamps: 36, // 3h MaximumMedianStamps: 24, // 3 days - AvgCounterParams: *DefaultAvgCounterParams(), } } @@ -138,11 +137,6 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { &p.MaximumMedianStamps, validateMaximumMedianStamps, ), - paramstypes.NewParamSetPair( - KeyHistoricAvgCounterParams, - &p.AvgCounterParams, - validateAvgCounterParams, - ), } } @@ -369,23 +363,6 @@ func validateMaximumMedianStamps(i interface{}) error { return nil } -func validateAvgCounterParams(i interface{}) error { - v, ok := i.(AvgCounterParams) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v.AvgPeriod.Seconds() <= 0 { - return fmt.Errorf("avg period must be positive: %d", v) - } - - if v.AvgShift.Seconds() <= 0 { - return fmt.Errorf("avg shift must be positive: %d", v) - } - - return nil -} - // ValidateVoteThreshold validates oracle exchange rates power vote threshold. // Must be // * a decimal value > 0.33 and <= 1. @@ -401,14 +378,3 @@ func ValidateVoteThreshold(x sdk.Dec) error { } return nil } - -func DefaultAvgCounterParams() *AvgCounterParams { - return &AvgCounterParams{ - AvgPeriod: DefaultAvgPeriod, // 16 hours - AvgShift: DefaultAvgShift, // 12 hours - } -} - -func (acp *AvgCounterParams) Equal(other *AvgCounterParams) bool { - return acp.AvgPeriod == other.AvgPeriod && acp.AvgShift == other.AvgShift -} diff --git a/x/oracle/types/params_test.go b/x/oracle/types/params_test.go index e122d9c2c4..6d91c79de8 100644 --- a/x/oracle/types/params_test.go +++ b/x/oracle/types/params_test.go @@ -277,5 +277,5 @@ func TestValidateVotingThreshold(t *testing.T) { func TestParams_ParamSetPairs(t *testing.T) { params := DefaultParams() - assert.Equal(t, 13, len(params.ParamSetPairs())) + assert.Equal(t, 12, len(params.ParamSetPairs())) }