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

`operation` index allows `contracts` mapping to be empty #544

Closed veqtor closed 1 year ago

veqtor commented 1 year ago

Steps to reproduce: Create a dipdup project, name it whatever, use this dipdup.yml:

spec_version: 1.2
package: fxhashbug

contracts:
  #FxHash
  FxHashModerationUser:
    address: KT1Wn2kkKmdbyLWBiLXWCkE7fKj1LsLKar2A
    typename: fxhash_moderation_user
  FxHashUserRegistry:
    address: KT1Ezht4PDKZri7aVppVGT4Jkw39sesaFnww
    typename: fxhash_user_registry

database:
  kind: sqlite
  path: fxhashbug.sqlite3

datasources:
  tzkt_mainnet:
    kind: tzkt
    url: https://api.tzkt.io

templates:
  fxhash:
    kind: operation
    datasource: <datasource>
    types:
      - transaction
    handlers:
      - callback: fxhash.admin.op.on_moderate
        pattern:
          - type: transaction
            destination: <fxhash_moderation_user>
            entrypoint: moderate
      - callback: fxhash.identity.op.on_update_profile
        pattern:
          - type: transaction
            destination: <fxhash_user_registry>
            entrypoint: update_profile

indexes:
  fxhashy:
    template: fxhash
    values:
      datasource: tzkt_mainnet
      fxhash_moderation_user: FxHashModerationUser
      fxhash_user_registry: FxHashUserRegistry

What did you expect to happen:

handlers are being called, it doesn't crash

What actually happened: with dipdup run it crashes, see log:

crash.log

when running in docker, handlers aren't called

Environment

config:

config.txt

droserasprout commented 1 year ago

Hi @veqtor! Your bug reports are great, as always.

The reason for a crash is empty contracts mapping. To fix your template add the following lines:

    contracts:
      - <fxhash_moderation_user>
      - <fxhash_user_registry>

Options for DipDup when the operation index has no contracts:

veqtor commented 1 year ago

Oh, of course facepalm

droserasprout commented 1 year ago

Let's keep this one open; RuntimeError is not an expected behavior.

droserasprout commented 1 year ago

No contracts section is okay in some cases (originations). To not overcomplicate things it's better to crash with ConfigurationError.

Fixed in #543; lazy to push another branch.