A holder can pay any Netz identity from spendable liquid funds. The recipient can register a validator and bond stake through the same signed transaction interface as any other wallet. Neither the payer nor a seed peer has authority to assign voting power.
The operator keeps its Netz recovery material offline and gives the validator process an Ed25519 voting key. In this example payer is an existing funded signer and payer-nonce is its next unsigned nonce. The receiving account starts at nonce 1.
(require '[clojure.core.async :refer [<!!]]
'[skuld.client :as client]
'[skuld.wire :as wire]
'[skuld.signer :as signer])
(def identity-record (client/new-identity))
(def operator (client/signer identity-record))
;; Run on the validator host and send only declaration back to the wallet.
(def declaration (signer/provision! "/var/lib/skuld/validator" chain (:ns operator)))
;; Send this signed CBOR frame to a transaction ingress.
(def payment (wire/encode-envelope
(client/fund-account payer chain payer-nonce (:genesis operator) 6000000)))
;; After funding finalizes, submit these in nonce order.
(def registration (client/register-validator-with-proof operator chain 1 declaration 0 1))
(def delegation
(client/sign-write operator chain 2
[{:db/id "bond" :urd.stake.intent/op :delegate
:urd.stake.intent/validator (:ns operator)
:urd.stake.intent/amount 3000000}]))
Check the finalized staking intent result as well as the envelope receipt. A previously funded recipient can receive another payment. The account signature authorizes registration and the vote key signs a separate proof bound to the chain and operator namespace. The registered key is immutable in this profile. Anyone with spendable funds can delegate. At an epoch boundary the ledger ranks eligible validators by stake under the chain's power reduction and committee cap. The incumbents certify the next proposal carrying that change. The new power applies at the following height. Have the candidate ready to sync and vote before activation, particularly if its weight is needed for quorum.
:require-consensus-key? true, and each genesis validator's public :consensus-key in its stake record. Keep the online vote secret and its signing WAL together across restarts.skuld.join/node-options. Proposals use a zero-based :height and a vector of canonical base64url signed CBOR frames in :txs. Use skuld.join/proposal-frames in the finalization handler.{:cursor n :digest hex} independently of the archive. A continuously following replica computes the digest by folding skuld.join/history-digest over finalized proposals in order, starting with nil. The checkpoint commits to the ordered history up to and excluding consensus height n. When old staking keys may have changed hands, verifying historical signatures alone cannot establish which chain the community currently follows.(join/bootstrap! driver wal options checkpoint (join/http-history archive-url) apply-finalized!) in fresh staging stores. The archive can be a static HTTP server serving one archival CBOR map {:proposal p :certificate c} per numeric height. Verification uses each historical committee's own keys and quorum. On failure discard the staging stores. A returning signer must recover its existing WAL to preserve double-sign protection.validator/start-validator! with the verified WAL, the same options and finalization handler, and a reachable Kabel seed. Every replica derives transport and vote verification keys from its own finalized staking state. A seed provides connectivity. Authorization comes from stake and verified keys.Open a dedicated, persistent gateway store per chain and run a single writer. Point the gateway at a following replica. The following ingress accepts ordinary signed writes from funded accounts. Supply the application’s other envelope verifiers to serve additional envelope kinds.
(require '[skuld.gateway :as gateway]
'[skuld.block :as block]
'[skuld.ledger.account :as account]
'[skuld.ledger.authz :as authz])
(def inbox (gateway/open! "/var/lib/skuld/gateway" chain))
(defn admit-write? [{:keys [sender public-key] :as env}]
(let [acct (account/account (block/finalized-db @conn) sender)]
(and (authz/authorised? (:genesis acct) public-key sender)
(<!! (authz/verified-author? env)))))
(def http (gateway/serve! inbox "127.0.0.1" 8080 admit-write?))
POST one CBOR frame to /transactions. HTTP 202 means the frame reached the persistent queue. HTTP 429 means the queue is full. Use (gateway/batch inbox) when proposing. It returns the oldest frames that fit a block. Bound the public endpoint’s request rate, connection lifetime and body size at a TLS reverse proxy. Multiple independently operated gateways can submit to the same chain through their own proposers.
Call (gateway/publish! inbox signing-committee {:proposal p :certificate c}) on locally finalized decisions in height order. Use gateway/committee-verifier to capture the powers and historical vote keys for the committee before the handoff at that height. The call verifies quorum, writes the history record, then advances the durable checkpoint and removes included frames. On restart resume at (:cursor (gateway/checkpoint inbox)), retrieving any missing decisions from retained consensus history or another verified archive. Retain backups of the archive before pruning consensus history.
GET /history/<height> for the archival CBOR record and GET /checkpoint for CBOR {:cursor n :digest hex}. Publish the checkpoint from an independently trusted following replica over an authenticated channel. Operators can mirror the history files anywhere and compare the locally reconstructed digest with that independently obtained pin.
signer/provision! creates a new POSIX owner-only directory containing a freshly generated vote secret and a dedicated Konserve WAL. Keep its parent on a private durable volume. Provision once. During service, hold (signer/open! dir chain operator-namespace) open, use its :private and :wal with the validator, and stop the validator before closing the signer. Opening verifies the chain, namespace and WAL binding and takes an exclusive local file lock.
For a planned move, stop and fence the old process, copy or move the complete quiescent directory and ledger, then reopen on the new host. An old copy of the matching WAL can still omit later votes. Local locking cannot fence another machine or detect a volume rollback. If the latest signing state is lost or uncertain, keep that key offline. Use the staking exit and new-identity registration path to return with a fresh key. Run bin/check-tendermint-restore to exercise recovery of a lagging replica while preserving its own signing witness.
bin/check-validator-join runs five replicas in one JVM with separate Datahike databases and WALs, real WebSocket consensus, and a loopback HTTP transaction and history endpoint. Four validators start with power one each. The fifth identity is generated after the first commit. It receives funds, registers, bonds three units of power, verifies four historical certificates, and signs at height 4. The committee's seven units of power require five for a commit, so the original four alone cannot pass the check.
The drill uses the persistent gateway and local signer. Its proposer schedules test batches, supplies deterministic block times and uses an empty rewards/liveness commit input.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |