diff --git a/node/impl/full/state.go b/node/impl/full/state.go index de1b77b4fc4..59fdd8e2e4c 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -808,8 +808,31 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *api.MessageMatc if match.To == address.Undef && match.From == address.Undef { return nil, xerrors.Errorf("must specify at least To or From in message filter") + } else if match.To != address.Undef { + _, err := a.StateLookupID(ctx, match.To, tsk) + + // if the recipient doesn't exist at the start point, we're not gonna find any matches + if xerrors.Is(err, types.ErrActorNotFound) { + return nil, nil + } + + if err != nil { + return nil, xerrors.Errorf("looking up match.To: %w", err) + } + } else if match.From != address.Undef { + _, err := a.StateLookupID(ctx, match.From, tsk) + + // if the sender doesn't exist at the start point, we're not gonna find any matches + if xerrors.Is(err, types.ErrActorNotFound) { + return nil, nil + } + + if err != nil { + return nil, xerrors.Errorf("looking up match.From: %w", err) + } } + // TODO: This should probably match on both ID and robust address, no? matchFunc := func(msg *types.Message) bool { if match.From != address.Undef && match.From != msg.From { return false