Skip to content

Commit

Permalink
rename createprice to pricefeed
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Jan 25, 2025
1 parent 6c95eac commit 2b0e8a1
Show file tree
Hide file tree
Showing 29 changed files with 329 additions and 328 deletions.
6 changes: 3 additions & 3 deletions app/ante/cosmos/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
return newCtx, sdkerrors.ErrTxDecode.Wrap("Tx must be GasTx")
}

// If the transaction is an OracleCreatePriceTx, we set the gas meter to infinite
// NOTE: this works fine with cosmossdk-noopmempool+tendermint-mempool, since tenderminit used gasMeter.Limit() to check the gaswanted of tx insteand of tx.GetGas(), but if works with application mempool, we need to be caution of the tx.GetGas() since oracle create-price tx doesn't really pay.
if anteutils.IsOracleCreatePriceTx(tx) {
// If the transaction is an OraclePriceFeedTx, we set the gas meter to infinite
// NOTE: this works fine with cosmossdk-noopmempool+tendermint-mempool, since tenderminit used gasMeter.Limit() to check the gaswanted of tx insteand of tx.GetGas(), but if works with application mempool, we need to be caution of the tx.GetGas() since oracle price-feed tx doesn't really pay.
if anteutils.IsOraclePriceFeedTx(tx) {
newCtx = ctx.WithGasMeter(evmostypes.NewInfiniteGasMeterWithLimit(0))
return next(newCtx, tx, simulate)
}
Expand Down
2 changes: 1 addition & 1 deletion app/ante/cosmos/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
return ctx, errorsmod.Wrap(errortypes.ErrTxDecode, "Tx must be a FeeTx")
}

if anteutils.IsOracleCreatePriceTx(tx) {
if anteutils.IsOraclePriceFeedTx(tx) {
newCtx := ctx.WithPriority(math.MaxInt64)
return next(newCtx, tx, simulate)
}
Expand Down
2 changes: 1 addition & 1 deletion app/ante/cosmos/min_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "invalid transaction type %T, expected sdk.FeeTx", tx)
}

