Liking cljdoc? Tell your friends :D

skuld

A permissionless ledger on urd, where the database is datahike and the smart contracts are Datalog.

Skuld is the third Norn, sister to Urðr. The name means debt — from Old Norse skulu, and sharing its root with English should. Urd decides what has become; skuld is what is owed. Both meanings are the subject matter: a ledger is obligations, and its contracts are invariants — statements of what should hold.

Status: pre-release, unaudited, no network. The consensus layer is reasonably settled; this is not. See Known incomplete below for what is missing rather than merely untested.

What it is

A sender signs a vector of Datahike entity maps and write operations.

{:chain :urd-net
 :sender  "<hex of your genesis hash>"
 :nonce   7
 :tx-data [{:db/id "note" :<your-namespace>/text "hello"}]
 :public-key <32 bytes>
 :signature  "<base64url Ed25519>"}

Validators apply an ordinary signed write in this order.

bounded envelope → chain and input checks → authorised signing key → signature
  → nonce and funds → permitted operations → bounded transaction preparation
  → ownership and price → change guards → settlement and storage → commit

A single entity retraction can remove an entire component tree. Datahike accounts for rows visited during preparation, and Skuld checks ownership and guards against the resulting changes. The transaction specification lists the supported forms, limits, fees and refusal reasons. Ordinary signed writes

Identity is a genesis hash, not a public key

Your account namespace is the hash of a genesis record. That indirection is what lets an operational key rotate without your identity moving — the difference between this and the did:key / SSB model, where the key is the name and rotation means becoming somebody else.

Ownership is per row, and the protocol's rows are nobody's

A hex namespace belongs to the key that owns it. Everything under db, invariant, urd.account, urd.stake and rules is protocol state that no sender may write. The one exception is urd.stake.intent, a request channel: writing one moves nothing, and the protocol re-validates every intent at the end of the block against state the sender does not control before any value moves.

Staking is an ordinary transaction

[{:db/id "intent"
  :urd.stake.intent/op :delegate
  :urd.stake.intent/validator "<validator namespace>"
  :urd.stake.intent/amount 3000000}]

No second envelope kind, no separate signing scheme. Solana is the precedent: its Stake Program was a builtin inside the validator and is now an ordinary program, so the runtime reads staking state rather than owning it.

Rewards are F1 (O(1) in delegators), slashing is share-dilution, and validator set changes reach consensus at epoch boundaries — except jailing, which does not wait, because a jailed validator held in the set keeps taking proposer turns it will not answer.

Conservation laws are checked every block

skuld.conservation states five properties over the stake projection and halts the node when one is false, the way Cosmos's crisis module does. They run against the candidate final state before the ledger publishes the completed height. Recovery preserves the already settled envelope prefix.

Each corresponds to a bug this codebase actually shipped and fixed.

Guides

  • Transactions — the envelope, the admission pipeline, every refusal reason and what it costs
  • Identity — why a namespace is a genesis hash rather than a public key, and what rotation does and does not do yet
  • Ownership — row ownership, protocol state, and the request namespace that lets you ask the protocol for something
  • Staking — validators, shares, F1 rewards, slashing, jailing, epochs, and the datom projection
  • Invariants — Datalog guards, dispatch on produced datoms, and what registration has to check before it is safe
  • Economics — gas versus storage, the fee schedule, who pays for a byte, issuance
  • Conservation laws — the five properties checked every block, and why a violation halts the node
  • Writing a client — in Python, sharing no code

Setting up

The beta language and signing SDK are on this draft branch. From a separate Clojure project, add a checkout of this branch to deps.edn:

{:deps {org.replikativ/skuld {:local/root "../skuld"}}}

Skuld uses the metered contract API from Datahike 0.8.1961 and the transition API from Kontor 0.1.42.

