Skip to content

Commit 0da5925

Browse files
committed
fixes to tailHeight and including messages/receipts/stateroots
1 parent 46f6789 commit 0da5925

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

cmd/filecoin-chain-archiver/cmds/create.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,15 @@ var cmdCreate = &cli.Command{
179179
EnvVars: []string{"FCA_CREATE_HEIGHT"},
180180
Value: 0,
181181
},
182+
&cli.IntFlag{
183+
Name: "stateroot-count",
184+
Usage: "number of stateroots to included in snapshot",
185+
EnvVars: []string{"FCA_CREATE_STATEROOT_COUNT"},
186+
Value: 2000,
187+
},
182188
&cli.StringFlag{
183-
Name: "filename",
184-
Usage: "name of exported CAR file for internal chain export",
189+
Name: "filename",
190+
Usage: "name of exported CAR file for internal chain export",
185191
EnvVars: []string{"FCA_EXPORT_FILENAME"},
186192
},
187193
&cli.DurationFlag{
@@ -191,8 +197,8 @@ var cmdCreate = &cli.Command{
191197
Value: 60 * time.Second,
192198
},
193199
&cli.StringFlag{
194-
Name: "export-dir",
195-
Usage: "directory where to save the exported CAR file",
200+
Name: "export-dir",
201+
Usage: "directory where to save the exported CAR file",
196202
EnvVars: []string{"FCA_EXPORT_DIR"},
197203
},
198204
},
@@ -211,8 +217,9 @@ var cmdCreate = &cli.Command{
211217
flagConfigPath := cctx.String("config-path")
212218
flagInterval := cctx.Int("interval")
213219
flagConfidence := cctx.Int("confidence")
214-
flagHeight := cctx.Int("height")
215220
flagAfter := cctx.Int("after")
221+
flagHeight := cctx.Int("height")
222+
flagStaterootCount := cctx.Int("stateroot-count")
216223
flagExportDir := cctx.String("export-dir")
217224
flagFileName := cctx.String("filename")
218225

@@ -301,8 +308,8 @@ var cmdCreate = &cli.Command{
301308
return err
302309
}
303310

304-
tailHeight := height - 2880
305-
tailTs, err := cm.GetTipset(ctx, tailHeight)
311+
tailHeight := flagHeight - flagStaterootCount
312+
tailTs, err := cm.GetTipset(ctx, abi.ChainEpoch(tailHeight))
306313
if err != nil {
307314
return err
308315
}
@@ -443,7 +450,7 @@ var cmdCreate = &cli.Command{
443450
var siCompressed *snapshotInfo
444451
g.Go(func() error {
445452
var err error
446-
siCompressed, err = runUploadCompressed(ctxGroup, minioClient, flagBucket, flagNamePrefix, flagRetrievalEndpointPrefix, flagFileName + ".zstd", peerID, bt, rr)
453+
siCompressed, err = runUploadCompressed(ctxGroup, minioClient, flagBucket, flagNamePrefix, flagRetrievalEndpointPrefix, flagFileName+".zstd", peerID, bt, rr)
447454
return err
448455
})
449456
if err := g.Wait(); err != nil {

pkg/export/export.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type Export struct {
9898
stateroots bool
9999
workers int
100100
exportName string
101-
exportDir string
101+
exportDir string
102102

103103
sizeMu sync.Mutex
104104
size int
@@ -116,7 +116,7 @@ func NewExport(node api.FullNode, head, tail types.TipSetKey, name, dir string)
116116
stateroots: true,
117117
workers: 50,
118118
exportName: name,
119-
exportDir: dir,
119+
exportDir: dir,
120120
}
121121
}
122122

@@ -152,8 +152,11 @@ func (e *Export) Export(ctx context.Context) error {
152152
logger.Infow("starting export")
153153
// lotus chain export-range --internal --messages --receipts --stateroots --workers 50 --head "@${END}" --tail "@${START}" --write-buffer=5000000 export.car
154154
err := e.node.ChainExportRangeInternal(ctx, e.head, e.tail, api.ChainExportConfig{
155-
FileName: e.exportName,
156-
ExportDir: e.exportDir,
155+
FileName: e.exportName,
156+
ExportDir: e.exportDir,
157+
IncludeMessages: e.messages,
158+
IncludeReceipts: e.receipts,
159+
IncludeStateRoots: e.stateroots,
157160
})
158161
if err != nil {
159162
return err

0 commit comments

Comments
 (0)