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

Report error on unsupported era #1219

Merged
merged 38 commits into from
Dec 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c83adaf
Add test stub for surviving a conway fork
locallycompact Dec 13, 2023
bc7c41a
Draft era mismatch e2e test and configurable Devnet setup
ch1bo Dec 14, 2023
852f355
Resolve TODO for setting up cardano node in devnet
ffakenz Dec 14, 2023
62e2469
Remove unnecessary config from default
ffakenz Dec 14, 2023
e0c3d12
Change default cardano node config file name to match ours
ffakenz Dec 14, 2023
2d98b3f
Implement forkIntoConwayInEpoch function
ffakenz Dec 14, 2023
8f64c76
fix forkIntoConwayInEpoch by passing the stateDirectory to find the c…
ffakenz Dec 14, 2023
a7ef7ec
Add genDelegs to genesis-conway as it is needed for cardano-node to run
ffakenz Dec 14, 2023
bfb796d
Make stderr configurable in withHydraNode
locallycompact Dec 14, 2023
a7977c0
Fetch slotLength and epochLength from args
ffakenz Dec 15, 2023
07bb345
Introduce ChainClientException and try to catch it as part of e2e
ffakenz Dec 18, 2023
3dacdf1
Fix end-to-end test on non-supported cardano era
ch1bo Dec 19, 2023
74f4dc1
Use displayException in hydra-node to explain EraNotSupportedException
ch1bo Dec 19, 2023
1e37e59
Draft another e2e test about node failing on incorrect era
ch1bo Dec 19, 2023
cd63e5a
Fix e2e spec to report on startup
ffakenz Dec 19, 2023
fcc24c7
Minor formatting changes
ffakenz Dec 19, 2023
ad88952
Migrate configuration exceptions to use displayException to explain
ffakenz Dec 19, 2023
5a019ff
Update CHANGELOG
ffakenz Dec 19, 2023
c34532f
Update explain messages for not supported era exceptions
ffakenz Dec 19, 2023
1443e45
Improve getField helper function by using lenses
ffakenz Dec 20, 2023
c00ca7e
Reduce epochLengh even further to speedup tests depending on it
ffakenz Dec 20, 2023
d383b8c
Apply review changes
ffakenz Dec 20, 2023
0005a09
Remove stderr to be configurable in withHydraNode, as not needed
ffakenz Dec 20, 2023
dc38469
Revert cabal.project changes in code
ffakenz Dec 21, 2023
63a8e79
Minor fix to error output assertions
ffakenz Dec 21, 2023
eb25cb0
Remove addField helper, use aeson-lenses instead
ffakenz Dec 21, 2023
91d4c19
Improve era missmatch error messages
ffakenz Dec 21, 2023
92247a1
Enhance error msg for EraNotSupportedException
ffakenz Dec 21, 2023
a8dceda
Update fourmolu fixities to match treefmt rules
ffakenz Dec 21, 2023
d45ff93
Minor haddock fix
ffakenz Dec 21, 2023
4341484
Remove getField helper, use aeson-lenses instead
ffakenz Dec 21, 2023
ed41f2d
Minor formatting changes
ffakenz Dec 21, 2023
c1ffcb5
Improved delayEpoch so it waits until it reaches the target epoch
ffakenz Dec 22, 2023
3b458e3
Revert "Update fourmolu fixities to match treefmt rules"
ffakenz Dec 22, 2023
7b1b1c6
Minor formatting changes
ffakenz Dec 22, 2023
a22e308
Fix formatting for <&> in presence of ?~
ch1bo Dec 22, 2023
46d0f1b
Remove commented code
ffakenz Dec 22, 2023
a67ec3e
Improve error messages by using printf
ffakenz Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make stderr configurable in withHydraNode
locallycompact authored and ffakenz committed Dec 20, 2023

Verified

This commit was signed with the committer’s verified signature.
kianenigma Kian Paimani
commit bfb796d13afb01e3b64bef136dd1ad302911aa26
4 changes: 0 additions & 4 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -33,10 +33,6 @@ packages:
package *
ghc-options: -j8

-- Warnings as errors for local packages
program-options
ghc-options: -Werror

-- Always build tests and benchmarks of local packages
tests: True
benchmarks: True
26 changes: 15 additions & 11 deletions hydra-cluster/src/HydraNode.hs
Original file line number Diff line number Diff line change
@@ -366,14 +366,16 @@ withHydraNode ::
IO a
withHydraNode tracer chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds hydraScriptsTxId action = do
withLogFile logFilePath $ \logFileHandle -> do
withHydraNode' chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds hydraScriptsTxId (Just logFileHandle) $ do
\_ processHandle -> do
race
(checkProcessHasNotDied ("hydra-node (" <> show hydraNodeId <> ")") processHandle)
(withConnectionToNode tracer hydraNodeId action)
<&> either absurd id
withLogFile errorLogFilePath $ \errorLogFileHandle -> do
withHydraNode' chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds hydraScriptsTxId (Just logFileHandle) (Just errorLogFileHandle) $ do
\_ _ processHandle -> do
race
(checkProcessHasNotDied ("hydra-node (" <> show hydraNodeId <> ")") processHandle)
(withConnectionToNode tracer hydraNodeId action)
<&> either absurd id
where
logFilePath = workDir </> "logs" </> "hydra-node-" <> show hydraNodeId <.> "log"
errorLogFilePath = workDir </> "logs" </> "hydra-node-" <> show hydraNodeId <> "-errors" <.> "log"

