go-spacemesh
go-spacemesh copied to clipboard
Hare validation of messages mem usage can be optimized
A Hare message M is composed of
- A sig []byte
- 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:
- sig []byte
- 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.
Do we see the same memory consumption reported in this issue now that the scale codec is being used?