chainhook icon indicating copy to clipboard operation
chainhook copied to clipboard

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

Open timstackblock opened this issue 2 years ago • 3 comments

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

timstackblock avatar Jul 25 '23 17:07 timstackblock

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.

lgalabru avatar Jul 31 '23 06:07 lgalabru

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

timstackblock avatar Aug 01 '23 14:08 timstackblock

Confirmed that expire_after_occurrence is not working as expected.

  • Predicate: to expire after 3 occurrences
{
  "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
    }
  }
}
  • Output: found 6 occurrences
{"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"}

csgui avatar Jan 09 '24 13:01 csgui