@@ -17,8 +17,6 @@ import (
1717)
1818
1919const (
20- // TxIDLenMin is the minimum length of a txID.
21- TxIDLenMin = 32
2220 // AddressLength is the length of a normalized Wormhole address in bytes.
2321 AddressLength = 32
2422
@@ -37,7 +35,6 @@ const (
3735 // The minimum size of a marshaled message publication. It is the sum of the sizes of each of
3836 // the fields plus length information for fields with variable lengths (TxID and Payload).
3937 marshaledMsgLenMin = 1 + // TxID length (uint8)
40- TxIDLenMin + // TxID ([]byte), minimum length of 32 bytes (but may be longer)
4138 8 + // Timestamp (int64)
4239 4 + // Nonce (uint32)
4340 8 + // Sequence (uint64)
@@ -103,7 +100,6 @@ var ErrInputTooLarge = errors.New("input data exceeds maximum allowed size")
103100var (
104101 ErrBinaryWrite = errors .New ("failed to write binary data" )
105102 ErrTxIDTooLong = errors .New ("field TxID too long" )
106- ErrTxIDTooShort = errors .New ("field TxID too short" )
107103 ErrInvalidPayload = errors .New ("field payload too long" )
108104 ErrDataTooShort = errors .New ("data too short" )
109105 ErrTimestampTooShort = errors .New ("data too short for timestamp" )
@@ -191,6 +187,8 @@ type MessagePublication struct {
191187 // whose buckets reach quorum at different observation subsets can still
192188 // pick different majorities; recovery for that case is the audit /
193189 // missing_observations reobs flow rather than the delegate-quorum path.
190+ //
191+ // TxID identifies the transaction that emitted this message. There is no minimum length.
194192 TxID []byte
195193 Timestamp time.Time
196194
@@ -357,17 +355,12 @@ func (msg *MessagePublication) MarshalBinary() ([]byte, error) {
357355 return nil , ErrInputSize {Msg : "TxID too long" , Want : TxIDSizeMax , Got : txIDLen }
358356 }
359357
360- if txIDLen < TxIDLenMin {
361- return nil , ErrInputSize {Msg : "TxID too short" , Want : TxIDLenMin , Got : txIDLen }
362- }
363-
364358 payloadLen := len (msg .Payload )
365359 // Set up for serialization
366360 var (
367361 be = binary .BigEndian
368362 // Size of the buffer needed to hold the serialized message.
369- // TxIDLenMin is already accounted for in the marshaledMsgLenMin calculation.
370- bufSize = (marshaledMsgLenMin - TxIDLenMin ) + txIDLen + payloadLen
363+ bufSize = marshaledMsgLenMin + txIDLen + payloadLen
371364 buf = make ([]byte , 0 , bufSize )
372365 )
373366
@@ -528,12 +521,8 @@ func (m *MessagePublication) UnmarshalBinary(data []byte) error {
528521 txIDLen := uint8 (data [pos ])
529522 pos ++
530523
531- // Bounds checks. TxID length should be at least TxIDLenMin, but not larger than the length of the data.
532- // The second check is to avoid panics.
533- if int (txIDLen ) < TxIDLenMin {
534- return ErrInputSize {Msg : "TxID length is too short" , Got : int (txIDLen ), Want : TxIDLenMin }
535- }
536-
524+ // Bounds check. TxID length should not be larger than the length of the data.
525+ // This check avoids panics.
537526 if int (txIDLen ) > len (data ) {
538527 return ErrInputSize {Msg : "TxID length is longer than bytes" , Got : int (txIDLen )}
539528 }
0 commit comments