feat: update dependencies in sync with node v9.1.0
Related to #326.
Is the remaining work here adding another GYEra, GYConway, then adding a GYConway branch to every place GYBabbage exists and doing the analogous thing?
Hey @eddiemundo, there are huge number of changes made that I haven't yet pushed to this branch as it's a bit of a mess atm. It's priority on our end to bring Conway support in Atlas asap.
Migration guide
General changes
- Atlas'
GYTxMonadhas been revamped, with details in this PR. In particular, to handle these changes, you might need to do following changes in your codebase:-
Use
runGYTxQueryMonadIOin place ofrunGYTxQueryMonadNode. I'll userunGYTxQueryMonadNode->runGYTxQueryMonadIOto denote such a change. -
GYTxQueryMonadNode->GYTxQueryMonadIO. -
GYTxMonadNode->GYTxBuilderMonadIO. -
GYTxBuildResult Identity->GYTxBuildResult. -
GYTxMonadcan likely be replaced withGYTxUserQueryMonadin your code. -
Some of the old functions such as
runGYTxMonadNodeare removed but these can be defined like so:runGYTxMonadNode :: GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO (GYTxSkeleton v) -> IO GYTxBody runGYTxMonadNode nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= buildTxBody runGYTxMonadNodeF :: forall t v. Traversable t => GYCoinSelectionStrategy -> GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO (t (GYTxSkeleton v)) -> IO (t GYTxBody) runGYTxMonadNodeF strat nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= traverse (buildTxBodyWithStrategy strat) runGYTxMonadNodeParallel :: GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO [GYTxSkeleton v] -> IO GYTxBuildResult runGYTxMonadNodeParallel nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= buildTxBodyParallel runGYTxMonadNodeParallelWithStrategy :: GYCoinSelectionStrategy -> GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO [GYTxSkeleton v] -> IO GYTxBuildResult runGYTxMonadNodeParallelWithStrategy strat nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= buildTxBodyParallelWithStrategy strat -
GYTxQueryMonadIOandGYTxBuilderMonadIOdo not haveMonadIOinstance, but these can be defined as shown:import GeniusYield.Unsafe (unsafeIOToQueryMonad, unsafeIOToTxBuilderMonad) instance MonadIO GYTxQueryMonadIO where liftIO = unsafeIOToQueryMonad instance MonadIO GYTxBuilderMonadIO where liftIO = unsafeIOToTxBuilderMonad
-
Privnet
How to run?
To run the privnet tests, first one needs to install cardano-node & cardano-cli like so:
cabal install --package-env=$(pwd) --overwrite-policy=always cardano-cli cardano-node
Then the tests can be ran, like for Atlas: cabal run atlas-privnet-tests -- -j1 --hide-successes
How to structure?
- Due to redesign of monads related to transaction building & query, functions such as
ctxRunIare no longer present, but they (and some of the related utilities) can be implemented like so:
ctxRunI :: Ctx -> User -> GYTxBuilderMonadIO (GYTxSkeleton v) -> IO GYTxBody
ctxRunI ctx user act = ctxRunBuilder ctx user $ act >>= buildTxBody
ctxRunC :: Ctx -> User -> GYTxBuilderMonadIO a -> IO a
ctxRunC = ctxRunBuilder
ctxRunF :: Traversable t => Ctx -> User -> GYTxBuilderMonadIO (t (GYTxSkeleton v)) -> IO (t GYTxBody)
ctxRunF ctx user act = ctxRunBuilder ctx user $ act >>= traverse buildTxBody
submitTxCtx :: Ctx -> User -> GYTxBody -> IO GYTxId
submitTxCtx ctx user txBody = ctxRun ctx user $ signAndSubmitConfirmed txBody
submitTxCtx' :: Ctx -> User -> GYTx -> IO GYTxId
submitTxCtx' ctx user tx = ctxRun ctx user $ submitTxConfirmed tx
addRefScriptCtx :: Ctx -> User -> GYScript PlutusV2 -> IO GYTxOutRef
addRefScriptCtx ctx user script = ctxRun ctx user $ addRefScriptToLimbo script
-
Earlier the tests might expect the argument
IO Setupbut now onlySetupis required which can be generated with following continuation:withPrivnet cardanoDefaultTestnetOptionsConway $ \setup. Please see privnet tests structured inside Atlas here for examples. -
Arguments of
withSetupare flipped, so instead ofwithSetup setup info, nowwithSetup info setupis required. -
Use
userChangeAddressinstead ofuserAddr. -
submitTxis removed, can use abovesubmitTxCtxfunction. -
In case you were catching of
BuildTxException(now renamed toGYBuildTxErrorand it no longer has instance forException), since now these are made part ofGYBuildTxExceptionconstructor insideGYTxMonadExceptiontype, catch for those instead. For example:- isTxBodyScriptExecutionError :: BuildTxException -> Bool - isTxBodyScriptExecutionError (BuildTxBodyErrorAutoBalance (Api.TxBodyScriptExecutionError _)) = True - isTxBodyScriptExecutionError _ = False + isTxBodyScriptExecutionError :: GYTxMonadException -> Bool + isTxBodyScriptExecutionError (GYBuildTxException (GYBuildTxBodyErrorAutoBalance (Api.TxBodyScriptExecutionError _))) = True + isTxBodyScriptExecutionError _ = False -
GYPrivnetnow has an additional field to store of the network information used internally, you can largely ignore those. -
Note that these privnet run against Conway era and protocol parameters can be check like so:
pp <- ctxRunQuery ctx protocolParams info $ printf "Protocol parameters: %s" (show pp)
Let us know if you think some of these should be changed!
CLB (cardano-ledger-backend, replacement of plutus-simple-model employed earlier) & new testing mechanism
Note that we now have unified testing in place, i.e., same test file can be ran against multiple backend interpreters, i.e., either utilising CLB, private testnet machinery or any of cardano network (testnet/mainnet).
It is best to see tests-unified directory to see how to structure these. In particular you don't need to write privnet tests separately!
-
There is no longer
Wallettype, useUserinstead. -
If you earlier had
runWallet w1 $ withWalletBalancesCheckSimple walletDiffList $ do ...You should instead do
withWalletBalancesCheckSimple walletDiffList $ asUser w1 $ do ... -
Note that since the testing mechanism is unified, you should no longer require to import types such as
GYTxMonadClbin your backend code. I.e., if you hadmyTrace :: SomeParameters -> Wallets -> GYTxMonadClb ()You should instead do
myTrace :: GYTxGameMonad m => SomeParameters -> Wallets -> m ()Note that
GYTxGameMonadconstraint should be added if you are employingasUserin your trace, otherwise make use ofGYTxMonadetc. -
Use
ownChangeAddressinstead ofownAddress. -
Instead of
fail ...usethrowAppError $ someBackendError $ .... -
sendSkeletonandsendSkeleton'can be defined like so:-- | This is simply defined as @buildTxBody skeleton >>= signAndSubmitConfirmed@. sendSkeleton :: GYTxMonad m => GYTxSkeleton v -> m GYTxId sendSkeleton skeleton = snd <$> sendSkeleton' skeleton sendSkeleton' :: GYTxMonad m => GYTxSkeleton v -> m (GYTxBody, GYTxId) sendSkeleton' skeleton = buildTxBody skeleton >>= \tx -> signAndSubmitConfirmed tx >>= \txId -> pure (tx, txId)
Single test inside atlas-tests test-suite fails as there is a bug in Maestro where it returns extra registered stake pools (on preprod) for it's /pools endpoint.
Good migration guide. I'd add that there is a withSetupOld that is there for compatibility. Furthermore, there is also a pattern User' with the old fields such as userAddr and such for compatibility.
I think the migration guide should also request people to move to the new tx monad hierarchy design (i.e don't use more powerful monad than needed), before opting for the drop in functions like runGYTxMonadNodeF, ctxRunF etc.
Could you also put the short brief on the tx monad hierarchy in the migration guide (when creating a new release?)
@TotallyNotChase Thanks for your review! It's highly appreciated.
@TotallyNotChase
But there ought to be some manual sanity checking transactions submitted to Preprod, and finally to mainnet later on.
Yes, we have been testing these changes with our dapp.
@TotallyNotChase
The hardcoded PParams related things need to have a tracking issue (so they can be updated later).
Yes, this was on radar! I have created issue for it here.
I tried pulling from the branch update-node-9.1.0 and it doesn't compile for me because
• Not in scope: data constructor ‘Blockfrost.PlutusV3’
NB: the module ‘Blockfrost.Client’ does not export ‘PlutusV3’.
• Perhaps use one of these:
‘Blockfrost.PlutusV1’ (imported from Blockfrost.Client),
‘Blockfrost.PlutusV2’ (imported from Blockfrost.Client)
which seems to be because blockfrost-client ^>=0.8.0 depends on blockfrost-api < 0.11 and Blockfrost.PlutusV3 comes from blockfrost-api 0.11.0
How do I get it to use blockfrost-api 0.11.0...
How do I get it to use
blockfrost-api 0.11.0...
Sorry, I just needed to cabal update.
@eddiemundo Yes, please make use of cabal.project file as given in this PR and get latest index state using cabal update.