Skip to content

Commit

Permalink
Merge pull request #553 from Juliusan/bugfixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
Juliusan authored Oct 27, 2021
2 parents 2ff8a94 + ff6b02c commit aacfe59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions packages/chain/consensus/commonsubset/commonsubset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/util/rwutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/cluster/tests/cluster_stability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aacfe59

Please sign in to comment.