Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getMsgInfo returns an ErrNotFound when there are no rows #12680

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- Make `EthTraceFilter` / `trace_filter` skip null rounds instead of erroring. ([filecoin-project/lotus#12702](https://github.com/filecoin-project/lotus/pull/12702))
- Event APIs (`GetActorEventsRaw`, `SubscribeActorEventsRaw`, `eth_getLogs`, `eth_newFilter`, etc.) will now return an error when a request matches more than `MaxFilterResults` (default: 10,000) rather than silently truncating the results. Also apply an internal event matcher for `eth_getLogs` (etc.) to avoid builtin actor events on database query so as not to include them in `MaxFilterResults` calculation. ([filecoin-project/lotus#12671](https://github.com/filecoin-project/lotus/pull/12671))
- GetMsgInfo returns an ErrNotFound when there are no rows ([filecoin-project/lotus#12680](https://github.com/filecoin-project/lotus/pull/12680))
rvagg marked this conversation as resolved.
Show resolved Hide resolved

## New Features

Expand Down
3 changes: 3 additions & 0 deletions chain/index/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (si *SqliteIndexer) GetMsgInfo(ctx context.Context, messageCid cid.Cid) (*M
var height int64

if err := si.queryMsgInfo(ctx, messageCid, &tipsetKeyCidBytes, &height); err != nil {
if err == sql.ErrNoRows {
return nil, ErrNotFound
}
return nil, err
}

Expand Down
39 changes: 25 additions & 14 deletions chain/index/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,34 @@ func TestGetMsgInfo(t *testing.T) {
t.Logf("seed: %d", seed)
rng := pseudo.New(pseudo.NewSource(seed))
s, _, _ := setupWithHeadIndexed(t, 10, rng)
msgCid := randomCid(t, rng)
msgCidBytes := msgCid.Bytes()
tsKeyCid := randomCid(t, rng)

insertTipsetMessage(t, s, tipsetMessage{
tipsetKeyCid: tsKeyCid.Bytes(),
height: uint64(1),
reverted: false,
messageCid: msgCidBytes,
messageIndex: 1,
t.Run("message exists", func(t *testing.T) {
msgCid := randomCid(t, rng)
msgCidBytes := msgCid.Bytes()
tsKeyCid := randomCid(t, rng)

insertTipsetMessage(t, s, tipsetMessage{
tipsetKeyCid: tsKeyCid.Bytes(),
height: uint64(1),
reverted: false,
messageCid: msgCidBytes,
messageIndex: 1,
})

mi, err := s.GetMsgInfo(ctx, msgCid)
require.NoError(t, err)
require.Equal(t, msgCid, mi.Message)
require.Equal(t, tsKeyCid, mi.TipSet)
require.Equal(t, abi.ChainEpoch(1), mi.Epoch)
})

mi, err := s.GetMsgInfo(ctx, msgCid)
require.NoError(t, err)
require.Equal(t, msgCid, mi.Message)
require.Equal(t, tsKeyCid, mi.TipSet)
require.Equal(t, abi.ChainEpoch(1), mi.Epoch)
t.Run("message not found", func(t *testing.T) {
nonExistentMsgCid := randomCid(t, rng)
mi, err := s.GetMsgInfo(ctx, nonExistentMsgCid)
require.Error(t, err)
require.ErrorIs(t, err, ErrNotFound)
require.Nil(t, mi)
})
}

func setupWithHeadIndexed(t *testing.T, headHeight abi.ChainEpoch, rng *pseudo.Rand) (*SqliteIndexer, *types.TipSet, *dummyChainStore) {
Expand Down
Loading