Skip to content

Commit

Permalink
Allow committing internal wallet utxos (#1463)
Browse files Browse the repository at this point in the history
Closes #1442

* [x] CHANGELOG updated or not needed
* [x] Documentation updated or not needed
* [x] Haddocks updated or not needed
* [x] No new TODOs introduced or explained herafter

---------

Co-authored-by: Sasha Bogicevic <[email protected]>
  • Loading branch information
errfrom and v0d1ch committed Jun 7, 2024
1 parent ce5e590 commit 4fed462
Show file tree
Hide file tree
Showing 10 changed files with 6,067 additions and 6,107 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ changes.
## [0.18.0] - Unreleased

- **DO NOT RELEASE** as the tested `cardano-node` version is not intended to be used on `mainnet` yet.

- Tested with `cardano-node 8.11.0` and `cardano-cli 8.23.1.0`.

- **BREAKING** Changes to the `hydra-node` API `/commit` endpoint [#1463](https://github.com/input-output-hk/hydra/pull/1463):
- Removed the check that prevented committing UTxOs from an internal `hydra-node` wallet.
- `SpendingNodeUtxoForbidden` error was removed.

## [0.17.0] - 2024-05-20

- **BREAKING** Change `hydra-node` API `/commit` endpoint for committing from scripts [#1380](https://github.com/input-output-hk/hydra/pull/1380):
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
inputs.iohk-nix.overlays.haskell-nix-crypto
# Keep haskell.nix as the last overlay!
#
# Reason: haskell.nix modules/overlays neds to be last
# Reason: haskell.nix modules/overlays needs to be last
# https://github.com/input-output-hk/haskell.nix/issues/1954
inputs.haskellNix.overlay
# Custom static libs used for darwin build
Expand Down
38 changes: 25 additions & 13 deletions hydra-cluster/test/Test/DirectChainSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,46 @@ spec = around (showLogsOnFailure "DirectChainSpec") $ do
ScriptFailedInWallet{} -> True
_ -> False

it "can commit" $ \tracer ->
it "can commit using external wallet" $ \tracer ->
withTempDir "hydra-cluster" $ \tmp -> do
withCardanoNodeDevnet (contramap FromNode tracer) tmp $ \node@RunningNode{nodeSocket} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
-- Alice setup
(aliceCardanoVk, aliceCardanoSk) <- keysFor Alice
(aliceCardanoVk, _) <- keysFor Alice
seedFromFaucet_ node aliceCardanoVk 100_000_000 (contramap FromFaucet tracer)
aliceChainConfig <- chainConfigFor Alice tmp nodeSocket hydraScriptsTxId [] cperiod
withDirectChainTest (contramap (FromDirectChain "alice") tracer) aliceChainConfig alice $
\aliceChain@DirectChainTest{postTx} -> do
aliceUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 (contramap FromFaucet tracer)

participants <- loadParticipants [Alice]
let headParameters = HeadParameters cperiod [alice]
postTx $ InitTx{participants, headParameters}

headId <- fst <$> aliceChain `observesInTimeSatisfying` hasInitTxWith headParameters participants
-- deliberately use alice's key known to hydra-node to trigger the error
externalCommit node aliceChain aliceCardanoSk headId aliceUTxO
`shouldThrow` \case
(SpendingNodeUtxoForbidden :: PostTxError Tx) -> True
_ -> False

(aliceExternalVk, aliceExternalSk) <- generate genKeyPair
newAliceUTxO <- seedFromFaucet node aliceExternalVk 1_000_000 (contramap FromFaucet tracer)
aliceUTxO <- seedFromFaucet node aliceExternalVk 1_000_000 (contramap FromFaucet tracer)
externalCommit node aliceChain aliceExternalSk headId aliceUTxO

externalCommit node aliceChain aliceExternalSk headId newAliceUTxO
aliceChain `observesInTime` OnCommitTx headId alice newAliceUTxO
aliceChain `observesInTime` OnCommitTx headId alice aliceUTxO

it "can commit using internal hydra-node wallet" $ \tracer ->
withTempDir "hydra-cluster" $ \tmp -> do
withCardanoNodeDevnet (contramap FromNode tracer) tmp $ \node@RunningNode{nodeSocket} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
-- Alice setup
(aliceCardanoVk, aliceCardanoSk) <- keysFor Alice
seedFromFaucet_ node aliceCardanoVk 100_000_000 (contramap FromFaucet tracer)
aliceChainConfig <- chainConfigFor Alice tmp nodeSocket hydraScriptsTxId [] cperiod
withDirectChainTest (contramap (FromDirectChain "alice") tracer) aliceChainConfig alice $
\aliceChain@DirectChainTest{postTx} -> do
participants <- loadParticipants [Alice]
let headParameters = HeadParameters cperiod [alice]
postTx $ InitTx{participants, headParameters}
headId <- fst <$> aliceChain `observesInTimeSatisfying` hasInitTxWith headParameters participants

aliceUTxO <- seedFromFaucet node aliceCardanoVk 1_000_000 (contramap FromFaucet tracer)
externalCommit node aliceChain aliceCardanoSk headId aliceUTxO

aliceChain `observesInTime` OnCommitTx headId alice aliceUTxO

it "can commit empty UTxO" $ \tracer -> do
withTempDir "hydra-cluster" $ \tmp -> do
Expand Down
Loading

0 comments on commit 4fed462

Please sign in to comment.