Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on configuring kupo #1556

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion doc/custom-query-layers.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<!-- DOCTOC SKIP -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Custom query layers in CTL](#custom-query-layers-in-ctl)
- [Adding a new backend](#adding-a-new-backend)
- [Replacing some queries in existing backend](#replacing-some-queries-in-existing-backend)
- [Configuring CTL's default query layer (Kupo/Ogmios)](#configuring-ctls-default-query-layer-kupoogmios)
- [Kupo](#kupo)
- [Faster sync for Kupo](#faster-sync-for-kupo)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Custom query layers in CTL

Expand All @@ -15,3 +25,24 @@ A new [backend option](https://github.com/Plutonomicon/cardano-transaction-lib/b
Substituting the query layer for a few functions only (assuming the original backend remains available for initial connection) can be done without forking CTL.

`ContractEnv` contains a QueryHandle (inside a `Reader`), so a [`local`](https://pursuit.purescript.org/packages/purescript-transformers/6.0.0/docs/Control.Monad.Reader.Class#v:local) call with a function that replaces some `QueryHandle` record entries will just work.

# Configuring CTL's default query layer (Kupo/Ogmios)

Optimising storage requirements and performance of the query layer, unfortunately, depends on your app query needs.

## Kupo

Kupo is used for "utxos-at-address" query in CTL.

This query is mainly used in two contexts:

- manual `utxosAt` calls
- wallet <-> backend synchronization (see [here](./query-layers.md))

If you don't need either, consider removing Kupo from the runtime and [disabling wallet <-> backend synchronization](./query-layers.md) (**IMPORTANT!**).

If your app works in a way that only requires UTxO lookups on certain addresses (e.g. script addresses), consider using [`--match-pattern`](https://cardanosolutions.github.io/kupo/#section/Getting-started/-match-pattern) to drastically reduce DB size. The downside would be that wallet<->backend sync will have to be disabled, because it requires looking up wallet's addresses via the backend.

### Faster sync for Kupo

Use [`--since` flag](https://cardanosolutions.github.io/kupo/#section/Getting-started/-since-slot-no.header_hash) to perform partial incomplete sync. Find block parameters on [a block explorer](https://cexplorer.io/block). It will let you sync things faster (than in ~4 days for mainnet), for the price of Kupo not seeing UTxOs created after the specified slot. If you disable wallet<->backend sync, and depending on your use case, that might be acceptable for production.
5 changes: 5 additions & 0 deletions doc/query-layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Configuring synchronization behavior](#configuring-synchronization-behavior)
- [Synchronization and wallet UTxO locking](#synchronization-and-wallet-utxo-locking)
- [Historical notes](#historical-notes)
- [See also](#see-also)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -113,3 +114,7 @@ Initially we underestimated the problem of UTxO set inconsistency between query
Conceptually, the wallet is responsible for *owning* the UTxOs, so wallet developers may implement behaviors that would prevent us from making general assumptions about the wallet state.

CTL `v5.1.0` introduces better consistency guarantees while not requiring the developer to change any code on their side - for the price of slight delays during the app runtime.

## See also

- [Optimising your app with custom query layers](./custom-query-layers.md)