Should add a docstring: this function encapsulates serialization, and ensures that any final steps needed before syncing (e.g. signing, incrementing counters, etc) are done.