From 14e6e9f9bd386c0eec5d0d0bc138f716d4b5d772 Mon Sep 17 00:00:00 2001 From: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com> Date: Wed, 2 Oct 2024 08:57:15 -0700 Subject: [PATCH] cleanup + fix tx processing issue --- app/preblocker.go | 38 ++++++++++++++++++-------------------- x/gasestimate/abci.go | 12 ------------ 2 files changed, 18 insertions(+), 32 deletions(-) delete mode 100644 x/gasestimate/abci.go diff --git a/app/preblocker.go b/app/preblocker.go index 9238bb64..0df1c144 100644 --- a/app/preblocker.go +++ b/app/preblocker.go @@ -47,28 +47,26 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock) } voteExtensionsEnabled := abci.VoteExtensionsEnabled(ctx) if voteExtensionsEnabled { - for _, tx := range req.Txs { - var injectedVoteExtTx types.InjectedVoteExtensionTx - if err := injectedVoteExtTx.Unmarshal(tx); err != nil { - app.Logger().Error("failed to decode injected vote extension tx", "err", err) - return nil, err - } - for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes { - valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter) - if err != nil { - app.Logger().Error("failed to get voter address", "err", err) - continue - } - app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote) - } - for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians { - app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{ - Network: gasEstimate.Network, - GasEstimate: gasEstimate.GasEstimation, - }) + 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 + } + for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes { + valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter) + if err != nil { + app.Logger().Error("failed to get voter address", "err", err) + continue } - app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians) + app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote) + } + for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians { + app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{ + Network: gasEstimate.Network, + GasEstimate: gasEstimate.GasEstimation, + }) } + app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians) } app.Logger().Info( diff --git a/x/gasestimate/abci.go b/x/gasestimate/abci.go deleted file mode 100644 index 21e8c86e..00000000 --- a/x/gasestimate/abci.go +++ /dev/null @@ -1,12 +0,0 @@ -package gasestimate - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/ojo-network/ojo/x/gasestimate/keeper" -) - -// EndBlocker is called at the end of every block -func EndBlocker(_ sdk.Context, _ keeper.Keeper) error { - return nil -}