You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/adr/2023-11-07_029-streaming-persistence.md
+19-12
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ tags: []
7
7
---
8
8
9
9
## Status
10
-
11
10
N/A
12
11
13
12
## Context
@@ -24,7 +23,7 @@ Additionally, much of the changes that would need to happen to solve any of thes
24
23
25
24
-------------------------------------
26
25
27
-
- Current client API is a stateful WebSocket connection. Client API has its own incrementally persisted state that must be maintained, and includes a monotonically increasing `Seq`number, but this is based off the events dealing with the client, not the host hydra-node.
26
+
- Current client API is a stateful WebSocket connection. Client API has its own incrementally persisted state that must be maintained, and includes a monotonically increasing `Seq`ID, but this is based off the events a client observes, not the Hydra host's event log.
28
27
29
28
- Client must be flexible and ready to handle many different events
30
29
@@ -35,31 +34,39 @@ Additionally, much of the changes that would need to happen to solve any of thes
35
34
- The challenge of subscribing to event types is complex to handle, but would be applicable to many parts of Hydra, not just for subscribing to new transactions. It's a good fit for passing stuff off to a message queue (MQTT, Kafka, whatever), probably from a dedicated process (see "Chain Server" below)
36
35
- Could also just directly use a "compatible" spec like STOMP or MQTT, but that would lock in implementation details
37
36
38
-
- Previous mock chain using ZeroMQ was [removed](https://github.com/input-output-hk/hydra/blob/41598800a9e0396c562a946780909732e5332245/CHANGELOG.md?plain=1#L710-) as part of [#119](https://github.com/input-output-hk/hydra/pull/119) due to complexity and feeling of ZeroMQ being unmaintained (primary author passed away, tag releases were not being cut for a while)
39
-
- Used for L1 mock chain, not L2 (Ledge, mentioned on line 32)
40
-
- Attempt in February 2023 to externalize chainsync server as part of [#231](https://github.com/input-output-hk/hydra/pull/230)
41
-
- Same sort of deal as #119, but the "Chain Server" component in charge of translating Hydra Websocket messages into direct chain, mock chain, or any hypothetical message queue, not necessarily just ZeroMQ
42
-
- Support from several people, but deemed low priority since they didn't know who would use it
43
-
- Roughly a template for what we want to do as a first pass, but for Hydra purposes we're more interested in Ledger as the target, and simply continuing to use L1 mock chain
37
+
- Previous mock chain using ZeroMQ was [removed][zmq] as part of [#119][#119], due to complexity and feeling of ZeroMQ being unmaintained (primary author no longer contributing, new tag release versions not being published)
38
+
- This mock chain was used to mock the layer L1 chain, not the L2 ledger
39
+
- Attempt in February 2023 to externalize chainsync server as part of [#230][#230]
40
+
- Similar to [#119][#119], but the "Chain Server" component in charge of translating Hydra Websocket messages into direct chain, mock chain, or any hypothetical message queue, not necessarily just ZeroMQ
41
+
- Deemed low priority due to ambiguous use-case at the time. SundaeSwap's Gummiworm Protocol would benefit from the additional control enabled by the Event Server
44
42
45
43
# Decision
46
44
47
45
A new abstraction, the EventServer, will be introduced. Each internal hydra event will be sent to the event server, which will be responsible for persisting that event and returning a durable monotonically increasing global event ID. Different implementations of the event server can handle this event differently. Initially, we will implement the following:
48
-
- MockEventServer, which increments a counter for the ID, and discards the event entirely
46
+
- MockEventServer, which increments a counter for the ID, and discards the event
49
47
- FileEventServer, which increments a counter for the ID, and encapsulates the existing file persistence mechanism
50
48
- SocketEventServer, which increments a counter for the ID, and writes the event to an arbitrary unix socket
51
49
- WebsocketBroadcastEventServer, which broadcasts the publicly visible events over the websocket API
50
+
- UTxOStateServer, which increments a counter for the ID, and updates a file with the latest UTxO after the event
51
+
- Generalizes the UTxO persistence mechanism introduced in [offline mode][offline-mode]
52
+
- May be configured to only persist UTxO state periodically and/or on SIGTERM, allowing for performant in-memory Hydra usage. This is intended for offline mode usecases where the transactions ingested are already persisted elsewhere.
53
+
- One configuration which we expect will be common and useful, is the usage of a MultiplexingEventServer configured with a primary MockEventServer, and a secondary UTxOStateServer, which will persist the UTxO state to disk.
52
54
- MultiplexingEventServer, which has a primary event server (which it writes to first, and uses its ID) and a list of secondary event servers (which it writes to in sequence, but discards the ID)
53
55
54
-
New configuration options will be introduced for choosing between and configuring these options for the event server. The default will be a multiplexing event server, using the file event server as its primary, and a websocket broadcast event server as its secondary.
56
+
New configuration options will be introduced for choosing between and configuring these options for the event server. The default will be a multiplexing event server, using the file event server as its primary event server, and a websocket broadcast event server as its secondary event server.
55
57
56
58
## Consequences
57
59
58
60
The primary consequence of this is to enable deeper integration and better operationalization of the Hydra node. For example:
59
61
- Users may now use the SocketEventServer to implement custom integrations with existing ecosystem tools
60
62
- To avoid the overhead of a unix socket, they may submit pull requests to add integrations with the most popular tools
61
-
- Developers may more easily maintain downstream forks with custom implementations that aren't appropriate for community-wide adoption
63
+
- Developers may more easily maintain downstream forks with custom implementations that aren't appropriate for community-wide adoption, such as the Gummiworm Protocol
62
64
- Developers can get exposure to events that aren't normally surfaced in the websocket API
63
65
- Logging, metrics, and durability can be improved or tailored to the application through such integrations
64
66
65
-
Note that while a future goal of this work is to improve the websocket API, making it more stateless and "subscription" based, this ADR does not seek to make those changes, only make them easier to implement in the future.
67
+
Note that while a future goal of this work is to improve the websocket API, making it more stateless and "subscription" based, this ADR does not seek to make those changes, only make them easier to implement in the future.
0 commit comments