/
acknowledgement_v4.go
29 lines (24 loc) · 1.13 KB
/
acknowledgement_v4.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package types
import (
"fmt"
sdkerrors "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/errors"
)
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 new instance of Acknowledgement using an Acknowledgement_Error
// type in the Response field.
// NOTE: Acknowledgements are written into state and thus, changes made to error strings included in packet acknowledgements
// risk an app hash divergence when nodes in a network are running different patch versions of software.
func NewErrorAcknowledgementV4(err error) 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
return Acknowledgement{
Response: &Acknowledgement_Error{
Error: fmt.Sprintf("ABCI code: %d: %s", code, ackErrorString),
},
}
}