From 768a9e5b339be73d803c6461cebf8852807de5a6 Mon Sep 17 00:00:00 2001 From: Julius Andrikonis Date: Tue, 26 Oct 2021 16:19:38 +0300 Subject: [PATCH 1/5] A little bit more logging --- tools/cluster/tests/cluster_stability_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cluster/tests/cluster_stability_test.go b/tools/cluster/tests/cluster_stability_test.go index c35a2dc06a..d9951263d5 100644 --- a/tools/cluster/tests/cluster_stability_test.go +++ b/tools/cluster/tests/cluster_stability_test.go @@ -113,7 +113,7 @@ func (e *SabotageEnv) sabotageNodes(sabotageOption SabotageOption, startDelay, i func (e *SabotageEnv) unfreezeNodes() { for _, nodeID := range e.SabotageList { - e.chainEnv.t.Logf("Unfreezing node %v", nodeID) + e.chainEnv.t.Logf("Unfreezing node %v (%s)", nodeID, time.Now()) err := e.chainEnv.clu.UnfreezeNode(nodeID) require.NoError(e.chainEnv.t, err) From d720a84f73486ded6e181a4da8d8400e55390edb Mon Sep 17 00:00:00 2001 From: Julius Andrikonis Date: Wed, 27 Oct 2021 10:01:05 +0300 Subject: [PATCH 2/5] Clearer logging --- packages/util/rwutil.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/util/rwutil.go b/packages/util/rwutil.go index c758b4d554..5183e88714 100644 --- a/packages/util/rwutil.go +++ b/packages/util/rwutil.go @@ -208,7 +208,7 @@ func ReadBytes16(r io.Reader) ([]byte, error) { func WriteBytes16(w io.Writer, data []byte) error { if len(data) > MaxUint16 { - panic("WriteBytes16: too long data") + panic(fmt.Sprintf("WriteBytes16: too long data (%v)", len(data))) } err := WriteUint16(w, uint16(len(data))) if err != nil { @@ -243,7 +243,7 @@ func ReadBytes32(r io.Reader) ([]byte, error) { func WriteBytes32(w io.Writer, data []byte) error { if len(data) > MaxUint32 { - panic("WriteBytes32: too long data") + panic(fmt.Sprintf("WriteBytes32: too long data (%v)", len(data))) } err := WriteUint32(w, uint32(len(data))) if err != nil { @@ -326,7 +326,7 @@ func ReadStrings16(r io.Reader) ([]string, error) { func WriteStrings16(w io.Writer, strs []string) error { if len(strs) > MaxUint16 { - panic("WriteStrings16: too long array") + panic(fmt.Sprintf("WriteStrings16: too long array (%v)", len(strs))) } if err := WriteUint16(w, uint16(len(strs))); err != nil { return err From 287a1ca07131662a9b247e1a1cfd7a1c959946d0 Mon Sep 17 00:00:00 2001 From: Julius Andrikonis Date: Wed, 27 Oct 2021 13:26:54 +0300 Subject: [PATCH 3/5] Recovered panic should be logged as error --- packages/vm/viewcontext/viewcontext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vm/viewcontext/viewcontext.go b/packages/vm/viewcontext/viewcontext.go index 8ed259d447..ba7eec6e20 100644 --- a/packages/vm/viewcontext/viewcontext.go +++ b/packages/vm/viewcontext/viewcontext.go @@ -58,8 +58,8 @@ func (v *Viewcontext) CallView(contractHname, epCode iscp.Hname, params dict.Dic default: err = xerrors.Errorf("viewcontext: panic in VM: %v", err1) } - v.log.Debugf("CallView: %v", err) - v.log.Debugf(string(debug.Stack())) + v.log.Errorf("CallView: %v", err) + v.log.Errorf(string(debug.Stack())) }() ret, err = v.callView(contractHname, epCode, params) }() From 573b937ea25f91aeb225be43aaa53a5788e3a970 Mon Sep 17 00:00:00 2001 From: Julius Andrikonis Date: Wed, 27 Oct 2021 15:04:18 +0300 Subject: [PATCH 4/5] More space for ACS data --- .../consensus/commonsubset/commonsubset.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/chain/consensus/commonsubset/commonsubset.go b/packages/chain/consensus/commonsubset/commonsubset.go index 30b9ef71b8..e39938c08a 100644 --- a/packages/chain/consensus/commonsubset/commonsubset.go +++ b/packages/chain/consensus/commonsubset/commonsubset.go @@ -469,11 +469,11 @@ func (b *msgBatch) Write(w io.Writer) error { if err = util.WriteBytes16(w, rbcMsgPayload.RootHash); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].RootHash: %w", i, err) } - if err = util.WriteUint16(w, uint16(len(rbcMsgPayload.Proof))); err != nil { + if err = util.WriteUint32(w, uint32(len(rbcMsgPayload.Proof))); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].Proof.len: %w", i, err) } for pi, p := range rbcMsgPayload.Proof { - if err = util.WriteBytes16(w, p); err != nil { + if err = util.WriteBytes32(w, p); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].Proof[%v]: %w", i, pi, err) } } @@ -490,11 +490,11 @@ func (b *msgBatch) Write(w io.Writer) error { if err = util.WriteBytes16(w, rbcMsgPayload.RootHash); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].RootHash: %w", i, err) } - if err = util.WriteUint16(w, uint16(len(rbcMsgPayload.Proof))); err != nil { + if err = util.WriteUint32(w, uint32(len(rbcMsgPayload.Proof))); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].Proof.len: %w", i, err) } for pi, p := range rbcMsgPayload.Proof { - if err = util.WriteBytes16(w, p); err != nil { + if err = util.WriteBytes32(w, p); err != nil { return xerrors.Errorf("failed to write msgBatch.msgs[%v].Proof[%v]: %w", i, pi, err) } } @@ -620,13 +620,13 @@ func (b *msgBatch) Read(r io.Reader) error { if proofRequest.RootHash, err = util.ReadBytes16(r); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].RootHash: %w", mi, err) } - var proofLen uint16 - if err = util.ReadUint16(r, &proofLen); err != nil { + var proofLen uint32 + if err = util.ReadUint32(r, &proofLen); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].Proof.len: %w", mi, err) } proofRequest.Proof = make([][]byte, proofLen) for pi := range proofRequest.Proof { - if proofRequest.Proof[pi], err = util.ReadBytes16(r); err != nil { + if proofRequest.Proof[pi], err = util.ReadBytes32(r); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].Proof[%v]: %w", mi, pi, err) } } @@ -648,13 +648,13 @@ func (b *msgBatch) Read(r io.Reader) error { if echoRequest.RootHash, err = util.ReadBytes16(r); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].RootHash: %w", mi, err) } - var proofLen uint16 - if err = util.ReadUint16(r, &proofLen); err != nil { + var proofLen uint32 + if err = util.ReadUint32(r, &proofLen); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].Proof.len: %w", mi, err) } echoRequest.Proof = make([][]byte, proofLen) for pi := range echoRequest.Proof { - if echoRequest.Proof[pi], err = util.ReadBytes16(r); err != nil { + if echoRequest.Proof[pi], err = util.ReadBytes32(r); err != nil { return xerrors.Errorf("failed to read msgBatch.msgs[%v].Proof[%v]: %w", mi, pi, err) } } From ff6b02cc397b638a1652db1a748541b453073cac Mon Sep 17 00:00:00 2001 From: Julius Andrikonis Date: Wed, 27 Oct 2021 16:05:52 +0300 Subject: [PATCH 5/5] Revert "Recovered panic should be logged as error" This reverts commit 287a1ca07131662a9b247e1a1cfd7a1c959946d0. --- packages/vm/viewcontext/viewcontext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vm/viewcontext/viewcontext.go b/packages/vm/viewcontext/viewcontext.go index ba7eec6e20..8ed259d447 100644 --- a/packages/vm/viewcontext/viewcontext.go +++ b/packages/vm/viewcontext/viewcontext.go @@ -58,8 +58,8 @@ func (v *Viewcontext) CallView(contractHname, epCode iscp.Hname, params dict.Dic default: err = xerrors.Errorf("viewcontext: panic in VM: %v", err1) } - v.log.Errorf("CallView: %v", err) - v.log.Errorf(string(debug.Stack())) + v.log.Debugf("CallView: %v", err) + v.log.Debugf(string(debug.Stack())) }() ret, err = v.callView(contractHname, epCode, params) }()