Skip to content

Commit

Permalink
Merge pull request DongCoNY#58 from onomyprotocol/dong/app-v1
Browse files Browse the repository at this point in the history
[Feat Update] Update oracle module
  • Loading branch information
hieuvubk authored Oct 31, 2024
2 parents 113acb2 + fbb6ea3 commit e27b6b0
Show file tree
Hide file tree
Showing 67 changed files with 6,587 additions and 3,374 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
.DS_Store
node_modules
6 changes: 4 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,11 @@ func NewAppKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[oracletypes.StoreKey]),
logger,
appKeepers.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.GetIBCKeeper,
appKeepers.GetScopedKeeper,
appKeepers.IBCKeeper.ChannelKeeper,
appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedOracleKeeper,
)

appKeepers.PSMKeeper = psmkeeper.NewKeeper(
Expand Down
14 changes: 8 additions & 6 deletions proto/reserve/oracle/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/onomyprotocol/reserve/x/oracle/types";

message EventBandAckSuccess {
string ack_result = 1;
int64 client_id = 2;
}
string ack_result = 1;
int64 client_id = 2;
}

message EventBandAckError {
string ack_error = 1;
int64 client_id = 2;
string ack_error = 1;
int64 client_id = 2;
}

message EventBandResponseTimeout { int64 client_id = 1; }
message EventBandResponseTimeout {
int64 client_id = 1;
}

