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

fix alonzo block serialization #2274

Merged
merged 3 commits into from
May 7, 2021
Merged

Conversation

JaredCorduan
Copy link
Contributor

The Alonzo blocks now pass the roundtrip serialization tests. I had to:

  • Remove the PreAlonzo constraint from the block generator. (Now that I have looked at that generator in detail, I see more cleanup that I want to do, but I will do that in a follow up PR. generators for serialization should be much more "white noise" than what we have).
  • Add a method to the SupportsSegWit class to return the number of non-body segments. This is used in the Block serialization to enforce the number of items in a Block.
  • Fix the alignedValidFlags function that is used in Alonzo TxSeq decoding. It is supposed to be the moral dual of nonValidatingIndices, but the recursive step was not taking into account the index of the last False that it had seen.

Additionally, clean up the arbitrary Block instance to work in Alonzo.
@@ -214,6 +214,7 @@ instance CC.Crypto c => EraModule.SupportsSegWit (AlonzoEra c) where
fromTxSeq = Alonzo.txSeqTxns
toTxSeq = Alonzo.TxSeq
hashTxSeq = Alonzo.hashTxSeq
numSegComponents = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be easier to have this return the total number of segregated components, rather than just the "non-body" ones?

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 think it would. I wasn't sure if that was breaking the abstraction, though (ie why should SupportsSegWit know about block size). but maybe that's silly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait, you mean to not include the block header. yea, that's better!

alignedValidFlags' prev n (x : xs) =
Seq.replicate (x - prev - 1) (IsValidating True)
Seq.>< IsValidating False
Seq.<| alignedValidFlags' x (n - (x - prev)) xs
Copy link
Contributor

Choose a reason for hiding this comment

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

Urgh, yes, good catch.

Jared Corduan added 2 commits May 7, 2021 08:00
I added a method to the SupportsSegWit class to return the number of
non-body segments. This is used in the Block serialization to enforce
the number of items in a Block.
@JaredCorduan JaredCorduan merged commit 9e0bc20 into master May 7, 2021
@iohk-bors iohk-bors bot deleted the jc/fix-alonzo-block-cbor branch May 7, 2021 16:23
nfrisby added a commit to IntersectMBO/ouroboros-network that referenced this pull request May 13, 2021
This commit hash matches and the sources.json content matches-or-exceeds that
of the first cardano-ledger-specs commit that provides everything we require
for our initial Alonzo integration (ie no serialization tests, but a
Mary-to-Alonzo HF ThreadNet test).

We needed to introduce the `Coherent` QuickCheck modifier because PR
IntersectMBO/cardano-ledger#2274 loosened the `Arbitrary` instance for
Shelley blocks. We have a few tests that assumed the arbitrary blocks would
pass "integrity" checks and that the header's claim for the block body's size
was mostly correct. The follow-up IntersectMBO/cardano-ledger#2280
re-introduced the generator for coherent header-body pairs, and the new
`Coherent` modifier lets us select that for the requisite properties.
nfrisby added a commit to IntersectMBO/ouroboros-network that referenced this pull request May 13, 2021
This commit hash matches and the sources.json content matches-or-exceeds that
of the first cardano-ledger-specs commit that provides everything we require
for our initial Alonzo integration (ie no serialization tests, but a
Mary-to-Alonzo HF ThreadNet test).

We needed to introduce the `Coherent` QuickCheck modifier because PR
IntersectMBO/cardano-ledger#2274 loosened the `Arbitrary` instance for
Shelley blocks. We have a few tests that assumed the arbitrary blocks would
pass "integrity" checks and that the header's claim for the block body's size
was mostly correct. The follow-up IntersectMBO/cardano-ledger#2280
re-introduced the generator for coherent header-body pairs, and the new
`Coherent` modifier lets us select that for the requisite properties.
nfrisby added a commit to IntersectMBO/ouroboros-network that referenced this pull request May 13, 2021
This commit hash matches and the sources.json content matches-or-exceeds that
of the first cardano-ledger-specs commit that provides everything we require
for our initial Alonzo integration (ie no serialization tests, but a
Mary-to-Alonzo HF ThreadNet test).

We needed to introduce the `Coherent` QuickCheck modifier because PR
IntersectMBO/cardano-ledger#2274 loosened the `Arbitrary` instance for
Shelley blocks. We have a few tests that assumed the arbitrary blocks would
pass "integrity" checks and that the header's claim for the block body's size
was mostly correct. The follow-up IntersectMBO/cardano-ledger#2280
re-introduced the generator for coherent header-body pairs, and the new
`Coherent` modifier lets us select that for the requisite properties.
nfrisby added a commit to IntersectMBO/ouroboros-network that referenced this pull request May 13, 2021
This commit hash matches and the sources.json content matches-or-exceeds that
of the first cardano-ledger-specs commit that provides everything we require
for our initial Alonzo integration (ie no serialization tests, but a
Mary-to-Alonzo HF ThreadNet test).

We needed to introduce the `Coherent` QuickCheck modifier because PR
IntersectMBO/cardano-ledger#2274 loosened the `Arbitrary` instance for
Shelley blocks. We have a few tests that assumed the arbitrary blocks would
pass "integrity" checks and that the header's claim for the block body's size
was mostly correct. The follow-up IntersectMBO/cardano-ledger#2280
re-introduced the generator for coherent header-body pairs, and the new
`Coherent` modifier lets us select that for the requisite properties.
nfrisby added a commit to IntersectMBO/ouroboros-network that referenced this pull request May 13, 2021
This commit hash matches and the sources.json content matches-or-exceeds that
of the first cardano-ledger-specs commit that provides everything we require
for our initial Alonzo integration (ie no serialization tests, but a
Mary-to-Alonzo HF ThreadNet test).

We needed to introduce the `Coherent` QuickCheck modifier because PR
IntersectMBO/cardano-ledger#2274 loosened the `Arbitrary` instance for
Shelley blocks. We have a few tests that assumed the arbitrary blocks would
pass "integrity" checks and that the header's claim for the block body's size
was mostly correct. The follow-up IntersectMBO/cardano-ledger#2280
re-introduced the generator for coherent header-body pairs, and the new
`Coherent` modifier lets us select that for the requisite properties.
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