Skip to content

Commit 69d3cfb

Browse files
committed
revisions
1 parent 4389fbb commit 69d3cfb

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

docs/adr/2023-10-25_025-streaming-persistence.md docs/adr/2023-11-07_029-streaming-persistence.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ tags: []
77
---
88

99
## Status
10-
1110
N/A
1211

1312
## Context
@@ -24,7 +23,7 @@ Additionally, much of the changes that would need to happen to solve any of thes
2423

2524
-------------------------------------
2625

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.
2827

2928
- Client must be flexible and ready to handle many different events
3029

@@ -35,31 +34,39 @@ Additionally, much of the changes that would need to happen to solve any of thes
3534
- 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)
3635
- Could also just directly use a "compatible" spec like STOMP or MQTT, but that would lock in implementation details
3736

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
4442

4543
# Decision
4644

4745
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
4947
- FileEventServer, which increments a counter for the ID, and encapsulates the existing file persistence mechanism
5048
- SocketEventServer, which increments a counter for the ID, and writes the event to an arbitrary unix socket
5149
- 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.
5254
- 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)
5355

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.
5557

5658
## Consequences
5759

5860
The primary consequence of this is to enable deeper integration and better operationalization of the Hydra node. For example:
5961
- Users may now use the SocketEventServer to implement custom integrations with existing ecosystem tools
6062
- 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
6264
- Developers can get exposure to events that aren't normally surfaced in the websocket API
6365
- Logging, metrics, and durability can be improved or tailored to the application through such integrations
6466

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.
68+
69+
[offline-mode]: 2023-10-16_028_offline_adr.md
70+
[#119]: https://github.com/input-output-hk/hydra/pull/119
71+
[zmq]: https://github.com/input-output-hk/hydra/blob/41598800a9e0396c562a946780909732e5332245/CHANGELOG.md?plain=1#L710-
72+
[#230]: https://github.com/input-output-hk/hydra/pull/230

0 commit comments

Comments
 (0)