Skip to content

Commit

Permalink
Change Era from BabbageEra to ConwayEra
Browse files Browse the repository at this point in the history
Do filter protocol updates in Arbitrary Tx anymore

Those are now represented differently in Conway and we'll see how the
fully random transactions (including governance actions that supersede
protocol updates) behave in situations where we use this generator.
  • Loading branch information
locallycompact committed Mar 14, 2024
1 parent c11f442 commit 8fae6e9
Show file tree
Hide file tree
Showing 31 changed files with 34,856 additions and 35,233 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ changes.

- **DO NOT RELEASE** as only tested against Sanchonet.

- **BREAKING** Update to and tested against `cardano-node 8.9.0` and `cardano-cli 8.20.3.0`. This made smoke tests incompatible with public testnets and mainnet.
- **BREAKING** Update to and tested against `cardano-node 8.9.0` and `cardano-cli 8.20.3.0`.

- **BREAKING** Hydra scripts changed due to updates in the `plutus` toolchain:
- Overall slight increase in script size.
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build": "yarn prepare && docusaurus build",
"build-dev": "yarn prepare && docusaurus build --no-minify -l en",
"start": "yarn dummy-spec && docusaurus start",
"validate:inputs": "./validate-api.js publish '/' '../hydra-node/golden/ReasonablySized (ClientInput (Tx BabbageEra)).json'",
"validate:outputs": "./validate-api.js subscribe '/' '../hydra-node/golden/ReasonablySized (TimedServerOutput (Tx BabbageEra)).json'",
"validate:inputs": "./validate-api.js publish '/' '../hydra-node/golden/ReasonablySized (ClientInput (Tx ConwayEra)).json'",
"validate:outputs": "./validate-api.js subscribe '/' '../hydra-node/golden/ReasonablySized (TimedServerOutput (Tx ConwayEra)).json'",
"validate": "yarn validate:inputs && yarn validate:outputs",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Cardano/Api/UTxO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Data.Text (Text)
import Data.Text qualified as T
import Prelude

type Era = BabbageEra
type Era = ConwayEra

type UTxO = UTxO' (TxOut CtxUTxO Era)

Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Data.Typeable (Typeable)
import GHC.Stack (HasCallStack)
import Test.QuickCheck (Arbitrary (..), Gen)

type Era = BabbageEra
type Era = ConwayEra

-- | Currently supported ledger era.
type LedgerEra = ShelleyLedgerEra Era
Expand Down
6 changes: 3 additions & 3 deletions hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Hydra.Cardano.Api.TxBody where
import Hydra.Cardano.Api.Prelude

import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
import Cardano.Ledger.Api (AlonzoPlutusPurpose (..), AsIndex, AsItem (..), PlutusPurpose)
import Cardano.Ledger.Api (AsIndex, AsItem (..), ConwayPlutusPurpose (..), PlutusPurpose)
import Cardano.Ledger.Babbage.Core (redeemerPointer)
import Cardano.Ledger.BaseTypes (strictMaybeToMaybe)
import Cardano.Ledger.Core qualified as Ledger
Expand All @@ -23,7 +23,7 @@ findRedeemerSpending ::
TxIn ->
Maybe a
findRedeemerSpending (getTxBody -> ShelleyTxBody _ body _ scriptData _ _) txIn = do
ptr <- strictMaybeToMaybe $ redeemerPointer body (AlonzoSpending . AsItem $ toLedgerTxIn txIn)
ptr <- strictMaybeToMaybe $ redeemerPointer body (ConwaySpending . AsItem $ toLedgerTxIn txIn)
lookupRedeemer ptr scriptData

findRedeemerMinting ::
Expand All @@ -32,7 +32,7 @@ findRedeemerMinting ::
PolicyId ->
Maybe a
findRedeemerMinting (getTxBody -> ShelleyTxBody _ body _ scriptData _ _) pid = do
ptr <- strictMaybeToMaybe $ redeemerPointer body (AlonzoMinting . AsItem $ toLedgerPolicyID pid)
ptr <- strictMaybeToMaybe $ redeemerPointer body (ConwayMinting . AsItem $ toLedgerPolicyID pid)
lookupRedeemer ptr scriptData

findScriptMinting ::
Expand Down
4 changes: 1 addition & 3 deletions hydra-chain-observer/src/Hydra/ChainObserver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Hydra.Cardano.Api (
UTxO,
chainTipToChainPoint,
connectToLocalNode,
convertTx,
getChainPoint,
getTxBody,
getTxId,
Expand Down Expand Up @@ -172,8 +171,7 @@ chainSyncClient tracer networkId startingPoint observerHandler =
ClientStNext
{ recvMsgRollForward = \blockInMode tip -> ChainSyncClient $ do
let txs = case blockInMode of
BlockInMode ConwayEra (Block _header conwayTxs) -> mapMaybe convertTx conwayTxs
BlockInMode BabbageEra (Block _header babbageTxs) -> babbageTxs
BlockInMode ConwayEra (Block _header conwayTxs) -> conwayTxs
_ -> []

(BlockInMode _ (Block bh@(BlockHeader _ _ blockNo) _)) = blockInMode
Expand Down
1 change: 1 addition & 0 deletions hydra-cluster/config/devnet/cardano-node.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"TestMaryHardForkAtEpoch": 0,
"TestAlonzoHardForkAtEpoch": 0,
"TestBabbageHardForkAtEpoch": 0,
"TestConwayHardForkAtEpoch": 0,

"RequiresNetworkMagic": "RequiresNoMagic",

Expand Down
11 changes: 0 additions & 11 deletions hydra-cluster/src/CardanoNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,6 @@ setupCardanoDevnet stateDirectory = do
Aeson.encodeFile (stateDirectory </> nodeTopologyFile args) $
mkTopology peers

-- | Modify the cardano-node configuration to fork into conway at given era
-- number.
forkIntoConwayInEpoch :: FilePath -> CardanoNodeArgs -> Natural -> IO ()
forkIntoConwayInEpoch stateDirectory args n = do
config <-
unsafeDecodeJsonFile @Aeson.Value (stateDirectory </> nodeConfigFile args)
<&> atKey "TestConwayHardForkAtEpoch" ?~ toJSON n
Aeson.encodeFile
(stateDirectory </> nodeConfigFile args)
config

withCardanoNode ::
Tracer IO NodeLog ->
FilePath ->
Expand Down
115 changes: 0 additions & 115 deletions hydra-cluster/test/Test/EndToEndSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import CardanoClient (
)
import CardanoNode (
CardanoNodeArgs (..),
forkIntoConwayInEpoch,
setupCardanoDevnet,
unsafeDecodeJsonFile,
withCardanoNode,
Expand Down Expand Up @@ -507,120 +506,6 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
logfile <- readFileBS logFilePath
BS.length logfile `shouldSatisfy` (> 0)

describe "forking eras" $ do
it "does report on unsupported era" $ \tracer -> do
pendingWith "Currently supporting Conway era no future upcoming"
withClusterTempDir $ \tmpDir -> do
args <- setupCardanoDevnet tmpDir
forkIntoConwayInEpoch tmpDir args 1
withCardanoNode (contramap FromCardanoNode tracer) tmpDir args $ \node@RunningNode{nodeSocket} -> do
let hydraTracer = contramap FromHydraNode tracer
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod
withHydraNode' hydraTracer chainConfig tmpDir 1 aliceSk [] [1] Nothing $ \out stdErr ph -> do
-- Assert nominal startup
waitForLog 5 out "missing NodeOptions" (Text.isInfixOf "NodeOptions")

waitUntilEpoch tmpDir args node 1

waitForProcess ph `shouldReturn` ExitFailure 1
errorOutputs <- hGetContents stdErr
errorOutputs `shouldContain` "Received blocks in unsupported era"
errorOutputs `shouldContain` "upgrade your hydra-node"

it "does report on unsupported era on startup" $ \tracer -> do
pendingWith "Currently supporting Conway era no future upcoming"
withClusterTempDir $ \tmpDir -> do
args <- setupCardanoDevnet tmpDir
forkIntoConwayInEpoch tmpDir args 1
withCardanoNode (contramap FromCardanoNode tracer) tmpDir args $ \node@RunningNode{nodeSocket} -> do
let hydraTracer = contramap FromHydraNode tracer
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod

waitUntilEpoch tmpDir args node 2

withHydraNode' hydraTracer chainConfig tmpDir 1 aliceSk [] [1] Nothing $ \_out stdErr ph -> do
waitForProcess ph `shouldReturn` ExitFailure 1
errorOutputs <- hGetContents stdErr
errorOutputs `shouldContain` "Connected to cardano-node in unsupported era"
errorOutputs `shouldContain` "upgrade your hydra-node"

it "support new era" $ \tracer -> do
withClusterTempDir $ \tmpDir -> do
args <- setupCardanoDevnet tmpDir

forkIntoConwayInEpoch tmpDir args 10
withCardanoNode (contramap FromCardanoNode tracer) tmpDir args $
\node@RunningNode{nodeSocket} -> do
let lovelaceBalanceValue = 100_000_000
-- Funds to be used as fuel by Hydra protocol transactions
(aliceCardanoVk, _) <- keysFor Alice
seedFromFaucet_ node aliceCardanoVk lovelaceBalanceValue (contramap FromFaucet tracer)
-- Get some UTXOs to commit to a head
(aliceExternalVk, aliceExternalSk) <- generate genKeyPair
committedUTxOByAlice <- seedFromFaucet node aliceExternalVk aliceCommittedToHead (contramap FromFaucet tracer)

hydraScriptsTxId <- publishHydraScriptsAs node Faucet
chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod

let hydraTracer = contramap FromHydraNode tracer
withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1] $ \n1 -> do
send n1 $ input "Init" []
headId <- waitForAllMatch 10 [n1] $ headIsInitializingWith (Set.fromList [alice])

requestCommitTx n1 committedUTxOByAlice <&> signTx aliceExternalSk >>= submitTx node

waitFor hydraTracer 3 [n1] $ output "HeadIsOpen" ["utxo" .= committedUTxOByAlice, "headId" .= headId]

waitUntilEpoch tmpDir args node 10

send n1 $ input "Close" []
waitMatch 3 n1 $ \v -> do
guard $ v ^? key "tag" == Just "HeadIsClosed"
guard $ v ^? key "headId" == Just (toJSON headId)
snapshotNumber <- v ^? key "snapshotNumber"
guard $ snapshotNumber == Aeson.Number 0

it "support new era on restart" $ \tracer -> do
withClusterTempDir $ \tmpDir -> do
args <- setupCardanoDevnet tmpDir

forkIntoConwayInEpoch tmpDir args 10
withCardanoNode (contramap FromCardanoNode tracer) tmpDir args $
\node@RunningNode{nodeSocket} -> do
let lovelaceBalanceValue = 100_000_000
-- Funds to be used as fuel by Hydra protocol transactions
(aliceCardanoVk, _) <- keysFor Alice
seedFromFaucet_ node aliceCardanoVk lovelaceBalanceValue (contramap FromFaucet tracer)
-- Get some UTXOs to commit to a head
(aliceExternalVk, aliceExternalSk) <- generate genKeyPair
committedUTxOByAlice <- seedFromFaucet node aliceExternalVk aliceCommittedToHead (contramap FromFaucet tracer)

hydraScriptsTxId <- publishHydraScriptsAs node Faucet
chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod

let hydraTracer = contramap FromHydraNode tracer
headId <- withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1] $ \n1 -> do
send n1 $ input "Init" []
headId <- waitForAllMatch 10 [n1] $ headIsInitializingWith (Set.fromList [alice])

requestCommitTx n1 committedUTxOByAlice <&> signTx aliceExternalSk >>= submitTx node

waitFor hydraTracer 3 [n1] $ output "HeadIsOpen" ["utxo" .= committedUTxOByAlice, "headId" .= headId]

pure headId

waitUntilEpoch tmpDir args node 10

withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1] $ \n1 -> do
send n1 $ input "Close" []
waitMatch 3 n1 $ \v -> do
guard $ v ^? key "tag" == Just "HeadIsClosed"
guard $ v ^? key "headId" == Just (toJSON headId)
snapshotNumber <- v ^? key "snapshotNumber"
guard $ snapshotNumber == Aeson.Number 0

-- | Wait until given number of epoch. This uses the epoch and slot lengths from
-- the 'ShelleyGenesisFile' of the node args passed in.
waitUntilEpoch :: FilePath -> CardanoNodeArgs -> RunningNode -> Natural -> IO ()
Expand Down
2 changes: 1 addition & 1 deletion hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec =
output
^? key "type" . _String `shouldSatisfy` \case
Nothing -> False
Just something -> something == "Witnessed Tx BabbageEra"
Just something -> something == "Witnessed Tx ConwayEra"

it "has expected cardano-cli version available" $
readProcess "cardano-cli" ["--version"] "" >>= (`shouldContain` "8.20.3.0")
Expand Down
Loading

0 comments on commit 8fae6e9

Please sign in to comment.