if anteutils.IsOracleCreatePriceTx(tx) {
if anteutils.IsOraclePriceFeedTx(tx) {
return next(ctx, tx, simulate)
}

Expand Down
14 changes: 7 additions & 7 deletions app/ante/cosmos/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func NewSetPubKeyDecorator(ak authante.AccountKeeper) SetPubKeyDecorator {
}

func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// skip publickkey set for oracle create-price message
if utils.IsOracleCreatePriceTx(tx) {
// skip publickkey set for oracle price-feed message
if utils.IsOraclePriceFeedTx(tx) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.ErrTxDecode.Wrap("invalid transaction type, expected SigVerifiableTx")
Expand Down Expand Up @@ -173,7 +173,7 @@ func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
return ctx, sdkerrors.ErrTxDecode.Wrap("invalid transaction type, expected SigVerifiableTx")
}

if utils.IsOracleCreatePriceTx(tx) {
if utils.IsOraclePriceFeedTx(tx) {
return next(ctx, tx, simulate)
}

Expand Down Expand Up @@ -258,7 +258,7 @@ func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool {
}

func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
if utils.IsOracleCreatePriceTx(tx) {
if utils.IsOraclePriceFeedTx(tx) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if !ok {
return ctx, sdkerrors.ErrTxDecode.Wrap("invalid transaction type, expected SigVerifiableTx")
Expand Down Expand Up @@ -385,10 +385,10 @@ func NewIncrementSequenceDecorator(ak authante.AccountKeeper, oracleKeeper utils
}

func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// oracle create-price message dont need to increment sequence, check its nonce instead
if utils.IsOracleCreatePriceTx(tx) {
// oracle price-feed message dont need to increment sequence, check its nonce instead
if utils.IsOraclePriceFeedTx(tx) {
for _, msg := range tx.GetMsgs() {
msg := msg.(*oracletypes.MsgCreatePrice)
msg := msg.(*oracletypes.MsgPriceFeed)
if accAddress, err := sdk.AccAddressFromBech32(msg.Creator); err != nil {
return ctx, errors.New("invalid address")
// #nosec G115 // safe conversion
Expand Down
6 changes: 3 additions & 3 deletions app/ante/cosmos/txsize_gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
return ctx, sdkerrors.ErrTxDecode.Wrap("invalid tx type")
}

// Skip gas consumption if tx is an OracleCreatePriceTx
if anteutils.IsOracleCreatePriceTx(tx) {
// Skip gas consumption if tx is an OraclePriceFeedTx
if anteutils.IsOraclePriceFeedTx(tx) {
if len(ctx.TxBytes()) > anteutils.TxSizeLimit {
return ctx, sdkerrors.ErrTxTooLarge.Wrapf("oracle create-price tx has exceeds size limit, limit:%d, got:%d", anteutils.TxSizeLimit, len(ctx.TxBytes()))
return ctx, sdkerrors.ErrTxTooLarge.Wrapf("oracle price-feed tx has exceeds size limit, limit:%d, got:%d", anteutils.TxSizeLimit, len(ctx.TxBytes()))
}
return next(ctx, tx, simulate)
}
Expand Down
2 changes: 1 addition & 1 deletion app/ante/evm/fee_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewGasWantedDecorator(
}

func (gwd GasWantedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
if anteutils.IsOracleCreatePriceTx(tx) {
if anteutils.IsOraclePriceFeedTx(tx) {
return next(ctx, tx, simulate)
}
evmParams := gwd.evmKeeper.GetParams(ctx)
Expand Down
6 changes: 3 additions & 3 deletions app/ante/utils/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// TxSizeLimit limits max size of a create-price tx, this is calculated based on one nativeTokenbalance message of worst case(max size), which will need 576 bytes for balance update
// TxSizeLimit limits max size of a price-feed tx, this is calculated based on one nativeTokenbalance message of worst case(max size), which will need 576 bytes for balance update
const TxSizeLimit = 1000

func IsOracleCreatePriceTx(tx sdk.Tx) bool {
func IsOraclePriceFeedTx(tx sdk.Tx) bool {
msgs := tx.GetMsgs()
if len(msgs) == 0 {
return false
}
for _, msg := range msgs {
if _, ok := msg.(*oracletypes.MsgCreatePrice); !ok {
if _, ok := msg.(*oracletypes.MsgPriceFeed); !ok {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func NewExocoreApp(

// Setup Mempool and Proposal Handlers
baseAppOptions = append(baseAppOptions, func(app *baseapp.BaseApp) {
// NOTE: we use a NoOpMempool here, for oracle create-price, it works fine since we have set a infinitgasmeterwithlimit in the ante handler to avoid the out-of-gas error no matter what the amount/gas is set by tx builder, and we set the highest priority for oracle create-price txs to work properly with tendermint mempool to make sure oracle creat-prie tx will be included in the mempool if received. And if we want to use some other application mempool, we need to take care of the gas limit and gas price in the oracle create-price txs.(we don't need to bother this since tendermint mempool use gasMeter.limit() instead of tx.Gas())
// NOTE: we use a NoOpMempool here, for oracle price-feed, it works fine since we have set a infinitgasmeterwithlimit in the ante handler to avoid the out-of-gas error no matter what the amount/gas is set by tx builder, and we set the highest priority for oracle price-feed txs to work properly with tendermint mempool to make sure oracle creat-prie tx will be included in the mempool if received. And if we want to use some other application mempool, we need to take care of the gas limit and gas price in the oracle price-feed txs.(we don't need to bother this since tendermint mempool use gasMeter.limit() instead of tx.Gas())
mempool := mempool.NoOpMempool{}
app.SetMempool(mempool)
handler := baseapp.NewDefaultProposalHandler(mempool, app)
Expand Down
24 changes: 12 additions & 12 deletions client/docs/swagger-ui/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -18811,10 +18811,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"title": "cached messages"
}
Expand Down Expand Up @@ -18999,10 +18999,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"title": "cached messages"
}
Expand Down Expand Up @@ -40922,10 +40922,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"exocore.oracle.v1.NOMSource": {
"type": "object",
Expand Down Expand Up @@ -41393,10 +41393,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"title": "cached messages"
}
Expand Down Expand Up @@ -41896,10 +41896,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"title": "cached messages"
}
Expand Down Expand Up @@ -42705,10 +42705,10 @@
},
"validator": {
"type": "string",
"title": "validator tells which validator create this price"
"title": "validator tells which validator provide this price"
}
},
"title": "MsgItem represents the message info of createPrice"
"title": "MsgItem represents the message info of priceFeed"
},
"title": "cached messages"
}
Expand Down
4 changes: 2 additions & 2 deletions proto/exocore/oracle/v1/recent_msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ message RecentMsg {
repeated MsgItem msgs = 2;
}

// MsgItem represents the message info of createPrice
// MsgItem represents the message info of priceFeed
message MsgItem {
// feeder_id tells of wich feeder this price if corresponding to
uint64 feeder_id = 2 [(gogoproto.customname) = "FeederID"];
// p_source price with its source info
repeated PriceSource p_sources = 3;
// validator tells which validator create this price
// validator tells which validator provide this price
string validator = 4;
}
12 changes: 6 additions & 6 deletions proto/exocore/oracle/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ option go_package = "github.com/ExocoreNetwork/exocore/x/oracle/types";

// Msg defines the Msg service.
service Msg {
// CreatePrice creates price for a new oracle round
rpc CreatePrice(MsgCreatePrice) returns (MsgCreatePriceResponse);
// PriceFeed creates price for a new oracle round
rpc PriceFeed(MsgPriceFeed) returns (MsgPriceFeedResponse);
// UpdateParams update params value
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgCreatePrice provide the price updating message
message MsgCreatePrice {
// MsgPriceFeed provide the price updating message
message MsgPriceFeed {
// creator tells which is the message sender and should sign this message
string creator = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
// refer to id from Params.TokenFeeders, 0 is reserved, invalid to use
Expand All @@ -34,8 +34,8 @@ message MsgCreatePrice {
int32 nonce = 5;
}

// MsgCreatePriceResponse
message MsgCreatePriceResponse {}
// MsgPriceFeedResponse
message MsgPriceFeedResponse {}

// MsgUpdateParms
message MsgUpdateParams {
Expand Down
Loading

0 comments on commit 2b0e8a1

Please sign in to comment.