@@ -45,7 +45,7 @@ func NewPriceOracleVoteExtHandler(logger log.Logger, valStore baseapp.ValidatorS
4545 }
4646
4747 return PriceOracleVoteExtHandler {
48- logger : logger ,
48+ logger : logger . With ( "module" , types . ModuleName ) ,
4949 currentBlock : 0 ,
5050 valStore : valStore ,
5151 Keeper : oracleKeeper ,
@@ -94,7 +94,6 @@ func (h *PriceOracleVoteExtHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteE
9494 }
9595
9696 validator := hex .EncodeToString (req .ValidatorAddress )
97- h .logger .Info ("VerifyVoteExtensionHandler" , "height" , req .Height , "validator" , validator )
9897 var voteExt types.OracleVoteExtension
9998 err := voteExt .Unmarshal (req .VoteExtension )
10099 if err != nil {
@@ -105,16 +104,7 @@ func (h *PriceOracleVoteExtHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteE
105104 return nil , fmt .Errorf ("vote extension height does not match request height; expected: %d, got: %d" , req .Height , voteExt .Height )
106105 }
107106
108- // if len(voteExt.Prices) > 0 {
109- // // check if a fack price is existing.
110- // if _, ok := voteExt.Prices[types.NULL_SYMBOL]; !ok {
111- // return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
112- // }
113- // }
114-
115- // if voteExt.HasError {
116- // return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
117- // }
107+ h .logger .Debug ("verify" , "height" , req .Height , "validator" , validator , "prices" , voteExt .Prices , "blocks" , voteExt .Blocks )
118108
119109 for _ , blk := range voteExt .Blocks {
120110 if err = blk .Validate (); err != nil {
@@ -222,7 +212,7 @@ func (h *PriceOracleVoteExtHandler) getAllVolumeWeightedPrices() map[string]stri
222212 }
223213 }
224214
225- h .logger .Info ( "AvgPrice " , "prices" , avgPrices )
215+ h .logger .Debug ( "avg exchange prices " , "prices" , avgPrices )
226216
227217 textPrices := make (map [string ]string )
228218 for symbol , price := range avgPrices {
@@ -321,7 +311,7 @@ func (h *PriceOracleVoteExtHandler) PreBlocker(ctx sdk.Context, req *abci.Reques
321311 return nil , err
322312 }
323313
324- h .logger .Warn ("Oracle Final States" , "price" , prices )
314+ h .logger .Info ("Oracle Final States" , "price" , prices , "headers" , headers )
325315
326316 return res , nil
327317}
@@ -345,7 +335,7 @@ func (h *PriceOracleVoteExtHandler) extractPricesAndBlockHeaders(_ sdk.Context,
345335 return nil , nil , err
346336 }
347337
348- h .logger .Warn ( "extension " , "validator" , hex .EncodeToString (v .Validator .Address ), "extension" , voteExt )
338+ h .logger .Debug ( "received " , "validator" , hex .EncodeToString (v .Validator .Address ), "extension" , voteExt )
349339
350340 totalStake += v .Validator .Power
351341
@@ -390,10 +380,11 @@ func (h *PriceOracleVoteExtHandler) extractPricesAndBlockHeaders(_ sdk.Context,
390380 }
391381
392382 // finalize average by dividing by total stake, i.e. total weights
383+ finalPrices := make (map [string ]math.LegacyDec , len (types .PRICE_CACHE ))
393384 for base , price := range stakeWeightedPrices {
394385 if price .GT (math .LegacyZeroDec ()) {
395386 if vp , ok := stakeWeightedVotingPower [base ]; ok && vp .RoundInt64 ()* 3 > totalStake * 2 {
396- stakeWeightedPrices [base ] = price .Quo (vp )
387+ finalPrices [base ] = price .Quo (vp )
397388 }
398389 } else {
399390 h .logger .Error ("Got invalid price." , "symbal" , base , "price" , price )
@@ -407,7 +398,7 @@ func (h *PriceOracleVoteExtHandler) extractPricesAndBlockHeaders(_ sdk.Context,
407398 break
408399 }
409400 }
410- return stakeWeightedPrices , headers , nil
401+ return finalPrices , headers , nil
411402}
412403
413404func voteExtensionEnabled (ctx sdk.Context , height int64 ) bool {
0 commit comments