Skip to content
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

Implement a simple stateless observation executable #1158

Merged
merged 55 commits into from
Nov 13, 2023

Conversation

abailly-iohk
Copy link
Contributor

@abailly-iohk abailly-iohk commented Nov 8, 2023

📋 Created a hydra-chain-observer executable, which prints a few basic observations of the head life-cycle.

📋 The chain observer does connect directly to a cardano-node just the same as a ydra-node` would.

📋 Refactored low-level observation functions to only take UTxO and Tx (especially the observeCommitTx).


  • CHANGELOG updated or not needed

  • Documentation updated or not needed

  • Haddocks updated or not needed

  • No new TODOs introduced or explained herafter

    • One TODO in State.hs about a stateful generator - this will be removed once we get rid of stateful observation anyways

ch1bo and others added 30 commits November 8, 2023 09:35
This asserts the initialization of a Hydra head is also seen by the (not
yet existing) hydra-chain-observer executable
We might want to implement that strategy as an observeRawCollectTx
first and see whether that aligns with the "full" observation.
@ch1bo ch1bo force-pushed the ensemble/stateless-observation-tool branch from 272f149 to 4dbfa12 Compare November 10, 2023 10:28
@ch1bo ch1bo marked this pull request as ready for review November 10, 2023 10:29
@ch1bo ch1bo mentioned this pull request Nov 10, 2023
3 tasks
@ch1bo ch1bo force-pushed the ensemble/stateless-observation-tool branch from 1eba0a4 to c8c9a7c Compare November 13, 2023 09:08
@ch1bo ch1bo requested review from v0d1ch and ffakenz November 13, 2023 09:13
@ch1bo ch1bo force-pushed the ensemble/stateless-observation-tool branch from 90f3532 to 22a9456 Compare November 13, 2023 10:03
This makes it clear that the hydra-node still only "cares" about commit
transactions about the head it knows in the chain layer.

prop "Does not updates UTxO state given transactions outside of Head lifecycle" $
forAll genSequenceOfSimplePaymentTransactions $ \(utxo, txs) ->
fst (observeAll testNetworkId utxo txs) === utxo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abailly-iohk Do we need this? It's no harm if the UTxO is always updated, even when nothing is observed. I think it would simplify the implementation a bit if we remove this constraint.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an optimization. That is, we do not accumulate memory on unrelated transactions.

let initials = fst3 <$> initialInitials
observation <- observeCommitTx networkId initials tx
let utxo = getKnownUTxO st
observation <- observeCommitTx networkId utxo tx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SB: Shouldn't we make sure we only process commits of "our head" now?

Yes. This is implicit here (as only UTxO of our head are resolvable), but could be improved by an explicit guard $ headId == commitHeadId or so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

github-actions bot commented Nov 13, 2023

Test Results

366 tests  +3   361 ✔️ +3   21m 38s ⏱️ + 1m 8s
124 suites +2       5 💤 ±0 
    5 files   ±0       0 ±0 

Results for commit 61ead85. ± Comparison against base commit 6a95190.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@v0d1ch v0d1ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work guys!

@ch1bo
Copy link
Collaborator

ch1bo commented Nov 13, 2023

Tested this manually against preprod to find the currently open head we use in our tactical meetings:

cabal run hydra-chain-observer -- --node-socket testnets/preprod/node.socket --testnet-magic 1 --start-chain-from "43251332.9ea784cd95687e3c90a17b6f3633b5554f25a3ceba82f860c2e4d3cb57a0b236" | jq 'select(.message.tag == "HeadInitTx")'

Will output:

{
  "timestamp": "2023-11-13T14:17:57.570680734Z",
  "threadId": 6,
  "namespace": "hydra-chain-observer",
  "message": {
    "headId": "1185347034540e3a9c60c69a73185ebdcd3b06cd243047aea289e6b6",
    "tag": "HeadInitTx"
  }
}

@ch1bo ch1bo merged commit 224405e into master Nov 13, 2023
20 checks passed
@ch1bo ch1bo deleted the ensemble/stateless-observation-tool branch November 13, 2023 14:36
@ch1bo ch1bo added this to the 0.14.0 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants