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

feat: add oracle module #791

Merged
merged 113 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
c5ba451
add: init oracle
Aug 3, 2022
b659ae1
chore: adjustments
Aug 3, 2022
101324c
more cleanups
Aug 3, 2022
b1163d4
remove: sdk.Handler
Aug 3, 2022
81629d4
add: tmp fixes
Aug 3, 2022
96b1777
add: adjust tests
Aug 4, 2022
075d50f
chore: cleanup naming
Aug 4, 2022
7b660de
chore: more cleanups
Aug 4, 2022
b71ae51
chore: more cleanups 2
Aug 4, 2022
8c71c10
chore: finalize denom cleanups
Aug 4, 2022
b9b5121
change: rename Denom to Pair
Aug 4, 2022
1313700
fix: change DenomList to PairList
Aug 4, 2022
b5bae46
change: VoteForTally.Denom=>Pair
Aug 4, 2022
6db393e
change: func param rename
Aug 4, 2022
bf5e531
chore: docs
Aug 4, 2022
c840aa7
chore: more renaming
Aug 4, 2022
d05ae91
chore: rename denoms to pairs in query.proto
Aug 4, 2022
5b2c688
change: rename denom to pair in oracle.proto
Aug 4, 2022
206a36a
change: rename denom to pair in genesis.proto
Aug 4, 2022
5c5e595
change: rename denom to pair in hash.go
Aug 4, 2022
2709ae5
change: rename SetLunaExchangeRate to SetExchangeRate
Aug 4, 2022
e3fcbfc
change: rename SetLunaExchangeRateWithEvent to SetExchangeRateWithEvent
Aug 4, 2022
6621aba
change: rename DeleteLunaExchangeRate to DeleteExchangeRate
Aug 4, 2022
5196be2
change: rename GetLunaExchangeRate to GetExchangeRate
Aug 4, 2022
27ad4f9
change: rename IterateLunaExchangeRates to IterateExchangeRates
Aug 4, 2022
215b00e
fix: remove unappliable test
Aug 4, 2022
881ae09
fix: keeper_test.go
Aug 4, 2022
30403f6
chore: renames and removing unused vars
Aug 4, 2022
95e996a
change: remove set denom metadata from whitelist apply
Aug 4, 2022
5f48807
change: ballot_test.go shouldn't check for denom registration
Aug 4, 2022
0d5879e
change: rename denom.go to pair_list.go
Aug 5, 2022
1abd617
add: vote parsing and partial testing
Aug 5, 2022
9801f61
add: duplicates logic check
Aug 5, 2022
b6f6ce2
change: ParseTuplesStr logic to use pairs instead of denoms
Aug 5, 2022
571092d
fix: adjust msgs_test.go
Aug 5, 2022
f42e9b1
change: temp disable rewards for oracles
Aug 5, 2022
3a6b3f4
fix: adjust abci test part 1
Aug 5, 2022
c078081
chore: adjust test oracle drop and oracle tally and test oracle rewar…
Aug 5, 2022
bde3552
chore: skip multireward test adjustment
Aug 5, 2022
9d946ee
chore: adjust TestOracleExchangeRate test
Aug 5, 2022
131d75c
chore: adjust last abci_test.go
Aug 5, 2022
91bec8c
fix: last tests
Aug 5, 2022
5f32a40
chore: adjust keeper Msgserver FeederDelegation test
Aug 5, 2022
9222dd7
chore: adjust final test
Aug 5, 2022
8b8a1e9
chore: lint
Aug 5, 2022
e10e73b
chore: CHANGELOG.md
Aug 5, 2022
c9f7ade
change: Rename ErrUnknownDenom to ErrUnknownPair
Aug 5, 2022
6f0f519
fix: null prefix string key to avoid prefix overlaps
Aug 5, 2022
1bf0ea3
chore: clear docs denom=>pair
Aug 5, 2022
8b627d6
chore: params renaming
Aug 5, 2022
5f6d11a
chore: clear docs denom=>pair
Aug 5, 2022
a944480
fix: null suffix string for tobin tax keys
Aug 5, 2022
693168d
chore: return param rename
Aug 5, 2022
1c247ab
remove: pair_list_test.go useless tests
Aug 5, 2022
5d11dee
chore: remove deprecated rest handlers
Aug 5, 2022
6950adc
chore: rename AttributeKeyDenom=>Pair
Aug 5, 2022
d5bcb93
chore: rename OrganizeBallotByDenom=>Pair
Aug 5, 2022
9e5ff5e
chore: rename denom to pair in ballot.go
Aug 5, 2022
7f3a670
chore: address TODO on pair being wrong on default params
Aug 5, 2022
7a04d19
chore: more denom=>pair renames
Aug 5, 2022
a2f2272
chore: denom=>pair msg_server.go
Aug 5, 2022
9ad2e85
chore: more denom=>pair renames
Aug 5, 2022
49272b1
chore: rename denom=>pair params_test.go
Aug 5, 2022
432c671
chore: rename denom=>pair ballot.go
Aug 5, 2022
0a19920
chore: rename denom=>pair keeper_test.go
Aug 5, 2022
03aaf99
chore: rename denom=>pair params.go
Aug 5, 2022
9bdeee7
chore: rename denom=>pair params.go
Aug 5, 2022
eab9891
chore: cleanup interface expected_keeper.go
Aug 5, 2022
51abfb3
chore: renames denom=>pair keys.go
Aug 5, 2022
c10eca3
chore: renames denom=>pair tally.go
Aug 8, 2022
6c7c26d
chore: lint
Aug 8, 2022
f2c859c
chore: rename denom=>pair vote_target.go
Aug 8, 2022
c0d2373
chore: rename denom=>pair querier.go
Aug 8, 2022
442f518
chore: rename denom=>pair genesis.go
Aug 8, 2022
04cbbfd
change: rename references of sdk.DecCoins to ExchangeRateTuples from …
Aug 8, 2022
31e72df
chore: refactor confusing tests
Aug 8, 2022
55c96dd
chore: refactor confusing tests 2
Aug 8, 2022
a1a0152
chore: refactor confusing tests 3
Aug 8, 2022
20edfec
remove l mentions
AgentSmithMatrix Aug 8, 2022
a054b86
remove messages array
AgentSmithMatrix Aug 8, 2022
f8e1257
refactor exchange rate tuple function
AgentSmithMatrix Aug 8, 2022
c2b6100
remove dead code
AgentSmithMatrix Aug 8, 2022
da208f0
change voter to feeder as in the message
AgentSmithMatrix Aug 8, 2022
a822e31
finish review Aggregate Exchange PreVote
AgentSmithMatrix Aug 8, 2022
e373579
linter
AgentSmithMatrix Aug 8, 2022
253dbb0
Merge remote-tracking branch 'origin/master' into mercilex/oracle
AgentSmithMatrix Aug 8, 2022
9e5e159
remove mentions to l
AgentSmithMatrix Aug 8, 2022
31222bd
Merge branch 'master' into mercilex/oracle-init
NibiruHeisenberg Aug 8, 2022
a2dd7da
Merge branch 'mercilex/oracle-init' into mercilex/oracle
NibiruHeisenberg Aug 9, 2022
c58df9c
refactor variable names in oracle abci
NibiruHeisenberg Aug 9, 2022
99e923d
Remove common.MicroUnit
NibiruHeisenberg Aug 9, 2022
1cc04af
Clean up calls to sdk.NewDec
NibiruHeisenberg Aug 9, 2022
70958a1
Remove more usages of common.MicroUnit
NibiruHeisenberg Aug 9, 2022
c604315
chore: cleanup TestOracleThreshold test
Aug 9, 2022
0082d61
Merge branch 'mercilex/oracle' of jackfan.us.kg-agent:NibiruChain/nibiru…
AgentSmithMatrix Aug 9, 2022
5952364
add exchange rate vote
AgentSmithMatrix Aug 9, 2022
a3fa547
change l mention
AgentSmithMatrix Aug 9, 2022
0fb2887
fix comment
AgentSmithMatrix Aug 9, 2022
58a344b
remove mentions to l
AgentSmithMatrix Aug 9, 2022
993be9e
add: more tests
Aug 9, 2022
aa7916c
Merge remote-tracking branch 'origin/mercilex/oracle' into mercilex/o…
Aug 9, 2022
011f662
chore: todo context
Aug 9, 2022
50bc391
chore: more cleanups
Aug 9, 2022
c471c13
chore: krw renames
Aug 9, 2022
1e642f5
chore: remove references of Terra
Aug 9, 2022
5d83fa3
chore: more renamings
Aug 9, 2022
3c8ab3f
chore: correct proto docs
Aug 9, 2022
e689375
Merge branch 'master' into mercilex/oracle
NibiruHeisenberg Aug 9, 2022
c94e56f
Remove references to Terra Luna
NibiruHeisenberg Aug 9, 2022
168cb1f
Remove usages of terra, luna, and denom in docs
NibiruHeisenberg Aug 9, 2022
098a7bd
Update 02_state.md
NibiruHeisenberg Aug 9, 2022
e7ed13c
Fix documentation regarding ordering of pair and exchange_rate
NibiruHeisenberg Aug 9, 2022
2cdcba4
Refactor OrganizeBallotByPair and struct name
NibiruHeisenberg Aug 9, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#801](https://github.com/NibiruChain/nibiru/pull/801) - remove unused pair constants
* [#788](https://github.com/NibiruChain/nibiru/pull/788) - add --overwrite flag to the nibid init call of localnet.sh

### Features
* [#791](https://github.com/NibiruChain/nibiru/pull/791) Add the x/oracle module

## [v0.12.1](https://github.com/NibiruChain/nibiru/releases/tag/v0.12.1) - 2022-08-04

* [#796](https://github.com/NibiruChain/nibiru/pull/796) - fix bug that caused that epochKeeper was nil when running epoch hook from Perp module
Expand Down
4 changes: 3 additions & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ type AnteHandlerOptions struct {
IBCKeeper *ibckeeper.Keeper
}

/* NewAnteHandler returns and AnteHandler that checks and increments sequence
/*
NewAnteHandler returns and AnteHandler that checks and increments sequence

numbers, checks signatures and account numbers, and deducts fees from the first signer.
*/
func NewAnteHandler(options AnteHandlerOptions) (sdk.AnteHandler, error) {
Expand Down
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (app *NibiruApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favor of export at a block height
//
// in favor of export at a block height
func (app *NibiruApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down
19 changes: 12 additions & 7 deletions app/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import (
"github.com/NibiruChain/nibiru/x/testutil/testapp"
)

/* SetupTestingApp returns the TestingApp and default genesis state used to
initialize the testing app. */
/*
SetupTestingApp returns the TestingApp and default genesis state used to

initialize the testing app.
*/
func SetupNibiruTestingApp() (
testingApp ibctesting.TestingApp,
defaultGenesis map[string]json.RawMessage,
Expand Down Expand Up @@ -86,11 +89,13 @@ func TestIBCTestSuite(t *testing.T) {
suite.Run(t, new(IBCTestSuite))
}

/* NewIBCTestingTransferPath returns a "path" for testing.
A path contains two endpoints, 'EndpointA' and 'EndpointB' that correspond
to the order of the chains passed into the ibctesting.NewPath function.
A path is a pointer, and its values will be filled in as necessary during
the setup portion of testing.
/*
NewIBCTestingTransferPath returns a "path" for testing.

A path contains two endpoints, 'EndpointA' and 'EndpointB' that correspond
to the order of the chains passed into the ibctesting.NewPath function.
A path is a pointer, and its values will be filled in as necessary during
the setup portion of testing.
*/
func NewIBCTestingTransferPath(
chainA, chainB *ibctesting.TestChain,
Expand Down
9 changes: 5 additions & 4 deletions cmd/nibid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ commands, then builds the rosetta root command given a protocol buffers
serializer/deserializer.

Args:
rootCmd: The root command called once in the 'main.go' of 'nibid'.
encodingConfig: EncodingConfig specifies the concrete encoding types to use
for a given app. This is provided for compatibility between protobuf and
amino implementations.

rootCmd: The root command called once in the 'main.go' of 'nibid'.
encodingConfig: EncodingConfig specifies the concrete encoding types to use
for a given app. This is provided for compatibility between protobuf and
amino implementations.
*/
func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cfg := sdk.GetConfig()
Expand Down
43 changes: 43 additions & 0 deletions proto/oracle/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";
package nibiru.oracle.v1beta1;

import "gogoproto/gogo.proto";
import "oracle/v1beta1/oracle.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/NibiruChain/nibiru/x/oracle/types";

// GenesisState defines the oracle module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated FeederDelegation feeder_delegations = 2 [(gogoproto.nullable) = false];
repeated ExchangeRateTuple exchange_rates = 3
[(gogoproto.castrepeated) = "ExchangeRateTuples", (gogoproto.nullable) = false];
repeated MissCounter miss_counters = 4 [(gogoproto.nullable) = false];
repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5 [(gogoproto.nullable) = false];
repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6 [(gogoproto.nullable) = false];
repeated TobinTax tobin_taxes = 7 [(gogoproto.nullable) = false];
}

// FeederDelegation is the address for where oracle feeder authority are
// delegated to. By default this struct is only used at genesis to feed in
// default feeder addresses.
message FeederDelegation {
string feeder_address = 1;
string validator_address = 2;
}

// MissCounter defines an miss counter and validator address pair used in
// oracle module's genesis state
message MissCounter {
string validator_address = 1;
uint64 miss_counter = 2;
}

// TobinTax defines a pair and tobin_tax pair used in
// oracle module's genesis state
message TobinTax {
string pair = 1;
string tobin_tax = 2
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just renaming denom to pair

99 changes: 99 additions & 0 deletions proto/oracle/v1beta1/oracle.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
syntax = "proto3";
package nibiru.oracle.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/NibiruChain/nibiru/x/oracle/types";

// Params defines the parameters for the oracle module.
message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

uint64 vote_period = 1 [(gogoproto.moretags) = "yaml:\"vote_period\""];
string vote_threshold = 2 [
(gogoproto.moretags) = "yaml:\"vote_threshold\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string reward_band = 3 [
(gogoproto.moretags) = "yaml:\"reward_band\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 reward_distribution_window = 4 [(gogoproto.moretags) = "yaml:\"reward_distribution_window\""];
repeated Pair whitelist = 5 [
(gogoproto.moretags) = "yaml:\"whitelist\"",
(gogoproto.castrepeated) = "PairList",
(gogoproto.nullable) = false
];
string slash_fraction = 6 [
(gogoproto.moretags) = "yaml:\"slash_fraction\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 slash_window = 7 [(gogoproto.moretags) = "yaml:\"slash_window\""];
string min_valid_per_window = 8 [
(gogoproto.moretags) = "yaml:\"min_valid_per_window\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// Pair is the object that holds configuration of each pair.
message Pair {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string name = 1 [(gogoproto.moretags) = "yaml:\"name\""];
string tobin_tax = 2 [
(gogoproto.moretags) = "yaml:\"tobin_tax\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// struct for aggregate prevoting on the ExchangeRateVote.
// The purpose of aggregate prevote is to hide vote exchange rates with hash
// which is formatted as hex string in SHA256("{salt}:({pair},{exchange_rate})|...,({pair},{exchange_rate}):{voter}")
message AggregateExchangeRatePrevote {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string hash = 1 [(gogoproto.moretags) = "yaml:\"hash\""];
string voter = 2 [(gogoproto.moretags) = "yaml:\"voter\""];
uint64 submit_block = 3 [(gogoproto.moretags) = "yaml:\"submit_block\""];
}

// MsgAggregateExchangeRateVote - struct for voting on
// the exchange rates different assets.
message AggregateExchangeRateVote {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

repeated ExchangeRateTuple exchange_rate_tuples = 1 [
(gogoproto.moretags) = "yaml:\"exchange_rate_tuples\"",
(gogoproto.castrepeated) = "ExchangeRateTuples",
(gogoproto.nullable) = false
];

string voter = 2 [(gogoproto.moretags) = "yaml:\"voter\""];
}

// ExchangeRateTuple - struct to store interpreted exchange rates data to store
message ExchangeRateTuple {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string pair = 1 [(gogoproto.moretags) = "yaml:\"pair\""];
string exchange_rate = 2 [
(gogoproto.moretags) = "yaml:\"exchange_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming denom to pair

(gogoproto.nullable) = false
];
}
Loading