diff --git a/proto/panacea/oracle/v2/oracle.proto b/proto/panacea/oracle/v2/oracle.proto index 3f540d84..41b5a769 100644 --- a/proto/panacea/oracle/v2/oracle.proto +++ b/proto/panacea/oracle/v2/oracle.proto @@ -4,13 +4,17 @@ package panacea.oracle.v2; option go_package = "github.com/medibloc/panacea-core/x/oracle/types"; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; // Oracle defines a detail of oracle. message Oracle { string oracle_address = 1; string unique_id = 2; string endpoint = 3; - string oracle_commission_rate = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + google.protobuf.Timestamp update_time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + string oracle_commission_rate = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_max_rate = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_max_change_rate = 7 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } // OracleRegistration defines the detailed states of the registration of oracle. @@ -28,5 +32,7 @@ message OracleRegistration { bytes trusted_block_hash = 6; string endpoint = 7; string oracle_commission_rate = 8 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - bytes encrypted_oracle_priv_key = 9; + string oracle_commission_max_rate = 9 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_max_change_rate = 10 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + bytes encrypted_oracle_priv_key = 11; } \ No newline at end of file diff --git a/proto/panacea/oracle/v2/tx.proto b/proto/panacea/oracle/v2/tx.proto index 939058ae..b8bbe4d9 100644 --- a/proto/panacea/oracle/v2/tx.proto +++ b/proto/panacea/oracle/v2/tx.proto @@ -32,6 +32,8 @@ message MsgRegisterOracle { bytes trusted_block_hash = 6; string endpoint = 7; string oracle_commission_rate = 8 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_max_rate = 9 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_max_change_rate = 10 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } // MsgRegisterOracleResponse defines the Msg/RegisterOracle response type. @@ -60,7 +62,7 @@ message MsgApproveOracleRegistrationResponse { message MsgUpdateOracleInfo { string oracle_address = 1; // panacea1.. account address string endpoint = 2; - string oracle_commission_rate = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string oracle_commission_rate = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",(gogoproto.nullable) = true]; } // MsgUpdateOracleInfoResponse defines the Msg/UpdateOracleInfo diff --git a/x/oracle/client/cli/tx.go b/x/oracle/client/cli/tx.go index 0c16d834..b74b4ec7 100644 --- a/x/oracle/client/cli/tx.go +++ b/x/oracle/client/cli/tx.go @@ -8,6 +8,18 @@ import ( "github.com/spf13/cobra" ) +const ( + flagOracleUniqueID = "oracle-unique-id" + flagNodePublicKey = "node-public-key" + flagNodePubKeyRemoteReport = "node-public-key-remote-report" + flagTrustedBlockHeight = "trusted-block-height" + flagTrustedBlockHash = "trusted-block-hash" + flagOracleEndpoint = "oracle-endpoint" + flagOracleCommRate = "oracle-commission-rate" + flagOracleCommMaxRate = "oracle-commission-max-rate" + flagOracleCommMaxChangeRate = "oracle-commission-max-change-rate" +) + // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ @@ -19,6 +31,7 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(CmdRegisterOracle()) + cmd.AddCommand(CmdUpdateOracleInfo()) return cmd } diff --git a/x/oracle/client/cli/txRegisterOracle.go b/x/oracle/client/cli/txRegisterOracle.go index 8723036a..d29c41b8 100644 --- a/x/oracle/client/cli/txRegisterOracle.go +++ b/x/oracle/client/cli/txRegisterOracle.go @@ -16,9 +16,8 @@ import ( func CmdRegisterOracle() *cobra.Command { cmd := &cobra.Command{ - Use: "register-oracle [unique ID] [node public key] [node public key remote report] [trusted block height] [trusted block hash] [endpoint] [oracle's commission rate]", + Use: "register-oracle", Short: "Register a new oracle", - Args: cobra.ExactArgs(7), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -26,32 +25,60 @@ func CmdRegisterOracle() *cobra.Command { } oracleAddress := clientCtx.GetFromAddress().String() - nodePubKey, err := base64.StdEncoding.DecodeString(args[1]) + + uniqueID, err := cmd.Flags().GetString(flagOracleUniqueID) if err != nil { - return err + return fmt.Errorf("failed to get oracle unique ID") + } + + nodePubkeyStr, err := cmd.Flags().GetString(flagNodePublicKey) + if err != nil { + return fmt.Errorf("failed to get node public key") } - nodePubKeyRemoteReport, err := base64.StdEncoding.DecodeString(args[2]) + nodePubKey, err := base64.StdEncoding.DecodeString(nodePubkeyStr) if err != nil { return err } - trustedBlockHeight, err := strconv.ParseInt(args[3], 10, 64) + nodePubkeyRemoteReportStr, err := cmd.Flags().GetString(flagNodePubKeyRemoteReport) + if err != nil { + return fmt.Errorf("failed to get node public key remote report") + } + + nodePubKeyRemoteReport, err := base64.StdEncoding.DecodeString(nodePubkeyRemoteReportStr) if err != nil { return err } - trustedBlockHash, err := hex.DecodeString(args[4]) + trustedBlockHeightStr, err := cmd.Flags().GetString(flagTrustedBlockHeight) + if err != nil { + return fmt.Errorf("failed to get trsuted block height") + } + + trustedBlockHeight, err := strconv.ParseInt(trustedBlockHeightStr, 10, 64) if err != nil { return err } - endpoint := args[5] + trustedBlockHashStr, err := cmd.Flags().GetString(flagTrustedBlockHash) + if err != nil { + return fmt.Errorf("failed to get trsuted block hash") + } - oracleCommissionRateStr := args[6] + trustedBlockHash, err := hex.DecodeString(trustedBlockHashStr) + if err != nil { + return err + } - if len(oracleCommissionRateStr) == 0 { - return fmt.Errorf("oracleCommissionRate is empty") + endpoint, err := cmd.Flags().GetString(flagOracleEndpoint) + if err != nil { + return fmt.Errorf("failed to get oralce end point") + } + + oracleCommissionRateStr, err := cmd.Flags().GetString(flagOracleCommRate) + if err != nil { + return fmt.Errorf("failed to get oralce commission rate") } oracleCommissionRate, err := sdk.NewDecFromStr(oracleCommissionRateStr) @@ -59,8 +86,28 @@ func CmdRegisterOracle() *cobra.Command { return err } + oracleCommissionMaxRateStr, err := cmd.Flags().GetString(flagOracleCommMaxRate) + if err != nil { + return fmt.Errorf("failed to get oralce commission max rate") + } + + oracleCommissionMaxRate, err := sdk.NewDecFromStr(oracleCommissionMaxRateStr) + if err != nil { + return err + } + + oracleCommissionMaxChangeRateStr, err := cmd.Flags().GetString(flagOracleCommMaxChangeRate) + if err != nil { + return fmt.Errorf("failed to get oralce commission max change rate") + } + + oracleCommissionMaxChangeRate, err := sdk.NewDecFromStr(oracleCommissionMaxChangeRateStr) + if err != nil { + return err + } + msg := types.NewMsgRegisterOracle( - args[0], + uniqueID, oracleAddress, nodePubKey, nodePubKeyRemoteReport, @@ -68,6 +115,8 @@ func CmdRegisterOracle() *cobra.Command { trustedBlockHash, endpoint, oracleCommissionRate, + oracleCommissionMaxRate, + oracleCommissionMaxChangeRate, ) if err := msg.ValidateBasic(); err != nil { return err @@ -77,6 +126,41 @@ func CmdRegisterOracle() *cobra.Command { }, } + cmd.Flags().String(flagOracleUniqueID, "", "unique ID for oracle") + cmd.Flags().String(flagNodePublicKey, "", "node public key for oracle") + cmd.Flags().String(flagNodePubKeyRemoteReport, "", "node public key remote report for oracle") + cmd.Flags().String(flagTrustedBlockHeight, "", "trusted block height of panacea trusted block") + cmd.Flags().String(flagTrustedBlockHash, "", "trusted block hash of panacea trusted block") + cmd.Flags().String(flagOracleEndpoint, "", "oracle's endpoint") + cmd.Flags().String(flagOracleCommRate, "", "oracle's commission rate") + cmd.Flags().String(flagOracleCommMaxRate, "", "oracle's commission max rate") + cmd.Flags().String(flagOracleCommMaxChangeRate, "", "oracle's commission max change rate") + + if err := cmd.MarkFlagRequired(flagOracleUniqueID); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagNodePublicKey); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagNodePubKeyRemoteReport); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagTrustedBlockHeight); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagTrustedBlockHash); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagOracleCommRate); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagOracleCommMaxRate); err != nil { + panic(err) + } + if err := cmd.MarkFlagRequired(flagOracleCommMaxChangeRate); err != nil { + panic(err) + } + flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/oracle/client/cli/txUpdateOracleInfo.go b/x/oracle/client/cli/txUpdateOracleInfo.go new file mode 100644 index 00000000..c37b7312 --- /dev/null +++ b/x/oracle/client/cli/txUpdateOracleInfo.go @@ -0,0 +1,62 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/medibloc/panacea-core/v2/x/oracle/types" + "github.com/spf13/cobra" +) + +func CmdUpdateOracleInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-oracle-info", + Short: "update an oracle information", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + oracleAddress := clientCtx.GetFromAddress().String() + + endpoint, err := cmd.Flags().GetString(flagOracleEndpoint) + if err != nil { + return fmt.Errorf("failed to get oracle end point") + } + + oracleCommissionRateStr, err := cmd.Flags().GetString(flagOracleCommRate) + if err != nil { + return fmt.Errorf("failed to get oralce commission rate") + } + var oracleCommissionRate *sdk.Dec + + if len(oracleCommissionRateStr) != 0 { + commissionRate, err := sdk.NewDecFromStr(oracleCommissionRateStr) + if err != nil { + return err + } + oracleCommissionRate = &commissionRate + } else { + oracleCommissionRate = nil + } + + msg := types.NewMsgUpdateOracleInfo(oracleAddress, endpoint, oracleCommissionRate) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagOracleEndpoint, "", "oracle's endpoint") + cmd.Flags().String(flagOracleCommRate, "", "oracle's commission rate") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/oracle/genesis_test.go b/x/oracle/genesis_test.go index 5c1f363a..cb717636 100644 --- a/x/oracle/genesis_test.go +++ b/x/oracle/genesis_test.go @@ -2,6 +2,7 @@ package oracle_test import ( "testing" + "time" "github.com/btcsuite/btcd/btcec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -59,34 +60,44 @@ func (suite *genesisTestSuite) TestInitGenesis() { suite.uniqueID, suite.endpoint, sdk.NewDecWithPrec(1, 1), + sdk.NewDecWithPrec(2, 1), + sdk.NewDecWithPrec(1, 2), + time.Unix(0, 0).UTC(), ), *types.NewOracle( suite.oracle2AccAddr.String(), suite.uniqueID, suite.endpoint, + sdk.NewDecWithPrec(1, 1), + sdk.NewDecWithPrec(2, 1), sdk.NewDecWithPrec(1, 2), + time.Unix(0, 0).UTC(), ), }, OracleRegistrations: []types.OracleRegistration{ { - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), - TrustedBlockHeight: 10, - TrustedBlockHash: nil, - Endpoint: suite.endpoint, - OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), + TrustedBlockHeight: 10, + TrustedBlockHash: nil, + Endpoint: suite.endpoint, + OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + OracleCommissionMaxRate: sdk.NewDecWithPrec(2, 1), + OracleCommissionMaxChangeRate: sdk.NewDecWithPrec(1, 2), }, { - UniqueId: suite.uniqueID, - OracleAddress: suite.oracle2AccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), - TrustedBlockHeight: 10, - TrustedBlockHash: nil, - Endpoint: suite.endpoint, - OracleCommissionRate: sdk.NewDecWithPrec(1, 2), + UniqueId: suite.uniqueID, + OracleAddress: suite.oracle2AccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), + TrustedBlockHeight: 10, + TrustedBlockHash: nil, + Endpoint: suite.endpoint, + OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + OracleCommissionMaxRate: sdk.NewDecWithPrec(2, 1), + OracleCommissionMaxChangeRate: sdk.NewDecWithPrec(1, 2), }, }, Params: types.DefaultParams(), @@ -111,23 +122,28 @@ func (suite *genesisTestSuite) TestInitGenesis() { func (suite *genesisTestSuite) TestExportGenesis() { ora := &types.Oracle{ - OracleAddress: suite.oracleAccAddr.String(), - UniqueId: suite.uniqueID, - Endpoint: suite.endpoint, - OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + OracleAddress: suite.oracleAccAddr.String(), + UniqueId: suite.uniqueID, + Endpoint: suite.endpoint, + UpdateTime: time.Unix(0, 0).UTC(), + OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + OracleCommissionMaxRate: sdk.NewDecWithPrec(2, 1), + OracleCommissionMaxChangeRate: sdk.NewDecWithPrec(1, 2), } err := suite.OracleKeeper.SetOracle(suite.Ctx, ora) suite.Require().NoError(err) oraRegistration := &types.OracleRegistration{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), - TrustedBlockHeight: 10, - TrustedBlockHash: nil, - Endpoint: suite.endpoint, - OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), + TrustedBlockHeight: 10, + TrustedBlockHash: nil, + Endpoint: suite.endpoint, + OracleCommissionRate: sdk.NewDecWithPrec(1, 1), + OracleCommissionMaxRate: sdk.NewDecWithPrec(2, 1), + OracleCommissionMaxChangeRate: sdk.NewDecWithPrec(1, 2), } err = suite.OracleKeeper.SetOracleRegistration(suite.Ctx, oraRegistration) suite.Require().NoError(err) diff --git a/x/oracle/handler.go b/x/oracle/handler.go index 466436dc..bc465962 100644 --- a/x/oracle/handler.go +++ b/x/oracle/handler.go @@ -23,9 +23,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgApproveOracleRegistration: res, err := msgServer.ApproveOracleRegistration(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - //case *types.MsgUpdateOracleInfo: - // res, err := msgServer.UpdateOracleInfo(sdk.WrapSDKContext(ctx), msg) - // return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUpdateOracleInfo: + res, err := msgServer.UpdateOracleInfo(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/oracle/keeper/grpc_query_oracle_test.go b/x/oracle/keeper/grpc_query_oracle_test.go index 762f902a..c3061281 100644 --- a/x/oracle/keeper/grpc_query_oracle_test.go +++ b/x/oracle/keeper/grpc_query_oracle_test.go @@ -18,17 +18,21 @@ type queryOracleTestSuite struct { uniqueID string - oracleAccPrivKey cryptotypes.PrivKey - oracleAccPubKey cryptotypes.PubKey - oracleAccAddr sdk.AccAddress - oracleEndpoint string - oracleCommissionRate sdk.Dec - - oracle2AccPrivKey cryptotypes.PrivKey - oracle2AccPubKey cryptotypes.PubKey - oracle2AccAddr sdk.AccAddress - oracle2Endpoint string - oracle2CommissionRate sdk.Dec + oracleAccPrivKey cryptotypes.PrivKey + oracleAccPubKey cryptotypes.PubKey + oracleAccAddr sdk.AccAddress + oracleEndpoint string + oracleCommissionRate sdk.Dec + oracleCommissionMaxRate sdk.Dec + oracleCommissionMaxChangeRate sdk.Dec + + oracle2AccPrivKey cryptotypes.PrivKey + oracle2AccPubKey cryptotypes.PubKey + oracle2AccAddr sdk.AccAddress + oracle2Endpoint string + oracle2CommissionRate sdk.Dec + oracle2CommissionMaxRate sdk.Dec + oracle2CommissionMaxChangeRate sdk.Dec nodePrivKey *btcec.PrivateKey nodePubKey *btcec.PublicKey @@ -45,13 +49,17 @@ func (suite *queryOracleTestSuite) BeforeTest(_, _ string) { suite.oracleAccPubKey = suite.oracleAccPrivKey.PubKey() suite.oracleAccAddr = sdk.AccAddress(suite.oracleAccPubKey.Address()) suite.oracleEndpoint = "https://my-validator.org" - suite.oracleCommissionRate = sdk.NewDecWithPrec(1, 1) + suite.oracleCommissionRate = sdk.NewDecWithPrec(1, 1) // 0.1 + suite.oracleCommissionMaxRate = sdk.NewDecWithPrec(2, 1) // 0.2 + suite.oracleCommissionMaxChangeRate = sdk.NewDecWithPrec(1, 2) // 0.01 suite.oracle2AccPrivKey = secp256k1.GenPrivKey() suite.oracle2AccPubKey = suite.oracle2AccPrivKey.PubKey() suite.oracle2AccAddr = sdk.AccAddress(suite.oracle2AccPubKey.Address()) suite.oracle2Endpoint = "https://my-validator2.org" - suite.oracle2CommissionRate = sdk.NewDecWithPrec(1, 2) + suite.oracle2CommissionRate = sdk.NewDecWithPrec(1, 1) // 0.1 + suite.oracle2CommissionMaxRate = sdk.NewDecWithPrec(3, 1) // 0.3 + suite.oracle2CommissionMaxChangeRate = sdk.NewDecWithPrec(2, 2) // 0.02 suite.nodePrivKey, _ = btcec.NewPrivateKey(btcec.S256()) suite.nodePubKey = suite.nodePrivKey.PubKey() @@ -61,11 +69,11 @@ func (suite *queryOracleTestSuite) TestOracles() { ctx := suite.Ctx oracleKeeper := suite.OracleKeeper - oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.oracleEndpoint, suite.oracleCommissionRate) + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.oracleEndpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) err := oracleKeeper.SetOracle(ctx, oracle) suite.Require().NoError(err) - oracle2 := types.NewOracle(suite.oracle2AccAddr.String(), suite.uniqueID, suite.oracle2Endpoint, suite.oracle2CommissionRate) + oracle2 := types.NewOracle(suite.oracle2AccAddr.String(), suite.uniqueID, suite.oracle2Endpoint, suite.oracle2CommissionRate, suite.oracle2CommissionMaxRate, suite.oracle2CommissionMaxChangeRate, ctx.BlockTime()) err = oracleKeeper.SetOracle(ctx, oracle2) suite.Require().NoError(err) @@ -81,11 +89,17 @@ func (suite *queryOracleTestSuite) TestOracles() { case suite.oracleAccAddr.String(): suite.Require().Equal(suite.uniqueID, oracle.UniqueId) suite.Require().Equal(suite.oracleEndpoint, oracle.Endpoint) + suite.Require().Equal(ctx.BlockTime(), oracle.UpdateTime) suite.Require().Equal(suite.oracleCommissionRate, oracle.OracleCommissionRate) + suite.Require().Equal(suite.oracleCommissionMaxRate, oracle.OracleCommissionMaxRate) + suite.Require().Equal(suite.oracleCommissionMaxChangeRate, oracle.OracleCommissionMaxChangeRate) case suite.oracle2AccAddr.String(): suite.Require().Equal(suite.uniqueID, oracle.UniqueId) suite.Require().Equal(suite.oracle2Endpoint, oracle.Endpoint) + suite.Require().Equal(ctx.BlockTime(), oracle.UpdateTime) suite.Require().Equal(suite.oracle2CommissionRate, oracle.OracleCommissionRate) + suite.Require().Equal(suite.oracle2CommissionMaxRate, oracle.OracleCommissionMaxRate) + suite.Require().Equal(suite.oracle2CommissionMaxChangeRate, oracle.OracleCommissionMaxChangeRate) default: panic("not found oracle address. address: " + oracle.OracleAddress) } @@ -96,7 +110,7 @@ func (suite *queryOracleTestSuite) TestOracle() { ctx := suite.Ctx oracleKeeper := suite.OracleKeeper - oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.oracleEndpoint, suite.oracleCommissionRate) + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.oracleEndpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) err := oracleKeeper.SetOracle(ctx, oracle) suite.Require().NoError(err) @@ -116,39 +130,45 @@ func (suite *queryOracleTestSuite) TestOracleRegistrations() { trustedBlockHash := []byte("hash") oracleRegistration := &types.OracleRegistration{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: remoteReport, - TrustedBlockHeight: 10, - TrustedBlockHash: trustedBlockHash, - Endpoint: suite.oracleEndpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: remoteReport, + TrustedBlockHeight: 10, + TrustedBlockHash: trustedBlockHash, + Endpoint: suite.oracleEndpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, EncryptedOraclePrivKey: nil, } oracleRegistration2 := &types.OracleRegistration{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracle2AccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: remoteReport, - TrustedBlockHeight: 10, - TrustedBlockHash: trustedBlockHash, - Endpoint: suite.oracle2Endpoint, - OracleCommissionRate: suite.oracle2CommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracle2AccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: remoteReport, + TrustedBlockHeight: 10, + TrustedBlockHash: trustedBlockHash, + Endpoint: suite.oracle2Endpoint, + OracleCommissionRate: suite.oracle2CommissionRate, + OracleCommissionMaxRate: suite.oracle2CommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracle2CommissionMaxChangeRate, EncryptedOraclePrivKey: nil, } anotherUniqueID := "uniqueID2" oracleRegistration3 := &types.OracleRegistration{ - UniqueId: anotherUniqueID, - OracleAddress: suite.oracle2AccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: remoteReport, - TrustedBlockHeight: 10, - TrustedBlockHash: trustedBlockHash, - Endpoint: suite.oracle2Endpoint, - OracleCommissionRate: suite.oracle2CommissionRate, + UniqueId: anotherUniqueID, + OracleAddress: suite.oracle2AccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: remoteReport, + TrustedBlockHeight: 10, + TrustedBlockHash: trustedBlockHash, + Endpoint: suite.oracle2Endpoint, + OracleCommissionRate: suite.oracle2CommissionRate, + OracleCommissionMaxRate: suite.oracle2CommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracle2CommissionMaxChangeRate, EncryptedOraclePrivKey: nil, } @@ -176,6 +196,8 @@ func (suite *queryOracleTestSuite) TestOracleRegistrations() { suite.Require().Equal(trustedBlockHash, oracleRegistration.TrustedBlockHash) suite.Require().Equal(suite.oracleEndpoint, oracleRegistration.Endpoint) suite.Require().Equal(suite.oracleCommissionRate, oracleRegistration.OracleCommissionRate) + suite.Require().Equal(suite.oracleCommissionMaxRate, oracleRegistration.OracleCommissionMaxRate) + suite.Require().Equal(suite.oracleCommissionMaxChangeRate, oracleRegistration.OracleCommissionMaxChangeRate) case suite.oracle2AccAddr.String(): suite.Require().Equal(suite.uniqueID, oracleRegistration.UniqueId) suite.Require().Equal(suite.nodePubKey.SerializeCompressed(), oracleRegistration.NodePubKey) @@ -184,6 +206,8 @@ func (suite *queryOracleTestSuite) TestOracleRegistrations() { suite.Require().Equal(trustedBlockHash, oracleRegistration.TrustedBlockHash) suite.Require().Equal(suite.oracle2Endpoint, oracleRegistration.Endpoint) suite.Require().Equal(suite.oracle2CommissionRate, oracleRegistration.OracleCommissionRate) + suite.Require().Equal(suite.oracle2CommissionMaxRate, oracleRegistration.OracleCommissionMaxRate) + suite.Require().Equal(suite.oracle2CommissionMaxChangeRate, oracleRegistration.OracleCommissionMaxChangeRate) default: panic("not found oracle address. address: " + oracleRegistration.OracleAddress) } @@ -202,6 +226,8 @@ func (suite *queryOracleTestSuite) TestOracleRegistrations() { suite.Require().Equal(trustedBlockHash, res.OracleRegistrations[0].TrustedBlockHash) suite.Require().Equal(suite.oracle2Endpoint, res.OracleRegistrations[0].Endpoint) suite.Require().Equal(suite.oracle2CommissionRate, res.OracleRegistrations[0].OracleCommissionRate) + suite.Require().Equal(suite.oracle2CommissionMaxRate, res.OracleRegistrations[0].OracleCommissionMaxRate) + suite.Require().Equal(suite.oracle2CommissionMaxChangeRate, res.OracleRegistrations[0].OracleCommissionMaxChangeRate) } func (suite *queryOracleTestSuite) TestOracleRegistration() { @@ -209,14 +235,16 @@ func (suite *queryOracleTestSuite) TestOracleRegistration() { oracleKeeper := suite.OracleKeeper oracleRegistration := &types.OracleRegistration{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), - TrustedBlockHeight: 10, - TrustedBlockHash: []byte("hash"), - Endpoint: suite.oracleEndpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: []byte("nodePubKeyRemoteReport"), + TrustedBlockHeight: 10, + TrustedBlockHash: []byte("hash"), + Endpoint: suite.oracleEndpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, EncryptedOraclePrivKey: nil, } err := oracleKeeper.SetOracleRegistration(ctx, oracleRegistration) diff --git a/x/oracle/keeper/msg_server_oracle.go b/x/oracle/keeper/msg_server_oracle.go index e6a1102c..bf422e0e 100644 --- a/x/oracle/keeper/msg_server_oracle.go +++ b/x/oracle/keeper/msg_server_oracle.go @@ -42,7 +42,19 @@ func (m msgServer) ApproveOracleRegistration(goCtx context.Context, msg *types.M return &types.MsgApproveOracleRegistrationResponse{}, nil } -func (m msgServer) UpdateOracleInfo(ctx context.Context, info *types.MsgUpdateOracleInfo) (*types.MsgUpdateOracleInfoResponse, error) { - //TODO implement me - panic("implement me") +func (m msgServer) UpdateOracleInfo(goCtx context.Context, msg *types.MsgUpdateOracleInfo) (*types.MsgUpdateOracleInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := m.Keeper.UpdateOracleInfo(ctx, msg); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + ) + + return &types.MsgUpdateOracleInfoResponse{}, nil } diff --git a/x/oracle/keeper/oracle.go b/x/oracle/keeper/oracle.go index 827cfcd9..27678663 100644 --- a/x/oracle/keeper/oracle.go +++ b/x/oracle/keeper/oracle.go @@ -66,6 +66,9 @@ func (k Keeper) ApproveOracleRegistration(ctx sdk.Context, msg *types.MsgApprove msg.ApproveOracleRegistration.UniqueId, oracleRegistration.Endpoint, oracleRegistration.OracleCommissionRate, + oracleRegistration.OracleCommissionMaxRate, + oracleRegistration.OracleCommissionMaxChangeRate, + ctx.BlockTime(), ) // append new oracle info @@ -116,6 +119,31 @@ func (k Keeper) validateApproveOracleRegistration(ctx sdk.Context, msg *types.Ms return nil } +func (k Keeper) UpdateOracleInfo(ctx sdk.Context, msg *types.MsgUpdateOracleInfo) error { + oracle, err := k.GetOracle(ctx, msg.OracleAddress) + if err != nil { + return sdkerrors.Wrapf(types.ErrUpdateOracle, err.Error()) + } + + if msg.OracleCommissionRate != nil && !oracle.OracleCommissionRate.Equal(*msg.OracleCommissionRate) { + blockTime := ctx.BlockHeader().Time + if err := oracle.ValidateOracleCommission(blockTime, *msg.OracleCommissionRate); err != nil { + return sdkerrors.Wrapf(types.ErrUpdateOracle, err.Error()) + } + oracle.OracleCommissionRate = *msg.OracleCommissionRate + oracle.UpdateTime = blockTime + } + + if len(msg.Endpoint) > 0 { + oracle.Endpoint = msg.Endpoint + } + + if err := k.SetOracle(ctx, oracle); err != nil { + return sdkerrors.Wrapf(types.ErrUpdateOracle, err.Error()) + } + return nil +} + func (k Keeper) SetOracleRegistration(ctx sdk.Context, regOracle *types.OracleRegistration) error { store := ctx.KVStore(k.storeKey) diff --git a/x/oracle/keeper/oracle_test.go b/x/oracle/keeper/oracle_test.go index bb683ed1..c531958e 100644 --- a/x/oracle/keeper/oracle_test.go +++ b/x/oracle/keeper/oracle_test.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "fmt" "testing" + "time" "github.com/btcsuite/btcd/btcec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -39,8 +40,13 @@ type oracleTestSuite struct { trustedBlockHeight int64 trustedBlockHash []byte - endpoint string - oracleCommissionRate sdk.Dec + endpoint string + oracleCommissionRate sdk.Dec + oracleCommissionMaxRate sdk.Dec + oracleCommissionMaxChangeRate sdk.Dec + + newEndpoint string + newOracleCommissionRate sdk.Dec } func TestOracleTestSuite(t *testing.T) { @@ -70,6 +76,11 @@ func (suite *oracleTestSuite) BeforeTest(_, _ string) { suite.endpoint = "https://my-validator.org" suite.oracleCommissionRate = sdk.NewDecWithPrec(1, 1) + suite.oracleCommissionMaxRate = sdk.NewDecWithPrec(2, 1) + suite.oracleCommissionMaxChangeRate = sdk.NewDecWithPrec(1, 2) + + suite.newEndpoint = "https://my-validator2.org" + suite.newOracleCommissionRate = sdk.NewDecWithPrec(11, 2) suite.OracleKeeper.SetParams(suite.Ctx, types.Params{ OraclePublicKey: base64.StdEncoding.EncodeToString(suite.oraclePubKey.SerializeCompressed()), @@ -82,14 +93,16 @@ func (suite *oracleTestSuite) TestRegisterOracleSuccess() { ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -116,19 +129,23 @@ func (suite *oracleTestSuite) TestRegisterOracleSuccess() { suite.Require().Equal(suite.trustedBlockHash, oracleFromKeeper.TrustedBlockHash) suite.Require().Equal(suite.endpoint, oracleFromKeeper.Endpoint) suite.Require().Equal(suite.oracleCommissionRate, oracleFromKeeper.OracleCommissionRate) + suite.Require().Equal(suite.oracleCommissionMaxRate, oracleFromKeeper.OracleCommissionMaxRate) + suite.Require().Equal(suite.oracleCommissionMaxChangeRate, oracleFromKeeper.OracleCommissionMaxChangeRate) } func (suite *oracleTestSuite) TestRegisterOracleFailedValidateToMsgOracleRegistration() { ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -182,19 +199,21 @@ func (suite *oracleTestSuite) TestRegisterOracleFailedValidateToMsgOracleRegistr func (suite *oracleTestSuite) TestRegisterOracleAlreadyExistOracle() { ctx := suite.Ctx - oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate) + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) err := suite.OracleKeeper.SetOracle(ctx, oracle) suite.Require().NoError(err) msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err = suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -206,14 +225,16 @@ func (suite *oracleTestSuite) TestRegisterOracleNotSameUniqueID() { ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: "wrongUniqueID", - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: "wrongUniqueID", + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -225,14 +246,16 @@ func (suite *oracleTestSuite) TestApproveOracleRegistrationSuccess() { ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -283,14 +306,16 @@ func (suite *oracleTestSuite) TestApproveOracleRegistrationFailedInvalidUniqueID ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -320,14 +345,16 @@ func (suite *oracleTestSuite) TestApproveOracleRegistrationFailedInvalidSignatur ctx := suite.Ctx msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } err := suite.OracleKeeper.RegisterOracle(ctx, msgRegisterOracle) @@ -358,19 +385,21 @@ func (suite *oracleTestSuite) TestApproveOracleRegistrationFailedInvalidSignatur func (suite *oracleTestSuite) TestApproveOracleRegistrationFailedAlreadyExistOracle() { ctx := suite.Ctx - oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate) + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) err := suite.OracleKeeper.SetOracle(ctx, oracle) suite.Require().NoError(err) msgRegisterOracle := &types.MsgRegisterOracle{ - UniqueId: suite.uniqueID, - OracleAddress: suite.oracleAccAddr.String(), - NodePubKey: suite.nodePubKey.SerializeCompressed(), - NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, - TrustedBlockHeight: suite.trustedBlockHeight, - TrustedBlockHash: suite.trustedBlockHash, - Endpoint: suite.endpoint, - OracleCommissionRate: suite.oracleCommissionRate, + UniqueId: suite.uniqueID, + OracleAddress: suite.oracleAccAddr.String(), + NodePubKey: suite.nodePubKey.SerializeCompressed(), + NodePubKeyRemoteReport: suite.nodePubKeyRemoteReport, + TrustedBlockHeight: suite.trustedBlockHeight, + TrustedBlockHash: suite.trustedBlockHash, + Endpoint: suite.endpoint, + OracleCommissionRate: suite.oracleCommissionRate, + OracleCommissionMaxRate: suite.oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: suite.oracleCommissionMaxChangeRate, } oracleRegistration := types.NewOracleRegistration(msgRegisterOracle) @@ -398,3 +427,123 @@ func (suite *oracleTestSuite) TestApproveOracleRegistrationFailedAlreadyExistOra suite.Require().Error(err, types.ErrOracleRegistration) suite.Require().ErrorContains(err, fmt.Sprintf("already registered oracle. address(%s)", msgRegisterOracle.OracleAddress)) } + +func (suite *oracleTestSuite) TestUpdateOracleInfoSuccess() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &suite.newOracleCommissionRate, + } + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Hour)) + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().NoError(err) + + getOracle, err := suite.OracleKeeper.GetOracle(ctx, suite.oracleAccAddr.String()) + suite.Require().NoError(err) + suite.Require().Equal(suite.newEndpoint, getOracle.Endpoint) + suite.Require().Equal(suite.newOracleCommissionRate, getOracle.OracleCommissionRate) + suite.Require().Equal(ctx.BlockTime(), getOracle.UpdateTime) +} + +func (suite *oracleTestSuite) TestUpdateOracleInfoSuccessWithNoCommissionChange() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &suite.oracleCommissionRate, + } + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().NoError(err) + + getOracle, err := suite.OracleKeeper.GetOracle(ctx, suite.oracleAccAddr.String()) + suite.Require().NoError(err) + suite.Require().Equal(suite.newEndpoint, getOracle.Endpoint) + suite.Require().Equal(suite.oracleCommissionRate, getOracle.OracleCommissionRate) + suite.Require().Equal(ctx.BlockTime(), getOracle.UpdateTime) +} + +func (suite *oracleTestSuite) TestUpdateOracleInfoFailedUpdateTime() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &suite.newOracleCommissionRate, + } + + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().Error(err, types.ErrUpdateOracle) + suite.Require().ErrorContains(err, "commission cannot be changed more than once in 24h") +} + +func (suite *oracleTestSuite) TestUpdateOracleInfoFailedGTMaxChangeRate() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + updateCommissionRate := sdk.NewDecWithPrec(12, 2) + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &updateCommissionRate, + } + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Hour)) + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().Error(err, types.ErrUpdateOracle) + suite.Require().ErrorContains(err, "commission cannot be changed more than max change rate") +} + +func (suite *oracleTestSuite) TestUpdateOracleInfoFailedGTMaxRate() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, sdk.NewDecWithPrec(3, 1), ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + updateCommissionRate := sdk.NewDecWithPrec(3, 1) + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &updateCommissionRate, + } + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Hour)) + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().Error(err, types.ErrUpdateOracle) + suite.Require().ErrorContains(err, "commission cannot be more than the max rate") +} + +func (suite *oracleTestSuite) TestUpdateOracleInfoFailedNegativeRate() { + ctx := suite.Ctx + + oracle := types.NewOracle(suite.oracleAccAddr.String(), suite.uniqueID, suite.endpoint, suite.oracleCommissionRate, suite.oracleCommissionMaxRate, suite.oracleCommissionMaxChangeRate, ctx.BlockTime()) + err := suite.OracleKeeper.SetOracle(ctx, oracle) + suite.Require().NoError(err) + + updateCommissionRate := sdk.NewDecWithPrec(-1, 1) + msgUpdateOracleInfo := &types.MsgUpdateOracleInfo{ + OracleAddress: suite.oracleAccAddr.String(), + Endpoint: suite.newEndpoint, + OracleCommissionRate: &updateCommissionRate, + } + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Hour)) + err = suite.OracleKeeper.UpdateOracleInfo(ctx, msgUpdateOracleInfo) + suite.Require().Error(err, types.ErrUpdateOracle) + suite.Require().ErrorContains(err, "commission must be positive") +} diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index f58538aa..5ca5a715 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -9,4 +9,9 @@ var ( ErrOracleNotFound = sdkerrors.Register(ModuleName, 4, "oracle not found") ErrInvalidUniqueID = sdkerrors.Register(ModuleName, 5, "invalid unique id") ErrApproveOracleRegistration = sdkerrors.Register(ModuleName, 6, "error while approving an oracle registration") + ErrUpdateOracle = sdkerrors.Register(ModuleName, 7, "error while updating oracle info") + ErrCommissionNegative = sdkerrors.Register(ModuleName, 8, "commission must be positive") + ErrCommissionGTMaxRate = sdkerrors.Register(ModuleName, 9, "commission cannot be more than the max rate") + ErrCommissionUpdateTime = sdkerrors.Register(ModuleName, 10, "commission cannot be changed more than once in 24h") + ErrCommissionGTMaxChangeRate = sdkerrors.Register(ModuleName, 11, "commission cannot be changed more than max change rate") ) diff --git a/x/oracle/types/message_oracle.go b/x/oracle/types/message_oracle.go index b9305d16..83be0c0c 100644 --- a/x/oracle/types/message_oracle.go +++ b/x/oracle/types/message_oracle.go @@ -8,16 +8,18 @@ import ( var _ sdk.Msg = &MsgRegisterOracle{} -func NewMsgRegisterOracle(uniqueID, oracleAddress string, nodePubKey, nodePubKeyRemoteReport []byte, trustedBlockHeight int64, trustedBlockHash []byte, endpoint string, oracleCommissionRate sdk.Dec) *MsgRegisterOracle { +func NewMsgRegisterOracle(uniqueID, oracleAddress string, nodePubKey, nodePubKeyRemoteReport []byte, trustedBlockHeight int64, trustedBlockHash []byte, endpoint string, oracleCommissionRate, oracleCommissionMaxRate, oracleCommissionMaxChangeRate sdk.Dec) *MsgRegisterOracle { return &MsgRegisterOracle{ - UniqueId: uniqueID, - OracleAddress: oracleAddress, - NodePubKey: nodePubKey, - NodePubKeyRemoteReport: nodePubKeyRemoteReport, - TrustedBlockHeight: trustedBlockHeight, - TrustedBlockHash: trustedBlockHash, - Endpoint: endpoint, - OracleCommissionRate: oracleCommissionRate, + UniqueId: uniqueID, + OracleAddress: oracleAddress, + NodePubKey: nodePubKey, + NodePubKeyRemoteReport: nodePubKeyRemoteReport, + TrustedBlockHeight: trustedBlockHeight, + TrustedBlockHash: trustedBlockHash, + Endpoint: endpoint, + OracleCommissionRate: oracleCommissionRate, + OracleCommissionMaxRate: oracleCommissionMaxRate, + OracleCommissionMaxChangeRate: oracleCommissionMaxChangeRate, } } @@ -59,6 +61,12 @@ func (m *MsgRegisterOracle) ValidateBasic() error { if m.OracleCommissionRate.LT(sdk.ZeroDec()) || m.OracleCommissionRate.GT(sdk.OneDec()) { return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "oracleCommissionRate must be between 0 and 1") } + if m.OracleCommissionMaxRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxRate must be between 0 and 1") + } + if m.OracleCommissionMaxChangeRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxChangeRate.GT(m.OracleCommissionMaxRate) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxChangeRate must be between 0 and OracleCommissionMaxRate") + } return nil } @@ -140,7 +148,7 @@ func (m *ApproveOracleRegistration) ValidateBasic() error { var _ sdk.Msg = &MsgUpdateOracleInfo{} -func NewMsgUpdateOracleInfo(address, endpoint string, commissionRate sdk.Dec) *MsgUpdateOracleInfo { +func NewMsgUpdateOracleInfo(address, endpoint string, commissionRate *sdk.Dec) *MsgUpdateOracleInfo { return &MsgUpdateOracleInfo{ OracleAddress: address, Endpoint: endpoint, diff --git a/x/oracle/types/oracle.go b/x/oracle/types/oracle.go index 741f8548..9c788ac2 100644 --- a/x/oracle/types/oracle.go +++ b/x/oracle/types/oracle.go @@ -2,18 +2,22 @@ package types import ( "fmt" + "time" "github.com/btcsuite/btcd/btcec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -func NewOracle(oracleAddress, uniqueID, endpoint string, oracleCommissionRate sdk.Dec) *Oracle { +func NewOracle(oracleAddress, uniqueID, endpoint string, rate, maxRate, maxChangeRate sdk.Dec, updatedAt time.Time) *Oracle { return &Oracle{ - OracleAddress: oracleAddress, - UniqueId: uniqueID, - Endpoint: endpoint, - OracleCommissionRate: oracleCommissionRate, + OracleAddress: oracleAddress, + UniqueId: uniqueID, + Endpoint: endpoint, + UpdateTime: updatedAt, + OracleCommissionRate: rate, + OracleCommissionMaxRate: maxRate, + OracleCommissionMaxChangeRate: maxChangeRate, } } @@ -27,25 +31,32 @@ func (m *Oracle) ValidateBasic() error { if len(m.Endpoint) == 0 { return fmt.Errorf("endpoint is empty") } - if m.OracleCommissionRate.IsNegative() { - return fmt.Errorf("oracle commission rate cannot be negative") + if m.OracleCommissionRate.LT(sdk.ZeroDec()) || m.OracleCommissionRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "oracleCommissionRate must be between 0 and 1") } - if m.OracleCommissionRate.GT(sdk.OneDec()) { - return fmt.Errorf("oracle commission rate cannot be greater than 1") + + if m.OracleCommissionMaxRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxRate must be between 0 and 1") + } + + if m.OracleCommissionMaxChangeRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxChangeRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxChangeRate must be between 0 and 1") } return nil } func NewOracleRegistration(msg *MsgRegisterOracle) *OracleRegistration { return &OracleRegistration{ - UniqueId: msg.UniqueId, - OracleAddress: msg.OracleAddress, - NodePubKey: msg.NodePubKey, - NodePubKeyRemoteReport: msg.NodePubKeyRemoteReport, - TrustedBlockHeight: msg.TrustedBlockHeight, - TrustedBlockHash: msg.TrustedBlockHash, - Endpoint: msg.Endpoint, - OracleCommissionRate: msg.OracleCommissionRate, + UniqueId: msg.UniqueId, + OracleAddress: msg.OracleAddress, + NodePubKey: msg.NodePubKey, + NodePubKeyRemoteReport: msg.NodePubKeyRemoteReport, + TrustedBlockHeight: msg.TrustedBlockHeight, + TrustedBlockHash: msg.TrustedBlockHash, + Endpoint: msg.Endpoint, + OracleCommissionRate: msg.OracleCommissionRate, + OracleCommissionMaxRate: msg.OracleCommissionMaxRate, + OracleCommissionMaxChangeRate: msg.OracleCommissionMaxChangeRate, } } @@ -79,5 +90,36 @@ func (m *OracleRegistration) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "oracleCommissionRate must be between 0 and 1") } + if m.OracleCommissionMaxRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxRate must be between 0 and 1") + } + + if m.OracleCommissionMaxChangeRate.LT(sdk.ZeroDec()) || m.OracleCommissionMaxChangeRate.GT(sdk.OneDec()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "OracleCommissionMaxChangeRate must be between 0 and 1") + } + + return nil +} + +// ValidateOracleCommission validate an oracle's commission rate. +// An error is returned if the new commission rate is invalid. +func (m *Oracle) ValidateOracleCommission(blockTime time.Time, newRate sdk.Dec) error { + switch { + case blockTime.Sub(m.UpdateTime).Hours() < 24: + return ErrCommissionUpdateTime + + case newRate.IsNegative(): + // new rate cannot be negative + return ErrCommissionNegative + + case newRate.GT(m.OracleCommissionMaxRate): + // new rate cannot be greater than the max rate + return ErrCommissionGTMaxRate + + case newRate.Sub(m.OracleCommissionRate).GT(m.OracleCommissionMaxChangeRate): + // new rate % points change cannot be greater than the max change rate + return ErrCommissionGTMaxChangeRate + } + return nil } diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 3ee57091..4470504a 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -8,15 +8,19 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -26,10 +30,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Oracle defines a detail of oracle. type Oracle struct { - OracleAddress string `protobuf:"bytes,1,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` - UniqueId string `protobuf:"bytes,2,opt,name=unique_id,json=uniqueId,proto3" json:"unique_id,omitempty"` - Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + OracleAddress string `protobuf:"bytes,1,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` + UniqueId string `protobuf:"bytes,2,opt,name=unique_id,json=uniqueId,proto3" json:"unique_id,omitempty"` + Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + UpdateTime time.Time `protobuf:"bytes,4,opt,name=update_time,json=updateTime,proto3,stdtime" json:"update_time"` + OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + OracleCommissionMaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=oracle_commission_max_rate,json=oracleCommissionMaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_rate"` + OracleCommissionMaxChangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=oracle_commission_max_change_rate,json=oracleCommissionMaxChangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_change_rate"` } func (m *Oracle) Reset() { *m = Oracle{} } @@ -86,6 +93,13 @@ func (m *Oracle) GetEndpoint() string { return "" } +func (m *Oracle) GetUpdateTime() time.Time { + if m != nil { + return m.UpdateTime + } + return time.Time{} +} + // OracleRegistration defines the detailed states of the registration of oracle. type OracleRegistration struct { UniqueId string `protobuf:"bytes,1,opt,name=unique_id,json=uniqueId,proto3" json:"unique_id,omitempty"` @@ -97,11 +111,13 @@ type OracleRegistration struct { NodePubKeyRemoteReport []byte `protobuf:"bytes,4,opt,name=node_pub_key_remote_report,json=nodePubKeyRemoteReport,proto3" json:"node_pub_key_remote_report,omitempty"` // The trusted block info is required for light client. // Other oracle can validate whether the oracle set correct trusted block info. - TrustedBlockHeight int64 `protobuf:"varint,5,opt,name=trusted_block_height,json=trustedBlockHeight,proto3" json:"trusted_block_height,omitempty"` - TrustedBlockHash []byte `protobuf:"bytes,6,opt,name=trusted_block_hash,json=trustedBlockHash,proto3" json:"trusted_block_hash,omitempty"` - Endpoint string `protobuf:"bytes,7,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` - EncryptedOraclePrivKey []byte `protobuf:"bytes,9,opt,name=encrypted_oracle_priv_key,json=encryptedOraclePrivKey,proto3" json:"encrypted_oracle_priv_key,omitempty"` + TrustedBlockHeight int64 `protobuf:"varint,5,opt,name=trusted_block_height,json=trustedBlockHeight,proto3" json:"trusted_block_height,omitempty"` + TrustedBlockHash []byte `protobuf:"bytes,6,opt,name=trusted_block_hash,json=trustedBlockHash,proto3" json:"trusted_block_hash,omitempty"` + Endpoint string `protobuf:"bytes,7,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + OracleCommissionMaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=oracle_commission_max_rate,json=oracleCommissionMaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_rate"` + OracleCommissionMaxChangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=oracle_commission_max_change_rate,json=oracleCommissionMaxChangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_change_rate"` + EncryptedOraclePrivKey []byte `protobuf:"bytes,11,opt,name=encrypted_oracle_priv_key,json=encryptedOraclePrivKey,proto3" json:"encrypted_oracle_priv_key,omitempty"` } func (m *OracleRegistration) Reset() { *m = OracleRegistration{} } @@ -201,36 +217,43 @@ func init() { func init() { proto.RegisterFile("panacea/oracle/v2/oracle.proto", fileDescriptor_35c1a1e2fbbbc7ea) } var fileDescriptor_35c1a1e2fbbbc7ea = []byte{ - // 454 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x6e, 0x56, 0x28, 0xad, 0x55, 0x10, 0x58, 0xd5, 0x14, 0x8a, 0x94, 0x55, 0x93, 0x40, 0x3b, - 0xb0, 0x04, 0x8d, 0x13, 0xdc, 0x28, 0x1c, 0x98, 0x76, 0x60, 0xf2, 0x91, 0x8b, 0xe5, 0xd8, 0x4f, - 0x89, 0xd5, 0x25, 0x0e, 0xb6, 0x13, 0x91, 0x7f, 0xc1, 0xcf, 0xda, 0x09, 0x4d, 0xe2, 0x82, 0x38, - 0x4c, 0xa8, 0xfd, 0x23, 0x28, 0x76, 0x36, 0xd6, 0xc1, 0x81, 0x03, 0xa7, 0x38, 0xdf, 0xf7, 0xe5, - 0xf9, 0xfb, 0xde, 0x7b, 0x41, 0x51, 0xc5, 0x4a, 0xc6, 0x81, 0x25, 0x4a, 0x33, 0x7e, 0x06, 0x49, - 0x73, 0xd4, 0x9f, 0xe2, 0x4a, 0x2b, 0xab, 0xf0, 0xa3, 0x9e, 0x8f, 0x7b, 0xb4, 0x39, 0x9a, 0xcf, - 0x32, 0x95, 0x29, 0xc7, 0x26, 0xdd, 0xc9, 0x0b, 0xf7, 0xbf, 0x06, 0x68, 0xf4, 0xc1, 0x69, 0xf0, - 0x53, 0xf4, 0xc0, 0xab, 0x29, 0x13, 0x42, 0x83, 0x31, 0x61, 0xb0, 0x08, 0x0e, 0x26, 0xe4, 0xbe, - 0x47, 0xdf, 0x78, 0x10, 0x3f, 0x41, 0x93, 0xba, 0x94, 0x9f, 0x6a, 0xa0, 0x52, 0x84, 0x3b, 0x4e, - 0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x41, + 0x97, 0x5d, 0x22, 0x16, 0x05, 0x25, 0xaf, 0xc1, 0x02, 0x79, 0xc6, 0x29, 0x4d, 0x1a, 0x36, 0x95, + 0x80, 0x95, 0x3d, 0xf7, 0xdc, 0xb9, 0xe7, 0x48, 0xf7, 0xd3, 0x20, 0x27, 0x27, 0x19, 0x89, 0x80, + 0x78, 0x5c, 0x90, 0x68, 0x04, 0xde, 0xb8, 0x5f, 0xfd, 0xb9, 0xb9, 0xe0, 0x8a, 0xe3, 0x3b, 0x95, + 0xee, 0x56, 0xd5, 0x71, 0xdf, 0x6e, 0xc7, 0x3c, 0xe6, 0x5a, 0xf5, 0xca, 0x3f, 0xd3, 0x68, 0x77, + 0x63, 0xce, 0xe3, 0x11, 0x78, 0xfa, 0x14, 0x16, 0x1f, 0x3d, 0xc5, 0x52, 0x90, 0x8a, 0xa4, 0xb9, + 0x69, 0xd8, 0xfb, 0xb1, 0x89, 0xb6, 0xdf, 0xe9, 0x21, 0xf8, 0x11, 0xba, 0x65, 0xc6, 0x05, 0x84, + 0x52, 0x01, 0x52, 0x76, 0xac, 0x9e, 0xb5, 0xdf, 0xf0, 0xff, 0x37, 0xd5, 0x97, 0xa6, 0x88, 0xef, + 0xa3, 0x46, 0x91, 0xb1, 0x4f, 0x05, 0x04, 0x8c, 0x76, 0x36, 0x74, 0x47, 0xdd, 0x14, 0x8e, 0x28, + 0xb6, 0x51, 0x1d, 0x32, 0x9a, 0x73, 0x96, 0xa9, 0xce, 0xa6, 0xd1, 0x16, 0x67, 0xfc, 0x1a, 0x35, + 0x8b, 0x9c, 0x12, 0x05, 0x41, 0x19, 0xa2, 0xf3, 0x5f, 0xcf, 0xda, 0x6f, 0xf6, 0x6d, 0xd7, 0x24, + 0x74, 0x17, 0x09, 0xdd, 0xf7, 0x8b, 0x84, 0x83, 0xfa, 0xd9, 0x45, 0xb7, 0x76, 0xfa, 0xad, 0x6b, + 0xf9, 0xc8, 0x5c, 0x2c, 0x25, 0x4c, 0xd1, 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, 0x41, 0x02, 0x2c, + 0x4e, 0x94, 0x66, 0x60, 0xd3, 0xc7, 0x95, 0x36, 0x28, 0xa5, 0x37, 0x5a, 0xc1, 0x4f, 0x10, 0x5e, + 0xb9, 0x41, 0x64, 0xa2, 0x37, 0xd9, 0xf2, 0x6f, 0x2f, 0xf5, 0x13, 0x99, 0x2c, 0x81, 0xbc, 0xb3, + 0x02, 0xf2, 0xef, 0x09, 0xac, 0xff, 0x35, 0x02, 0x1b, 0xff, 0x80, 0x40, 0xf4, 0x07, 0x08, 0xc4, + 0xcf, 0xd1, 0x3d, 0xc8, 0x22, 0x31, 0xcd, 0xcb, 0xc5, 0x54, 0x19, 0x72, 0xc1, 0xc6, 0x9a, 0x99, + 0xa6, 0x61, 0xe0, 0xb2, 0xc1, 0xa0, 0x7a, 0x22, 0xd8, 0xf8, 0x18, 0xa6, 0x83, 0xa3, 0xb3, 0x99, + 0x63, 0x9d, 0xcf, 0x1c, 0xeb, 0xfb, 0xcc, 0xb1, 0x4e, 0xe7, 0x4e, 0xed, 0x7c, 0xee, 0xd4, 0xbe, + 0xcc, 0x9d, 0xda, 0x07, 0xef, 0x4a, 0xb6, 0x14, 0x28, 0x2b, 0x17, 0xee, 0x55, 0x6f, 0xe6, 0x41, + 0xc4, 0x05, 0x78, 0x93, 0xc5, 0xd3, 0xaa, 0x83, 0x86, 0xdb, 0xfa, 0xf9, 0x79, 0xf6, 0x33, 0x00, + 0x00, 0xff, 0xff, 0xfe, 0x90, 0x21, 0x01, 0x79, 0x05, 0x00, 0x00, } func (m *Oracle) Marshal() (dAtA []byte, err error) { @@ -253,6 +276,26 @@ func (m *Oracle) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.OracleCommissionMaxChangeRate.Size() + i -= size + if _, err := m.OracleCommissionMaxChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.OracleCommissionMaxRate.Size() + i -= size + if _, err := m.OracleCommissionMaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 { size := m.OracleCommissionRate.Size() i -= size @@ -262,6 +305,14 @@ func (m *Oracle) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintOracle(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x2a + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdateTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintOracle(dAtA, i, uint64(n1)) + i-- dAtA[i] = 0x22 if len(m.Endpoint) > 0 { i -= len(m.Endpoint) @@ -312,8 +363,28 @@ func (m *OracleRegistration) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.EncryptedOraclePrivKey) i = encodeVarintOracle(dAtA, i, uint64(len(m.EncryptedOraclePrivKey))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x5a + } + { + size := m.OracleCommissionMaxChangeRate.Size() + i -= size + if _, err := m.OracleCommissionMaxChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + { + size := m.OracleCommissionMaxRate.Size() + i -= size + if _, err := m.OracleCommissionMaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOracle(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x4a { size := m.OracleCommissionRate.Size() i -= size @@ -403,8 +474,14 @@ func (m *Oracle) Size() (n int) { if l > 0 { n += 1 + l + sovOracle(uint64(l)) } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime) + n += 1 + l + sovOracle(uint64(l)) l = m.OracleCommissionRate.Size() n += 1 + l + sovOracle(uint64(l)) + l = m.OracleCommissionMaxRate.Size() + n += 1 + l + sovOracle(uint64(l)) + l = m.OracleCommissionMaxChangeRate.Size() + n += 1 + l + sovOracle(uint64(l)) return n } @@ -443,6 +520,10 @@ func (m *OracleRegistration) Size() (n int) { } l = m.OracleCommissionRate.Size() n += 1 + l + sovOracle(uint64(l)) + l = m.OracleCommissionMaxRate.Size() + n += 1 + l + sovOracle(uint64(l)) + l = m.OracleCommissionMaxChangeRate.Size() + n += 1 + l + sovOracle(uint64(l)) l = len(m.EncryptedOraclePrivKey) if l > 0 { n += 1 + l + sovOracle(uint64(l)) @@ -582,6 +663,39 @@ func (m *Oracle) Unmarshal(dAtA []byte) error { m.Endpoint = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdateTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionRate", wireType) } @@ -615,6 +729,74 @@ func (m *Oracle) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOracle(dAtA[iNdEx:]) @@ -917,6 +1099,74 @@ func (m *OracleRegistration) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + 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 ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EncryptedOraclePrivKey", wireType) } diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index dc19f436..6b9fe61b 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -34,14 +34,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgRegisterOracle defines the Msg/RegisterOracle request type. type MsgRegisterOracle struct { - UniqueId string `protobuf:"bytes,1,opt,name=unique_id,json=uniqueId,proto3" json:"unique_id,omitempty"` - OracleAddress string `protobuf:"bytes,2,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` - NodePubKey []byte `protobuf:"bytes,3,opt,name=node_pub_key,json=nodePubKey,proto3" json:"node_pub_key,omitempty"` - NodePubKeyRemoteReport []byte `protobuf:"bytes,4,opt,name=node_pub_key_remote_report,json=nodePubKeyRemoteReport,proto3" json:"node_pub_key_remote_report,omitempty"` - TrustedBlockHeight int64 `protobuf:"varint,5,opt,name=trusted_block_height,json=trustedBlockHeight,proto3" json:"trusted_block_height,omitempty"` - TrustedBlockHash []byte `protobuf:"bytes,6,opt,name=trusted_block_hash,json=trustedBlockHash,proto3" json:"trusted_block_hash,omitempty"` - Endpoint string `protobuf:"bytes,7,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + UniqueId string `protobuf:"bytes,1,opt,name=unique_id,json=uniqueId,proto3" json:"unique_id,omitempty"` + OracleAddress string `protobuf:"bytes,2,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` + NodePubKey []byte `protobuf:"bytes,3,opt,name=node_pub_key,json=nodePubKey,proto3" json:"node_pub_key,omitempty"` + NodePubKeyRemoteReport []byte `protobuf:"bytes,4,opt,name=node_pub_key_remote_report,json=nodePubKeyRemoteReport,proto3" json:"node_pub_key_remote_report,omitempty"` + TrustedBlockHeight int64 `protobuf:"varint,5,opt,name=trusted_block_height,json=trustedBlockHeight,proto3" json:"trusted_block_height,omitempty"` + TrustedBlockHash []byte `protobuf:"bytes,6,opt,name=trusted_block_hash,json=trustedBlockHash,proto3" json:"trusted_block_hash,omitempty"` + Endpoint string `protobuf:"bytes,7,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + OracleCommissionMaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=oracle_commission_max_rate,json=oracleCommissionMaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_rate"` + OracleCommissionMaxChangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=oracle_commission_max_change_rate,json=oracleCommissionMaxChangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_max_change_rate"` } func (m *MsgRegisterOracle) Reset() { *m = MsgRegisterOracle{} } @@ -324,9 +326,9 @@ var xxx_messageInfo_MsgApproveOracleRegistrationResponse proto.InternalMessageIn // MsgUpdateOracleInfo defines the Msg/UpdateOracleInfo type MsgUpdateOracleInfo struct { - OracleAddress string `protobuf:"bytes,1,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` - Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - OracleCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate"` + OracleAddress string `protobuf:"bytes,1,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` + Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + OracleCommissionRate *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=oracle_commission_rate,json=oracleCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"oracle_commission_rate,omitempty"` } func (m *MsgUpdateOracleInfo) Reset() { *m = MsgUpdateOracleInfo{} } @@ -426,53 +428,56 @@ func init() { func init() { proto.RegisterFile("panacea/oracle/v2/tx.proto", fileDescriptor_91b53ec53f5557f6) } var fileDescriptor_91b53ec53f5557f6 = []byte{ - // 731 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x4f, 0xdb, 0x4a, - 0x14, 0x8d, 0xc9, 0x7b, 0x3c, 0x98, 0xc7, 0x43, 0x60, 0x3e, 0x9e, 0xe3, 0xf0, 0x42, 0x14, 0xf1, - 0x10, 0xaa, 0xc0, 0x53, 0x52, 0xa9, 0x55, 0xbb, 0x83, 0x76, 0x51, 0x84, 0x22, 0x90, 0xa5, 0x6e, - 0xba, 0xb1, 0xc6, 0xf6, 0xc5, 0x99, 0x12, 0x7b, 0xcc, 0xcc, 0x38, 0x22, 0x3f, 0xa0, 0xfb, 0xee, - 0xfa, 0x1f, 0xfa, 0x23, 0xba, 0x66, 0xc9, 0xb2, 0xea, 0x02, 0x2a, 0xf8, 0x23, 0x55, 0xc6, 0x93, - 0x10, 0xf2, 0x81, 0xa8, 0xd4, 0x55, 0xe2, 0x7b, 0xce, 0x3d, 0xf7, 0xda, 0xe7, 0xd8, 0x83, 0xec, - 0x94, 0x24, 0x24, 0x00, 0x82, 0x19, 0x27, 0x41, 0x0b, 0x70, 0xbb, 0x8e, 0xe5, 0xb9, 0x93, 0x72, - 0x26, 0x99, 0xb9, 0xa8, 0x31, 0x27, 0xc7, 0x9c, 0x76, 0xdd, 0x5e, 0x8e, 0x58, 0xc4, 0x14, 0x8a, - 0xbb, 0xff, 0x72, 0xa2, 0xbd, 0x1e, 0x31, 0x16, 0xb5, 0x00, 0xab, 0x2b, 0x3f, 0x3b, 0xc1, 0x92, - 0xc6, 0x20, 0x24, 0x89, 0x53, 0x4d, 0x78, 0x12, 0x30, 0x11, 0x33, 0x81, 0x7d, 0x22, 0x00, 0x9f, - 0x65, 0xc0, 0x3b, 0xb8, 0xbd, 0xeb, 0x83, 0x24, 0xbb, 0x38, 0x25, 0x11, 0x4d, 0x88, 0xa4, 0x2c, - 0xd1, 0xdc, 0x35, 0x2d, 0x46, 0x52, 0x8a, 0x49, 0x92, 0x30, 0xa9, 0x40, 0xa1, 0xd1, 0xca, 0xe8, - 0xbe, 0x7a, 0x3b, 0xbd, 0xca, 0x28, 0x1e, 0x41, 0x02, 0x82, 0x6a, 0x81, 0xda, 0xe7, 0x22, 0x5a, - 0x6c, 0x88, 0xc8, 0x85, 0x88, 0x0a, 0x09, 0xfc, 0x48, 0xd1, 0xcc, 0x32, 0x9a, 0xcd,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 0x32, 0xc6, 0xbd, 0x52, - 0x83, 0xa1, 0x9c, 0x7a, 0x74, 0x28, 0x8b, 0xbf, 0x31, 0x94, 0xff, 0xa1, 0xf2, 0x98, 0xfd, 0x7b, - 0xf7, 0x57, 0xbf, 0x9e, 0x42, 0xc5, 0x86, 0x88, 0xcc, 0x10, 0xcd, 0x0f, 0x7d, 0x51, 0x36, 0xc6, - 0x44, 0x6d, 0x24, 0xde, 0xf6, 0xf6, 0x63, 0x58, 0xbd, 0x69, 0xe6, 0xc7, 0x07, 0x73, 0x85, 0xc7, - 0x6b, 0x4d, 0x6c, 0xb0, 0x5f, 0xfc, 0x62, 0x43, 0x7f, 0x8f, 0x0f, 0x68, 0x61, 0xc4, 0xd1, 0xcd, - 0xf1, 0x62, 0xc3, 0x3c, 0xdb, 0x79, 0x1c, 0xaf, 0x37, 0x6b, 0xff, 0xe0, 0xe2, 0xa6, 0x62, 0x5c, - 0xde, 0x54, 0x8c, 0x1f, 0x37, 0x15, 0xe3, 0xd3, 0x6d, 0xa5, 0x70, 0x79, 0x5b, 0x29, 0x7c, 0xbb, - 0xad, 0x14, 0xde, 0xe3, 0x01, 0x63, 0x63, 0x08, 0x69, 0xf7, 0x23, 0x87, 0xb5, 0xf8, 0x4e, 0xc0, - 0x38, 0xe0, 0xf3, 0xde, 0x29, 0xa0, 0x5c, 0xf6, 0xa7, 0xd5, 0x09, 0xf0, 0xec, 0x67, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x2d, 0x36, 0x58, 0x7f, 0xf4, 0x06, 0x00, 0x00, + // 780 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x41, 0x6f, 0xdb, 0x36, + 0x14, 0x8e, 0xe2, 0xae, 0x8b, 0xb9, 0xac, 0x68, 0xd5, 0xb4, 0x95, 0xe5, 0xd4, 0xf1, 0x8c, 0x2e, + 0x08, 0x86, 0x54, 0x5c, 0x3d, 0x60, 0xc3, 0x76, 0x6b, 0xba, 0xc3, 0x82, 0xc2, 0x68, 0x21, 0x60, + 0x97, 0x5d, 0x04, 0x4a, 0x7a, 0xa5, 0x39, 0x5b, 0xa4, 0x4a, 0x52, 0x86, 0xfd, 0x03, 0x76, 0xdf, + 0xef, 0xd8, 0x8f, 0xd8, 0xb9, 0xc7, 0x1e, 0x87, 0x1d, 0xda, 0x21, 0xf9, 0x1f, 0xc3, 0x20, 0x8a, + 0x76, 0x1d, 0x5b, 0x0e, 0xb2, 0xf4, 0x94, 0x88, 0xdf, 0xf7, 0xbe, 0xef, 0x59, 0xef, 0x7d, 0x14, + 0xf2, 0x73, 0xc2, 0x49, 0x02, 0x04, 0x0b, 0x49, 0x92, 0x31, 0xe0, 0x49, 0x1f, 0xeb, 0x69, 0x90, + 0x4b, 0xa1, 0x85, 0x7b, 0xc7, 0x62, 0x41, 0x85, 0x05, 0x93, 0xbe, 0xbf, 0x47, 0x05, 0x15, 0x06, + 0xc5, 0xe5, 0x7f, 0x15, 0xd1, 0x3f, 0xa0, 0x42, 0xd0, 0x31, 0x60, 0xf3, 0x14, 0x17, 0xaf, 0xb0, + 0x66, 0x19, 0x28, 0x4d, 0xb2, 0xdc, 0x12, 0xbe, 0x4a, 0x84, 0xca, 0x84, 0xc2, 0x31, 0x51, 0x80, + 0x5f, 0x17, 0x20, 0x67, 0x78, 0xf2, 0x24, 0x06, 0x4d, 0x9e, 0xe0, 0x9c, 0x50, 0xc6, 0x89, 0x66, + 0x82, 0x5b, 0xee, 0xbe, 0x15, 0x23, 0x39, 0xc3, 0x84, 0x73, 0xa1, 0x0d, 0xa8, 0x2c, 0xda, 0x59, + 0xef, 0xd7, 0x76, 0x67, 0x5b, 0x59, 0xc7, 0x29, 0x70, 0x50, 0xcc, 0x0a, 0xf4, 0xfe, 0xbd, 0x81, + 0xee, 0x0c, 0x14, 0x0d, 0x81, 0x32, 0xa5, 0x41, 0xbe, 0x30, 0x34, 0xb7, 0x8d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 0xba, 0x6f, 0xfe, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0xc9, 0xc3, 0xe6, 0x21, 0xdb, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -653,6 +658,26 @@ func (m *MsgRegisterOracle) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.OracleCommissionMaxChangeRate.Size() + i -= size + if _, err := m.OracleCommissionMaxChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + { + size := m.OracleCommissionMaxRate.Size() + i -= size + if _, err := m.OracleCommissionMaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a { size := m.OracleCommissionRate.Size() i -= size @@ -872,16 +897,18 @@ func (m *MsgUpdateOracleInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.OracleCommissionRate.Size() - i -= size - if _, err := m.OracleCommissionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if m.OracleCommissionRate != nil { + { + size := m.OracleCommissionRate.Size() + i -= size + if _, err := m.OracleCommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.Endpoint) > 0 { i -= len(m.Endpoint) copy(dAtA[i:], m.Endpoint) @@ -968,6 +995,10 @@ func (m *MsgRegisterOracle) Size() (n int) { } l = m.OracleCommissionRate.Size() n += 1 + l + sovTx(uint64(l)) + l = m.OracleCommissionMaxRate.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.OracleCommissionMaxChangeRate.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1045,8 +1076,10 @@ func (m *MsgUpdateOracleInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.OracleCommissionRate.Size() - n += 1 + l + sovTx(uint64(l)) + if m.OracleCommissionRate != nil { + l = m.OracleCommissionRate.Size() + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1345,6 +1378,74 @@ func (m *MsgRegisterOracle) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleCommissionMaxChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OracleCommissionMaxChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1889,6 +1990,8 @@ func (m *MsgUpdateOracleInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.OracleCommissionRate = &v if err := m.OracleCommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err }