-
Notifications
You must be signed in to change notification settings - Fork 205
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
Support submitMustFail in DAML Script Service #7076
Conversation
3f2200f
to
6775841
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
// This branch is superseded by SubmitMustFail below, | ||
// however, it is maintained for backwards | ||
// compatibility with DAML script DARs generated by | ||
// older SDK versions that didn't distinguish Submit | ||
// and SubmitMustFail. |
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 have confirmed that replacing this branch by Future.failed(...)
breaks the corresponding compatibility test.
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.
We don’t seem to have a submitMustFail
in the compat tests. Should we add one?
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 nvm, I just saw that you added it 🤦
changelog_begin changelog_end
Pushes handling of `submitMustFail` into the DAML script interpreter rather than DAML script itself.
bf2311b
to
d75d28c
Compare
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.
Nice work, thank you! I’d like to understand a bit better if we can get rid of the duplication between submit
and submitMustFail
but I’m fine with merging this and trying to improve it in a follow-up PR.
// This branch is superseded by SubmitMustFail below, | ||
// however, it is maintained for backwards | ||
// compatibility with DAML script DARs generated by | ||
// older SDK versions that didn't distinguish Submit | ||
// and SubmitMustFail. |
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.
We don’t seem to have a submitMustFail
in the compat tests. Should we add one?
@@ -463,6 +476,73 @@ class IdeClient(val compiledPackages: CompiledPackages) extends ScriptLedgerClie | |||
Future.fromTry(result) | |||
} | |||
|
|||
override def submitMustFail(party: SParty, commands: List[ScriptLedgerClient.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 am slightly worried that we are effectively replicating a significant part of the logic of submit
. What happens if we replace the whole implementation here by something that catches SError
and flips it?
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.
By catching SError
you mean the SResultError
branch? AFAIU that's not enough as we also want to flip in other cases, e.g. on commitTransaction
error in SResultScenarioCommit
. Conversely we don't always want to recover from Failure
, e.g. AFAIU we don't want to recover from Failure(new RuntimeException(s"Unexpected abort: $x"))
. The other submit
implementations use Left
for errors that should be caught by submitMustFail
but the Left
parameter is restricted to StatusRuntimeException
which doesn't really work in this case.
An alternative might be to use a more general or a trait associated type instead of StatusRuntimeException
and then use Success(Left(_))
in IdeClient.submit
for errors that submitMustFail
should catch.
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.
Side note: SResultScenarioCommit was a bug, fixed in #7089. Doesn’t change anything here.
There are a few cases to consider here:
- The future completes successfully. In that case, we want to turn it into a failure.
- The future fails with
SError
. This includes calls toerror
as well asScenarioErrorCommitError
which we will get back from a failed commit for things like authorization errors. - Other stuff, e.g., the wildcard match at the end which we hope not to hit.
My idea would be to call submit
and then handle the three cases.
- This is an actual failure. We expected things to fail and they didn’t.
- This is the successful case. We expected a failure during submission and we got one.
- This is a crash, something went wrong.
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.
Ah, I see. That seems to be possible. I've pushed a commit implementing this.
// This branch is superseded by SubmitMustFail below, | ||
// however, it is maintained for backwards | ||
// compatibility with DAML script DARs generated by | ||
// older SDK versions that didn't distinguish Submit | ||
// and SubmitMustFail. |
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 nvm, I just saw that you added it 🤦
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.
Nice, thanks for simplifying it!
Closes #7008
Pushes handling of
submitMustFail
into the DAML script interpreter rather than DAML script itself.For backwards compatibility we keep the implementation of the old handling around.
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.