Skip to content

Conversation

@droserasprout
Copy link
Collaborator

@droserasprout droserasprout commented Aug 10, 2021

Improvements:

  • New entity: hook. User-defined callback with arbitrary code. Same as handler but not linked to any index. Called either from ctx.fire_hook (from hadlers or by DupDup) or by scheduler (jobs config section). Optionally typed with args. Jobs are now schedules for hooks.
hooks:
  a:
    callback: a
    atomic: True
    args:
     foo: int
     bar: str

jobs:
  a_leet:
    hook: a
    interval: 1337
    args:
      foo: 1337
      bar: "1337"
  • SQL hooks. hooks/callback.sql directory next to hooks/callback.py. Both Python and SQL hooks are always fired (but not nescessary non-empty). Executed by CallbackManager.

  • Built-in hooks defined declaratively in config.

  • Unified codegen based on a single template for all callbacks. Config section must implement CallbackMixin.

  • Unified callbacks processing in CallbackManager. Optional dynamic type-checking of arguments (basic types and dotted notations, skipped for handlers).

  • All above finally apply to big_map indexes, debt closed.

  • Massive refactoring of dipdup.config module. Easier to understand stages of complex config initialization flow.

  • Callback-specific context classes removed. Callbacks receive either HandlerContext or HookContext. Required context created in base context.

  • Matching Websocket data with cached head block.

  • Bunch of internal models:

    • Schema: just hash
    • Index: status, template, template values, full config
    • Head: last Websocket connection status
    • Contract: hack to keep dynamically spawned contracts after restart (ignored if presented in config)
  • No more "temporary states"!

    1. Indexes from config: just verify hash
    2. Indexes from template: recreate from config template, check hash
    3. Indexes with template missing: reindex
    4. Indexes without template not in config: ignore (must be just commented out)

See edge cases in TODO.

  • Datasource now maintains linked models.Head. More on int.models below.
  • Completely rewritten DipDup boot sequence. Main entrypoint splitted to _set_up_smth methods using stack and task set.

TODO:

  • Reindex if on_rollback hook is not implemented
  • Fix ParentMixin generic
  • Fix formatted loggers missing context due to init in base context
  • Set ONESHOT status on complete
  • Context reused between job runs
  • Factory level updated, config not reloaded, indexer dies -> invalid state
  • Project migration: move SQL scripts, remove default handlers
  • Check migration on demos
  • Spec and major version bump
  • hooks: List[HookConfig]? Now name must be equal to callback.

@droserasprout
Copy link
Collaborator Author

@droserasprout
Copy link
Collaborator Author

@droserasprout droserasprout changed the title Keep more details about index state Hooks, typed callbacks, more builtin tables, no more tempstates Aug 19, 2021
@droserasprout
Copy link
Collaborator Author

@droserasprout
Copy link
Collaborator Author

@droserasprout
Copy link
Collaborator Author

self._blocks[block.level] = block
self._events[block.level].set()

last_blocks = sorted(self._blocks.keys())[-self._limit :]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сложна

@droserasprout
Copy link
Collaborator Author

@droserasprout droserasprout marked this pull request as ready for review August 31, 2021 07:14
@droserasprout droserasprout requested a review from m-kus August 31, 2021 07:17
@droserasprout droserasprout merged commit 937e932 into master Sep 1, 2021
@m-kus m-kus deleted the feat/dipdup-state branch September 29, 2021 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants