dipdup-io / dipdup

Modular framework for creating selective indexers and featureful backends for dapps
https://dipdup.io
MIT License
92 stars 52 forks source link

Can't seem to mix contracts with code_hash and address in an index #584

Closed 852Kerfunkle closed 1 year ago

852Kerfunkle commented 1 year ago

Steps to reproduce:

Config (functional excerpt):

contracts:
  tezlandItemsV2:
    address: KT1Fw3CTyc3b1tQDhQrvq6vCd4wNphSm1qgg
    typename: tezlandFA2FungibleV2

  tezlandFactory:
    address: KT1Qo5rBCWDCqo124ccdWsd4TKN8NAUVpHZR
    typename: tezlandFactory

  tezlandItemsCollection:
    code_hash: -767789104
    typename: tezlandItemsCollection

indexes:
  tezland_mainnet:
    kind: operation
    datasource: tzkt_mainnet
    contracts: 
      - tezlandItemsV2
      - tezlandFactory
      - tezlandItemsCollection
    types:
      - transaction
      - origination
    handlers:
      # FA2 Item V2
      - callback: on_item_transfer
        pattern:
          - type: transaction
            destination: tezlandItemsV2
            entrypoint: transfer
      - callback: on_item_v2_mint
        pattern:
          - type: transaction
            destination: tezlandItemsV2
            entrypoint: mint
      - callback: on_item_burn
        pattern:
          - type: transaction
            destination: tezlandItemsV2
            entrypoint: burn

      # Items Collection
      - callback: on_item_v2_mint
        pattern:
          - type: transaction
            destination: tezlandItemsCollection
            entrypoint: mint
      - callback: on_item_burn
        pattern:
          - type: transaction
            destination: tezlandItemsCollection
            entrypoint: burn
      - callback: on_item_transfer
        pattern:
          - type: transaction
            destination: tezlandItemsCollection
            entrypoint: transfer

      # Factory
      - callback: on_create_token
        pattern:
          - type: origination
            source: tezlandFactory

Log output with code_hash contract in index:

INFO     dipdup.index         tezland_mainnet: Index is behind the datasource level, syncing: 0 -> 371
INFO     dipdup.index         tezland_mainnet: Synchronizing index to level 371
INFO     dipdup.index         tezland_mainnet: Fetching operations from level 1 to 371
WARNING  dipdup.fetcher       `source.address` filter significantly hurts indexing performance and doesn't support strict typing. Consider using `originated_contract.code_hash` instead
INFO     dipdup.tzkt          tzkt_mainnet: Fetching originated contracts for address `KT1UJCCAx2nS2W8sFhmP1KFDot5Wxikkbnnk`
INFO     dipdup.fetcher       Fetching originations from 3 addresses and 0 code hashes
INFO     dipdup.index         tezland_mainnet: Processing operations of level 122
INFO     dipdup.matcher       opHEEbvG5m3U2fS5239vniZfDDpPy31Yyyz3uKK3RsL7JSL5Bz9: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: opHEEbvG5m3U2fS5239vniZfDDpPy31Yyyz3uKK3RsL7JSL5Bz9: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `79`
INFO     dipdup.index         tezland_mainnet: Processing operations of level 248
INFO     dipdup.matcher       onvhiMSvZCcDmcXBrbGwgg4Gf1hvwnnsEu9ey1Re3p137v8CJod: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: onvhiMSvZCcDmcXBrbGwgg4Gf1hvwnnsEu9ey1Re3p137v8CJod: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `84`
INFO     dipdup.index         tezland_mainnet: Processing operations of level 264
INFO     dipdup.matcher       ooH62eKG4xCGRszafkPG9eguav2fpJo6in8uBEjutYYY1bawbJv: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: ooH62eKG4xCGRszafkPG9eguav2fpJo6in8uBEjutYYY1bawbJv: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `89`
INFO     dipdup.index         tezland_mainnet: Index is synchronized to level 371
WARNING  landex.hooks.on_synchronized Database backup failed: Not postgres database, skipping backup
INFO     dipdup.tzkt          tzkt_mainnet: Subscribing to 5 channels
INFO     dipdup               Spawning datasources
INFO     dipdup.tzkt          tzkt_mainnet: Creating SignalR client
INFO     dipdup.tzkt          tzkt_mainnet: Establishing realtime connection
INFO     dipdup.tzkt          tzkt_mainnet: Realtime connection established
INFO     dipdup.tzkt          tzkt_mainnet: Subscribed to 5 channels
INFO     dipdup.tzkt          tzkt_mainnet: Realtime message received: head, DATA, 371 -> 372

Log output without code_hash contract in index:

