You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+21-25Lines changed: 21 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,23 @@
2
2
3
3
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt).
4
4
5
-
## General
5
+
## For contributors
6
+
7
+
### General
6
8
7
9
- All code in this repository MUST be licensed under the [MIT License](./LICENSE.md).
8
10
- Python code in this repository MUST run on Python 3.11. Using modern language features is encouraged.
9
11
- Python code in this repository MUST run in Linux, macOS, Docker, and `amd64`/`arm64` environments. Windows SHOULD be supported as well.
10
-
- We use the [Poetry](https://python-poetry.org/docs/#installation) package manager and GNU Make to set up the development environment. You SHOULD install both tools and run `make help` to see available shortcuts.
11
-
-Developers SHOULD have fun while contributing to the project.
12
+
- We use the PDM package manager to set up the development environment. You SHOULD install it and run `pdm run -l` to see available shortcuts.
13
+
-Have fun!
12
14
13
-
##GitHub
15
+
### Git workflow
14
16
15
-
- Branch names MUST follow `prefix/short-description` format. Prefixes currently in use: `feat` for features, `fix` for bugfixes, `docs` for documentation, `exp` for experiments, `aux` for everything else.
17
+
- Branch names MUST follow `prefix/short-description` format. Prefixes currently in use: `feat` for features, `fix` for bugfixes, `docs` for documentation, `exp` for experiments, `ci` for GHA and Docker stuff, `aux` for everything else.
16
18
- Commits in pull requests MUST be squashed when merging to `next`.
17
19
- Issues and pull requests MUST have a descriptive title; they SHOULD be linked to each other, appropriately labeled, and assigned to maintainers while in progress.
18
20
19
-
## Codestyle
21
+
###Codestyle
20
22
21
23
We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` for typechecking. All checks MUST pass before merging the code to default branch. Everything not enforced by these tools is up to the developer. But here are some recommendations:
22
24
@@ -26,13 +28,13 @@ We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` fo
26
28
- Some methods and attributes made private to avoid polluting the public API. Feel free to access them from the outside if you know what you are doing.
27
29
- Finally, about exact language features. F-string formatting is preferred over other syntax. Be careful with walrus operator. Don't forget else in conditional expressions. Listen to you mom. We have no consensus about the match-case yet.
28
30
29
-
## Packaging
31
+
###Packaging
30
32
31
33
- All dependencies MUST be declared in `pyproject.toml` file.
32
34
- Non-development dependencies MUST be pinned to non-breaking versions (e.g. `^1.2.3`).
33
35
- Core dependencies that we patch MUST be pinned to specific versions (e.g. `1.2.3`).
34
36
35
-
## Changelog
37
+
###Changelog
36
38
37
39
- All changes that affect user (developer) experience MUST be documented in the CHANGELOG.md file.
38
40
- Changes that significantly affect DipDup maintainers' experience MAY be documented in the CHANGELOG.md file.
@@ -42,47 +44,41 @@ We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` fo
42
44
## Documentation
43
45
44
46
- A page in Release Notes SHOULD accompany all major releases.
45
-
- All internal links MUST be created with `{{ #summary ...` shortcodes.
46
-
- All values used in project templates MUST be replaced with `{{ #cookiecutter ...` shortcodes.
47
47
48
-
#DipDup maintainer guide
48
+
## For maintainers
49
49
50
-
## Security
50
+
###Security
51
51
52
52
- GitHub alerts about dependencies that contain vulnerabilities MUST be investigated and resolved as soon as possible.
53
53
- Security-related bugfixes MUST be mentioned in the changelog under the "Security" section.
54
54
55
-
## Privacy
55
+
###Privacy
56
56
57
57
- Crash reporting MUST be opt-in (disabled by default) both in config and project templates.
58
58
- Sentry events and crash reports MUST NOT contain any sensitive information (IP addresses, hostnames, etc.)
59
59
- DipDup SHOULD NOT perform network requests to APIs not defined in config as datasources. Current exceptions: GitHub.
60
60
61
-
## Docker images
61
+
###Docker images
62
62
63
-
- DipDup dockerfiles use autogenerated `requirements.txt` files. Maintainers MUST run `make update` script on every change in dependencies.
63
+
- DipDup dockerfiles use autogenerated `requirements.txt` files. Maintainers MUST run `pdm run update` script on every change in dependencies.
64
64
- Docker images for stable releases MUST be published on Docker Hub. They MAY also be published on GHCR.
65
65
- Maintainers MAY publish arbitrary images on GHCR and remove them when not needed.
66
66
67
-
## Installer
67
+
###Installer
68
68
69
69
- Installer module MUST depend on Python stdlib only.
70
70
71
-
## Scaffolding
71
+
###Scaffolding
72
72
73
73
- Project templates SHOULD cover all index types available in DipDup.
74
74
- They also MAY contain additional features and integrations.
75
75
76
-
## Demo projects
76
+
###Demo projects
77
77
78
-
- Demos are stored in `demos` root directory. They MUST be generated automatically from project templates using replay files.
79
-
- Maintainers SHOULD run `make demos replays` command regularly to ensure that demo projects are up to date.
78
+
- Demos are stored in `src` directory. They MUST be generated automatically from project templates using replay files.
79
+
- Maintainers SHOULD run `pdm demos` command regularly to ensure that demo projects are up to date.
80
80
81
-
## Releases
81
+
###Releases
82
82
83
83
- Release versions MUST conform to [Semantic Versioning](https://semver.org/). Releases that introduce breaking changes MUST be major ones.
84
84
- Only the latest major version is supported in general. Critical fixes MAY be backported to the previous major release. To do so, create an `aux/X.Y.Z` branch from the latest stable tag, bump the DipDup version manually, and add a new tag.
Copy file name to clipboardExpand all lines: docs/0.quickstart.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ A modern Linux/macOS distribution with Python 3.11 installed is required to run
21
21
You can initialize a hello-world project interactively by choosing configuration options in the terminal. The following command will install DipDup for the current user:
Copy file name to clipboardExpand all lines: docs/1.getting-started/4.package.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Package"
3
3
description: "Each DipDup project consists of a YAML config and a Python package of a specific structure. It could be placed anywhere, but needs to be importable. The package name is defined in the config file."
4
4
---
5
5
6
-
# Package structure
6
+
# Project package
7
7
8
8
Each DipDup project consists of a YAML config and a Python package of a specific structure. It could be placed anywhere, but needs to be importable. The package name is defined in the config file.
Copy file name to clipboardExpand all lines: docs/1.getting-started/8.handlers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Handlers"
3
3
description: "After defining the index in the configuration file and initializing the project, you can start implementing handlers. DipDup generates callback stubs for all handlers specified in the configuration file. You can find them in the handlers directory."
4
4
---
5
5
6
-
# Implementing handlers
6
+
# Handlers
7
7
8
8
After defining the index in the configuration file and initializing the project, you can start implementing handlers. DipDup generates callback stubs for all handlers specified in the configuration file. You can find them in the `handlers`{lang="python"} directory.
Copy file name to clipboardExpand all lines: docs/12.faq.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,9 @@ nested: Resources
8
8
9
9
This page contains answers to the most popular questions about DipDup guts. If you landed here - congrats, you're writing a pretty advanced indexer!
10
10
11
-
## How to index similar but not identical contracts as a single entity?
11
+
## Indexing
12
+
13
+
### How to index similar but not identical contracts as a single entity?
12
14
13
15
Multiple contracts can provide the same interface (like FA1.2 and FA2 standard tokens) but have a different storage structure. If you try to use the same typename for them, indexing will fail. However, you can modify typeclasses manually. Modify `types/<typename>/storage.py` file and comment out unique fields that are not important for your index:
14
16
@@ -24,23 +26,25 @@ class ContractStorage(BaseModel):
24
26
25
27
Don't forget `Extra.ignore` Pydantic hint, otherwise storage deserialization will fail. To restore the original typeclass, remove modified file and run `dipdup init` again. You can also add `--force` flag to overwrite all ABIs and typeclasses.
26
28
27
-
## How to use off-chain datasources?
29
+
###How to use off-chain datasources?
28
30
29
31
DipDup provides convenient helpers to process off-chain data like market quotes or IPFS metadata. Follow the tips below to use them most efficiently.
30
32
31
33
- Do not perform off-chain requests in handers until necessary. Handlers need to be as fast as possible not to block the database transaction. Use hooks instead, enriching indexed data on-demand.
32
34
- Use generic `http` datasource for external APIs instead of plain `aiohttp` requests. It makes available the same features DipDup uses for internal requests: retry with backoff, rate limiting, Prometheus integration etc.
33
35
- Database tables that store off-chain data can be marked as immune, to speed up reindexing.
34
36
35
-
## How to process indexes in a specific order?
37
+
###How to process indexes in a specific order?
36
38
37
39
Indexes of all kinds are fully independent. They are processed in parallel, have their own message queues, and don't share any state. It is one of the essential DipDup concepts, so there's no "official" way to manage the order of indexing.
38
40
39
41
Avoid using sync primitives like `asyncio.Event` or `asyncio.Lock` in handlers. Indexing will be stuck forever, waiting for the database transaction to complete.
40
42
41
43
Instead, save raw data in handlers and process it later with hooks when all conditions are met. For example, process data batch only when all indexes in the `dipdup_index` table have reached a specific level.
42
44
43
-
## How to perform database migrations?
45
+
## Database
46
+
47
+
### How to perform database migrations?
44
48
45
49
DipDup does not provide any tooling for database migrations. The reason is that schema changes almost always imply reindexing when speaking about indexers. However, you can perform migrations yourself using any tool you like. First, disable schema hash check in config:
Now you can prepare and execute an `ALTER TABLE` query manually or using SQL hooks.
77
81
78
-
## I get `schema_modified` error, but I didn't change anything
82
+
###I get `schema_modified` error, but I didn't change anything
79
83
80
84
DipDup compares the current schema hash with the one stored in the database. If they don't match, it throws an error. If models were not modified, most likely the reason is incorrect model definitions. e.g. if you define a timestamp field like this…
81
85
@@ -104,7 +108,7 @@ You need to make the following change in models.py:
104
108
105
109
We plan to improve field classes in future releases to accept callables as default values.
106
110
107
-
## Why am I getting `decimal.InvalidOperation` error?
111
+
###Why am I getting `decimal.InvalidOperation` error?
108
112
109
113
If your models contain `DecimalField`s, you may encounter this error when performing arithmetic operations. It's because the value is too big to fit into the current decimal context.
0 commit comments