diff --git a/app/preblocker.go b/app/preblocker.go index db06b262..6b5f8aa8 100644 --- a/app/preblocker.go +++ b/app/preblocker.go @@ -1,13 +1,13 @@ package app import ( - "encoding/json" "fmt" "cosmossdk.io/core/appmodule" cometabci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ojo-network/ojo/x/oracle/abci" + "github.com/ojo-network/ojo/x/oracle/types" ) // PreBlocker is run before finalize block to update the aggregrate exchange rate votes on the oracle module @@ -45,8 +45,8 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock) } voteExtensionsEnabled := abci.VoteExtensionsEnabled(ctx) if voteExtensionsEnabled { - var injectedVoteExtTx abci.AggregateExchangeRateVotes - if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil { + var injectedVoteExtTx types.InjectedVoteExtensionTx + if err := injectedVoteExtTx.Unmarshal(req.Txs[0]); err != nil { app.Logger().Error("failed to decode injected vote extension tx", "err", err) return nil, err } diff --git a/proto/ojo/oracle/v1/abci.proto b/proto/ojo/oracle/v1/abci.proto new file mode 100644 index 00000000..2272d02a --- /dev/null +++ b/proto/ojo/oracle/v1/abci.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package ojo.oracle.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "ojo/oracle/v1/oracle.proto"; + +option go_package = "github.com/ojo-network/ojo/x/oracle/types"; + +option (gogoproto.goproto_getters_all) = false; + +// OracleVoteExtension defines the vote extension structure used by the oracle +// module. +message OracleVoteExtension { + int64 height = 1; + repeated cosmos.base.v1beta1.DecCoin exchange_rates = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// InjectedVoteExtensionTx defines the vote extension tx injected by the prepare +// proposal handler. +message InjectedVoteExtensionTx { + repeated AggregateExchangeRateVote exchange_rate_votes = 1[ + (gogoproto.nullable) = false + ]; + bytes extended_commit_info = 2; +} diff --git a/x/oracle/abci/endblocker.go b/x/oracle/abci/endblocker.go index 88ce64d9..c184c10a 100644 --- a/x/oracle/abci/endblocker.go +++ b/x/oracle/abci/endblocker.go @@ -57,7 +57,7 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) error { // Execute price feeder oracle tick. if err := k.PriceFeeder.Oracle.TickClientless(ctx); err != nil { - return err + sdkCtx.Logger().Error("Error in Oracle Keeper price feeder clientless tick", "err", err) } } diff --git a/x/oracle/abci/proposal.go b/x/oracle/abci/proposal.go index 9af3ffca..12be7400 100644 --- a/x/oracle/abci/proposal.go +++ b/x/oracle/abci/proposal.go @@ -1,7 +1,6 @@ package abci import ( - "encoding/json" "fmt" "sort" @@ -16,11 +15,6 @@ import ( oracletypes "github.com/ojo-network/ojo/x/oracle/types" ) -type AggregateExchangeRateVotes struct { - ExchangeRateVotes []oracletypes.AggregateExchangeRateVote - ExtendedCommitInfo cometabci.ExtendedCommitInfo -} - type ProposalHandler struct { logger log.Logger oracleKeeper oraclekeeper.Keeper @@ -74,15 +68,17 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler { if err != nil { return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err } + extendedCommitInfoBz, err := req.LocalLastCommit.Marshal() + if err != nil { + return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, err + } - injectedVoteExtTx := AggregateExchangeRateVotes{ + injectedVoteExtTx := oracletypes.InjectedVoteExtensionTx{ ExchangeRateVotes: exchangeRateVotes, - ExtendedCommitInfo: req.LocalLastCommit, + ExtendedCommitInfo: extendedCommitInfoBz, } - // TODO: Switch from stdlib JSON encoding to a more performant mechanism. - // REF: https://github.com/ojo-network/ojo/issues/411 - bz, err := json.Marshal(injectedVoteExtTx) + bz, err := injectedVoteExtTx.Marshal() if err != nil { h.logger.Error("failed to encode injected vote extension tx", "err", err) return &cometabci.ResponsePrepareProposal{Txs: make([][]byte, 0)}, oracletypes.ErrEncodeInjVoteExt @@ -127,17 +123,29 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { voteExtensionsEnabled := VoteExtensionsEnabled(ctx) if voteExtensionsEnabled { - var injectedVoteExtTx AggregateExchangeRateVotes - if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil { + if len(req.Txs) < 1 { + h.logger.Error("got process proposal request with no commit info") + return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, + oracletypes.ErrNoCommitInfo + } + + var injectedVoteExtTx oracletypes.InjectedVoteExtensionTx + if err := injectedVoteExtTx.Unmarshal(req.Txs[0]); err != nil { h.logger.Error("failed to decode injected vote extension tx", "err", err) return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err } + var extendedCommitInfo cometabci.ExtendedCommitInfo + if err := extendedCommitInfo.Unmarshal(injectedVoteExtTx.ExtendedCommitInfo); err != nil { + h.logger.Error("failed to decode injected extended commit info", "err", err) + return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err + } + err := baseapp.ValidateVoteExtensions( ctx, h.stakingKeeper, req.Height, ctx.ChainID(), - injectedVoteExtTx.ExtendedCommitInfo, + extendedCommitInfo, ) if err != nil { return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err @@ -145,7 +153,7 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { // Verify the proposer's oracle exchange rate votes by computing the same // calculation and comparing the results. - exchangeRateVotes, err := h.generateExchangeRateVotes(ctx, injectedVoteExtTx.ExtendedCommitInfo) + exchangeRateVotes, err := h.generateExchangeRateVotes(ctx, extendedCommitInfo) if err != nil { return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, err } @@ -173,8 +181,8 @@ func (h *ProposalHandler) generateExchangeRateVotes( continue } - var voteExt OracleVoteExtension - if err := json.Unmarshal(vote.VoteExtension, &voteExt); err != nil { + var voteExt oracletypes.OracleVoteExtension + if err := voteExt.Unmarshal(vote.VoteExtension); err != nil { h.logger.Error( "failed to decode vote extension", "err", err, diff --git a/x/oracle/abci/proposal_test.go b/x/oracle/abci/proposal_test.go index 04daad37..95e8e696 100644 --- a/x/oracle/abci/proposal_test.go +++ b/x/oracle/abci/proposal_test.go @@ -2,7 +2,6 @@ package abci_test import ( "bytes" - "encoding/json" "sort" "cosmossdk.io/core/header" @@ -106,8 +105,8 @@ func (s *IntegrationTestSuite) TestPrepareProposalHandler() { s.Require().NoError(err) s.Require().NotNil(resp) - var injectedVoteExtTx abci.AggregateExchangeRateVotes - err = json.Unmarshal(resp.Txs[0], &injectedVoteExtTx) + var injectedVoteExtTx oracletypes.InjectedVoteExtensionTx + err = injectedVoteExtTx.Unmarshal(resp.Txs[0]) s.Require().NoError(err) sort.Slice(valKeys[:], func(i, j int) bool { @@ -168,21 +167,25 @@ func (s *IntegrationTestSuite) TestProcessProposalHandler() { Voter: valKeys[1].ValAddress.String(), }, } - injectedVoteExtTx := abci.AggregateExchangeRateVotes{ + localCommitInfoBz, err := localCommitInfo.Marshal() + s.Require().NoError(err) + injectedVoteExtTx := oracletypes.InjectedVoteExtensionTx{ ExchangeRateVotes: exchangeRateVotes, - ExtendedCommitInfo: localCommitInfo, + ExtendedCommitInfo: localCommitInfoBz, } - bz, err := json.Marshal(injectedVoteExtTx) + bz, err := injectedVoteExtTx.Marshal() s.Require().NoError(err) var txs [][]byte txs = append(txs, bz) // create tx with conflicting local commit info - injectedVoteExtTxConflicting := abci.AggregateExchangeRateVotes{ + localCommitInfoConflictingBz, err := localCommitInfoConflicting.Marshal() + s.Require().NoError(err) + injectedVoteExtTxConflicting := oracletypes.InjectedVoteExtensionTx{ ExchangeRateVotes: exchangeRateVotes, - ExtendedCommitInfo: localCommitInfoConflicting, + ExtendedCommitInfo: localCommitInfoConflictingBz, } - bz, err = json.Marshal(injectedVoteExtTxConflicting) + bz, err = injectedVoteExtTxConflicting.Marshal() s.Require().NoError(err) var txsConflicting [][]byte txsConflicting = append(txsConflicting, bz) @@ -302,11 +305,11 @@ func buildLocalCommitInfo( valKeys [2]integration.TestValidatorKey, chainID string, ) (cometabci.ExtendedCommitInfo, error) { - voteExt := abci.OracleVoteExtension{ + voteExt := oracletypes.OracleVoteExtension{ ExchangeRates: exchangeRates, Height: ctx.BlockHeight(), } - bz, err := json.Marshal(voteExt) + bz, err := voteExt.Marshal() if err != nil { return cometabci.ExtendedCommitInfo{}, err } diff --git a/x/oracle/abci/voteextension.go b/x/oracle/abci/voteextension.go index 096c50e2..21b51343 100644 --- a/x/oracle/abci/voteextension.go +++ b/x/oracle/abci/voteextension.go @@ -1,7 +1,6 @@ package abci import ( - "encoding/json" "fmt" "cosmossdk.io/log" @@ -13,12 +12,6 @@ import ( "github.com/ojo-network/price-feeder/oracle" ) -// OracleVoteExtension defines the canonical vote extension structure. -type OracleVoteExtension struct { - Height int64 - ExchangeRates sdk.DecCoins -} - type VoteExtensionHandler struct { logger log.Logger oracleKeeper keeper.Keeper @@ -64,6 +57,7 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { h.logger.Error(err.Error()) return &cometabci.ResponseExtendVote{VoteExtension: []byte{}}, err } + prices := h.oracleKeeper.PriceFeeder.Oracle.GetPrices() exchangeRatesStr := oracle.GenerateExchangeRatesString(prices) @@ -80,19 +74,19 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { // Filter out rates which aren't included in the AcceptList. acceptList := h.oracleKeeper.AcceptList(ctx) - filteredDecCoins := sdk.DecCoins{} + filteredDecCoins := []sdk.DecCoin{} for _, decCoin := range exchangeRates { if acceptList.Contains(decCoin.Denom) { filteredDecCoins = append(filteredDecCoins, decCoin) } } - voteExt := OracleVoteExtension{ + voteExt := types.OracleVoteExtension{ Height: req.Height, ExchangeRates: filteredDecCoins, } - bz, err := json.Marshal(voteExt) + bz, err := voteExt.Marshal() if err != nil { err := fmt.Errorf("failed to marshal vote extension: %w", err) h.logger.Error( @@ -101,6 +95,7 @@ func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { ) return &cometabci.ResponseExtendVote{VoteExtension: []byte{}}, err } + h.logger.Info( "created vote extension", "height", req.Height, @@ -123,8 +118,17 @@ func (h *VoteExtensionHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteExtens return nil, err } - var voteExt OracleVoteExtension - err := json.Unmarshal(req.VoteExtension, &voteExt) + if len(req.VoteExtension) == 0 { + h.logger.Info( + "verify vote extension handler received empty vote extension", + "height", req.Height, + ) + + return &cometabci.ResponseVerifyVoteExtension{Status: cometabci.ResponseVerifyVoteExtension_ACCEPT}, nil + } + + var voteExt types.OracleVoteExtension + err := voteExt.Unmarshal(req.VoteExtension) if err != nil { err := fmt.Errorf("verify vote extension handler failed to unmarshal vote extension: %w", err) h.logger.Error( diff --git a/x/oracle/abci/voteextension_test.go b/x/oracle/abci/voteextension_test.go index 3ec16bbd..16ea4e88 100644 --- a/x/oracle/abci/voteextension_test.go +++ b/x/oracle/abci/voteextension_test.go @@ -1,7 +1,6 @@ package abci_test import ( - "encoding/json" "fmt" "cosmossdk.io/log" @@ -10,6 +9,7 @@ import ( "github.com/ojo-network/ojo/pricefeeder" "github.com/ojo-network/ojo/x/oracle/abci" "github.com/ojo-network/ojo/x/oracle/keeper" + "github.com/ojo-network/ojo/x/oracle/types" ) func (s *IntegrationTestSuite) TestExtendVoteHandler() { @@ -41,8 +41,7 @@ func (s *IntegrationTestSuite) TestExtendVoteHandler() { extendVoteRequest: &cometabci.RequestExtendVote{ Height: ctx.BlockHeight(), }, - expErr: true, - expErrMsg: "price feeder oracle not set", + expErr: true, }, { name: "vote extension handled successfully", @@ -71,10 +70,9 @@ func (s *IntegrationTestSuite) TestExtendVoteHandler() { } else { s.Require().NoError(err) s.Require().NotNil(resp) - s.Require().Greater(len(resp.VoteExtension), 0) - var voteExt abci.OracleVoteExtension - err = json.Unmarshal(resp.VoteExtension, &voteExt) + var voteExt types.OracleVoteExtension + err = voteExt.Unmarshal(resp.VoteExtension) s.Require().NoError(err) s.Require().Equal(ctx.BlockHeight(), voteExt.Height) } @@ -86,9 +84,10 @@ func (s *IntegrationTestSuite) TestVerifyVoteExtensionHandler() { app, ctx := s.app, s.ctx pf := MockPriceFeeder() - voteExtension, err := json.Marshal(&cometabci.RequestExtendVote{ + voteExtension := cometabci.RequestExtendVote{ Height: ctx.BlockHeight(), - }) + } + voteExtensionBz, err := voteExtension.Marshal() s.Require().NoError(err) testCases := []struct { @@ -115,7 +114,7 @@ func (s *IntegrationTestSuite) TestVerifyVoteExtensionHandler() { priceFeeder: pf, verifyVoteRequest: &cometabci.RequestVerifyVoteExtension{ Height: ctx.BlockHeight() + 1, - VoteExtension: voteExtension, + VoteExtension: voteExtensionBz, }, expErr: true, expErrMsg: fmt.Sprintf("verify vote extension handler received vote extension height that doesn't"+ @@ -131,7 +130,7 @@ func (s *IntegrationTestSuite) TestVerifyVoteExtensionHandler() { priceFeeder: pf, verifyVoteRequest: &cometabci.RequestVerifyVoteExtension{ Height: ctx.BlockHeight(), - VoteExtension: voteExtension, + VoteExtension: voteExtensionBz, }, expErr: false, }, diff --git a/x/oracle/types/abci.pb.go b/x/oracle/types/abci.pb.go new file mode 100644 index 00000000..d4accf5e --- /dev/null +++ b/x/oracle/types/abci.pb.go @@ -0,0 +1,587 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/oracle/v1/abci.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// OracleVoteExtension defines the vote extension structure used by the oracle +// module. +type OracleVoteExtension struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + ExchangeRates github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"exchange_rates"` +} + +func (m *OracleVoteExtension) Reset() { *m = OracleVoteExtension{} } +func (m *OracleVoteExtension) String() string { return proto.CompactTextString(m) } +func (*OracleVoteExtension) ProtoMessage() {} +func (*OracleVoteExtension) Descriptor() ([]byte, []int) { + return fileDescriptor_a17fd58ec0319b85, []int{0} +} +func (m *OracleVoteExtension) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleVoteExtension) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleVoteExtension.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleVoteExtension) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleVoteExtension.Merge(m, src) +} +func (m *OracleVoteExtension) XXX_Size() int { + return m.Size() +} +func (m *OracleVoteExtension) XXX_DiscardUnknown() { + xxx_messageInfo_OracleVoteExtension.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleVoteExtension proto.InternalMessageInfo + +// InjectedVoteExtensionTx defines the vote extension tx injected by the prepare +// proposal handler. +type InjectedVoteExtensionTx struct { + ExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,1,rep,name=exchange_rate_votes,json=exchangeRateVotes,proto3" json:"exchange_rate_votes"` + ExtendedCommitInfo []byte `protobuf:"bytes,2,opt,name=extended_commit_info,json=extendedCommitInfo,proto3" json:"extended_commit_info,omitempty"` +} + +func (m *InjectedVoteExtensionTx) Reset() { *m = InjectedVoteExtensionTx{} } +func (m *InjectedVoteExtensionTx) String() string { return proto.CompactTextString(m) } +func (*InjectedVoteExtensionTx) ProtoMessage() {} +func (*InjectedVoteExtensionTx) Descriptor() ([]byte, []int) { + return fileDescriptor_a17fd58ec0319b85, []int{1} +} +func (m *InjectedVoteExtensionTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InjectedVoteExtensionTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InjectedVoteExtensionTx.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *InjectedVoteExtensionTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_InjectedVoteExtensionTx.Merge(m, src) +} +func (m *InjectedVoteExtensionTx) XXX_Size() int { + return m.Size() +} +func (m *InjectedVoteExtensionTx) XXX_DiscardUnknown() { + xxx_messageInfo_InjectedVoteExtensionTx.DiscardUnknown(m) +} + +var xxx_messageInfo_InjectedVoteExtensionTx proto.InternalMessageInfo + +func init() { + proto.RegisterType((*OracleVoteExtension)(nil), "ojo.oracle.v1.OracleVoteExtension") + proto.RegisterType((*InjectedVoteExtensionTx)(nil), "ojo.oracle.v1.InjectedVoteExtensionTx") +} + +func init() { proto.RegisterFile("ojo/oracle/v1/abci.proto", fileDescriptor_a17fd58ec0319b85) } + +var fileDescriptor_a17fd58ec0319b85 = []byte{ + // 382 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcf, 0x8e, 0xd3, 0x30, + 0x10, 0xc6, 0xe3, 0x5d, 0xb4, 0x87, 0xc0, 0x22, 0x91, 0x5d, 0x41, 0x54, 0x21, 0x6f, 0xb5, 0xa7, + 0x20, 0xb4, 0x36, 0x65, 0x9f, 0x80, 0x2e, 0x08, 0xf5, 0x84, 0x14, 0x21, 0x0e, 0x1c, 0x88, 0x12, + 0x67, 0xea, 0x38, 0x25, 0x9e, 0x2a, 0x36, 0x25, 0xbc, 0x05, 0x6f, 0x81, 0x04, 0x2f, 0xd2, 0x63, + 0x8f, 0x9c, 0xf8, 0xd3, 0xbe, 0x08, 0x72, 0xfe, 0x08, 0xc2, 0x29, 0x93, 0xf9, 0x3c, 0xdf, 0xfc, + 0xf4, 0x8d, 0x1f, 0x62, 0x89, 0x1c, 0xeb, 0x54, 0xbc, 0x07, 0xbe, 0x99, 0xf1, 0x34, 0x13, 0x8a, + 0xad, 0x6b, 0xb4, 0x18, 0x9c, 0x62, 0x89, 0xac, 0x53, 0xd8, 0x66, 0x36, 0x39, 0x97, 0x28, 0xb1, + 0x55, 0xb8, 0xab, 0xba, 0x47, 0x13, 0x2a, 0xd0, 0x54, 0x68, 0x78, 0x96, 0x1a, 0x37, 0x9f, 0x81, + 0x4d, 0x67, 0x5c, 0xa0, 0xd2, 0xbd, 0x3e, 0x19, 0xdb, 0xf7, 0x76, 0xad, 0x76, 0xf9, 0x85, 0xf8, + 0x67, 0xaf, 0xda, 0xc6, 0x1b, 0xb4, 0xf0, 0xa2, 0xb1, 0xa0, 0x8d, 0x42, 0x1d, 0xdc, 0xf7, 0x4f, + 0x0a, 0x50, 0xb2, 0xb0, 0x21, 0x99, 0x92, 0xe8, 0x38, 0xee, 0xff, 0x82, 0xc6, 0xbf, 0x0b, 0x8d, + 0x28, 0x52, 0x2d, 0x21, 0xa9, 0x53, 0x0b, 0x26, 0x3c, 0x9a, 0x1e, 0x47, 0xb7, 0x9f, 0x3e, 0x64, + 0x1d, 0x04, 0x73, 0x10, 0xac, 0x87, 0x60, 0xcf, 0x41, 0xdc, 0xa0, 0xd2, 0xf3, 0xeb, 0xed, 0x8f, + 0x0b, 0xef, 0xeb, 0xcf, 0x8b, 0xc7, 0x52, 0xd9, 0xe2, 0x43, 0xc6, 0x04, 0x56, 0xbc, 0x87, 0xee, + 0x3e, 0x57, 0x26, 0x5f, 0x71, 0xfb, 0x69, 0x0d, 0x66, 0x98, 0x31, 0xf1, 0xe9, 0xb0, 0x28, 0x76, + 0x7b, 0x2e, 0xbf, 0x11, 0xff, 0xc1, 0x42, 0x97, 0x20, 0x2c, 0xe4, 0x23, 0xd6, 0xd7, 0x4d, 0xf0, + 0xce, 0x3f, 0x1b, 0x51, 0x25, 0x1b, 0x74, 0x68, 0xa4, 0x45, 0x8b, 0xd8, 0x28, 0x44, 0xf6, 0x4c, + 0xca, 0x1a, 0x64, 0xea, 0x1c, 0xfe, 0xfa, 0x3b, 0xc7, 0xf9, 0x2d, 0x87, 0x19, 0xdf, 0x83, 0xff, + 0xfa, 0x26, 0x78, 0xe2, 0x9f, 0x83, 0x5b, 0x97, 0x43, 0x9e, 0x08, 0xac, 0x2a, 0x65, 0x13, 0xa5, + 0x97, 0x18, 0x1e, 0x4d, 0x49, 0x74, 0x27, 0x0e, 0x06, 0xed, 0xa6, 0x95, 0x16, 0x7a, 0x89, 0xf3, + 0x97, 0xdb, 0xdf, 0xd4, 0xdb, 0xee, 0x29, 0xd9, 0xed, 0x29, 0xf9, 0xb5, 0xa7, 0xe4, 0xf3, 0x81, + 0x7a, 0xbb, 0x03, 0xf5, 0xbe, 0x1f, 0xa8, 0xf7, 0xf6, 0xd1, 0x3f, 0x39, 0x60, 0x89, 0x57, 0x1a, + 0xec, 0x47, 0xac, 0x57, 0xae, 0xe6, 0xcd, 0x70, 0xaa, 0x36, 0x8e, 0xec, 0xa4, 0xbd, 0xd3, 0xf5, + 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x73, 0x9c, 0xa3, 0x24, 0x02, 0x00, 0x00, +} + +func (m *OracleVoteExtension) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleVoteExtension) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExchangeRates) > 0 { + for iNdEx := len(m.ExchangeRates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExchangeRates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAbci(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Height != 0 { + i = encodeVarintAbci(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *InjectedVoteExtensionTx) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InjectedVoteExtensionTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InjectedVoteExtensionTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExtendedCommitInfo) > 0 { + i -= len(m.ExtendedCommitInfo) + copy(dAtA[i:], m.ExtendedCommitInfo) + i = encodeVarintAbci(dAtA, i, uint64(len(m.ExtendedCommitInfo))) + i-- + dAtA[i] = 0x12 + } + if len(m.ExchangeRateVotes) > 0 { + for iNdEx := len(m.ExchangeRateVotes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExchangeRateVotes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAbci(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintAbci(dAtA []byte, offset int, v uint64) int { + offset -= sovAbci(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OracleVoteExtension) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovAbci(uint64(m.Height)) + } + if len(m.ExchangeRates) > 0 { + for _, e := range m.ExchangeRates { + l = e.Size() + n += 1 + l + sovAbci(uint64(l)) + } + } + return n +} + +func (m *InjectedVoteExtensionTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ExchangeRateVotes) > 0 { + for _, e := range m.ExchangeRateVotes { + l = e.Size() + n += 1 + l + sovAbci(uint64(l)) + } + } + l = len(m.ExtendedCommitInfo) + if l > 0 { + n += 1 + l + sovAbci(uint64(l)) + } + return n +} + +func sovAbci(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAbci(x uint64) (n int) { + return sovAbci(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OracleVoteExtension) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleVoteExtension: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleVoteExtension: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAbci + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAbci + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExchangeRates = append(m.ExchangeRates, types.DecCoin{}) + if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAbci(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAbci + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InjectedVoteExtensionTx) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: InjectedVoteExtensionTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InjectedVoteExtensionTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRateVotes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAbci + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAbci + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExchangeRateVotes = append(m.ExchangeRateVotes, AggregateExchangeRateVote{}) + if err := m.ExchangeRateVotes[len(m.ExchangeRateVotes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtendedCommitInfo", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAbci + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAbci + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAbci + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtendedCommitInfo = append(m.ExtendedCommitInfo[:0], dAtA[iNdEx:postIndex]...) + if m.ExtendedCommitInfo == nil { + m.ExtendedCommitInfo = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAbci(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAbci + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAbci(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAbci + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAbci + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAbci + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAbci + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAbci + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAbci + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAbci = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAbci = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAbci = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index 29b98fdd..5d4340d6 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -37,4 +37,5 @@ var ( ErrEncodeInjVoteExt = errors.Register(ModuleName, 27, "failed to encode injected vote extension tx") ErrNonEqualInjVotesLen = errors.Register(ModuleName, 28, "number of exchange rate votes in vote extension and extended commit info are not equal") //nolint: lll ErrNonEqualInjVotesRates = errors.Register(ModuleName, 29, "injected exhange rate votes and generated exchange votes are not equal") //nolint: lll + ErrNoCommitInfo = errors.Register(ModuleName, 30, "no commit info in process proposal request") )