(require '[skuld.client :as client])
(def identity-record (client/new-identity))
(def signer (client/signer identity-record))
;; After genesis funds this identity and installs the business attributes:
(def nonce (:next-nonce (client/account-state db (:ns signer))))
(def deployment (client/sign-guard signer chain nonce registration))
;; Submit deployment to the validator transport. Use :guard-digest from the
;; confirmed result as :replaces when signing a later guard revision.

Run clojure -M -m tickets from the ticketing example to fund two accounts, install and replace a guard, verify acceptance and refusal, and transfer a shared row with the recipient’s countersignature.

The signer contains the operational key. Keep the identity's rotation key and revocation secret offline. The local devnet below demonstrates transport and certificate verification.

Try a signed contract locally

Run bin/check-guard-devnet from this checkout. A client JVM creates a signing identity, funds its account at local genesis, and submits a signed deployment, two assertions, a retraction and a replay. Four Tendermint validators execute the batch on independent databases. The client verifies the quorum certificate for every height from genesis and replays the history to check the receipts and balance. The drill uses a private temporary directory for client submission and localhost WebSockets between validators. Contract syntax and semantics

The metered inventory experiment shows how to publish a signed Datalog invariant, limit its fuel, and replay the ledger using the pinned Datahike dependency.

Running the tests

clj -M:test

The suite exercises two integration scenarios:

  • four validators over websockets — each with its own file-backed datahike database, speaking Tendermint through kabel with real Ed25519 identities and wall-clock timers. Nothing coordinates the four databases; if they agree it is because consensus made them agree. Order is asserted, not just content.
  • three separate JVMs replaying the same blocks and comparing their databases datom for datom, because determinism is what the whole thing rests on and two replicas in one process share caches that make them agree for the wrong reason.

Both are tagged ^:integration because they bind ports and assert progress against a wall clock, but clj -M:test does not exclude them. A consensus ledger whose socket path is optional in CI is one whose socket path rots.

Consensus support

Urd algorithmWhat Skuld exercises
TendermintCertified contract deployment and replay, four-validator transport, stake-driven committee changes, recovery drills
Round-robinStake updates and jailing in simulation
RaftDecided log entries driving the Datahike ledger
NakamotoReal fork selection and reorganization of a Datahike ledger

Tendermint is the proposed public-network profile. Switching the underlying algorithm changes what a client can accept as final and how membership and operator incentives work. Skuld has no live consensus-switch operation.

Tendermint integration

The four-validator socket demo uses a fixed committee. Each validator signs Tendermint votes as well as network envelopes, verifies the content ID and schema of every proposed demo transaction, and stores consensus history in a Konserve WAL beside its Datahike database. Datahike's committed vertex marks supply the delivery cursor on restart. The socket test takes a client offline, lets the other three commit new transactions, and reopens both stores. It checks the recovered commit certificate and compares the transaction order across all four databases.

Run clojure -M:test -n skuld.ledger.cluster-test to exercise the cluster. The demo keeps validator keys and the roster in the running harness. Restarting the whole deployment requires durable identity provisioning. Its one-fact schema is for the demo; signed ledger admission, fees and staking are exercised in separate Skuld tests. The Tendermint set-change simulation applies blocks to independent Skuld databases, derives a jailed validator’s removal from stake, then checks that the remaining validators activate the new powers and continue committing. Compute each proposal’s content ID after attaching these updates. For a stake-backed validator, install skuld.consensus/tendermint-options with a getter for the local driver and the application's payload validator. This requires Urd's :valid-at-height? callback. The validator compares the updates with its own applied ledger at the consensus height, including during catch-up. The stake projection stores the expected updates in the same transaction as the block's final stake state, so reopening the driver preserves an outstanding change. All validators must upgrade together because this adds data to the application state. A non-genesis legacy stake database without a recorded update boundary requires replay from verified history before voting.

Run bin/check-tendermint-restore to exercise offline state transfer. It starts three fresh JVMs and uses temporary file stores and per-validator Ed25519 identities. The returning peer stops at cursor 3. The surviving quorum changes voting power and reaches cursor 12 with a three-height decision window. After the donor stops, stage its database image and compare the application digest and cursor with an independently trusted consensus boundary (committee, powers, priorities, and last decided height). Retain the returning peer's signing state and replay registers in its own WAL. The drill checks stale/mismatched pairs before activating the staged copy, then checks agreement and a fresh certificate through cursor 15. The copied Datahike image retains its store ID; the donor stays offline in the final phase. The drill pins its manifest in a trusted temporary directory. Production distribution needs an authenticated manifest and an atomic, restartable switch of the application and consensus stores.

Reopening a linear Datahike history scans its ordered vertex metadata and commit boundaries. Histories with merges, rewinds or nonstandard metadata use the historical recovery path. This bounds repeated enumeration on the normal path; the database still opens its historical commit objects.

Known incomplete

Not "untested" — not built yet, and the chain would behave wrongly if used:

  • The block pays matured unbonding principal and allocates fees. Validator commission and delegator rewards are withdrawable. Operators can reconcile a finalized snapshot against the opening supply with skuld.block/reconcile-supply.
  • Public-network genesis allocations, validator incentives, governance and collateral rate changes need an agreed policy. Economics
  • On-chain guard deployment supports metered queries over resolved assertions and retractions, as well as integer value predicates. A guard may read declared attributes of other accounts. Only the attribute owner can attach a revision to that attribute. An attribute can have four guards. Within an envelope each distinct triggered revision executes once and sees resolved changes on its readable attributes. Named contract revisions can be published independently, replaced by digest or frozen. The four-source guard and rule-program registration API is limited to trusted local installation.
  • Authenticated equivocation evidence still needs a block entry point: stake/handle-equivocation has no live block caller, so slashing for a double-sign is state-level machinery with nothing driving it.

There is more, with measurements, in the internal backlog.

Layout

src/skuld/            the chain: boundary, block, staking, invariant, conservation
src/skuld/ledger/     the substrate: accounts, authz, ownership, cost, stake
doc/interop/          a client in Python, sharing no code with skuld

License

Copyright © 2026 Christian Weilbach. Distributed under the MIT License.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close