-
Notifications
You must be signed in to change notification settings - Fork 170
Implement block-submitting Imp functions #5404
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
base: master
Are you sure you want to change the base?
Conversation
4961345 to
fa2b2b1
Compare
lehins
left a comment
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 really do like the direction where this is going, however this PR does need some changes.
I'll be happy to talk more about all the suggestions that I made in this PR
eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs
Outdated
Show resolved
Hide resolved
eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs
Outdated
Show resolved
Hide resolved
eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs
Outdated
Show resolved
Hide resolved
| -- Return the block that was created using the transactions and any predicate | ||
| -- failures that are produced. | ||
| -- The transactions are not modified to make them balance. | ||
| trySubmitBlock :: |
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 in order to have it consistent with trySubmitTx, this function should accept a list of transactions that have not been fixed up and this function itself will call the simulateThenRestore in order to do all the fixing up and then submission as a block.
If we don't do that then usability of these functions will be limited.
That being said, naturally we'll need a help like this that will be capable of submitting transactions that have already been fixed up and ready to go into a block, I just think it needs to have a special name that is distinct from trySubmitBlock. Maybe trySubmitFixedUpBlock 🤷
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.
Yes, this makes sense.
There are two Conway tests that I've updated to use these functions (in eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs). The first doesn't require running the simulation itself, but the second definitely does, because the transactions all depend on each other. Also, the tests I'm porting from AlonzoBBODY work that way too. I think we'll find that this style will be more common, but time will tell.
Also, I found that it was just more convenient to write test code as if the transactions are being submitted, so that they use the same patterns as the rest of our test code, and then harvest them afterwards (by wrapping the transaction-generating code inside withTxsInBlock) rather than having to save the transactions explicitly. The fact that they're submitted in a block is then abstracted away from the code that creates the transactions.
I'll make all the other improvements (such as splitting events and transactions, and using SMaybe) first and then see how trySubmitBlock looks. Also, I'll push my latest changes to my AlonzoBBODY PR so that we can see what that test code looks like.
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 now have tryTxsInBlock that provides all the functionality for the other functions, and I've trimmed down the list of other functions to just:
submitBlock_submitBlocksubmitFailingBlocksubmitFailingBlockMwithTxsInBlock_withTxsInBlockwithTxsInFailingBlockwithTxsInFailingBlockM
The submit functions are just simple wrappers for the with functions that run traverse_ submitTx_ on the input list first.
The two main with functions, withTxsInBlock and withTxsInFailingBlockM just force and check the result of tryTxsInBlock and the other two with functions are simple wrappers for these two.
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.
Also, tryTxsInBlock uses impTransactionsFrom instead of simulateThenRestore because we actually want the final state after all the transactions have been through submitTx. simulateThenRestore is now used just in tests that want to run rules functions explicitly (currently, only totalRefScriptSizeInBlock).
eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs
Outdated
Show resolved
Hide resolved
eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs
Outdated
Show resolved
Hide resolved
eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs
Outdated
Show resolved
Hide resolved
eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs
Outdated
Show resolved
Hide resolved
0265db7 to
0a74033
Compare
|
OK, this is ready for another review now |
|
With the new commit to switch to using |
8e9a655 to
5c3a86f
Compare
Also abstract the interface for obtaining events from ImpTestM actions
5c3a86f to
ddc356c
Compare
|
I had to change the design slightly, because there wasn't a way to submit a block containing failing transactions, because failing transactions aren't recorded. I therefore changed Unfortunately, |
|
I suppose another possibility would be to have |
Description
Add functions to:
Checklist
CHANGELOG.mdfiles updated for packages with externally visible changes.NOTE: New section is never added with the code changes. (See RELEASING.md).
.cabalandCHANGELOG.mdfiles when necessary, according to theversioning process.
.cabalfiles updated when necessary.NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
scripts/fourmolize.sh).scripts/cabal-format.sh).scripts/gen-cddl.sh)hie.yamlupdated (usescripts/gen-hie.sh).