diff --git a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Ledger/Block.hs b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Ledger/Block.hs index dfabdba24eb..97b3dda8712 100644 --- a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Ledger/Block.hs +++ b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Ledger/Block.hs @@ -153,7 +153,14 @@ instance GetHeader ByronBlock where CC.ABOBBoundary blk -> recoverBytes blk } where - overhead = 5 {- CBOR-in-CBOR -} + 2 {- EBB tag -} + -- The maximum block size is 65536, the CBOR-in-CBOR tag for this block + -- is: + -- + -- > D8 18 # tag(24) + -- > 1A 00010000 # bytes(65536) + -- + -- Which is 7 bytes, enough for up to 4294967295 bytes. + overhead = 7 {- CBOR-in-CBOR -} + 2 {- EBB tag -} -- Check if a block matches its header -- diff --git a/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_EBB b/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_EBB index 9b6534973da..f69f3d57969 100644 Binary files a/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_EBB and b/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_EBB differ diff --git a/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_regular b/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_regular index 594c59ad74e..749614e068b 100644 Binary files a/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_regular and b/ouroboros-consensus-cardano/test/golden/CardanoNodeToNodeVersion2/Header_Byron_regular differ diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs index 3cb5ec05a2b..41081fb9025 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs @@ -374,7 +374,14 @@ instance ConfigSupportsNode (ShelleyBlock c) where instance TPraosCrypto c => RunNode (ShelleyBlock c) where nodeBlockFetchSize hdr = overhead + headerSize + bodySize where - overhead = 5 {- CBOR-in-CBOR -} + 1 {- encodeListLen -} + -- The maximum block size is 65536, the CBOR-in-CBOR tag for this block + -- is: + -- + -- > D8 18 # tag(24) + -- > 1A 00010000 # bytes(65536) + -- + -- Which is 7 bytes, enough for up to 4294967295 bytes. + overhead = 7 {- CBOR-in-CBOR -} + 1 {- encodeListLen -} bodySize = fromIntegral . SL.bsize . SL.bhbody . shelleyHeaderRaw $ hdr headerSize = fromIntegral . SL.bHeaderSize . shelleyHeaderRaw $ hdr diff --git a/ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs b/ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs index dc1d5aae2bd..1a0bc103504 100644 --- a/ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs +++ b/ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs @@ -58,7 +58,7 @@ instance ( LedgerSupportsProtocol (SimpleBlock SimpleMockCrypto ext) , RunMockBlock SimpleMockCrypto ext ) => RunNode (SimpleBlock SimpleMockCrypto ext) where nodeBlockFetchSize hdr = - 5 {- CBOR-in-CBOR -} + 1 {- encodeListLen 2 -} + hdrSize + bodySize + 7 {- CBOR-in-CBOR -} + 1 {- encodeListLen 2 -} + hdrSize + bodySize where hdrSize = fromIntegral (Lazy.length (serialise hdr)) bodySize = simpleBodySize (simpleHeaderStd hdr)