From 817f64f9fe39dc7e6d2254a375c8f8cf5e12ddc2 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 11 Jan 2023 16:36:41 +0300 Subject: [PATCH] state: always marshal applog exception into JSON, fix #2869 Fortunately, this is backwards-compatible in any direction. See 98b5e2b3538af80bf94d18364f745bc9ef0a843b also. --- pkg/core/state/notification_event.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/core/state/notification_event.go b/pkg/core/state/notification_event.go index 70d1683ed..87f09dfee 100644 --- a/pkg/core/state/notification_event.go +++ b/pkg/core/state/notification_event.go @@ -218,7 +218,7 @@ type executionAux struct { GasConsumed int64 `json:"gasconsumed,string"` Stack json.RawMessage `json:"stack"` Events []NotificationEvent `json:"notifications"` - FaultException string `json:"exception,omitempty"` + FaultException *string `json:"exception"` } // MarshalJSON implements the json.Marshaler interface. @@ -235,13 +235,17 @@ func (e Execution) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } + var exception *string + if e.FaultException != "" { + exception = &e.FaultException + } return json.Marshal(&executionAux{ Trigger: e.Trigger.String(), VMState: e.VMState.String(), GasConsumed: e.GasConsumed, Stack: st, Events: e.Events, - FaultException: e.FaultException, + FaultException: exception, }) } @@ -280,7 +284,9 @@ func (e *Execution) UnmarshalJSON(data []byte) error { e.VMState = state e.Events = aux.Events e.GasConsumed = aux.GasConsumed - e.FaultException = aux.FaultException + if aux.FaultException != nil { + e.FaultException = *aux.FaultException + } return nil }