-
Notifications
You must be signed in to change notification settings - Fork 639
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
Add a generic function to construct error acks with abci codes & string const #819
Comments
After giving this more thought. I'm very much in favor of adjusting the current |
Is this something we should try to get included for v3? If so, I can pick this up later this week. |
I think not (that boat has sailed), but lets get it in for a minor release (it doesn't need to be API breaking) |
So is it the idea to refactor the existing func NewErrorAcknowledgement(err error, errString string) Acknowledgement {
// the ABCI code is included in the abcitypes.ResponseDeliverTx hash
// constructed in Tendermint and is therefore deterministic
_, code, _ := sdkerrors.ABCIInfo(err, false) // discard non-determinstic codespace and log values
errorString := fmt.Sprintf("ABCI code: %d: %s", code, errString)
return Acknowledgement{
Response: &Acknowledgement_Error{
Error: errorString,
},
}
} The |
I actually don't think we should take in an error string as an argument. The intention behind this function is that we remove the possibility of accidental state changes via modification of the error string. I think it is very likely this function would be misused if we allowed the developers to pass in their own error string. I'd prefer to use our own constant "error handling packet: see events for details". If developers want a custom error string, they can construct their own error acknowledgement (as currently requried) |
Ok, cool. Then we have to remove the const (
// ackErrorString defines a string constant included in error acknowledgements
// NOTE: Changing this const is state machine breaking as acknowledgements are written into state
ackErrorString = "error handling packet: see events for details"
)
// NewErrorAcknowledgement returns a deterministic error string which may be used in
// the packet acknowledgement.
func NewErrorAcknowledgement(err error) channeltypes.Acknowledgement {
// the ABCI code is included in the abcitypes.ResponseDeliverTx hash
// constructed in Tendermint and is therefore deterministic
_, code, _ := sdkerrors.ABCIInfo(err, false) // discard non-determinstic codespace and log values
errorString := fmt.Sprintf("ABCI code: %d: %s", code, ackErrorString)
return Acknowledgement{
Response: &Acknowledgement_Error{
Error: errorString,
},
}
} And we use this one everywhere. |
Summary
Code is duplicated in ics27 and ics20 in package
types
to provide deterministic error acknowledgements that include the ABCI error code and a string constant defined at the local package level.Application developers may want to define their own string constants to be included, however a generic approach would also be useful.
See: #777 & #794
Proposal
04-channel/types
which extracts the ABCI code from a given error and returns a deterministic error acknowledgementFor Admin Use
The text was updated successfully, but these errors were encountered: