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

SC-7142 envelope id and error return #105

Merged
merged 2 commits into from
Jul 18, 2022
Merged

SC-7142 envelope id and error return #105

merged 2 commits into from
Jul 18, 2022

Conversation

pdeziel
Copy link
Collaborator

@pdeziel pdeziel commented Jul 18, 2022

This fixes two rVASP issues: One where the envelope id was being recreated and one where the error field was not being populated in the response to a user API request.

@pdeziel pdeziel requested a review from bbengfort July 18, 2022 14:37
case *protocol.Error:
log.Warn().Str("message", err.Error()).Msg("TRISA protocol error while performing transfer")
reply.Error = &pb.Error{
Message: err.Error(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to put the error code in here instead of using Error() but apparently it wasn't being populated on envelope.Reject()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not? That's not good - let me take a look at the TRISA code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Reject is just adding the error to the struct without modification:

https://github.com/trisacrypto/trisa/blob/main/pkg/trisa/envelope/envelope.go#L136-L149

I guess it's up to the client to return an error that has an error code? Is there somewhere in the rVASP code where we're forgetting to add a code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there was a spot where the rVASP was not returning the error code back which I fixed in the previous push but I forgot to update the code here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Collaborator

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdeziel looks great - I agree that a smoke test with Charlie would be appropriate.

I also received one additional request today; could we change the Transaction envelope field to envelope_id:

https://github.com/trisacrypto/testnet/blob/main/proto/rvasp/v1/api.proto#L47

There was some confusion about that field. Although it's not best practice to rename fields, I don't think this will affect any code outside of the rvasps and the cli should still be backwards compatible since all it does is print out the json of the transfer reply.

Comment on lines 239 to 241
reply.Error = &pb.Error{
Message: err.Error(),
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also include the code here as well?

Suggested change
reply.Error = &pb.Error{
Message: err.Error(),
}
reply.Error = &pb.Error{
Code: err.Code,
Message: err.Message,
}

pkg/rvasp/rvasp.go Show resolved Hide resolved
@@ -371,8 +382,7 @@ func (s *Server) sendTransfer(xfer *db.Transaction, beneficiary *db.Wallet, part
reject, isErr := envelope.Check(msg)
if isErr {
if reject != nil {
xfer.SetState(pb.TransactionState_REJECTED)
return nil
return reject
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming from above comment that it is returning the rejection error as an error.

@@ -80,7 +80,7 @@ message TransferRequest {
// or an error if there are insufficient funds or the account or beneficiary could not
// be looked up. Errors encountered during the TRISA protocol may also be returned.
message TransferReply {
Error error = 1; // Only used in live stream
Error error = 1; // populated with an error encountered during the transfer or from the response envelope
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@pdeziel pdeziel merged commit d55e619 into main Jul 18, 2022
@pdeziel pdeziel deleted the sc-7142 branch July 18, 2022 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants