stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 672 forks source link

[Signer] Message versioning? #5483

Open jcnelson opened 2 days ago

jcnelson commented 2 days ago

I didn't get a chance to ask on the review of #5466, but since the wire format of BlockAccept is changing, should the wire format itself be updated to be versioned? Not all signers will upgrade at the same time; signers with the new format in #5466 will produce BlockAccepts that (1) other signers can't decode and (2) older nodes can't decode.

hstove commented 1 day ago

I'm totally on board with a version byte, but I'd note that we're a bit lucky in this case in that the only time we're reading a list of signer messages is from reading StackerDBChunksEvent, where each chunk just has data, and then each chunk's data is deserialized into a SignerMessage.

So, when it comes to the question of "should nodes/signers completely ignore signer messages with a future version", I think there may be some debate, vs trying to be as backwards-compatible as possible.

Another option is to add an explicit bytes_len field to consensus_serialize to prevent the issues around deserializing a list, but that, too, wouldn't be strictly backwards compatible.

jferrant commented 1 day ago

I do think we need signer versioning, but I imagine the version number should be the very first byte of the message. This will not be backwards compatible and would require us to update all our signers/miners if we add it now.

Like Hank mentioned, we are lucky in the sense that we always just attempt to consensus deserialize whatever SignerMessage our signer/node version expects and we have enforced backwards compatibility by setting the missing timestamp value to u64::MAX. This def is not a good long term solution, but should we plan this addition of a version number to be part of a hardfork improvement?

hstove commented 1 day ago

I think there are a few things here:

With all that said, I think we should do a few things now:

If we seriously wanted to have a scheme like "nodes ignore signer messages with a higher version", we need to implement an "activation block" mechanism, so that nodes/signers all upgrade at the same time. I'd like to avoid this if possible.