Skip to content

Commit a7311f5

Browse files
author
LazyLuis
committed
enhance verification
1 parent e087b1f commit a7311f5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

x/oracle/abci/extension.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ func (h *PriceOracleVoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler {
7171
h.logger.Error("failed to fetch bitcoin headers", "error", err)
7272
}
7373
voteExt := types.OracleVoteExtension{
74-
Height: req.Height,
75-
Prices: prices,
76-
Blocks: headers,
74+
Height: req.Height,
75+
Prices: prices,
76+
Blocks: headers,
77+
HasError: err != nil,
7778
}
7879

7980
bz, err := voteExt.Marshal()
@@ -103,6 +104,16 @@ func (h *PriceOracleVoteExtHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteE
103104
return nil, fmt.Errorf("vote extension height does not match request height; expected: %d, got: %d", req.Height, voteExt.Height)
104105
}
105106

107+
for _, symbol := range types.SupportedPairs {
108+
if _, ok := voteExt.Prices[symbol]; !ok {
109+
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
110+
}
111+
}
112+
113+
if voteExt.HasError {
114+
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil
115+
}
116+
106117
for _, blk := range voteExt.Blocks {
107118
if err = blk.Validate(); err != nil {
108119
return nil, types.ErrInvalidBlockHeader

x/oracle/types/keys.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const (
3232
)
3333

3434
var (
35+
SupportedPairs = []string{BTCUSD}
36+
3537
Percent = math.NewInt(100)
3638
Permille = math.NewInt(1000)
3739

0 commit comments

Comments
 (0)