-
Notifications
You must be signed in to change notification settings - Fork 15
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
New debug transaction echo
command
#709
base: master
Are you sure you want to change the base?
Conversation
0accede
to
73045d3
Compare
, Just | ||
$ subParser "echo" | ||
$ Opt.info pTransactionEcho | ||
$ Opt.progDesc "Echo a transaction" |
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.
Can you provide more context as to when this command is useful?
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.
Yep, I don't understand why we need this command.
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 gather that's verifying that we're capable of reading the transaction and saving it again. I don't know if saving can fail in this scenario, but reading should be verifiable with transaction view
imo.
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, reading and saving the transaction again and verifying that the new transaction is byte-wise identical to the old.
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.
Related to this investigation. https://input-output-rnd.slack.com/archives/CR599HMFX/p1712568383003499
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.
Sooo... what's the advantage over transaction view
? 😃
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.
transaction view
doesn't do a roundtrip. It reads a transaction and writes it in some other format.
Using transaction view
doesn't give us any information about whether the tx
could have been generated by cardano-api
or cardano-cli
.
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 looks like a thing we should have a property test for.
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.
So should we have a roundtrip test instead of a command?
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 guess both? The command could be useful too I think.
Code looks fine to me 👍 Not approving to give a chance to @Jimbo4350 and @CarlosLopezDeLara to chime in on the design. |
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'd like to have this clarified first https://github.com/IntersectMBO/cardano-cli/pull/709/files#r1557852979
This PR is stale because it has been open 45 days with no activity. |
) | ||
--out-file FILE | ||
|
||
Echo a transaction |
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 needs more explanation what does this command exactly do.
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.
LGTM, but it needs more explanation why an user would like to use this command. Also I'm not sure if it wouldn't be better to make this command live under debug
hierarchy, since it's not very useful in normal transaction processing.
c288b0e
to
e264596
Compare
transaction echo
commanddebug transaction echo
command
] | ||
, subParser "echo" | ||
$ Opt.info (DebugTransactionCmds <$> pDebugTransactionEcho) | ||
$ Opt.progDesc "Echo a transaction" |
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.
Can you add more info why specifically we are adding this? I can approve after.
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 was going to say the same. Something like "it parses and rewrites the transaction" or "it deserialises and then reserialises a transaction" or "it re-formats the transaction". And it would be nice to say why this may be useful too, e.g: "because we may want to update/reformat the transaction using the format of the current version of the cli".
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 should be very useful to work with changes to transaction format. I have included a couple of suggestions that I think could improve clarity
] | ||
, subParser "echo" | ||
$ Opt.info (DebugTransactionCmds <$> pDebugTransactionEcho) | ||
$ Opt.progDesc "Echo a transaction" |
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 was going to say the same. Something like "it parses and rewrites the transaction" or "it deserialises and then reserialises a transaction" or "it re-formats the transaction". And it would be nice to say why this may be useful too, e.g: "because we may want to update/reformat the transaction using the format of the current version of the cli".
unwitnessed <- firstExceptT DebugCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | ||
|
||
case unwitnessed of | ||
IncompleteCddlTxBody anyTxBody -> do | ||
InAnyShelleyBasedEra sbe txbody <- pure anyTxBody | ||
|
||
let tx = makeSignedTransaction [] txbody | ||
|
||
firstExceptT DebugCmdWriteFileError . newExceptT | ||
$ writeLazyByteStringFile outTxFile | ||
$ shelleyBasedEraConstraints sbe | ||
$ textEnvelopeToJSON Nothing tx |
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.
unwitnessed <- firstExceptT DebugCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | |
case unwitnessed of | |
IncompleteCddlTxBody anyTxBody -> do | |
InAnyShelleyBasedEra sbe txbody <- pure anyTxBody | |
let tx = makeSignedTransaction [] txbody | |
firstExceptT DebugCmdWriteFileError . newExceptT | |
$ writeLazyByteStringFile outTxFile | |
$ shelleyBasedEraConstraints sbe | |
$ textEnvelopeToJSON Nothing tx | |
IncompleteCddlTxBody (InAnyShelleyBasedEra sbe txbody) | |
<- firstExceptT DebugCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | |
let tx = makeSignedTransaction [] txbody | |
firstExceptT DebugCmdWriteFileError . newExceptT | |
$ writeLazyByteStringFile outTxFile | |
$ shelleyBasedEraConstraints sbe | |
$ textEnvelopeToJSON Nothing tx |
This case is unnecessary because it only has one option (it is a newtype)
anyTx <- lift (readFileTx inputTxFile) & onLeft (left . DebugCmdTextEnvCddlError) | ||
|
||
InAnyShelleyBasedEra sbe tx <- pure anyTx |
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.
anyTx <- lift (readFileTx inputTxFile) & onLeft (left . DebugCmdTextEnvCddlError) | |
InAnyShelleyBasedEra sbe tx <- pure anyTx | |
InAnyShelleyBasedEra sbe tx <- lift (readFileTx inputTxFile) & onLeft (left . DebugCmdTextEnvCddlError) |
I was thinking that this would be equivalent to:
let InAnyShelleyBasedEra sbe tx = anyTx
But it is not. The let
version doesn't compile, interesting 🤔
But still can do the suggestion, unless you are doing it for clarity.
anyTx <- lift (readFileTx inputTxFile) & onLeft (left . TxCmdTextEnvCddlError) | ||
|
||
InAnyShelleyBasedEra sbe tx <- pure anyTx |
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.
anyTx <- lift (readFileTx inputTxFile) & onLeft (left . TxCmdTextEnvCddlError) | |
InAnyShelleyBasedEra sbe tx <- pure anyTx | |
InAnyShelleyBasedEra sbe tx <- lift (readFileTx inputTxFile) & onLeft (left . TxCmdTextEnvCddlError) |
Same here
unwitnessed <- firstExceptT TxCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | ||
|
||
case unwitnessed of | ||
IncompleteCddlTxBody anyTxBody -> do | ||
InAnyShelleyBasedEra sbe txbody <- pure anyTxBody | ||
|
||
let tx = makeSignedTransaction [] txbody | ||
|
||
firstExceptT TxCmdWriteFileError . newExceptT | ||
$ writeLazyByteStringFile outTxFile | ||
$ shelleyBasedEraConstraints sbe | ||
$ textEnvelopeToJSON Nothing tx |
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.
unwitnessed <- firstExceptT TxCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | |
case unwitnessed of | |
IncompleteCddlTxBody anyTxBody -> do | |
InAnyShelleyBasedEra sbe txbody <- pure anyTxBody | |
let tx = makeSignedTransaction [] txbody | |
firstExceptT TxCmdWriteFileError . newExceptT | |
$ writeLazyByteStringFile outTxFile | |
$ shelleyBasedEraConstraints sbe | |
$ textEnvelopeToJSON Nothing tx | |
IncompleteCddlTxBody (InAnyShelleyBasedEra sbe txbody) | |
<- firstExceptT TxCmdTextEnvCddlError . newExceptT $ readFileTxBody txbodyFile | |
let tx = makeSignedTransaction [] txbody | |
firstExceptT TxCmdWriteFileError . newExceptT | |
$ writeLazyByteStringFile outTxFile | |
$ shelleyBasedEraConstraints sbe | |
$ textEnvelopeToJSON Nothing tx |
And here
e264596
to
1bba1f5
Compare
FYI: I have rebased your branch because we have done changes to the formatting. I have made a copy of the unrebased branch that you can find in my previous comment in this PR. |
This PR is stale because it has been open 45 days with no activity. |
Changelog
Context
New command is useful for testing if decode/encode roundtrip has problems.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist