-
Notifications
You must be signed in to change notification settings - Fork 214
Conversation
f5e3d45
to
261eff0
Compare
plutus-pab/src/Plutus/PAB/Core/ContractInstance/BlockchainEnv.hs
Outdated
Show resolved
Hide resolved
|
@sjoerdvisscher hmm, well, there are
I suppose we should use it but I suspect we don't already do it because we need to convert the transaction from our representation to the cardano-node's types? |
We even have |
2b94ec1
to
a44e654
Compare
@ak3n What's the status of this? |
@sjoerdvisscher I had to switch to a different task. Will get back to this PR a bit later. |
07327d3
to
9e99391
Compare
56c39ca
to
a9532b3
Compare
plutus-contract/src/Plutus/Contract/Test/ContractModel/MissingLovelace.hs
Outdated
Show resolved
Hide resolved
plutus-contract/src/Plutus/Contract/Test/ContractModel/MissingLovelace.hs
Outdated
Show resolved
Hide resolved
plutus-contract/src/Plutus/Contract/Test/ContractModel/MissingLovelace.hs
Outdated
Show resolved
Hide resolved
(Left _, _) -> (acc, txOut) -- acc is an error, do nothing | ||
(Right _, Left e) -> (Left e, txOut) -- failed somewhere, return error as acc | ||
(Right acc', Right (ada, txOut')) -> (Right $ ada:acc', txOut') | ||
adjustTxOut :: TxOut -> Either Tx.ToCardanoError (Ada.Ada, TxOut) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you let this return Either Tx.ToCardanoError ([Ada.Ada], TxOut)
you have 2 nested applicative effects (Either Tx.ToCardanoError
and (,) [Ada.Ada]
), which you could use in a traversal using Compose
. Then you won't need step
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate or provide an example how to do it? I thought how to compose traversal and fold here (we want to traverse UnbalancedTx
and also collect some info at the same time) but ended up with step
solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked even better than I thought, trying it out in vscode I got:
adjustUnbalancedTx params = alaf Compose (tx . Tx.outputs . traverse) adjustTxOut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, indeed, looks cool and works fine! Thanks!
But lacks some readability as non-trivial lens code as usual.
_ -> [] | ||
otherWalletsTxOutCosts = concatMap (map Ada.fromValue . snd) $ txOutCosts | ||
let txOutCosts' = concatMap snd $ filter ((== w) . fst) txOutCosts | ||
otherWalletsTxOutCosts = concatMap snd txOutCosts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this allWalletsTxOutCosts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, indeed, thanks for pointing this out. I will refactor and write a comment a bit later.
54cd01d
to
d7b31b7
Compare
plutus-contract/src/Plutus/Contract/Test/ContractModel/Internal.hs
Outdated
Show resolved
Hide resolved
6ec19e2
to
7200032
Compare
import PlutusTx.Prelude qualified as P | ||
import Wallet.Emulator (Wallet) | ||
|
||
-- | Returns the calculated delta between initial and final values. Might be false positive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "false positive"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a risk when expected delta has only ada part and expected delta /= realDelta
and realDelta
is divisible by some delta from deltas, then we will return realDelta
's ada. Which means that the test will pass but without strong confidence in wallets' funds consistency.
For example, we expected -n
, but there is n
among deltas and realDelta
is n
, it is divisible by n
=> our test will pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this explanation should be added as a comment on the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the comment. 👍
plutus-contract/src/Plutus/Contract/Test/ContractModel/MissingLovelace.hs
Outdated
Show resolved
Hide resolved
plutus-contract/src/Plutus/Contract/Test/ContractModel/MissingLovelace.hs
Outdated
Show resolved
Hide resolved
Looking at what the problem could be with walletsAdjustedTxEvents = preMapMaybe (preview (eteEvent . walletEvent' . to (\x -> (x ^. _1, x ^. _2 . _RequestHandlerLog . _AdjustingUnbalancedTx)))) L.list One thing I notice is I do think that with the current implementation you don't need the wallet in the return value, since you throw them away in walletsAdjustedTxEvents = preMapMaybe (preview (eteEvent . walletEvent' . _2 . _RequestHandlerLog . _AdjustingUnbalancedTx)) L.list |
c6a6969
to
a105b34
Compare
Thanks, it works. I remember that initially I tried to go this way but later decided to add the information about wallets trying to be more precise with deltas using the |
Well you could still do that (I think) by passing the result of |
@ak3n You can merge whenever you think it's done :) |
Adds
AdjustUnbalancedTx
PABReq
effect that uses protocol parameters.Should fix #414.
Pre-submit checklist: