Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deser fix for Update + pre-Alonzo blocks support #28

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

rooooooooob
Copy link
Contributor

Update's ProtocolVersion was generated as an array due to cddl-codegen
not supporting occurencies so it treated [protocol_version] as an array
rather than a single one as all other occurences of an array with a
single element were * occurences in the cddl.

As of Alozno, Blocks have a mandatory invalid_transactions field which
makes it one of the 2 non-backwards-compatible (the other being
transaction which we already support deserializing both) era changes to
the CDDL. This includes a fix for this by ignoring it if it's not
present.

Update's ProtocolVersion was generated as an array due to cddl-codegen
not supporting occurencies so it treated [protocol_version] as an array
rather than a single one as all other occurences of an array with a
single element were * occurences in the cddl.

As of Alozno, Blocks have a mandatory invalid_transactions field which
makes it one of the 2 non-backwards-compatible (the other being
transaction which we already support deserializing both) era changes to
the CDDL. This includes a fix for this by ignoring it if it's not
present.
@@ -3069,15 +3042,23 @@ impl Deserialize for Block {
let auxiliary_data_set = (|| -> Result<_, DeserializeError> {
Ok(AuxiliaryDataSet::deserialize(raw)?)
})().map_err(|e| e.annotate("auxiliary_data_set"))?;
let invalid_present = match len {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this permissive deserialization just for now. When we do the complete re-generation I can add in a ShelleyBlock type and have the Block type that works for Alonzo separately, same for Transaction if you think that's the right decision. We can always make it optional as well instead of separate structures. We don't have them as separate in any of the backwards-compatible things like TransactionMetadata/AuxiliaryData, or Value and TransactionOutput and those are semantically similar. Or do you think it's better to be separate since then you are explicitly aware you're passing blocks from the incorrect era?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do have the blocks separate, but don't have separate structs for TransactionMetadata/AuxiliaryData, Value and TransactionOutput, then users would think those would be there but that's not the case in the library since you could have a pre-Alonzo block with datum hashes in the TransactionOutputs which is not allowed by the CDDL/protocol. It's a bit inconsistent.

Copy link
Contributor

@SebastienGllmt SebastienGllmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@rooooooooob rooooooooob merged commit 053ea0f into develop Mar 28, 2022
@SebastienGllmt SebastienGllmt deleted the pre-alonzo-block-and-protocolversion-fix branch March 31, 2022 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants