Skip to content

Commit 2fe866e

Browse files
authored
Embed etcd into hydra-node (#1992)
By compiling `etcd` into `hydra-node` we can get rid of the runtime dependency onto `etcd` in exchange for a build-time dependency and bigger binary size. ![image](https://github.com/user-attachments/assets/9cc82b87-3d92-4ad3-aec8-ef0895375d0f) While I was worried that we would need a static compiled `etcd`, it turns out the default one is already a static binary (likely because it's a go project!): ``` λ ldd $(realpath $(which etcd)) not a dynamic executable ``` That means, all our `hydra-node` builds contain a statically linked `etcd` binary now. ## File sizes Dynamic linked `hydra-node`: ``` λ ll $(nix build .#hydra-node --print-out-paths)/bin/hydra-node warning: Git tree '/home/ch1bo/code/iog/hydra' is dirty warning: Git tree '/home/ch1bo/code/iog/hydra' is dirty .r-xr-xr-x root root 90 MB Thu Jan 1 01:00:01 1970  /nix/store/mca588qi4glryha0d1kkg4s0lmbw6xqk-hydra-node/bin/hydra-node ``` Static linked `hydra-node`: ``` λ ll $(nix build .#hydra-node-static --print-out-paths)/bin/hydra-node warning: Git tree '/home/ch1bo/code/iog/hydra' is dirty warning: Git tree '/home/ch1bo/code/iog/hydra' is dirty .r-xr-xr-x root root 94 MB Thu Jan 1 01:00:01 1970  /nix/store/q3dr4fa7w3iy2rqrwp0xgr8bk364s6ka-hydra-node-x86_64-unknown-linux-musl/bin/hydra-node ``` Compressed (and darwin): ![image](https://github.com/user-attachments/assets/329680e3-f830-4310-8710-4a2ad22a8d56) ## Try it please It's unclear whether this works for all target platforms. To try it, download the binary of your platform from this CI action https://github.com/cardano-scaling/hydra/actions/workflows/binaries.yaml?query=branch%3Aembed-etcd and run ``` echo "{}" > utxo.json ./bin/hydra-node --offline-head-seed 01 --initial-utxo utxo.json --ledger-protocol-parameters hydra-cluster/config/protocol-parameters.json --persistence-dir ./tmp-etcd --node-id foo --hydra-signing-key demo/alice.sk ``` from within a hydra working copy. --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated * [x] Documentation updated * [x] Haddocks updated * [x] No new TODOs introduced
2 parents 73add22 + 0024f67 commit 2fe866e

File tree

17 files changed

+354
-197
lines changed

17 files changed

+354
-197
lines changed

.github/workflows/binaries.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- master
88
- release
9+
- embed-etcd
910
tags:
1011
- "*.*.*"
1112

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ changes.
1414

1515
- Fix tutorial usage of `cardano-cli` and include download of `etcd`.
1616

17-
* **BREAKING** Update scripts to plutus 1.45.0.0.
17+
- Remove runtime dependency to `etcd` by embedding and shipping it with `hydra-node`.
18+
- New option `--use-system-etcd` to prefer the system etcd instead of the embedded one.
19+
20+
- **BREAKING** Update scripts to plutus 1.45.0.0.
1821

1922
## [0.21.0] - 2025-04-28
2023

docs/adr/2025-02-12_032-network-properties-etcd.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Accepted
5757

5858
- Using `etcd` as-is adds a run-time dependency onto that binary.
5959
- Docker image users should not see any different UX
60+
- We can ship the binary through `hydra-node`.
6061

6162
- Introspectability network as the `etcd` cluster is queriable could improve debugging experience
6263

hydra-cluster/src/HydraNode.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Hydra.API.HTTPServer (DraftCommitTxRequest (..), DraftCommitTxResponse (.
2323
import Hydra.Cluster.Util (readConfigFile)
2424
import Hydra.HeadLogic.State (SeenSnapshot)
2525
import Hydra.Logging (Tracer, Verbosity (..), traceWith)
26-
import Hydra.Network (Host (Host), NodeId (NodeId))
26+
import Hydra.Network (Host (Host), NodeId (NodeId), WhichEtcd (EmbeddedEtcd))
2727
import Hydra.Network qualified as Network
2828
import Hydra.Options (ChainConfig (..), DirectChainConfig (..), LedgerConfig (..), RunOptions (..), defaultDirectChainConfig, toArgs)
2929
import Hydra.Tx (ConfirmedSnapshot)
@@ -399,6 +399,7 @@ prepareHydraNode chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds
399399
, hydraVerificationKeys
400400
, persistenceDir = stateDir
401401
, chainConfig
402+
, whichEtcd = EmbeddedEtcd
402403
, ledgerConfig =
403404
CardanoLedgerConfig
404405
{ cardanoLedgerProtocolParametersFile
@@ -518,6 +519,7 @@ withHydraNode tracer chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNod
518519
, hydraVerificationKeys
519520
, persistenceDir = stateDir
520521
, chainConfig
522+
, whichEtcd = EmbeddedEtcd
521523
, ledgerConfig =
522524
CardanoLedgerConfig
523525
{ cardanoLedgerProtocolParametersFile

0 commit comments

Comments
 (0)