onflow / kitty-items

Kitty Items: CryptoKitties Sample App

Home Page:https://kitty-items.onflow.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential listing event edge case

MrDSGC opened this issue · comments

Context
Example scenario:

  • ListingAvailable event is detected in block 19.
  • This calls StorefrontService.addListing, which in turn executes the get_listing_item.cdc Cadence script on the emulator. It calls this script because it only has the listing ID -- it needs more information about the listing to insert into the database.
  • This uses fcl.query, which by default executes the script against the state from the current latest block.
  • The kicker is: by this point, the latest block is 20, which is the block at which that listing was removed. The script returns empty because the listing no longer exists at that version of the blockchain state.

So if this is a problem (I'm just guessing at this point), one possible solution would be to make the event processors "block height aware". i.e. If a ListingAvailable event is detected at block 19, then the script to fetch the listing is also executed at block 19.

Definition of Done

  • recreate example scenario and verify edgecase
  • address edge case if found (potential fix: execute script on specific block). if unable to recreate, close ticket.