INFO     dipdup.index         tezland_mainnet: Index is behind the datasource level, syncing: 0 -> 399
INFO     dipdup.index         tezland_mainnet: Synchronizing index to level 399
INFO     dipdup.index         tezland_mainnet: Fetching operations from level 1 to 399
WARNING  dipdup.fetcher       `source.address` filter significantly hurts indexing performance and doesn't support strict typing. Consider using `originated_contract.code_hash` instead
INFO     dipdup.tzkt          tzkt_mainnet: Fetching originated contracts for address `KT1UJCCAx2nS2W8sFhmP1KFDot5Wxikkbnnk`
INFO     dipdup.fetcher       Fetching originations from 3 addresses and 0 code hashes
INFO     dipdup.index         tezland_mainnet: Processing operations of level 55
INFO     dipdup.matcher       onf6DP3rb9sjvvfRWNzCX3Ppt7ZZ8MhitLYUdqMnzeA5BAyQCef: `on_item_v2_mint` handler matched!
INFO     dipdup.index         tezland_mainnet: onf6DP3rb9sjvvfRWNzCX3Ppt7ZZ8MhitLYUdqMnzeA5BAyQCef: `on_item_v2_mint` handler matched!
INFO     dipdup.matcher       onf6DP3rb9sjvvfRWNzCX3Ppt7ZZ8MhitLYUdqMnzeA5BAyQCef: `on_item_v2_mint` handler matched!
INFO     dipdup.index         tezland_mainnet: onf6DP3rb9sjvvfRWNzCX3Ppt7ZZ8MhitLYUdqMnzeA5BAyQCef: `on_item_v2_mint` handler matched!
INFO     dipdup.index         tezland_mainnet: Processing operations of level 62
INFO     dipdup.matcher       ooadUEHRz7AhYVtiKYzwYECAH6QaJF8nAaQawZe52wBUuY2exUD: `on_item_transfer` handler matched!
INFO     dipdup.index         tezland_mainnet: ooadUEHRz7AhYVtiKYzwYECAH6QaJF8nAaQawZe52wBUuY2exUD: `on_item_transfer` handler matched!
INFO     dipdup.index         tezland_mainnet: Processing operations of level 122
INFO     dipdup.matcher       opHEEbvG5m3U2fS5239vniZfDDpPy31Yyyz3uKK3RsL7JSL5Bz9: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: opHEEbvG5m3U2fS5239vniZfDDpPy31Yyyz3uKK3RsL7JSL5Bz9: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `79`
INFO     dipdup.index         tezland_mainnet: Processing operations of level 248
INFO     dipdup.matcher       onvhiMSvZCcDmcXBrbGwgg4Gf1hvwnnsEu9ey1Re3p137v8CJod: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: onvhiMSvZCcDmcXBrbGwgg4Gf1hvwnnsEu9ey1Re3p137v8CJod: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `84`
INFO     dipdup.index         tezland_mainnet: Processing operations of level 264
INFO     dipdup.matcher       ooH62eKG4xCGRszafkPG9eguav2fpJo6in8uBEjutYYY1bawbJv: `on_create_token` handler matched!
INFO     dipdup.index         tezland_mainnet: ooH62eKG4xCGRszafkPG9eguav2fpJo6in8uBEjutYYY1bawbJv: `on_create_token` handler matched!
INFO     dipdup.tzkt          tzkt_mainnet: Fetching keys of bigmap `89`
INFO     dipdup.index         tezland_mainnet: Index is synchronized to level 399
WARNING  landex.hooks.on_synchronized Database backup failed: Not postgres database, skipping backup
INFO     dipdup.tzkt          tzkt_mainnet: Subscribing to 4 channels
INFO     dipdup               Spawning datasources
INFO     dipdup.tzkt          tzkt_mainnet: Creating SignalR client
INFO     dipdup.tzkt          tzkt_mainnet: Establishing realtime connection
INFO     dipdup.tzkt          tzkt_mainnet: Realtime connection established
INFO     dipdup.tzkt          tzkt_mainnet: Subscribed to 4 channels
INFO     dipdup.tzkt          tzkt_mainnet: Realtime message received: head, DATA, 399 -> 400

What did you expect to happen:

Expected result is dipdup working normally and all entry points on all contracts in the index being processed.

What actually happened:

The only callback being called in this case is on_create_token - and neither the callbacks by address or by code hash are.

Environment

852Kerfunkle commented 1 year ago

A working branch showing the problem: https://github.com/tz1and/tezland-indexer/tree/code_hash-issue

You should be able to just run make run and/or make run-clean (assuming you ran poetry install first).

Try commenting out the handlers under # Items Collection, to see the different behaviour.