go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

Hare validation of messages mem usage can be optimized

Open gavraz opened this issue 5 years ago • 1 comments

A Hare message M is composed of

  1. A sig []byte
  2. An inner msg which is a struct called InnerMessage

Validating such messages requires the receiver to unmarshal the msg M, then marshall the inner msg M.inner and then validate. XDR marshal/unmarshal uses a non-negligible amount of mem (relatively to the Hare msg size). Hence, we propose to introduce a signed message struct as follows:

  1. sig []byte
  2. inner []byte Now we can verify it right away and do an additional unmarshall to get the inner message. We assume that the first unmarshall (from raw bytes) is significantly better than the marshal of the inner message.

To sum up, we need to add a struct SignedMsg to be used by all protocols who need to send signed messages. If you approach this issue please talk to @noamnelke to see if he already has such a struct in use.

gavraz avatar Jul 14 '19 13:07 gavraz

Do we see the same memory consumption reported in this issue now that the scale codec is being used?

jonZlotnik avatar Sep 21 '22 18:09 jonZlotnik