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

[Feature] Improve oracle spec #325

Merged
merged 24 commits into from
Mar 25, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a8aad2d
append new msgs - assoicate oracle prevote & vote with updated whitel…
Feb 13, 2020
04e4ed6
append querier for associate oracle prevote, cmd & rest interface to …
Feb 13, 2020
ecb0dc4
append simulation code for associate msgs
Feb 13, 2020
e0d2637
implement import & export for associate prevote
Feb 13, 2020
c475c73
delete associate prevotes at export for zero height
Feb 13, 2020
291fbe2
change associate to aggregate
Feb 13, 2020
ae49a13
update swagger docs
Feb 14, 2020
e90f64a
store aggregate vote in the keeper to reduce file I/O operation
Feb 16, 2020
48f2bb8
add genesis export import feature for aggregate vote
Feb 19, 2020
8b7026d
add codec & cmd tx
Feb 20, 2020
edcd820
introduce vote targets to avoid directly refering params.Whitelist fr…
Feb 27, 2020
8b902d1
apply default value for default VotesTarget at genesis import step
Feb 27, 2020
86ce702
store illiquid factors for safe swap & make vote hash type
Mar 17, 2020
1a7f0df
bugfix - delete aggregate votes&prevotes after tally
Mar 17, 2020
72b509f
ignore vote from the voter who did aggregate vote
Mar 17, 2020
dd8b975
simulation code fix
Mar 17, 2020
e3ecaa4
skip reward allocation when the reward is zero
Mar 19, 2020
1e44cc1
add max exchange rates length limit on aggregate vote msg & return de…
Mar 23, 2020
1182941
for internal map structure, directly stringify validator address to p…
Mar 23, 2020
8fef74e
change to use unique tobin taxes per denom in oracle params & variabl…
Mar 25, 2020
cc1a825
wording changes
Mar 25, 2020
4c31179
remove unused yaml definition
Mar 25, 2020
62ceec2
fix lint
Mar 25, 2020
9c102ad
fix wrong description on cmd
Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement import & export for associate prevote
Yun committed Feb 13, 2020
commit e0d26378455f432a8064855e044c79e399f2dc81
12 changes: 11 additions & 1 deletion x/oracle/genesis.go
Original file line number Diff line number Diff line change
@@ -55,6 +55,10 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) {
keeper.SetMissCounter(ctx, operator, missCounter)
}

for _, associatePrevote := range data.AssociateExchangeRatePrevotes {
keeper.AddAssociateExchangeRatePrevote(ctx, associatePrevote)
}

keeper.SetParams(ctx, data.Params)
keeper.GetRewardPool(ctx)
}
@@ -95,5 +99,11 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) (data GenesisState) {
return false
})

return NewGenesisState(params, exchangeRatePrevotes, exchangeRateVotes, rates, feederDelegations, missCounters)
var associateExchangeRatePrevotes []AssociateExchangeRatePrevote
keeper.IterateAssociateExchangeRatePrevotes(ctx, func(associatePrevote AssociateExchangeRatePrevote) (stop bool) {
associateExchangeRatePrevotes = append(associateExchangeRatePrevotes, associatePrevote)
return false
})

return NewGenesisState(params, exchangeRatePrevotes, exchangeRateVotes, rates, feederDelegations, missCounters, associateExchangeRatePrevotes)
}
2 changes: 1 addition & 1 deletion x/oracle/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -336,7 +336,7 @@ func (k Keeper) DeleteAssociateExchangeRatePrevote(ctx sdk.Context, associatePre
// IterateAssociateExchangeRatePrevotes iterates rate over prevotes in the store
func (k Keeper) IterateAssociateExchangeRatePrevotes(ctx sdk.Context, handler func(associatePrevote types.AssociateExchangeRatePrevote) (stop bool)) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.PrevoteKey)
iter := sdk.KVStorePrefixIterator(store, types.AssociatePrevoteKey)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var associatePrevote types.AssociateExchangeRatePrevote
40 changes: 22 additions & 18 deletions x/oracle/internal/types/genesis.go
Original file line number Diff line number Diff line change
@@ -8,40 +8,44 @@ import (

// GenesisState - all oracle state that must be provided at genesis
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
FeederDelegations map[string]sdk.AccAddress `json:"feeder_delegations" yaml:"feeder_delegations"`
ExchangeRates map[string]sdk.Dec `json:"exchange_rates" yaml:"exchange_rates"`
ExchangeRatePrevotes []ExchangeRatePrevote `json:"exchange_rate_prevotes" yaml:"exchange_rate_prevotes"`
ExchangeRateVotes []ExchangeRateVote `json:"exchange_rate_votes" yaml:"exchange_rate_votes"`
MissCounters map[string]int64 `json:"miss_counters" yaml:"miss_counters"`
Params Params `json:"params" yaml:"params"`
FeederDelegations map[string]sdk.AccAddress `json:"feeder_delegations" yaml:"feeder_delegations"`
ExchangeRates map[string]sdk.Dec `json:"exchange_rates" yaml:"exchange_rates"`
ExchangeRatePrevotes []ExchangeRatePrevote `json:"exchange_rate_prevotes" yaml:"exchange_rate_prevotes"`
ExchangeRateVotes []ExchangeRateVote `json:"exchange_rate_votes" yaml:"exchange_rate_votes"`
MissCounters map[string]int64 `json:"miss_counters" yaml:"miss_counters"`
AssociateExchangeRatePrevotes []AssociateExchangeRatePrevote `json:"associate_exchange_rate_prevotes" yaml:"associate_exchange_rate_prevotes"`
}

// NewGenesisState creates a new GenesisState object
func NewGenesisState(
params Params, exchangeRatePrevotes []ExchangeRatePrevote,
exchangeRateVotes []ExchangeRateVote, rates map[string]sdk.Dec,
feederDelegations map[string]sdk.AccAddress, missCounters map[string]int64,
associateExchangeRatePrevotes []AssociateExchangeRatePrevote,
) GenesisState {

return GenesisState{
Params: params,
ExchangeRatePrevotes: exchangeRatePrevotes,
ExchangeRateVotes: exchangeRateVotes,
ExchangeRates: rates,
FeederDelegations: feederDelegations,
MissCounters: missCounters,
Params: params,
ExchangeRatePrevotes: exchangeRatePrevotes,
ExchangeRateVotes: exchangeRateVotes,
ExchangeRates: rates,
FeederDelegations: feederDelegations,
MissCounters: missCounters,
AssociateExchangeRatePrevotes: associateExchangeRatePrevotes,
}
}

// DefaultGenesisState - default GenesisState used by columbus-2
func DefaultGenesisState() GenesisState {
return GenesisState{
Params: DefaultParams(),
ExchangeRatePrevotes: []ExchangeRatePrevote{},
ExchangeRateVotes: []ExchangeRateVote{},
ExchangeRates: make(map[string]sdk.Dec),
FeederDelegations: make(map[string]sdk.AccAddress),
MissCounters: make(map[string]int64),
Params: DefaultParams(),
ExchangeRatePrevotes: []ExchangeRatePrevote{},
ExchangeRateVotes: []ExchangeRateVote{},
ExchangeRates: make(map[string]sdk.Dec),
FeederDelegations: make(map[string]sdk.AccAddress),
MissCounters: make(map[string]int64),
AssociateExchangeRatePrevotes: []AssociateExchangeRatePrevote{},
}
}