several fixes and improvements while debugging interop
This commit is contained in:
parent
ea135991e3
commit
417d434973
@ -462,7 +462,7 @@ func (mp *MessagePool) PushWithNonce(addr address.Address, cb func(uint64) (*typ
|
||||
|
||||
nonce, err := mp.getNonceLocked(addr, mp.curTs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, xerrors.Errorf("get nonce locked failed: %w", err)
|
||||
}
|
||||
|
||||
msg, err := cb(nonce)
|
||||
@ -476,7 +476,7 @@ func (mp *MessagePool) PushWithNonce(addr address.Address, cb func(uint64) (*typ
|
||||
}
|
||||
|
||||
if err := mp.addLocked(msg); err != nil {
|
||||
return nil, err
|
||||
return nil, xerrors.Errorf("add locked failed: %w", err)
|
||||
}
|
||||
if err := mp.addLocal(msg, msgb); err != nil {
|
||||
log.Errorf("addLocal failed: %+v", err)
|
||||
|
@ -2,9 +2,10 @@ package sub
|
||||
|
||||
import (
|
||||
"context"
|
||||
"golang.org/x/xerrors"
|
||||
"time"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
@ -511,10 +511,11 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
||||
return xerrors.Errorf("block had nil signature")
|
||||
}
|
||||
|
||||
if h.Timestamp > uint64(time.Now().Unix()+build.AllowableClockDrift) {
|
||||
return xerrors.Errorf("block was from the future: %w", ErrTemporal)
|
||||
now := uint64(time.Now().Unix())
|
||||
if h.Timestamp > now+build.AllowableClockDrift {
|
||||
return xerrors.Errorf("block was from the future (now=%d, blk=%d): %w", now, h.Timestamp, ErrTemporal)
|
||||
}
|
||||
if h.Timestamp > uint64(time.Now().Unix()) {
|
||||
if h.Timestamp > now {
|
||||
log.Warn("Got block from the future, but within threshold", h.Timestamp, time.Now().Unix())
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/minio/blake2b-simd"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
@ -90,7 +89,7 @@ func tipsetSortFunc(blks []*BlockHeader) func(i, j int) bool {
|
||||
|
||||
if ti.Equals(tj) {
|
||||
log.Warnf("blocks have same ticket (%s %s)", blks[i].Miner, blks[j].Miner)
|
||||
return blks[i].Cid().KeyString() < blks[j].Cid().KeyString()
|
||||
return bytes.Compare(blks[i].Cid().Bytes(), blks[j].Cid().Bytes()) < 0
|
||||
}
|
||||
|
||||
return ti.Less(tj)
|
||||
@ -171,9 +170,7 @@ func (ts *TipSet) Equals(ots *TipSet) bool {
|
||||
}
|
||||
|
||||
func (t *Ticket) Less(o *Ticket) bool {
|
||||
tDigest := blake2b.Sum256(t.VRFProof)
|
||||
oDigest := blake2b.Sum256(o.VRFProof)
|
||||
return bytes.Compare(tDigest[:], oDigest[:]) < 0
|
||||
return bytes.Compare(t.VRFProof, o.VRFProof) < 0
|
||||
}
|
||||
|
||||
func (ts *TipSet) MinTicket() *Ticket {
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
@ -469,6 +470,8 @@ var chainGetCmd = &cli.Command{
|
||||
return handleHamtAddress(ctx, api, obj.Cid)
|
||||
case "cronevent":
|
||||
cbu = new(power.CronEvent)
|
||||
case "account-state":
|
||||
cbu = new(account.State)
|
||||
default:
|
||||
return fmt.Errorf("unknown type: %q", t)
|
||||
}
|
||||
|
12
cli/send.go
12
cli/send.go
@ -17,6 +17,11 @@ var sendCmd = &cli.Command{
|
||||
Name: "source",
|
||||
Usage: "optionally specify the account to send funds from",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-price",
|
||||
Usage: "specify gas price to use in AttoFIL",
|
||||
Value: "0",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
@ -58,12 +63,17 @@ var sendCmd = &cli.Command{
|
||||
fromAddr = addr
|
||||
}
|
||||
|
||||
gp, err := types.BigFromString(cctx.String("gas-price"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := &types.Message{
|
||||
From: fromAddr,
|
||||
To: toAddr,
|
||||
Value: types.BigInt(val),
|
||||
GasLimit: 10000,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasPrice: gp,
|
||||
}
|
||||
|
||||
_, err = api.MpoolPushMessage(ctx, msg)
|
||||
|
@ -7,12 +7,13 @@ import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
@ -42,7 +43,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sealing"
|
||||
"github.com/filecoin-project/sector-storage"
|
||||
sectorstorage "github.com/filecoin-project/sector-storage"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
)
|
||||
@ -99,12 +100,22 @@ var initCmd = &cli.Command{
|
||||
Name: "no-local-storage",
|
||||
Usage: "don't use storageminer repo for sector storage",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-price",
|
||||
Usage: "set gas price for initialization messages in AttoFIL",
|
||||
Value: "0",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
log.Info("Initializing lotus storage miner")
|
||||
|
||||
ssize := abi.SectorSize(cctx.Uint64("sector-size"))
|
||||
|
||||
gasPrice, err := types.BigFromString(cctx.String("gas-price"))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to parse gas-price flag: %s", err)
|
||||
}
|
||||
|
||||
symlink := cctx.Bool("symlink-imported-sectors")
|
||||
if symlink {
|
||||
log.Info("will attempt to symlink to imported sectors")
|
||||
@ -218,7 +229,7 @@ var initCmd = &cli.Command{
|
||||
}
|
||||
}
|
||||
|
||||
if err := storageMinerInit(ctx, cctx, api, r, ssize); err != nil {
|
||||
if err := storageMinerInit(ctx, cctx, api, r, ssize, gasPrice); err != nil {
|
||||
log.Errorf("Failed to initialize lotus-storage-miner: %+v", err)
|
||||
path, err := homedir.Expand(repoPath)
|
||||
if err != nil {
|
||||
@ -358,7 +369,7 @@ func findMarketDealID(ctx context.Context, api lapi.FullNode, deal market.DealPr
|
||||
return 0, xerrors.New("deal not found")
|
||||
}
|
||||
|
||||
func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, r repo.Repo, ssize abi.SectorSize) error {
|
||||
func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode, r repo.Repo, ssize abi.SectorSize, gasPrice types.BigInt) error {
|
||||
lr, err := r.Lock(repo.StorageMiner)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -424,7 +435,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
||||
return xerrors.Errorf("failed to start up genesis miner: %w", err)
|
||||
}
|
||||
|
||||
cerr := configureStorageMiner(ctx, api, a, peerid)
|
||||
cerr := configureStorageMiner(ctx, api, a, peerid, gasPrice)
|
||||
|
||||
if err := m.Unregister(ctx, a); err != nil {
|
||||
log.Error("failed to shut down storage miner: ", err)
|
||||
@ -464,13 +475,13 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
|
||||
}
|
||||
}
|
||||
|
||||
if err := configureStorageMiner(ctx, api, a, peerid); err != nil {
|
||||
if err := configureStorageMiner(ctx, api, a, peerid, gasPrice); err != nil {
|
||||
return xerrors.Errorf("failed to configure storage miner: %w", err)
|
||||
}
|
||||
|
||||
addr = a
|
||||
} else {
|
||||
a, err := createStorageMiner(ctx, api, peerid, cctx)
|
||||
a, err := createStorageMiner(ctx, api, peerid, gasPrice, cctx)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("creating miner failed: %w", err)
|
||||
}
|
||||
@ -512,7 +523,7 @@ func makeHostKey(lr repo.LockedRepo) (crypto.PrivKey, error) {
|
||||
return pk, nil
|
||||
}
|
||||
|
||||
func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.Address, peerid peer.ID) error {
|
||||
func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.Address, peerid peer.ID, gasPrice types.BigInt) error {
|
||||
waddr, err := api.StateMinerWorker(ctx, addr, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getWorkerAddr returned bad address: %w", err)
|
||||
@ -529,7 +540,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
|
||||
Method: builtin.MethodsMiner.ChangePeerID,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: 100000000,
|
||||
}
|
||||
|
||||
@ -551,7 +562,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
|
||||
return nil
|
||||
}
|
||||
|
||||
func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, cctx *cli.Context) (address.Address, error) {
|
||||
func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, gasPrice types.BigInt, cctx *cli.Context) (address.Address, error) {
|
||||
log.Info("Creating StorageMarket.CreateStorageMiner message")
|
||||
|
||||
var err error
|
||||
@ -602,7 +613,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
||||
Params: params,
|
||||
|
||||
GasLimit: 10000000,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasPrice: gasPrice,
|
||||
}
|
||||
|
||||
signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg)
|
||||
|
@ -59,7 +59,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sealing"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/sector-storage"
|
||||
sectorstorage "github.com/filecoin-project/sector-storage"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
)
|
||||
|
@ -92,6 +92,16 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
||||
}
|
||||
}()
|
||||
|
||||
protos, err := hs.h.Peerstore().GetProtocols(s.Conn().RemotePeer())
|
||||
if err != nil {
|
||||
log.Warnf("got error from peerstore.GetProtocols: %s", err)
|
||||
}
|
||||
if len(protos) == 0 {
|
||||
log.Warn("other peer hasnt completed libp2p identify, waiting a bit")
|
||||
// TODO: this better
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
}
|
||||
|
||||
ts, err := hs.syncer.FetchTipSet(context.Background(), s.Conn().RemotePeer(), types.NewTipSetKey(hmsg.HeaviestTipSet...))
|
||||
if err != nil {
|
||||
log.Errorf("failed to fetch tipset from peer during hello: %+v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user