Skip to content

Commit 0ebf227

Browse files
committed
Merge branch 'main' into hm/snapshot-export
2 parents 6ac2aca + e7f84e7 commit 0ebf227

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

certstore/snapshot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
var ErrUnknownLatestCertificate = errors.New("latest certificate is not known")
1616

1717
// ExportLatestSnapshot exports an F3 snapshot that includes the finality certificate chain until the current `latestCertificate`.
18+
//
19+
// Checkout the format specification at <https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0108.md>
1820
func (cs *Store) ExportLatestSnapshot(ctx context.Context, writer io.Writer) error {
1921
if cs.latestCertificate == nil {
2022
return ErrUnknownLatestCertificate
@@ -23,6 +25,8 @@ func (cs *Store) ExportLatestSnapshot(ctx context.Context, writer io.Writer) err
2325
}
2426

2527
// ExportSnapshot exports an F3 snapshot that includes the finality certificate chain from the `Store.firstInstance` to the specified `lastInstance`.
28+
//
29+
// Checkout the format specification at <https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0108.md>
2630
func (cs *Store) ExportSnapshot(ctx context.Context, latestInstance uint64, writer io.Writer) error {
2731
initialPowerTable, err := cs.GetPowerTable(ctx, cs.firstInstance)
2832
if err != nil {

certstore/snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package certstore
1+
package certstore

observer/model.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package observer
22

33
import (
4-
"encoding/base64"
54
"fmt"
65
"time"
76

@@ -151,11 +150,11 @@ func supplementalDataFromGpbft(sd gpbft.SupplementalData) SupplementalData {
151150
func (m Message) ToPartialMessage() (*gpbft.PartialGMessage, error) {
152151
payload, err := m.Vote.ToGpbftPayload()
153152
if err != nil {
154-
return nil, err
153+
return nil, fmt.Errorf("could not convert vote to gpbft payload: %w", err)
155154
}
156155
gj, err := m.Justification.ToGpbftJustification()
157156
if err != nil {
158-
return nil, err
157+
return nil, fmt.Errorf("could not convert justification to gpbft justification: %w", err)
159158
}
160159

161160
return &gpbft.PartialGMessage{
@@ -173,16 +172,16 @@ func (m Message) ToPartialMessage() (*gpbft.PartialGMessage, error) {
173172
func (p Payload) ToGpbftPayload() (gpbft.Payload, error) {
174173
phase, err := phaseFromString(p.Phase)
175174
if err != nil {
176-
return gpbft.Payload{}, err
175+
return gpbft.Payload{}, fmt.Errorf("could not convert phase: %w", err)
177176
}
178177
sd, err := p.SupplementalData.ToGpbftSupplementalData()
179178
if err != nil {
180-
return gpbft.Payload{}, err
179+
return gpbft.Payload{}, fmt.Errorf("could not convert supplemental data: %w", err)
181180
}
182181

183182
gv, err := ToGpbftChain(p.Value...)
184183
if err != nil {
185-
return gpbft.Payload{}, err
184+
return gpbft.Payload{}, fmt.Errorf("could not convert value: %w", err)
186185
}
187186

188187
return gpbft.Payload{
@@ -246,20 +245,13 @@ func (j *Justification) ToGpbftJustification() (*gpbft.Justification, error) {
246245
gsigners, _ := bitfield.NewFromIter(ri)
247246
payload, err := j.Vote.ToGpbftPayload()
248247
if err != nil {
249-
return nil, err
250-
}
251-
252-
// Embedded struct as json, hence the decode.
253-
s := string(j.Signature)
254-
decoded, err := base64.StdEncoding.DecodeString(s)
255-
if err != nil {
256-
return nil, err
248+
return nil, fmt.Errorf("could not convert vote to gpbft payload: %w", err)
257249
}
258250

259251
return &gpbft.Justification{
260252
Vote: payload,
261253
Signers: gsigners,
262-
Signature: decoded,
254+
Signature: j.Signature,
263255
}, nil
264256
}
265257

observer/observer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (o *Observer) createOrReplaceMessagesView(ctx context.Context, includeParqu
215215
if includeParquet {
216216
includeParquetFiles = fmt.Sprintf("UNION ALL SELECT * FROM '%s'", filepath.Join(o.rotatePath, "*.parquet"))
217217
}
218-
createView := fmt.Sprintf(`CREATE VIEW IF NOT EXISTS messages AS SELECT * FROM latest_messages %s`, includeParquetFiles)
218+
createView := fmt.Sprintf(`CREATE OR REPLACE VIEW messages AS SELECT * FROM latest_messages %s`, includeParquetFiles)
219219
_, err := o.db.ExecContext(ctx, createView)
220220
return err
221221

0 commit comments

Comments
 (0)