feat: move banner, embed, and run at v8 upgrade only

1. Embed the banner in the upgrades subsystem instead of reading it at
runtime.
2. Print it all at once instead of line-by-line.
3. Run it in the v8 upgrade itself.
This commit is contained in:
Steven Allen 2022-06-22 12:41:14 -07:00
parent 17cd28028f
commit cd6c0c2ad3
3 changed files with 8 additions and 10 deletions

View File

@ -2,9 +2,12 @@ package filcns
import ( import (
"context" "context"
"fmt"
"runtime" "runtime"
"time" "time"
_ "embed"
"github.com/docker/go-units" "github.com/docker/go-units"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
@ -47,6 +50,9 @@ import (
"github.com/filecoin-project/lotus/node/bundle" "github.com/filecoin-project/lotus/node/bundle"
) )
//go:embed FVMLiftoff.txt
var fvmLiftoffBanner string
func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
var us stmgr.UpgradeSchedule var us stmgr.UpgradeSchedule
@ -1338,6 +1344,8 @@ func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.Mi
return cid.Undef, xerrors.Errorf("migrating actors v7 state: %w", err) return cid.Undef, xerrors.Errorf("migrating actors v7 state: %w", err)
} }
fmt.Print(fvmLiftoffBanner)
return newRoot, nil return newRoot, nil
} }

View File

@ -1,12 +1,9 @@
package stmgr package stmgr
import ( import (
"bufio"
"bytes" "bytes"
"context" "context"
"encoding/binary" "encoding/binary"
"fmt"
"os"
"sort" "sort"
"sync" "sync"
"time" "time"
@ -195,13 +192,6 @@ func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, heig
"to", retCid, "to", retCid,
"duration", time.Since(startTime), "duration", time.Since(startTime),
) )
f, _ := os.Open("/Users/jennijuju/filecoin/lotus/FVMLiftoff.txt")
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := scanner.Text()
fmt.Println(line)
}
} }
return retCid, nil return retCid, nil