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

Audit changes #445

Merged
merged 62 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
579ecbe
tests pass with new mockchain return type
Jul 4, 2024
fc36439
more log levels
Jul 4, 2024
38c0718
logging removal of unusable balancing utxos
Jul 4, 2024
b525aeb
improving logging in balancing
mmontin Jul 8, 2024
98b5e81
new log version with dedicated constructors
mmontin Jul 10, 2024
47f54a5
changing item
mmontin Jul 10, 2024
2ff0e46
integrating comments, adding comments and more readable bullets
mmontin Jul 10, 2024
73d8ab2
fixing the bug where collateral inputs were not resolved
mmontin Jul 10, 2024
a94db0a
CHANGELOG.md
mmontin Jul 10, 2024
580b35c
merging main in this
Jul 28, 2024
f2cfce6
integrating review comments
Jul 28, 2024
8764a1a
typo
Jul 28, 2024
798c8c3
removing useless instances
Jul 28, 2024
492d057
wip
mmontin Jul 7, 2024
817c777
reverting balancingspec
mmontin Jul 10, 2024
c59f14c
starting to consume scripts in balancing spec, to be continued
mmontin Jul 10, 2024
96b3250
reworking empty collaterals
mmontin Jul 11, 2024
34aa2af
2 first test groups passé
mmontin Jul 11, 2024
291df89
all tests fixed
mmontin Jul 11, 2024
5f696fd
doc
mmontin Jul 11, 2024
c8cf373
updating doc
mmontin Jul 11, 2024
73c209f
logging of unused collateral option
mmontin Jul 11, 2024
2275916
post-rebase small fixes
Jul 28, 2024
f44b98e
bye bye Ledger.TxOut
Jul 28, 2024
6ffc16e
Merge branch 'main' into mm/logger
Jul 29, 2024
089191f
Merge branch 'mm/logger' into mm/collateral-when-no-script
Jul 29, 2024
47e99e6
Merge branch 'mm/collateral-when-no-script' into mm/txout
Jul 29, 2024
14da58f
update capi
mmontin Jul 31, 2024
1ccb4b1
Proper script hash computation for all plutus versions
mmontin Jul 31, 2024
5114f60
helpers and qol changes
mmontin Jul 31, 2024
5c6adbe
MockChainSt has its own module now
mmontin Jul 31, 2024
db84394
Support for hashed datums in reference inputs
mmontin Jul 31, 2024
72e2820
withdrawal support
mmontin Jul 31, 2024
cc595b1
fixing balancing bug
mmontin Jul 31, 2024
63bb587
small post-rebase changes
mmontin Jul 31, 2024
97d1460
showbsspec finally gone
mmontin Jul 31, 2024
bdf3676
Recreating an index to pass to the new fee estimate function
mmontin Jul 31, 2024
2e6897d
merging logging into this
mmontin Aug 1, 2024
57fec8c
merging collaterals into this
mmontin Aug 1, 2024
cd8e5de
merging txout into this
mmontin Aug 1, 2024
5e465f4
merging bump cardano api into this
mmontin Aug 6, 2024
13271b9
post merge fix
mmontin Aug 6, 2024
395cc53
no tests built for dependencies, relying on cne directly
mmontin Aug 8, 2024
9d4be2d
CHANGELOG.md
mmontin Aug 8, 2024
1555195
merging update to new version of capi
mmontin Aug 8, 2024
4854587
relying on the fork for translation functions
mmontin Aug 8, 2024
f33029e
Merge branch 'mm/bump-capi' into mm/djed-audit
mmontin Aug 8, 2024
55c00e2
credential and staking credential of a wallet
mmontin Aug 29, 2024
785be72
moving time from either the lower or upper bound of current slot
mmontin Aug 29, 2024
cdc788b
depending on cne
mmontin Aug 29, 2024
c1d6f45
merging main into this
mmontin Aug 29, 2024
82f2b7f
merging main into this
mmontin Aug 29, 2024
ee333f6
post merge mini fix
mmontin Aug 29, 2024
70a0bee
merging collaterals into this
mmontin Aug 29, 2024
1554e51
merging txout into this
mmontin Aug 29, 2024
1654dbb
Merge branch 'main' into mm/collateral-when-no-script
mmontin Aug 30, 2024
bb45ed1
Merge branch 'mm/collateral-when-no-script' into mm/txout
mmontin Aug 30, 2024
3e1b3a1
Merge branch 'mm/txout' into mm/djed-audit
mmontin Aug 30, 2024
f08e504
reworking withdrawals for proper maps
mmontin Aug 30, 2024
b15fc69
hpack
mmontin Aug 30, 2024
bbe4122
merging
mmontin Sep 5, 2024
943d937
post review changes
mmontin Sep 10, 2024
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
2 changes: 1 addition & 1 deletion cooked-validators.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.4

-- This file has been generated from package.yaml by hpack version 0.36.1.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
4 changes: 2 additions & 2 deletions src/Cooked/MockChain/GenerateTx/Withdrawals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ toWithdrawals (Map.toList -> withdrawals) =
fmap
(Cardano.TxWithdrawals Cardano.ShelleyBasedEraConway)
$ forM withdrawals
$ \(staker, Script.Lovelace n) ->
$ \(staker, (red, Script.Lovelace n)) ->
do
(witness, sCred) <-
case staker of
Expand All @@ -46,7 +46,7 @@ toWithdrawals (Map.toList -> withdrawals) =
throwOnToCardanoError "toWithdrawals: unable to translate pkh stake credential" $
Cardano.StakeCredentialByKey <$> Ledger.toCardanoStakeKeyHash pkh
return (Cardano.KeyWitness Cardano.KeyWitnessForStakeAddr, sCred)
Left (script, red) -> do
Left script -> do
witness <-
Cardano.ScriptWitness Cardano.ScriptWitnessForStakeAddr
<$> liftTxGen (toScriptWitness script red Cardano.NoScriptDatumForStake)
Expand Down
6 changes: 3 additions & 3 deletions src/Cooked/Pretty/Cooked.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ prettyWithdrawals :: PrettyCookedOpts -> TxSkelWithdrawals -> Maybe DocCooked
prettyWithdrawals pcOpts withdrawals =
prettyItemizeNonEmpty "Withdrawals:" "-" $ prettyWithdrawal <$> Map.toList withdrawals
where
prettyWithdrawal :: (Either (Script.Versioned Script.Script, TxSkelRedeemer) Api.PubKeyHash, Script.Ada) -> DocCooked
prettyWithdrawal (cred, ada) =
prettyWithdrawal :: (Either (Script.Versioned Script.Script) Api.PubKeyHash, (TxSkelRedeemer, Script.Ada)) -> DocCooked
prettyWithdrawal (cred, (red, ada)) =
prettyItemizeNoTitle "-" $
( case cred of
Left (script, red) -> prettyCookedOpt pcOpts script : prettyTxSkelRedeemer pcOpts red
Left script -> prettyCookedOpt pcOpts script : prettyTxSkelRedeemer pcOpts red
Right pkh -> [prettyCookedOpt pcOpts pkh]
)
++ [prettyCookedOpt pcOpts (toValue ada)]
Expand Down
19 changes: 15 additions & 4 deletions src/Cooked/Skeleton.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module Cooked.Skeleton
TxSkelWithdrawals,
txSkelWithdrawnValue,
txSkelWithdrawalsScripts,
pkWithdrawal,
scriptWithdrawal,
TxSkel (..),
txSkelLabelL,
txSkelOptsL,
Expand Down Expand Up @@ -590,16 +592,25 @@ withAnchor prop url = prop {txSkelProposalAnchor = Just url}

-- * Description of the Withdrawals

-- | Withdrawals associate either a script or a private key with a redeemer and
-- a certain amount of ada. Note that the redeemer will be ignored in the case
-- of a private key.
type TxSkelWithdrawals =
Map
(Either (Script.Versioned Script.Script, TxSkelRedeemer) Api.PubKeyHash)
Script.Ada
(Either (Script.Versioned Script.Script) Api.PubKeyHash)
(TxSkelRedeemer, Script.Ada)

txSkelWithdrawnValue :: TxSkel -> Api.Value
txSkelWithdrawnValue = mconcat . (toValue . snd <$>) . Map.toList . txSkelWithdrawals
txSkelWithdrawnValue = mconcat . (toValue . snd . snd <$>) . Map.toList . txSkelWithdrawals

txSkelWithdrawalsScripts :: TxSkel -> [Script.Versioned Script.Script]
txSkelWithdrawalsScripts = (fst <$>) . fst . partitionEithers . (fst <$>) . Map.toList . txSkelWithdrawals
txSkelWithdrawalsScripts = fst . partitionEithers . (fst <$>) . Map.toList . txSkelWithdrawals

pkWithdrawal :: (ToPubKeyHash pkh) => pkh -> Script.Ada -> TxSkelWithdrawals
pkWithdrawal pkh amount = Map.singleton (Right $ toPubKeyHash pkh) (txSkelEmptyRedeemer, amount)

scriptWithdrawal :: (ToScript script) => script -> TxSkelRedeemer -> Script.Ada -> TxSkelWithdrawals
scriptWithdrawal script red amount = Map.singleton (Left $ toScript script) (red, amount)

-- * Description of the Minting

Expand Down
6 changes: 1 addition & 5 deletions tests/Cooked/WithdrawalsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Cooked.WithdrawalsSpec where
import Control.Monad
import Cooked
import Data.Default
import Data.Map qualified as Map
import Plutus.Script.Utils.Ada qualified as Script
import Plutus.Script.Utils.Scripts qualified as Script
import PlutusLedgerApi.V3 qualified as Api
Expand Down Expand Up @@ -40,10 +39,7 @@ testWithdrawingScript n1 n2 =
validateTxSkel $
txSkelTemplate
{ txSkelSigners = [wallet 1],
txSkelWithdrawals =
Map.singleton
(Left (checkWithdrawalVersionedScript, txSkelSomeRedeemer (n1 * 1_000 :: Integer)))
(Script.Lovelace $ n2 * 1_000)
txSkelWithdrawals = scriptWithdrawal checkWithdrawalVersionedScript (txSkelSomeRedeemer (n1 * 1_000 :: Integer)) $ Script.Lovelace $ n2 * 1_000
}

tests :: TestTree
Expand Down
Loading