@@ -110,3 +110,174 @@ func (lcb *LightClientBootstrap) HashTreeRoot(spec *common.Spec, hFn tree.HashFn
110
110
& lcb .CurrentSyncCommitteeBranch ,
111
111
)
112
112
}
113
+
114
+ func LightClientUpdateType (spec * common.Spec ) * view.ContainerTypeDef {
115
+ return view .ContainerType ("SyncCommittee" , []view.FieldDef {
116
+ {Name : "attested_header" , Type : common .BeaconBlockHeaderType },
117
+ {Name : "next_sync_committee" , Type : common .SyncCommitteeType (spec )},
118
+ {Name : "next_sync_committee_branch" , Type : altair .SyncCommitteeProofBranchType },
119
+ {Name : "finalized_header" , Type : common .BeaconBlockHeaderType },
120
+ {Name : "finality_branch" , Type : altair .FinalizedRootProofBranchType },
121
+ {Name : "sync_aggregate" , Type : altair .SyncAggregateType (spec )},
122
+ {Name : "signature_slot" , Type : common .SlotType },
123
+ })
124
+ }
125
+
126
+ type LightClientUpdate struct {
127
+ // Update beacon block header
128
+ AttestedHeader LightClientHeader `yaml:"attested_header" json:"attested_header"`
129
+ // Next sync committee corresponding to the header
130
+ NextSyncCommittee common.SyncCommittee `yaml:"next_sync_committee" json:"next_sync_committee"`
131
+ NextSyncCommitteeBranch altair.SyncCommitteeProofBranch `yaml:"next_sync_committee_branch" json:"next_sync_committee_branch"`
132
+ // Finality proof for the update header
133
+ FinalizedHeader common.BeaconBlockHeader `yaml:"finalized_header" json:"finalized_header"`
134
+ FinalityBranch altair.FinalizedRootProofBranch `yaml:"finality_branch" json:"finality_branch"`
135
+ // Sync committee aggregate signature
136
+ SyncAggregate altair.SyncAggregate `yaml:"sync_aggregate" json:"sync_aggregate"`
137
+ // Slot at which the aggregate signature was created (untrusted)
138
+ SignatureSlot common.Slot `yaml:"signature_slot" json:"signature_slot"`
139
+ }
140
+
141
+ func (lcu * LightClientUpdate ) Deserialize (spec * common.Spec , dr * codec.DecodingReader ) error {
142
+ return dr .FixedLenContainer (
143
+ & lcu .AttestedHeader ,
144
+ spec .Wrap (& lcu .NextSyncCommittee ),
145
+ & lcu .NextSyncCommitteeBranch ,
146
+ & lcu .FinalizedHeader ,
147
+ & lcu .FinalityBranch ,
148
+ spec .Wrap (& lcu .SyncAggregate ),
149
+ & lcu .SignatureSlot ,
150
+ )
151
+ }
152
+
153
+ func (lcu * LightClientUpdate ) Serialize (spec * common.Spec , w * codec.EncodingWriter ) error {
154
+ return w .FixedLenContainer (
155
+ & lcu .AttestedHeader ,
156
+ spec .Wrap (& lcu .NextSyncCommittee ),
157
+ & lcu .NextSyncCommitteeBranch ,
158
+ & lcu .FinalizedHeader ,
159
+ & lcu .FinalityBranch ,
160
+ spec .Wrap (& lcu .SyncAggregate ),
161
+ & lcu .SignatureSlot ,
162
+ )
163
+ }
164
+
165
+ func (lcu * LightClientUpdate ) ByteLength (spec * common.Spec ) uint64 {
166
+ return codec .ContainerLength (
167
+ & lcu .AttestedHeader ,
168
+ spec .Wrap (& lcu .NextSyncCommittee ),
169
+ & lcu .NextSyncCommitteeBranch ,
170
+ & lcu .FinalizedHeader ,
171
+ & lcu .FinalityBranch ,
172
+ spec .Wrap (& lcu .SyncAggregate ),
173
+ & lcu .SignatureSlot ,
174
+ )
175
+ }
176
+
177
+ func (lcu * LightClientUpdate ) FixedLength (spec * common.Spec ) uint64 {
178
+ return codec .ContainerLength (
179
+ & lcu .AttestedHeader ,
180
+ spec .Wrap (& lcu .NextSyncCommittee ),
181
+ & lcu .NextSyncCommitteeBranch ,
182
+ & lcu .FinalizedHeader ,
183
+ & lcu .FinalityBranch ,
184
+ spec .Wrap (& lcu .SyncAggregate ),
185
+ & lcu .SignatureSlot ,
186
+ )
187
+ }
188
+
189
+ func (lcu * LightClientUpdate ) HashTreeRoot (spec * common.Spec , hFn tree.HashFn ) common.Root {
190
+ return hFn .HashTreeRoot (
191
+ & lcu .AttestedHeader ,
192
+ spec .Wrap (& lcu .NextSyncCommittee ),
193
+ & lcu .NextSyncCommitteeBranch ,
194
+ & lcu .FinalizedHeader ,
195
+ & lcu .FinalityBranch ,
196
+ spec .Wrap (& lcu .SyncAggregate ),
197
+ & lcu .SignatureSlot ,
198
+ )
199
+ }
200
+
201
+ type LightClientFinalityUpdate struct {
202
+ AttestedHeader LightClientHeader `yaml:"attested_header" json:"attested_header"`
203
+ FinalizedHeader common.BeaconBlockHeader `yaml:"finalized_header" json:"finalized_header"`
204
+ FinalityBranch altair.FinalizedRootProofBranch `yaml:"finality_branch" json:"finality_branch"`
205
+ SyncAggregate altair.SyncAggregate `yaml:"sync_aggregate" json:"sync_aggregate"`
206
+ SignatureSlot common.Slot `yaml:"signature_slot" json:"signature_slot"`
207
+ }
208
+
209
+ func LightClientFinalityUpdateType (spec * common.Spec ) * view.ContainerTypeDef {
210
+ return view .ContainerType ("SyncCommittee" , []view.FieldDef {
211
+ {Name : "attested_header" , Type : LightClientHeaderType },
212
+ {Name : "finalized_header" , Type : common .BeaconBlockHeaderType },
213
+ {Name : "finality_branch" , Type : altair .FinalizedRootProofBranchType },
214
+ {Name : "sync_aggregate" , Type : altair .SyncAggregateType (spec )},
215
+ {Name : "signature_slot" , Type : common .SlotType },
216
+ })
217
+ }
218
+
219
+ func (lcfu * LightClientFinalityUpdate ) FixedLength (spec * common.Spec ) uint64 {
220
+ return codec .ContainerLength (& lcfu .AttestedHeader , & lcfu .FinalizedHeader , & lcfu .FinalityBranch , spec .Wrap (& lcfu .SyncAggregate ), & lcfu .SignatureSlot )
221
+ }
222
+
223
+ func (lcfu * LightClientFinalityUpdate ) Deserialize (spec * common.Spec , dr * codec.DecodingReader ) error {
224
+ return dr .Container (& lcfu .AttestedHeader , & lcfu .FinalizedHeader , & lcfu .FinalityBranch , spec .Wrap (& lcfu .SyncAggregate ), & lcfu .SignatureSlot )
225
+ }
226
+
227
+ func (lcfu * LightClientFinalityUpdate ) Serialize (spec * common.Spec , w * codec.EncodingWriter ) error {
228
+ return w .Container (& lcfu .AttestedHeader , & lcfu .FinalizedHeader , & lcfu .FinalityBranch , spec .Wrap (& lcfu .SyncAggregate ), & lcfu .SignatureSlot )
229
+ }
230
+
231
+ func (lcfu * LightClientFinalityUpdate ) ByteLength (spec * common.Spec ) uint64 {
232
+ return codec .ContainerLength (& lcfu .AttestedHeader , & lcfu .FinalizedHeader , & lcfu .FinalityBranch , spec .Wrap (& lcfu .SyncAggregate ), & lcfu .SignatureSlot )
233
+ }
234
+
235
+ func (lcfu * LightClientFinalityUpdate ) HashTreeRoot (spec * common.Spec , hFn tree.HashFn ) common.Root {
236
+ return hFn .HashTreeRoot (
237
+ & lcfu .AttestedHeader ,
238
+ & lcfu .FinalizedHeader ,
239
+ & lcfu .FinalityBranch ,
240
+ spec .Wrap (& lcfu .SyncAggregate ),
241
+ & lcfu .SignatureSlot ,
242
+ )
243
+ }
244
+
245
+ type LightClientOptimisticUpdate struct {
246
+ AttestedHeader LightClientHeader `yaml:"attested_header" json:"attested_header"`
247
+ SyncAggregate altair.SyncAggregate `yaml:"sync_aggregate" json:"sync_aggregate"`
248
+ SignatureSlot common.Slot `yaml:"signature_slot" json:"signature_slot"`
249
+ }
250
+
251
+ func LightClientOptimisticUpdateType (spec * common.Spec ) * view.ContainerTypeDef {
252
+ return view .ContainerType ("SyncCommittee" , []view.FieldDef {
253
+ {Name : "attested_header" , Type : LightClientHeaderType },
254
+ {Name : "finalized_header" , Type : common .BeaconBlockHeaderType },
255
+ {Name : "finality_branch" , Type : altair .FinalizedRootProofBranchType },
256
+ {Name : "sync_aggregate" , Type : altair .SyncAggregateType (spec )},
257
+ {Name : "signature_slot" , Type : common .SlotType },
258
+ })
259
+ }
260
+
261
+ func (lcou * LightClientOptimisticUpdate ) FixedLength (spec * common.Spec ) uint64 {
262
+ return codec .ContainerLength (& lcou .AttestedHeader , spec .Wrap (& lcou .SyncAggregate ), & lcou .SignatureSlot )
263
+ }
264
+
265
+ func (lcou * LightClientOptimisticUpdate ) Deserialize (spec * common.Spec , dr * codec.DecodingReader ) error {
266
+ return dr .Container (& lcou .AttestedHeader , spec .Wrap (& lcou .SyncAggregate ), & lcou .SignatureSlot )
267
+ }
268
+
269
+ func (lcou * LightClientOptimisticUpdate ) Serialize (spec * common.Spec , w * codec.EncodingWriter ) error {
270
+ return w .Container (& lcou .AttestedHeader , spec .Wrap (& lcou .SyncAggregate ), & lcou .SignatureSlot )
271
+ }
272
+
273
+ func (lcou * LightClientOptimisticUpdate ) ByteLength (spec * common.Spec ) uint64 {
274
+ return codec .ContainerLength (& lcou .AttestedHeader , spec .Wrap (& lcou .SyncAggregate ), & lcou .SignatureSlot )
275
+ }
276
+
277
+ func (lcou * LightClientOptimisticUpdate ) HashTreeRoot (spec * common.Spec , hFn tree.HashFn ) common.Root {
278
+ return hFn .HashTreeRoot (
279
+ & lcou .AttestedHeader ,
280
+ spec .Wrap (& lcou .SyncAggregate ),
281
+ & lcou .SignatureSlot ,
282
+ )
283
+ }
0 commit comments