message SetBandPriceEvent {
string relayer = 1;
Expand Down
44 changes: 43 additions & 1 deletion proto/reserve/oracle/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "reserve/oracle/params.proto";
import "cosmos/base/v1beta1/coin.proto";
import "reserve/oracle/proposal.proto";

option go_package = "github.com/onomyprotocol/reserve/x/oracle/types";

Expand Down Expand Up @@ -74,3 +73,46 @@ message CalldataRecord {
uint64 client_id = 1;
bytes calldata = 2;
}

message BandParams {
// block request interval to send Band IBC prices
int64 ibc_request_interval = 1;
// band IBC source channel
string ibc_source_channel = 2;
// band IBC version
string ibc_version = 3;
// band IBC portID
string ibc_port_id = 4;
// legacy oracle scheme ids
repeated int64 legacy_oracle_ids = 5;
}

message BandOracleRequest {
// Unique Identifier for band ibc oracle request
uint64 request_id = 1;
// OracleScriptID is the unique identifier of the oracle script to be
// executed.
int64 oracle_script_id = 2;
// Symbols is the list of symbols to prepare in the calldata
repeated string symbols = 3;
// AskCount is the number of validators that are requested to respond to this
// oracle request. Higher value means more security, at a higher gas cost.
uint64 ask_count = 4;
// MinCount is the minimum number of validators necessary for the request to
// proceed to the execution phase. Higher value means more security, at the
// cost of liveness.
uint64 min_count = 5;
// FeeLimit is the maximum tokens that will be paid to all data source
// providers.
repeated cosmos.base.v1beta1.Coin fee_limit = 6 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// PrepareGas is amount of gas to pay to prepare raw requests
uint64 prepare_gas = 7;
// ExecuteGas is amount of gas to reserve for executing
uint64 execute_gas = 8;
// MinSourceCount is the minimum number of data sources that must be used by
// each validator
uint64 min_source_count = 9;
}
89 changes: 0 additions & 89 deletions proto/reserve/oracle/proposal.proto

This file was deleted.

70 changes: 70 additions & 0 deletions proto/reserve/oracle/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ service Query {
option (google.api.http).get =
"/reserve/oracle/band_price_states";
}
// Retrieves the price of base/quote
rpc Price(QueryPriceRequest)
returns (QueryPriceResponse) {
option (google.api.http).get =
"/reserve/oracle/price";
}
// Retrieves the band paraparametersms
rpc BandParams(QueryBandParamsRequest)
returns (QueryBandParamsResponse) {
option (google.api.http).get =
"/reserve/oracle/band_params";
}
// Retrieves the band oracle request parameters
rpc BandOracleRequestParams(QueryBandOracleRequestParamsRequest)
returns (QueryBandOracleRequestParamsResponse) {
option (google.api.http).get =
"/reserve/oracle/band_oracle_request_params";
}
// Retrieves the band oracle request parameters
rpc BandOracleRequest(QueryBandOracleRequestRequest)
returns (QueryBandOracleRequestResponse) {
option (google.api.http).get =
"/reserve/oracle/band_oracle_request";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand All @@ -42,3 +66,49 @@ message QueryBandPriceStatesRequest {}
message QueryBandPriceStatesResponse {
repeated BandPriceState price_states = 1;
}

// QueryPriceRequest is the request type for the
// Query/Price RPC method.
message QueryPriceRequest {
string base_denom = 1;

string quote_denom = 2;
}

// QueryPriceResponse is the response type for the
// Query/Price RPC method
message QueryPriceResponse {
string price = 1;
}

// QueryBandParamsRequest is the request type for the
// Query/BandParams RPC method.
message QueryBandParamsRequest {}

// QueryBandParamsResponse is the response type for the
// Query/BandParams RPC method.
message QueryBandParamsResponse {
BandParams band_params = 1;
}

// QueryBandOracleRequestParamsRequest is the request type for the
// Query/BandOracleRequestParams RPC method.
message QueryBandOracleRequestParamsRequest {}

// QueryBandOracleRequestParamsResponse is the response type for the
// Query/BandOracleRequestParams RPC method.
message QueryBandOracleRequestParamsResponse {
BandOracleRequestParams band_oracle_request_params = 1;
}

// QueryBandOracleRequestRequest is the request type for the
// Query/QueryBandOracleRequest RPC method.
message QueryBandOracleRequestRequest {
string request_id = 1;
}

// QueryBandOracleRequestResponse is the response type for the
// Query/QueryBandOracleRequest RPC method.
message QueryBandOracleRequestResponse {
BandOracleRequest band_oracle_request = 1;
}
70 changes: 69 additions & 1 deletion proto/reserve/oracle/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "reserve/oracle/params.proto";
import "reserve/oracle/genesis.proto";

option go_package = "github.com/onomyprotocol/reserve/x/oracle/types";

Expand All @@ -18,12 +19,20 @@ service Msg {
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

rpc RequestBandRates(MsgRequestBandRates) returns (MsgRequestBandRatesResponse);

rpc UpdateBandParams(MsgUpdateBandParams) returns (MsgUpdateBandParamsResponse);

rpc UpdateBandOracleRequest(MsgUpdateBandOracleRequestRequest) returns (MsgUpdateBandOracleRequestResponse);

rpc DeleteBandOracleRequests(MsgDeleteBandOracleRequests) returns (MsgDeleteBandOracleRequestsResponse);

rpc UpdateBandOracleRequestParams(MsgUpdateBandOracleRequestParamsRequest) returns (MsgUpdateBandOracleRequestParamsResponse);
}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "reserve/x/oracle/MsgUpdateParams";
option (amino.name) = "oracle/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
Expand Down Expand Up @@ -54,3 +63,62 @@ message MsgRequestBandRates {

// MsgRequestBandRatesResponse defines the Msg/RequestBandRates response type.
message MsgRequestBandRatesResponse {}

// MsgUpdateBandParams define defines a SDK message for update band parameters
message MsgUpdateBandParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "oracle/UpdateBandParams";
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
BandParams band_params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateBandParamsResponse define the Msg/UpdateBandParams response type.
message MsgUpdateBandParamsResponse {}

// MsgUpdateBandOracleRequestRequest define defines a SDK message for update band oracle requests
message MsgUpdateBandOracleRequestRequest{
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "oracle/UpdateBandOracleRequest";
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

BandOracleRequest update_oracle_request = 2;
}

// MsgUpdateBandOracleRequestResponse define the Msg/MsgUpdateBandOracleRequest response type.
message MsgUpdateBandOracleRequestResponse {}

// MsgDeleteBandOracleRequests define defines a SDK message for delete band oracle requests
message MsgDeleteBandOracleRequests{
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "oracle/UpdateBandOracleRequest";
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

repeated uint64 delete_request_ids = 2;
}

// MsgDeleteBandOracleRequestsResponse define the Msg/MsgDeleteBandOracleRequests response type.
message MsgDeleteBandOracleRequestsResponse {}

// MsgUpdateBandOracleRequestParamsRequest define defines a SDK message for update band oracle request parameters
message MsgUpdateBandOracleRequestParamsRequest {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "oracle/UpdateBandOracleRequestParams";
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

BandOracleRequestParams update_band_oracle_request_params = 2;
}

// MsgUpdateBandOracleRequestParamsResponse define the Msg/UpdateBandOracleRequestParams response type.
message MsgUpdateBandOracleRequestParamsResponse {}
24 changes: 24 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set -xeu
MNE1="amused rural desk trick safe whip first menu worth swap enhance punch spin figure elevator abandon camera idea peace nurse coyote adjust modify produce"

# init
rm -rf .onomy
reserved init asd --chain-id local_onomy-1 --home .onomy -o

# provider and consumer keys
echo $MNE1 | reserved keys add god --recover --keyring-backend test --home .onomy

# provider validator
reserved genesis add-genesis-account god 1000000000000000000000000000anom --keyring-backend test --home .onomy
reserved genesis gentx god 1000000000000000000000000anom --keyring-backend test --home .onomy --chain-id local_onomy-1
reserved genesis collect-gentxs --home .onomy

# provider genesis
cat .onomy/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="100"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["gov"]["voting_params"]["voting_period"]="6s"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["amount"]="100"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="anom"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="anom"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="anom"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="anom"' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
cat .onomy/config/genesis.json | jq '.app_state["oracle"]["band_oracle_requests"]+=[{"request_id":1,"oracle_script_id":360,"symbols":["BTC","ETH","BAND","USDT"],"ask_count":4,"min_count":3,"prepare_gas":100000,"execute_gas":500000,"fee_limit":[{"denom":"uband","amount":"250000"}]}]' > .onomy/config/tmp_genesis.json && mv .onomy/config/tmp_genesis.json .onomy/config/genesis.json
Loading

0 comments on commit e27b6b0

Please sign in to comment.