-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hydra as a source #823
base: main
Are you sure you want to change the base?
Conversation
a69fcb2
to
db0e8fa
Compare
- use tokio-tungstenite to communicate with hydra node - deserialize some messages and pass data to oura To run, first start the hydra demo: ```bash cd hydra/demo ./prepare-devnet.sh docker compose up -d cardano-node ./seed-devnet.sh docker compose up -d hydra-node-{1,2,3} ``` Then, in this repositroy, run: ```bash cargo run daemon --config examples/hydra/daemon.toml ```
c8bd0ec
to
bc48a28
Compare
this is looking really good! 🚀 |
This allows us to resume processing from a point specified in the config. Tested manually using the following steps: 1. Ensure hydra demo is running 2. `cargo run daemon --config examples/hydra/daemon.toml` 3. Read the `seq` and `head_id` of the last message printed 4. Set the following in `hydra/daemon.toml`: ``` [intersect] type = "Point" value = [ 7, "84e657e3dd5241caac75b749195f78684023583736cc08b2896290ab" ] ``` but with `7` and `84e657e3dd5241caac75b749195f78684023583736cc08b2896290ab` being the actually observed `seq` and `head_id` values. 5. Restart `oura` 6. Observe that `oura` ignores all previously processed messages
Add basic intersect logic to hydra source
With this we see output from oura like: ```json {"event":"apply","point":{"hash":"0000000000000000000000000000000000000000000000000000000000000000","slot":1},"record":{"peer":"2","seq":1,"tag":"PeerConnected","timestamp":"2024-10-15T11:48:00.516366926Z"}} ```
Forward all `raw_json` of hydra messages
I believe the `skip_deserializing` turn messages of these types into the `Other` payload anyway, so having them here is confusing.
Drop unneeded `Optional` from `payload` field
- Use random TCP ports - Use random output files - Use goldenfile (has the practical UPDATE_GOLDENFILES=1 flag)
Tweak integration tests
Integration tests
Make intersection logic more robust
We can't know of the chain tip before we actually reach it when processing.
Drop unused metrics & correct dummy hash length
examples/.gitignore
Outdated
scratchpad | ||
tests/hydra/logs.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/hydra/logs.txt |
src/sources/hydra.rs
Outdated
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct Snapshot { | ||
number: u64, | ||
confirmed_transaction_ids: Vec<String>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Serialize, Deserialize, Debug, Clone)] | |
pub struct Snapshot { | |
number: u64, | |
confirmed_transaction_ids: Vec<String>, | |
} |
This is currently unused
src/sources/hydra.rs
Outdated
|
||
#[derive(Deserialize)] | ||
pub struct Config { | ||
pub hydra_socket_url: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this is more correct:
pub hydra_socket_url: String, | |
pub hydra_socket_path: String, |
hi @scarmuega ready for the review! cheers |
The PR adds hydra as a source talking through websocket opened as hydra side.
The core of the solution is pinned around:
As a result of Hydra websocket communication hydra source offers :
(a) sequence number which orders communication msgs
(b) optional hydra tail id (optional as it is established only when all parties commit)
(c) payload which determines if a given msg is either valid tx (here cbor is extracted) or of other sort (fanning out, commiting, ..etc)
(d) raw json in case consumer wants to get more than is extracted in (c)
Intersection support if added. If one wants to consume from a given slot onwards the older msg are filtered out for the consumer.
In order to test the solution the following tests were added.