-- | Run a hydra-node with given 'ChainConfig' and using the config from
-- config/.
@@ -388,9 +390,11 @@ withHydraNode' ::
TxId ->
-- | If given use this as std out.
Maybe Handle ->
(Handle -> ProcessHandle -> IO a) ->
-- | If given use this as std err.
Maybe Handle ->
(Handle -> Handle -> ProcessHandle -> IO a) ->
IO a
withHydraNode' chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds hydraScriptsTxId mGivenStdOut action = do
withHydraNode' chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds hydraScriptsTxId mGivenStdOut mGivenStdErr action = do
withSystemTempDirectory "hydra-node" $ \dir -> do
let cardanoLedgerProtocolParametersFile = dir </> "protocol-parameters.json"
readConfigFile "protocol-parameters.json" >>= writeFileBS cardanoLedgerProtocolParametersFile
@@ -423,12 +427,12 @@ withHydraNode' chainConfig workDir hydraNodeId hydraSKey hydraVKeys allNodeIds h
}
)
{ std_out = maybe CreatePipe UseHandle mGivenStdOut
, std_err = Inherit
, std_err = maybe CreatePipe UseHandle mGivenStdErr
}
withCreateProcess p $ \_stdin mCreatedHandle mErr processHandle ->
case (mCreatedHandle, mGivenStdOut, mErr) of
(Just out, _, _) -> action out processHandle
(Nothing, Just out, _) -> action out processHandle
(Just out, _, Just err) -> action out err processHandle
(Nothing, Just out, Just err) -> action out err processHandle
(_, _, _) -> error "Should not happen™"
where
peers =
13 changes: 7 additions & 6 deletions hydra-cluster/test/Test/EndToEndSpec.hs
Original file line number Diff line number Diff line change
@@ -461,7 +461,7 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
withCardanoNodeDevnet (contramap FromCardanoNode tracer) dir $ \node@RunningNode{nodeSocket} -> do
chainConfig <- chainConfigFor Alice dir nodeSocket [] (UnsafeContestationPeriod 1)
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
withHydraNode' chainConfig dir 1 aliceSk [] [1] hydraScriptsTxId Nothing $ \stdOut _processHandle -> do
withHydraNode' chainConfig dir 1 aliceSk [] [1] hydraScriptsTxId Nothing Nothing $ \stdOut _ _processHandle -> do
waitForLog 10 stdOut "JSON object with key NodeOptions" $ \line ->
line ^? key "message" . key "tag" == Just (Aeson.String "NodeOptions")

@@ -493,18 +493,19 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
withCardanoNode (contramap FromCardanoNode tracer) defaultNetworkId tmpDir args $ \node@RunningNode{nodeSocket} -> do
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
chainConfig <- chainConfigFor Alice tmpDir nodeSocket [] cperiod
withHydraNode' chainConfig tmpDir 1 aliceSk [] [1] hydraScriptsTxId Nothing $ \stdOut _processHandle -> do
withHydraNode' chainConfig tmpDir 1 aliceSk [] [1] hydraScriptsTxId Nothing Nothing $ \stdout stderr n1 -> do
-- Assert nominal startup
waitForLog 5 stdOut "missing NodeOptions" (Text.isInfixOf "NodeOptions")
waitForLog 5 stdout "missing NodeOptions" (Text.isInfixOf "NodeOptions")

delayEpoch args 1
-- TODO: should assert on stderr
hGetContents stdOut >>= (`shouldContain` "upgrade hydra-node")

hGetContents stderr >>= (`shouldContain` "upgrade hydra-node")

-- | Wait for given number of epochs. This uses the epoch and slot lengths from
-- the 'ShelleyGenesisFile' of the node args passed in.
-- TODO: not hard-code but use args
delayEpoch :: CardanoNodeArgs -> Natural -> IO ()
delayEpoch args epochs =
delayEpoch _ epochs =
threadDelay . realToFrac $ fromIntegral epochs * epochLength * slotLength
where
epochLength = 20
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Chain/Direct.hs
Original file line number Diff line number Diff line change
@@ -298,7 +298,7 @@ chainSyncClient handler wallet startingPoint =
onRollForward handler header txs
pure clientStIdle
_ -> do
_ <- error "Not supported"
_ <- error "Era not supported. Please upgrade hydra-node."
-- NOTE: We are just ignoring different era blocks. It's not
-- entirely clear if we would reach this point on a "next-era"
-- network (e.g. Conway) or just have a handshake problem before.