flow-go
flow-go copied to clipboard
Modify Service Event encoding to be compatible with CBOR "strict" mode
Context
We would like to change the global CBOR Decoder to use strict mode (see #5534). This is incompatible with the current implementation of service event decoding (see discussion https://github.com/onflow/flow-go/pull/5428#discussion_r1511987247).
Change service event encoding to be compatible with CBOR strict mode. Some implementation ideas:
- Separately encode the inner specific event type as a separate encode step
type ServiceEvent struct {
Type string
Event []byte
}
- Keep the existing ServiceEvent type, override "strict" mode for outer decode to read the
Type
field, then decode the specific inner event type with "strict" mode
Definition of Done
- Service event decoding should function without errors when CBOR "strict" mode is enabled globally