Skip to content

Merge upstream CardanoSolutions/kupo master at 1c73467 - #25

Merged
carbolymer merged 72 commits into
masterfrom
mgalazyn/feature/upstream-sync
Nov 26, 2026
Merged

carbolymer merged 72 commits into
masterfrom
mgalazyn/feature/upstream-sync

Conversation

@carbolymer

@carbolymer carbolymer commented Nov 24, 2026 •

Copy link
Copy Markdown

This merges upstream CardanoSolutions/kupo master at 1c73467 into the fork with a real merge, so the next upstream sync starts from 1c73467 instead of the fork point 3944e06. With the follow-up commits it completes the upstream port tracked in IntersectMBO/kupo issue 24.

From upstream

  • Plain application/json responses give asset quantities as integers again; only requests that ask for strings in the Accept header get strings.
  • Custom database indexes through KUPO_INDEX_* environment variables, combined with the fork's gated migrations.
  • PlutusV4 script decoding in the Hydra and Ogmios decoders.
  • The accept test suite, which takes six node tests out of unit, plus benchmarks, API docs and the v2.12.0 changelog section.

Kept from the fork

Where both sides changed the same code, the fork's version stays: Dijkstra era support with sub-transactions, the cardano-node 11.2 dependency set, gated migrations and the split CI workflows. Upstream's own Dijkstra code, written for cardano-node 11.0, is dropped where the fork already covers it, and upstream's build.yaml stays deleted. The Alonzo part of upstream 8f32e3b is not taken, because upgradeData re-encodes the datum and loses its on-chain bytes. The README compatibility row for v2.12 names cardano-node 11.1 and 11.2.

Follow-up commits

  • ci: run the accept suite against the preprod node adds kupo-tests-accept to the flake and runs it in the integration job, with kupo and a cached cardano-cli on PATH. Four of the moved tests ran in this job before, so without this they would run nowhere. The two flaky tests stay skipped under their new names.
  • Avoid partial list functions in the accept suite clears two -Wx-partial warnings.
  • Bound the statistics scan of PRAGMA optimize sets PRAGMA analysis_limit = 1000 on every connection that runs PRAGMA optimize (start-up, garbage collection and copy finalisation) and in the Makefile. Without it, optimize can scan whole indexes for hours on large databases and stall chain sync. SQLite 3.46 applies such a limit by itself, but kupo bundles 3.45.

The Dockerfile lint and the witness datum fix moved to their own PRs:

Testing

  • nix build .#kupo .#kupo-tests .#kupo-tests-accept builds with no GHC warnings in src/, app/, test/ and test-accept/.
  • Unit suite: 459 examples, 0 failures, with the end-to-end tests skipped because no node was available.
  • A fresh database from this branch has the same schema and the same 13 migrations as master, also when it upgrades a database that master created, and a KUPO_INDEX_* variable adds exactly its index.
  • The accept suite and the integration job have not run yet; they need the preprod node in CI.

Reviewing

GitHub lists upstream's 66 commits as part of this PR. To see only how the conflicts were resolved, run git show --remerge-diff a816aa4. Please merge with "Create a merge commit": a squash or rebase merge drops the merge, and the next sync would start from 3944e06 again.

Closes #24

Related issues:

johnalotoski and others added 30 commits May 13, 2026 23:59
Update cabal.project constraints and index-state for cardano-node
11.0.1 (ouroboros-consensus 3.0.1, cardano-ledger-conway >= 1.22.1).
Pin validation < 1.2 to avoid breaking API change. Update ogmios
source-repository-package to rebased node-11.0 branch. Bump
dependency bounds in package.yaml.

Co-Authored-By: Claude <noreply@anthropic.com>
Add BlockDijkstra and DijkstraEra pattern matches across block
processing, scripts, transactions, and Hydra/Ogmios modules. Dijkstra
transactions are coerced to Conway at the block-processing boundary
since the types are representationally identical. Replace unsafeCoerce
in Metadata era translation with explicit pattern match and
translateTimelock. Update Prelude era list and codec config.

Co-Authored-By: Claude <noreply@anthropic.com>
…wayEra

Replace the unsafeCoerce-based approach to Dijkstra era handling with
proper TransactionDijkstra constructors and explicit era conversion
functions. Change the Metadata, Output, Script, and BinaryData type
aliases from ConwayEra to DijkstraEra and add the necessary upgrade
paths through all era conversion functions using Ledger.Dijkstra.upgradeTimelock.

Add cardano-ledger-dijkstra as an explicit dependency.

Co-Authored-By: Claude <noreply@anthropic.com>
Replace unsafeBinaryDataFromBytes with Ledger.dataToBinaryData and
Ledger.upgradeData for era conversions. With BinaryData now aliased
to DijkstraEra, fromDijkstraBinaryData and toDijkstraBinaryData
simplify to identity. Uses coerce for the phantom era parameter in
Conway datum conversions.

