hirosystems / chainhook

Extract transactions from Stacks and Bitcoin and build event driven re-org resistant indexers and databases.
GNU General Public License v3.0
147 stars 60 forks source link

expire after 1 occurrence doesn't seem to limit the data returned to 1 occurrence #353

Open timstackblock opened 1 year ago

timstackblock commented 1 year ago

Describe the bug I am searching for a stx event and I expected the predicate to only return the first occurrence since I specified "expire_after_occurance=1" maybe this functionality doesn't work but it is listed in the document so I wanted to test it out. Please let me know if something should be changed to get this to work on my end.

Screen Shot 2023-07-25 at 1 01 13 PM

I was expecting only the first record but it returned all of them

Screen Shot 2023-07-25 at 1 06 00 PM
lgalabru commented 1 year ago

Thanks for the time spent on this @timstackblock, I think it's time for us to take on https://github.com/hirosystems/chainhook/issues/287.

Note: we have some unit tests for this feature when chainhook runs as a service, but the scan command (which was re-introduced relatively recently) is using a few codepath that we should deprecate / update.

timstackblock commented 1 year ago

Ok I have pushed up my test here https://github.com/hirosystems/chainhook/pull/347#issuecomment-1660404718 some are blocked by the corresponding bugs I found but I will comment on https://github.com/hirosystems/chainhook/issues/287

csgui commented 10 months ago

Confirmed that expire_after_occurrence is not working as expected.

{
  "chain": "stacks",
  "uuid": "1950fbed-85b5-467f-b4ac-fc464e18e021",
  "name": "STX event file",
  "version": 1,
  "networks": {
    "testnet": {
      "if_this": {
        "scope": "stx_event",
        "actions": ["transfer", "lock"]
      },
      "then_that": {
        "file_append": {
          "path": "test-out.json"
        }
      },
      "start_block": 113310,
      "end_block": 113315,
      "expire_after_occurrence": 3
    }
  }
}
{"msg":"Stacks archive file already up to date","level":"INFO","ts":"2024-01-09T13:47:40.459073Z"}
{"msg":"Starting predicate evaluation on Stacks blocks","level":"INFO","ts":"2024-01-09T13:48:57.741336Z"}
{"msg":"6 blocks scanned, 6 occurrences found","level":"INFO","ts":"2024-01-09T13:48:58.734843Z"}