@@ -129,6 +129,11 @@ func (ch *Chunk) ID() Identifier {
129129 return MakeID (ch )
130130}
131131
132+ // ChunkDataPackHeader is a reduced representation of ChunkDataPack. In a nutshell, we substitute
133+ // the larger [ChunkDataPack.Proof] and [ChunkDataPack.Collection] with their collision-resistant hashes.
134+ // Note, ChunkDataPackHeader.ID() is the same as ChunkDataPack.ID().
135+ //
136+ //structwrite:immutable - mutations allowed only within the constructor
132137type ChunkDataPackHeader struct {
133138 ChunkID Identifier // ID of the chunk this data pack is for
134139 StartState StateCommitment // commitment for starting state
@@ -141,6 +146,8 @@ type ChunkDataPackHeader struct {
141146 ExecutionDataRoot BlockExecutionDataRoot
142147}
143148
149+ // NewChunkDataPackHeader instantiates an "immutable" ChunkDataPackHeader.
150+ // The `CollectionID` field is set to [flow.ZeroID] for system chunks.
144151func NewChunkDataPackHeader (ChunkID Identifier , StartState StateCommitment , ProofID Identifier , CollectionID Identifier , ExecutionDataRoot BlockExecutionDataRoot ) * ChunkDataPackHeader {
145152 return & ChunkDataPackHeader {
146153 ChunkID : ChunkID ,
@@ -197,8 +204,9 @@ type ChunkDataPack struct {
197204// a trusted ChunkDataPack using NewChunkDataPack constructor.
198205type UntrustedChunkDataPack ChunkDataPack
199206
200- // NewChunkDataPack returns an initialized chunk data pack.
201- // Construction ChunkDataPack allowed only within the constructor.
207+ // FromUntrustedChunkDataPack converts a chunk data pack from an untrusted source
208+ // into its canonical representation. Here, basic structural validation is performed.
209+ // Construction of ChunkDataPacks is ONLY allowed via THIS CONSTRUCTOR.
202210//
203211// All errors indicate a valid ChunkDataPack cannot be constructed from the input.
204212func FromUntrustedChunkDataPack (untrusted UntrustedChunkDataPack ) (* ChunkDataPack , error ) {
@@ -231,6 +239,8 @@ func FromUntrustedChunkDataPack(untrusted UntrustedChunkDataPack) (*ChunkDataPac
231239 ), nil
232240}
233241
242+ // NewChunkDataPack instantiates an "immutable" ChunkDataPack.
243+ // The `collection` field is set to `nil` for system chunks.
234244func NewChunkDataPack (chunkID Identifier , startState StateCommitment , proof StorageProof , collection * Collection , executionDataRoot BlockExecutionDataRoot ) * ChunkDataPack {
235245 return & ChunkDataPack {
236246 ChunkID : chunkID ,
0 commit comments