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 getting event logs by topic #9819

Merged
merged 1 commit into from
Dec 8, 2022
Merged

Conversation

iand
Copy link
Contributor

@iand iand commented Dec 8, 2022

Related Issues

Fixes filecoin-project/ref-fvm#1207

Proposed Changes

Finding event logs in the historical index by topic was broken for a few separate reasons:

  1. sometime between original implementation and FIP-0049 landing the indexable flag was split into 2 distinct flags - this PR adds these as constants in the types package
  2. decoding the cbor encoded byte array values was added as a fix in the api but didn't find its way into the database code which was recording cbor encoded versions of the entry values
  3. the query code was not accounting for zero padding of the topic byte arrays

Points 1+2 result in bad data in the database so any existing indexed events will not be retrievable by topic even after this PR is merged. They are still retrievable via other criteria. New events logged after this merge is deployed should be fine.

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@iand iand requested a review from a team as a code owner December 8, 2022 17:29
@arajasek arajasek merged commit 6da93cf into feat/nv18-events Dec 8, 2022
@arajasek arajasek deleted the issue/ref-fvm-1207 branch December 8, 2022 19:29
@jaeaster
Copy link

Question on these fixes... I'm seeing behavior where I can query for an event and find it
if fromBlock == targetBlock == toBlock,
but not when fromBlock < targetBlock < toBlock

e.g.

await provider.getLogs({
  address: "0xa3743970690B21043c5d14A0c9418DC7bAF33A3d",
  fromBlock: 15638,
  toBlock: 15639,
  topics: []
})
=> []

await provider.getLogs({
  address: "0xa3743970690B21043c5d14A0c9418DC7bAF33A3d",
  fromBlock: 15639,
  toBlock: 15639,
  topics: []
})
=> (3) [{…}, {…}, {…}]

Does this PR fix this issue? Otherwise, I'll open another issue. I'm not sure if the cbor encoding problem applies to block numbers (probably not)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants