Skip to content

False positive when searching for a prefix of a tag value #2908

@feldgendler

Description

@feldgendler

Tendermint version: 0.22.8

The patch below adds a unit test that fails:

--- a/state/txindex/kv/kv_test.go
+++ b/state/txindex/kv/kv_test.go
@@ -89,6 +89,8 @@ func TestTxSearch(t *testing.T) {
                {"account.owner CONTAINS 'an'", 1},
                // search using CONTAINS
                {"account.owner CONTAINS 'Vlad'", 0},
+               // search using a prefix of the stored value
+               {"account.owner = 'Iv'", 0},
        }

        for _, tc := range testCases {

The stored value for account.owner is Ivan, but searching for just Iv produces a false positive.

The reason this happens is that startKey in state/txindex/kv/kv.go returns a prefix that matches too much: account.owner/Iv in this case. To avoid false positives, it should rather return account.owner/Iv/.

There is probably a similar bug where matchRange looks up key when it really should look up key/.

Metadata

Metadata

Assignees

Labels

C:rpcComponent: JSON RPC, gRPCT:bugType Bug (Confirmed)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions