Skip to content

Commit 6c486ae

Browse files
committed
indexers: get rid of multiblockproof related code from proof stats
1 parent 900d953 commit 6c486ae

File tree

1 file changed

+11
-163
lines changed

1 file changed

+11
-163
lines changed

blockchain/indexers/utreexoproofstats.go

Lines changed: 11 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,23 @@ import (
1010
"io"
1111
"math"
1212

13-
"github.com/utreexo/utreexod/chaincfg/chainhash"
1413
"github.com/utreexo/utreexod/wire"
1514
)
1615

17-
// proofStatsSize has 19 elements that are each 8 bytes big.
18-
const proofStatsSize int = 8 * 19
16+
// proofStatsSize has 10 elements that are each 8 bytes big.
17+
const proofStatsSize int = 8 * 10
1918

2019
// proofStats are the relevant proof statistics to check how big each proofs are.
2120
type proofStats struct {
2221
// The height of the chain for the below stats.
2322
BlockHeight uint64
2423

25-
// The overhead of the multi interval proof.
26-
MultiBlockProofOverheadSum float64
27-
MultiBlockProofCount uint64
28-
2924
// The overhead of the single interval proof.
3025
BlockProofOverheadSum float64
3126
BlockProofCount uint64
3227

33-
// Total deletions vs the proven deletions by the multi-block proof.
34-
TotalDels uint64
35-
TotalProvenDels uint64
28+
// Total deletions.
29+
TotalDels uint64
3630

3731
// Size of all the leaf datas.
3832
LdSize uint64
@@ -45,18 +39,6 @@ type proofStats struct {
4539
// Size of all the proofs in the batchproofs.
4640
ProofSize uint64
4741
ProofCount uint64
48-
49-
// Size of the multi-block targets.
50-
MbTgSize uint64
51-
MbTgCount uint64
52-
53-
// Size of the multi-block proofs.
54-
MbProofSize uint64
55-
MbProofCount uint64
56-
57-
// Size of the leafhashes for the multi-block proofs.
58-
MbHashSize uint64
59-
MbHashCount uint64
6042
}
6143

6244
// UpdateTotalDelCount updates the deletion count in the proof stats.
@@ -86,40 +68,15 @@ func (ps *proofStats) UpdateUDStats(excludeAccProof bool, ud *wire.UData) {
8668
ps.BlockProofOverheadSum += overhead
8769
}
8870

89-
// UpdateMultiUDStats updates the multi-block utreexo data statistics.
90-
func (ps *proofStats) UpdateMultiUDStats(delCount int, multiUd *wire.UData) {
91-
// Update target size.
92-
ps.MbTgSize += uint64(wire.BatchProofSerializeTargetSize(&multiUd.AccProof))
93-
ps.MbTgCount += uint64(len(multiUd.AccProof.Targets))
94-
95-
// Update proof size.
96-
ps.MbProofSize += uint64(wire.BatchProofSerializeAccProofSize(&multiUd.AccProof))
97-
ps.MbProofCount += uint64(len(multiUd.AccProof.Proof))
98-
99-
// Update multi-block proof overhead.
100-
overhead := calcProofOverhead(multiUd)
101-
ps.MultiBlockProofCount++
102-
ps.MultiBlockProofOverheadSum += overhead
103-
104-
// Update the multi-block proof hash size.
105-
ps.MbHashSize += uint64(delCount * chainhash.HashSize)
106-
ps.MbHashCount += uint64(delCount)
107-
108-
// Update proven dels by the multi-block proofs.
109-
ps.TotalProvenDels += uint64(delCount)
110-
}
111-
11271
// LogProofStats outputs a log of the proof statistics.
11372
func (ps *proofStats) LogProofStats() {
114-
log.Infof("height %d: totalProvenPercentage %f, totalDels %d, totalProvenDels %d, ldSize %d, ldCount %d, tgSize %d, tgCount %d, proofSize %d, proofCount %d "+
115-
"mbTgSize %d, mbTgCount %d, mbProofSize %d, mbProofCount %d, mbHashSize %d, mbHashCount %d",
116-
ps.BlockHeight, float64(ps.TotalProvenDels)/float64(ps.TotalDels), ps.TotalDels, ps.TotalProvenDels, ps.LdSize, ps.LdCount, ps.TgSize, ps.TgCount,
117-
ps.ProofSize, ps.ProofCount, ps.MbTgSize, ps.MbTgCount,
118-
ps.MbProofSize, ps.MbProofCount, ps.MbHashSize, ps.MbHashCount)
119-
120-
log.Infof("height %d, average-blockoverhead %f, average-multiblockoverhead %f, blockoverhead-sum %f, blockcount %d, mboverhead-sum %f, mbCount %d",
121-
ps.BlockHeight, ps.BlockProofOverheadSum/float64(ps.BlockProofCount), ps.MultiBlockProofOverheadSum/float64(ps.MultiBlockProofCount),
122-
ps.BlockProofOverheadSum, ps.BlockProofCount, ps.MultiBlockProofOverheadSum, ps.MultiBlockProofCount)
73+
log.Infof("height %d: totalDels %d, ldSize %d, ldCount %d, tgSize %d, tgCount %d, proofSize %d, proofCount %d",
74+
ps.BlockHeight, ps.TotalDels, ps.LdSize, ps.LdCount, ps.TgSize, ps.TgCount,
75+
ps.ProofSize, ps.ProofCount)
76+
77+
log.Infof("height %d, average-blockoverhead %f, blockoverhead-sum %f, blockcount %d",
78+
ps.BlockHeight, ps.BlockProofOverheadSum/float64(ps.BlockProofCount),
79+
ps.BlockProofOverheadSum, ps.BlockProofCount)
12380
}
12481

12582
// Serialize serializes the proof statistics into the writer.
@@ -133,18 +90,6 @@ func (ps *proofStats) Serialize(w io.Writer) error {
13390
return err
13491
}
13592

136-
binary.BigEndian.PutUint64(buf[:], math.Float64bits(ps.MultiBlockProofOverheadSum))
137-
_, err = w.Write(buf[:])
138-
if err != nil {
139-
return err
140-
}
141-
142-
binary.BigEndian.PutUint64(buf[:], ps.MultiBlockProofCount)
143-
_, err = w.Write(buf[:])
144-
if err != nil {
145-
return err
146-
}
147-
14893
binary.BigEndian.PutUint64(buf[:], math.Float64bits(ps.BlockProofOverheadSum))
14994
_, err = w.Write(buf[:])
15095
if err != nil {
@@ -163,12 +108,6 @@ func (ps *proofStats) Serialize(w io.Writer) error {
163108
return err
164109
}
165110

166-
binary.BigEndian.PutUint64(buf[:], ps.TotalProvenDels)
167-
_, err = w.Write(buf[:])
168-
if err != nil {
169-
return err
170-
}
171-
172111
binary.BigEndian.PutUint64(buf[:], ps.LdSize)
173112
_, err = w.Write(buf[:])
174113
if err != nil {
@@ -205,42 +144,6 @@ func (ps *proofStats) Serialize(w io.Writer) error {
205144
return err
206145
}
207146

208-
binary.BigEndian.PutUint64(buf[:], ps.MbTgSize)
209-
_, err = w.Write(buf[:])
210-
if err != nil {
211-
return err
212-
}
213-
214-
binary.BigEndian.PutUint64(buf[:], ps.MbTgCount)
215-
_, err = w.Write(buf[:])
216-
if err != nil {
217-
return err
218-
}
219-
220-
binary.BigEndian.PutUint64(buf[:], ps.MbProofSize)
221-
_, err = w.Write(buf[:])
222-
if err != nil {
223-
return err
224-
}
225-
226-
binary.BigEndian.PutUint64(buf[:], ps.MbProofCount)
227-
_, err = w.Write(buf[:])
228-
if err != nil {
229-
return err
230-
}
231-
232-
binary.BigEndian.PutUint64(buf[:], ps.MbHashSize)
233-
_, err = w.Write(buf[:])
234-
if err != nil {
235-
return err
236-
}
237-
238-
binary.BigEndian.PutUint64(buf[:], ps.MbHashCount)
239-
_, err = w.Write(buf[:])
240-
if err != nil {
241-
return err
242-
}
243-
244147
return nil
245148
}
246149

@@ -255,19 +158,6 @@ func (ps *proofStats) Deserialize(r io.Reader) error {
255158
}
256159
ps.BlockHeight = binary.BigEndian.Uint64(buf[:])
257160

258-
_, err = r.Read(buf[:])
259-
if err != nil {
260-
return err
261-
}
262-
res = binary.BigEndian.Uint64(buf[:])
263-
ps.MultiBlockProofOverheadSum = math.Float64frombits(res)
264-
265-
_, err = r.Read(buf[:])
266-
if err != nil {
267-
return err
268-
}
269-
ps.MultiBlockProofCount = binary.BigEndian.Uint64(buf[:])
270-
271161
_, err = r.Read(buf[:])
272162
if err != nil {
273163
return err
@@ -287,12 +177,6 @@ func (ps *proofStats) Deserialize(r io.Reader) error {
287177
}
288178
ps.TotalDels = binary.BigEndian.Uint64(buf[:])
289179

290-
_, err = r.Read(buf[:])
291-
if err != nil {
292-
return err
293-
}
294-
ps.TotalProvenDels = binary.BigEndian.Uint64(buf[:])
295-
296180
_, err = r.Read(buf[:])
297181
if err != nil {
298182
return err
@@ -329,42 +213,6 @@ func (ps *proofStats) Deserialize(r io.Reader) error {
329213
}
330214
ps.ProofCount = binary.BigEndian.Uint64(buf[:])
331215

332-
_, err = r.Read(buf[:])
333-
if err != nil {
334-
return err
335-
}
336-
ps.MbTgSize = binary.BigEndian.Uint64(buf[:])
337-
338-
_, err = r.Read(buf[:])
339-
if err != nil {
340-
return err
341-
}
342-
ps.MbTgCount = binary.BigEndian.Uint64(buf[:])
343-
344-
_, err = r.Read(buf[:])
345-
if err != nil {
346-
return err
347-
}
348-
ps.MbProofSize = binary.BigEndian.Uint64(buf[:])
349-
350-
_, err = r.Read(buf[:])
351-
if err != nil {
352-
return err
353-
}
354-
ps.MbProofCount = binary.BigEndian.Uint64(buf[:])
355-
356-
_, err = r.Read(buf[:])
357-
if err != nil {
358-
return err
359-
}
360-
ps.MbHashSize = binary.BigEndian.Uint64(buf[:])
361-
362-
_, err = r.Read(buf[:])
363-
if err != nil {
364-
return err
365-
}
366-
ps.MbHashCount = binary.BigEndian.Uint64(buf[:])
367-
368216
return nil
369217
}
370218

0 commit comments

Comments
 (0)