Co-Authored-By: Claude <noreply@anthropic.com>
Replace Timelock ConwayEra with DijkstraNativeScript DijkstraEra and
simplify scriptFromBytes to decode directly at DijkstraEra instead of
decoding at ConwayEra and upgrading. Removes the extra upgradeTimelock
and fromConwayScript steps from fromNativeScript.

Co-Authored-By: Claude <noreply@anthropic.com>
Add comment noting that ouroboros-network provides a general
ToJSON (Point block) instance that conflicts with this one.

Co-Authored-By: Claude <noreply@anthropic.com>
Use Ledger.dataToBinaryData with Ledger.upgradeData for Alonzo and
Babbage era data conversions, removing the HasCallStack constraint
from fromAlonzoData and the intermediate type annotation from
fromBabbageData.

Co-Authored-By: Claude <noreply@anthropic.com>
These Conway-era datum conversions are dead code now that the Datum,
BinaryData, and Output types are all aliased to DijkstraEra.

Co-Authored-By: Claude <noreply@anthropic.com>
The previous genServerPort (1024 + size + arbitrary) could generate
privileged ports below 1024 and duplicate ports across iterations,
causing bind failures. Replace with OS-assigned ephemeral ports via
bind-to-zero on localhost. Also use newEnvironmentWith throwIO so
test failures surface the real exception instead of opaque ExitFailure 1.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
  This is only used to pull in the fast-bech32 module, which is not impacted by the hard fork at all.
  Buildjet has shut down, and github does provide arm runners nowadays.
- Make `Dynamically add pattern` like the original, i.e. at tip
- Make `Can restart with same arguments` totally reliable (was flaky)
@carbolymer carbolymer changed the title Mgalazyn/feature/upstream sync Merge upstream CardanoSolutions/kupo master at 1c73467 Nov 24, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/feature/upstream-sync branch 2 times, most recently from 56daed2 to afc0cc4 Compare November 24, 2026 15:54
@carbolymer
carbolymer marked this pull request as ready for review November 24, 2026 16:01
Comment thread test-accept/Test/KupoSpec.hs Outdated
-- Add stakeA pattern forcing rollback to last Byron block
putNewPattern 1447 stakeA lastByron `shouldReturn` True
-- Wait for rollback (checkpoints should go back in time)
eventually (hasNotReachedPoint 1447 lastByron136K)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Polling can miss the rollback because syncing resumes immediately. Could this wait for both expected matches and the target checkpoint instead? That would also wait for replay to finish before asserting the results.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in fdf5b00. The test now waits until both matches are in the window, then until the checkpoint reaches lastByron136K, and only then asserts the patterns and matches.

hasNotReachedPoint and hasNotReached had no other users, so I removed them.

,"--workdir", dir
] $ eventually (hasReachedPoint 1448 pointC)
-- Change permissions on database's directory
makeUnwritable dir

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The previous test made the database files unwritable too; this only changes the directory. Could we restore that and run this case without sudo so the permissions are actually enforced?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Restored in f9192e3: the test makes every file in the database directory unwritable again, as well as the directory itself.

This case now runs in its own CI step without sudo, before the sudo step, which skips it: 02ae596. The step first runs sudo chmod a+w on the node socket so that the runner user can connect to the node.

Brings in upstream's v2.12.0 work: the asset quantity encoding fix, custom database indexes through KUPO_INDEX_* environment variables, PlutusV4 script decoding for Hydra and Ogmios, the accept test suite, benchmarks and API docs.

Where both sides changed the same code, the fork's version stays: Dijkstra era support with sub-transactions, the cardano-node 11.2 dependency set, gated migrations and the split CI workflows. The Alonzo part of upstream 8f32e3b is not taken, because upgradeData re-encodes the datum and loses its original bytes.
@carbolymer
carbolymer force-pushed the mgalazyn/feature/upstream-sync branch from afc0cc4 to cff3e2d Compare November 26, 2026 14:11
The upstream merge moved four node tests that the integration job ran from the unit suite into the new accept suite, so the job now builds and runs accept as well. It runs against the synced preprod node, with kupo and a cardano-cli fetched from the Hydra cache; the two known-flaky tests stay skipped under their new names.
The checkpoint checks called head, which GHC 9.12 flags with -Wx-partial. They now use listToMaybe and treat an empty list as a failed check, which the callers already guaranteed cannot happen.
Without PRAGMA analysis_limit, PRAGMA optimize can read whole indexes, which takes hours on large databases and stalls chain sync at start-up (CardanoSolutions#209). Set the limit to 1000 on every connection that runs optimize: the long-lived connection, the short-lived ones the garbage collector opens, and the connection that finalises a copy. SQLite 3.46 applies such a limit by itself, but kupo bundles 3.45.
@carbolymer
carbolymer force-pushed the mgalazyn/feature/upstream-sync branch from cff3e2d to f9192e3 Compare November 26, 2026 14:58
@carbolymer
carbolymer merged commit 7da388e into master Nov 26, 2026
7 checks passed
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.

Port upstream CardanoSolutions/kupo fixes up to 1c73467

6 participants