Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d11e375f82 | ||
|
|
7b8ee40275 |
@@ -1,12 +1,6 @@
|
||||
/dns4/bootstrap-0-sin.fil-test.net/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
||||
/ip4/86.109.15.57/tcp/1347/p2p/12D3KooWKNF7vNFEhnvB45E9mw2B5z6t419W3ziZPLdUDVnLLKGs
|
||||
/dns4/bootstrap-0-dfw.fil-test.net/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
||||
/ip4/139.178.84.45/tcp/1347/p2p/12D3KooWECJTm7RUPyGfNbRwm6y2fK4wA7EB8rDJtWsq5AKi7iDr
|
||||
/dns4/bootstrap-0-fra.fil-test.net/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
||||
/ip4/136.144.49.17/tcp/1347/p2p/12D3KooWC7MD6m7iNCuDsYtNr7xVtazihyVUizBbhmhEiyMAm9ym
|
||||
/dns4/bootstrap-1-sin.fil-test.net/tcp/1347/p2p/12D3KooWD8eYqsKcEMFax6EbWN3rjA7qFsxCez2rmN8dWqkzgNaN
|
||||
/ip4/86.109.15.55/tcp/1347/p2p/12D3KooWD8eYqsKcEMFax6EbWN3rjA7qFsxCez2rmN8dWqkzgNaN
|
||||
/dns4/bootstrap-1-dfw.fil-test.net/tcp/1347/p2p/12D3KooWLB3RR8frLAmaK4ntHC2dwrAjyGzQgyUzWxAum1FxyyqD
|
||||
/ip4/139.178.84.41/tcp/1347/p2p/12D3KooWLB3RR8frLAmaK4ntHC2dwrAjyGzQgyUzWxAum1FxyyqD
|
||||
/dns4/bootstrap-1-fra.fil-test.net/tcp/1347/p2p/12D3KooWGPDJAw3HW4uVU3JEQBfFaZ1kdpg4HvvwRMVpUYbzhsLQ
|
||||
/ip4/136.144.49.131/tcp/1347/p2p/12D3KooWGPDJAw3HW4uVU3JEQBfFaZ1kdpg4HvvwRMVpUYbzhsLQ
|
||||
/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWQfrGdBE8N2RzcnuHfyWZ4MBKMYZ6z1oPdhEbFxSNo1du
|
||||
/ip4/34.217.110.132/tcp/1347/p2p/12D3KooWQfrGdBE8N2RzcnuHfyWZ4MBKMYZ6z1oPdhEbFxSNo1du
|
||||
/dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWKmHh5mQofRhFr6f6qsT4ksL7qUtd2BWC24wPHVFL9gej
|
||||
/ip4/54.187.182.170/tcp/1347/p2p/12D3KooWKmHh5mQofRhFr6f6qsT4ksL7qUtd2BWC24wPHVFL9gej
|
||||
/dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWCWWtn3GMFVSn2PY7k9K7QkQTVA6p6wojUr5PgS5h1xtK
|
||||
/ip4/52.24.84.39/tcp/1347/p2p/12D3KooWCWWtn3GMFVSn2PY7k9K7QkQTVA6p6wojUr5PgS5h1xtK
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -15,7 +14,6 @@ func init() {
|
||||
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
// Seconds
|
||||
|
||||
@@ -25,7 +25,7 @@ func DefaultSectorSize() abi.SectorSize {
|
||||
}
|
||||
|
||||
sort.Slice(szs, func(i, j int) bool {
|
||||
return szs[i] < szs[j]
|
||||
return szs[i] < szs[i]
|
||||
})
|
||||
|
||||
return szs[0]
|
||||
|
||||
@@ -12,10 +12,11 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
power.ConsensusMinerMinPower = big.NewInt(1024 << 30)
|
||||
power.ConsensusMinerMinPower = big.NewInt(2 << 30)
|
||||
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
|
||||
abi.RegisteredProof_StackedDRG32GiBSeal: {},
|
||||
abi.RegisteredProof_StackedDRG64GiBSeal: {},
|
||||
abi.RegisteredProof_StackedDRG512MiBSeal: {},
|
||||
abi.RegisteredProof_StackedDRG32GiBSeal: {},
|
||||
abi.RegisteredProof_StackedDRG64GiBSeal: {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ type eventApi interface {
|
||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
|
||||
|
||||
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) // optional / for CalledMsg
|
||||
}
|
||||
@@ -164,11 +163,6 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error {
|
||||
if err := e.headChange(rev, app); err != nil {
|
||||
log.Warnf("headChange failed: %s", err)
|
||||
}
|
||||
|
||||
// sync with fake chainstore (for tests)
|
||||
if fcs, ok := e.api.(interface{notifDone()}); ok {
|
||||
fcs.notifDone()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -125,13 +125,7 @@ func (e *calledEvents) handleReverts(ts *types.TipSet) {
|
||||
}
|
||||
|
||||
func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
|
||||
pts, err := e.cs.ChainGetTipSet(e.ctx, ts.Parents()) // we actually care about messages in the parent tipset here
|
||||
if err != nil {
|
||||
log.Errorf("getting parent tipset in checkNewCalls: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
e.messagesForTs(pts, func(msg *types.Message) {
|
||||
e.messagesForTs(ts, func(msg *types.Message) {
|
||||
// TODO: provide receipts
|
||||
|
||||
for tid, matchFns := range e.matchers {
|
||||
@@ -160,7 +154,8 @@ func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
|
||||
func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message, ts *types.TipSet) {
|
||||
trigger := e.triggers[triggerId]
|
||||
|
||||
appliedH := ts.Height()
|
||||
// messages are not applied in the tipset they are included in
|
||||
appliedH := ts.Height() + 1
|
||||
|
||||
triggerH := appliedH + abi.ChainEpoch(trigger.confidence)
|
||||
|
||||
|
||||
+30
-149
@@ -3,20 +3,21 @@ package events
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/multiformats/go-multihash"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
@@ -39,17 +40,9 @@ type fakeCS struct {
|
||||
msgs map[cid.Cid]fakeMsg
|
||||
blkMsgs map[cid.Cid]cid.Cid
|
||||
|
||||
sync sync.Mutex
|
||||
|
||||
tipsets map[types.TipSetKey]*types.TipSet
|
||||
|
||||
sub func(rev, app []*types.TipSet)
|
||||
}
|
||||
|
||||
func (fcs *fakeCS) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) {
|
||||
return fcs.tipsets[key], nil
|
||||
}
|
||||
|
||||
func (fcs *fakeCS) StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -62,7 +55,7 @@ func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types
|
||||
panic("Not Implemented")
|
||||
}
|
||||
|
||||
func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet {
|
||||
func makeTs(t *testing.T, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet {
|
||||
a, _ := address.NewFromString("t00")
|
||||
b, _ := address.NewFromString("t02")
|
||||
var ts, err = types.NewTipSet([]*types.BlockHeader{
|
||||
@@ -70,8 +63,6 @@ func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msg
|
||||
Height: h,
|
||||
Miner: a,
|
||||
|
||||
Parents: parents,
|
||||
|
||||
Ticket: &types.Ticket{VRFProof: []byte{byte(h % 2)}},
|
||||
|
||||
ParentStateRoot: dummyCid,
|
||||
@@ -85,8 +76,6 @@ func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msg
|
||||
Height: h,
|
||||
Miner: b,
|
||||
|
||||
Parents: parents,
|
||||
|
||||
Ticket: &types.Ticket{VRFProof: []byte{byte((h + 1) % 2)}},
|
||||
|
||||
ParentStateRoot: dummyCid,
|
||||
@@ -98,11 +87,6 @@ func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msg
|
||||
},
|
||||
})
|
||||
|
||||
if fcs.tipsets == nil {
|
||||
fcs.tipsets = map[types.TipSetKey]*types.TipSet{}
|
||||
}
|
||||
fcs.tipsets[ts.Key()] = ts
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
return ts
|
||||
@@ -196,7 +180,7 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
||||
continue
|
||||
}
|
||||
|
||||
ts := fcs.makeTs(fcs.t, fcs.tsc.best().Key().Cids(), fcs.h, mc)
|
||||
ts := makeTs(fcs.t, fcs.h, mc)
|
||||
require.NoError(fcs.t, fcs.tsc.add(ts))
|
||||
|
||||
if hasMsgs {
|
||||
@@ -206,17 +190,8 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
||||
apps = append(apps, ts)
|
||||
}
|
||||
|
||||
fcs.sync.Lock()
|
||||
|
||||
fcs.sub(revs, apps)
|
||||
|
||||
fcs.sync.Lock()
|
||||
fcs.sync.Unlock()
|
||||
|
||||
}
|
||||
|
||||
func (fcs *fakeCS) notifDone() {
|
||||
fcs.sync.Unlock()
|
||||
time.Sleep(100 * time.Millisecond) // TODO: :c
|
||||
}
|
||||
|
||||
var _ eventApi = &fakeCS{}
|
||||
@@ -227,7 +202,7 @@ func TestAt(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -292,7 +267,7 @@ func TestAtDoubleTrigger(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -334,7 +309,7 @@ func TestAtNullTrigger(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -368,7 +343,7 @@ func TestAtNullConf(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -407,7 +382,7 @@ func TestAtStart(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -441,7 +416,7 @@ func TestAtStartConfidence(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -471,7 +446,7 @@ func TestAtChained(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -505,7 +480,7 @@ func TestAtChainedConfidence(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -539,7 +514,7 @@ func TestAtChainedConfidenceNull(t *testing.T) {
|
||||
h: 1,
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -577,7 +552,7 @@ func TestCalled(t *testing.T) {
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -653,7 +628,7 @@ func TestCalled(t *testing.T) {
|
||||
|
||||
// revert the message
|
||||
|
||||
fcs.advance(2, 1, nil) // H=7, we reverted ts with the msg execution, but not the msg itself
|
||||
fcs.advance(2, 1, nil) // H=7, we reverted ts with the msg
|
||||
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, true, reverted)
|
||||
@@ -667,17 +642,10 @@ func TestCalled(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
fcs.advance(0, 3, map[int]cid.Cid{ // (n2msg confidence=1)
|
||||
fcs.advance(0, 5, map[int]cid.Cid{ // (confidence=3)
|
||||
0: n2msg,
|
||||
})
|
||||
|
||||
require.Equal(t, true, applied) // msg from H=7, which had reverted execution
|
||||
require.Equal(t, false, reverted)
|
||||
require.Equal(t, abi.ChainEpoch(10), appliedH)
|
||||
applied = false
|
||||
|
||||
fcs.advance(0, 2, nil) // (confidence=3)
|
||||
|
||||
require.Equal(t, true, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
applied = false
|
||||
@@ -691,7 +659,7 @@ func TestCalled(t *testing.T) {
|
||||
|
||||
// revert and apply at different height
|
||||
|
||||
fcs.advance(8, 6, map[int]cid.Cid{ // (confidence=3)
|
||||
fcs.advance(4, 6, map[int]cid.Cid{ // (confidence=3)
|
||||
1: n2msg,
|
||||
})
|
||||
|
||||
@@ -703,9 +671,9 @@ func TestCalled(t *testing.T) {
|
||||
reverted = false
|
||||
applied = false
|
||||
|
||||
require.Equal(t, abi.ChainEpoch(7), appliedTs.Height())
|
||||
require.Equal(t, abi.ChainEpoch(11), appliedTs.Height())
|
||||
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
||||
require.Equal(t, abi.ChainEpoch(10), appliedH)
|
||||
require.Equal(t, abi.ChainEpoch(14), appliedH)
|
||||
require.Equal(t, t0123, appliedMsg.To)
|
||||
require.Equal(t, uint64(2), appliedMsg.Nonce)
|
||||
require.Equal(t, abi.MethodNum(5), appliedMsg.Method)
|
||||
@@ -729,7 +697,7 @@ func TestCalled(t *testing.T) {
|
||||
}),
|
||||
})
|
||||
|
||||
fcs.advance(2, 5, nil) // H=19, but message reverted
|
||||
fcs.advance(1, 4, nil) // H=19, but message reverted
|
||||
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
@@ -789,7 +757,7 @@ func TestCalledTimeout(t *testing.T) {
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -829,7 +797,7 @@ func TestCalledTimeout(t *testing.T) {
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events = NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -863,7 +831,7 @@ func TestCalledOrder(t *testing.T) {
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -926,7 +894,7 @@ func TestCalledNull(t *testing.T) {
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
@@ -981,90 +949,3 @@ func TestCalledNull(t *testing.T) {
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, true, reverted)
|
||||
}
|
||||
|
||||
func TestRemoveTriggersOnMessage(t *testing.T) {
|
||||
fcs := &fakeCS{
|
||||
t: t,
|
||||
h: 1,
|
||||
|
||||
msgs: map[cid.Cid]fakeMsg{},
|
||||
blkMsgs: map[cid.Cid]cid.Cid{},
|
||||
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
|
||||
}
|
||||
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
|
||||
|
||||
events := NewEvents(context.Background(), fcs)
|
||||
|
||||
t0123, err := address.NewFromString("t0123")
|
||||
require.NoError(t, err)
|
||||
|
||||
more := true
|
||||
var applied, reverted bool
|
||||
|
||||
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
||||
return false, true, nil
|
||||
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
|
||||
require.Equal(t, false, applied)
|
||||
fmt.Println(msg == nil)
|
||||
fmt.Println(curH)
|
||||
applied = true
|
||||
return more, nil
|
||||
}, func(_ context.Context, ts *types.TipSet) error {
|
||||
reverted = true
|
||||
return nil
|
||||
}, 3, 20, matchAddrMethod(t0123, 5))
|
||||
require.NoError(t, err)
|
||||
|
||||
// create few blocks to make sure nothing get's randomly called
|
||||
|
||||
fcs.advance(0, 4, nil) // H=5
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// create blocks with message (but below confidence threshold)
|
||||
|
||||
fcs.advance(0, 3, map[int]cid.Cid{ // msg occurs at H=5, applied at H=6; H=8 (confidence=2)
|
||||
0: fcs.fakeMsgs(fakeMsg{
|
||||
bmsgs: []*types.Message{
|
||||
{To: t0123, From: t0123, Method: 5, Nonce: 1},
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// revert applied TS & message TS
|
||||
fcs.advance(3, 1, nil) // H=6 (tipset message applied in reverted, AND message reverted)
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// create additional blocks so we are above confidence threshold, but message not applied
|
||||
// as it was reverted
|
||||
fcs.advance(0, 5, nil) // H=11 (confidence=3, apply)
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// create blocks with message again (but below confidence threshold)
|
||||
|
||||
fcs.advance(0, 3, map[int]cid.Cid{ // msg occurs at H=12, applied at H=13; H=15 (confidence=2)
|
||||
0: fcs.fakeMsgs(fakeMsg{
|
||||
bmsgs: []*types.Message{
|
||||
{To: t0123, From: t0123, Method: 5, Nonce: 2},
|
||||
},
|
||||
}),
|
||||
})
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// revert applied height TS, but don't remove message trigger
|
||||
fcs.advance(2, 1, nil) // H=13 (tipset message applied in reverted, by tipset with message not reverted)
|
||||
require.Equal(t, false, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
|
||||
// create additional blocks so we are above confidence threshold
|
||||
fcs.advance(0, 4, nil) // H=18 (confidence=3, apply)
|
||||
|
||||
require.Equal(t, true, applied)
|
||||
require.Equal(t, false, reverted)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||
@@ -18,7 +17,6 @@ func init() {
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
func testGeneration(t testing.TB, n int, msgs int, sectors int) {
|
||||
|
||||
@@ -5,10 +5,8 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/filecoin-project/go-amt-ipld/v2"
|
||||
"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/verifreg"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
@@ -22,7 +20,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
"github.com/filecoin-project/lotus/genesis"
|
||||
)
|
||||
|
||||
@@ -218,72 +215,9 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
||||
}
|
||||
}
|
||||
|
||||
vregroot, err := address.NewIDAddress(80)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vrst, err := cst.Put(ctx, &account.State{Address: RootVerifierAddr})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = state.SetActor(vregroot, &types.Actor{
|
||||
Code: builtin.AccountActorCodeID,
|
||||
Balance: types.NewInt(0),
|
||||
Head: vrst,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("setting account from actmap: %w", err)
|
||||
}
|
||||
|
||||
return state, nil
|
||||
}
|
||||
|
||||
func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template) (cid.Cid, error) {
|
||||
verifNeeds := make(map[address.Address]abi.PaddedPieceSize)
|
||||
var sum abi.PaddedPieceSize
|
||||
for _, m := range template.Miners {
|
||||
for _, s := range m.Sectors {
|
||||
amt := s.Deal.PieceSize
|
||||
verifNeeds[s.Deal.Client] += amt
|
||||
sum += amt
|
||||
}
|
||||
}
|
||||
|
||||
verifier, err := address.NewIDAddress(80)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
vm, err := vm.NewVM(stateroot, 0, &fakeRand{}, cs.Blockstore(), &fakedSigSyscalls{cs.VMSys()})
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
||||
}
|
||||
|
||||
_, err = doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, RootVerifierAddr, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg.AddVerifierParams{
|
||||
Address: verifier,
|
||||
Allowance: abi.NewStoragePower(int64(sum)), // eh, close enough
|
||||
|
||||
}))
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to failed to create verifier: %w", err)
|
||||
}
|
||||
|
||||
for c, amt := range verifNeeds {
|
||||
_, err := doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, verifier, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg.AddVerifiedClientParams{
|
||||
Address: c,
|
||||
Allowance: abi.NewStoragePower(int64(amt)),
|
||||
}))
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to add verified client: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return vm.Flush(ctx)
|
||||
}
|
||||
|
||||
func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Syscalls, template genesis.Template) (*GenesisBootstrap, error) {
|
||||
st, err := MakeInitialStateTree(ctx, bs, template)
|
||||
if err != nil {
|
||||
@@ -297,13 +231,6 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys
|
||||
|
||||
// temp chainstore
|
||||
cs := store.NewChainStore(bs, datastore.NewMapDatastore(), sys)
|
||||
|
||||
// Verify PreSealed Data
|
||||
stateroot, err = VerifyPreSealedData(ctx, cs, stateroot, template)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to verify presealed data: %w", err)
|
||||
}
|
||||
|
||||
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("setup storage miners failed: %w", err)
|
||||
|
||||
@@ -130,7 +130,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
|
||||
params := &market.PublishStorageDealsParams{}
|
||||
for _, preseal := range m.Sectors {
|
||||
preseal.Deal.VerifiedDeal = true
|
||||
params.Deals = append(params.Deals, market.ClientDealProposal{
|
||||
Proposal: preseal.Deal,
|
||||
ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup?
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||
@@ -46,10 +45,6 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
|
||||
}
|
||||
}
|
||||
|
||||
if err := amap.Set(context.TODO(), string(RootVerifierAddr.Bytes()), 80); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := amap.Flush(context.TODO()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package genesis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/ipfs/go-hamt-ipld"
|
||||
@@ -14,26 +15,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var RootVerifierAddr address.Address
|
||||
|
||||
var RootVerifierID address.Address
|
||||
|
||||
func init() {
|
||||
k, err := address.NewFromString("t3qfoulel6fy6gn3hjmbhpdpf6fs5aqjb5fkurhtwvgssizq4jey5nw4ptq5up6h7jk7frdvvobv52qzmgjinq")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
RootVerifierAddr = k
|
||||
|
||||
idk, err := address.NewFromString("t080")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
RootVerifierID = idk
|
||||
}
|
||||
|
||||
func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) {
|
||||
cst := cbor.NewCborStore(bs)
|
||||
|
||||
@@ -42,7 +23,11 @@ func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sms := verifreg.ConstructState(h, RootVerifierID)
|
||||
var r [32]byte // TODO: grab from genesis template
|
||||
_, _ = rand.Read(r[:])
|
||||
k, _ := address.NewSecp256k1Address(r[:])
|
||||
|
||||
sms := verifreg.ConstructState(h, k)
|
||||
|
||||
stcid, err := cst.Put(context.TODO(), sms)
|
||||
if err != nil {
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -41,7 +40,6 @@ func init() {
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
const testForkHeight = 40
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
@@ -26,7 +25,6 @@ func init() {
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
func BenchmarkGetRandomness(b *testing.B) {
|
||||
|
||||
+39
-7
@@ -31,6 +31,7 @@ import (
|
||||
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||
@@ -841,13 +842,44 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock
|
||||
return xerrors.Errorf("failed to load base state tree: %w", err)
|
||||
}
|
||||
|
||||
checkMsg := func(msg types.ChainMsg) error {
|
||||
m := msg.VMMessage()
|
||||
|
||||
checkMsg := func(m *types.Message) error {
|
||||
// Phase 1: syntactic validation, as defined in the spec
|
||||
minGas := vm.PricelistByEpoch(baseTs.Height()).OnChainMessage(msg.ChainLength())
|
||||
if err := m.ValidForBlockInclusion(minGas); err != nil {
|
||||
return err
|
||||
|
||||
if m.Version != 0 {
|
||||
return xerrors.New("'Version' unsupported")
|
||||
}
|
||||
|
||||
if m.To == address.Undef {
|
||||
return xerrors.New("'To' address cannot be empty")
|
||||
}
|
||||
|
||||
if m.From == address.Undef {
|
||||
return xerrors.New("'From' address cannot be empty")
|
||||
}
|
||||
|
||||
if m.Value.LessThan(big.Zero()) {
|
||||
return xerrors.New("'Value' field cannot be negative")
|
||||
}
|
||||
|
||||
if m.Value.GreaterThan(types.TotalFilecoinInt) {
|
||||
return xerrors.New("'Value' field cannot be greater than total filecoin supply")
|
||||
}
|
||||
|
||||
if len(m.Params) != 0 && m.Method == 0 {
|
||||
return xerrors.New("'Params' field should be empty if no 'Method' is being called")
|
||||
}
|
||||
|
||||
if m.GasPrice.LessThan(big.Zero()) {
|
||||
return xerrors.New("'GasPrice' field cannot be negative")
|
||||
}
|
||||
|
||||
if m.GasLimit > build.BlockGasLimit {
|
||||
return xerrors.New("'GasLimit' field cannot be greater than a block's gas limit")
|
||||
}
|
||||
|
||||
// since prices might vary with time, this is technically semantic validation
|
||||
if m.GasLimit < vm.PricelistByEpoch(baseTs.Height()).OnChainMessage(m.ChainLength()) {
|
||||
return xerrors.New("'GasLimit' field cannot be less than the cost of storing a message on chain")
|
||||
}
|
||||
|
||||
// Phase 2: (Partial) semantic validation:
|
||||
@@ -887,7 +919,7 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock
|
||||
|
||||
var secpkCids []cbg.CBORMarshaler
|
||||
for i, m := range b.SecpkMessages {
|
||||
if err := checkMsg(m); err != nil {
|
||||
if err := checkMsg(&m.Message); err != nil {
|
||||
return xerrors.Errorf("block had invalid secpk message at index %d: %w", i, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
@@ -38,7 +37,6 @@ func init() {
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
const source = 0
|
||||
|
||||
@@ -4,13 +4,10 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
block "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/multiformats/go-multihash"
|
||||
xerrors "golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
)
|
||||
@@ -124,40 +121,3 @@ func (m *Message) VMMessage() *Message {
|
||||
func (m *Message) Equals(o *Message) bool {
|
||||
return m.Cid() == o.Cid()
|
||||
}
|
||||
|
||||
func (m *Message) ValidForBlockInclusion(minGas int64) error {
|
||||
if m.Version != 0 {
|
||||
return xerrors.New("'Version' unsupported")
|
||||
}
|
||||
|
||||
if m.To == address.Undef {
|
||||
return xerrors.New("'To' address cannot be empty")
|
||||
}
|
||||
|
||||
if m.From == address.Undef {
|
||||
return xerrors.New("'From' address cannot be empty")
|
||||
}
|
||||
|
||||
if m.Value.LessThan(big.Zero()) {
|
||||
return xerrors.New("'Value' field cannot be negative")
|
||||
}
|
||||
|
||||
if m.Value.GreaterThan(TotalFilecoinInt) {
|
||||
return xerrors.New("'Value' field cannot be greater than total filecoin supply")
|
||||
}
|
||||
|
||||
if m.GasPrice.LessThan(big.Zero()) {
|
||||
return xerrors.New("'GasPrice' field cannot be negative")
|
||||
}
|
||||
|
||||
if m.GasLimit > build.BlockGasLimit {
|
||||
return xerrors.New("'GasLimit' field cannot be greater than a block's gas limit")
|
||||
}
|
||||
|
||||
// since prices might vary with time, this is technically semantic validation
|
||||
if m.GasLimit < minGas {
|
||||
return xerrors.New("'GasLimit' field cannot be less than the cost of storing a message on chain")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+17
-22
@@ -210,33 +210,28 @@ func ReqContext(cctx *cli.Context) context.Context {
|
||||
}
|
||||
|
||||
var CommonCommands = []*cli.Command{
|
||||
netCmd,
|
||||
authCmd,
|
||||
fetchParamCmd,
|
||||
netCmd,
|
||||
versionCmd,
|
||||
logCmd,
|
||||
waitApiCmd,
|
||||
fetchParamCmd,
|
||||
versionCmd,
|
||||
}
|
||||
|
||||
var Commands = []*cli.Command{
|
||||
withCategory("basic", sendCmd),
|
||||
withCategory("basic", walletCmd),
|
||||
withCategory("basic", clientCmd),
|
||||
withCategory("basic", multisigCmd),
|
||||
withCategory("basic", paychCmd),
|
||||
withCategory("developer", authCmd),
|
||||
withCategory("developer", mpoolCmd),
|
||||
withCategory("developer", stateCmd),
|
||||
withCategory("developer", chainCmd),
|
||||
withCategory("developer", logCmd),
|
||||
withCategory("developer", waitApiCmd),
|
||||
withCategory("developer", fetchParamCmd),
|
||||
withCategory("network", netCmd),
|
||||
withCategory("network", syncCmd),
|
||||
authCmd,
|
||||
chainCmd,
|
||||
clientCmd,
|
||||
fetchParamCmd,
|
||||
mpoolCmd,
|
||||
multisigCmd,
|
||||
netCmd,
|
||||
paychCmd,
|
||||
sendCmd,
|
||||
stateCmd,
|
||||
syncCmd,
|
||||
versionCmd,
|
||||
}
|
||||
|
||||
func withCategory(cat string, cmd *cli.Command) *cli.Command {
|
||||
cmd.Category = cat
|
||||
return cmd
|
||||
walletCmd,
|
||||
logCmd,
|
||||
waitApiCmd,
|
||||
}
|
||||
|
||||
+4
-29
@@ -1113,39 +1113,14 @@ var stateWaitMsgCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
m, err := api.ChainGetMessage(ctx, msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("message was executed in tipset: %s\n", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x\n", mw.Receipt.Return)
|
||||
if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("message was executed in tipset: %s", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x", mw.Receipt.Return)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message, r types.MessageReceipt) error {
|
||||
act, err := api.StateGetActor(ctx, m.To, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jret, err := jsonReturn(act.Code, m.Method, r.Return)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(jret)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var stateSearchMsgCmd = &cli.Command{
|
||||
Name: "search-msg",
|
||||
Usage: "Search to see whether a message has appeared on chain",
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<span>Enter destination address:</span>
|
||||
<input type='text' name='address' style="width: 300px">
|
||||
<select name="sectorSize">
|
||||
<option selected value="34359738368">32GiB sectors</option>
|
||||
<option selected value="536870912">512MiB sectors</option>
|
||||
<option value="34359738368">32GiB sectors</option>
|
||||
<option value="68719476736">64GiB sectors</option>
|
||||
</select>
|
||||
<button type='submit'>Create Miner</button>
|
||||
|
||||
@@ -4,11 +4,10 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
|
||||
@@ -79,7 +79,7 @@ var initCmd = &cli.Command{
|
||||
&cli.StringFlag{
|
||||
Name: "sector-size",
|
||||
Usage: "specify sector size to use",
|
||||
Value: units.BytesSize(float64(build.DefaultSectorSize())),
|
||||
Value: fmt.Sprint(build.DefaultSectorSize()),
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "pre-sealed-sectors",
|
||||
@@ -603,10 +603,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
||||
return address.Undef, err
|
||||
}
|
||||
|
||||
ssize, err := units.RAMInBytes(cctx.String("sector-size"))
|
||||
if err != nil {
|
||||
return address.Undef, fmt.Errorf("failed to parse sector size: %w", err)
|
||||
}
|
||||
ssize := cctx.Uint64("sector-size")
|
||||
|
||||
worker := owner
|
||||
if cctx.String("worker") != "" {
|
||||
|
||||
@@ -102,11 +102,6 @@ var provingInfoCmd = &cli.Command{
|
||||
provenSectors += c
|
||||
}
|
||||
|
||||
var faultPerc float64
|
||||
if provenSectors > 0 {
|
||||
faultPerc = float64(faults*10000/provenSectors) / 100
|
||||
}
|
||||
|
||||
fmt.Printf("Current Epoch: %d\n", cd.CurrentEpoch)
|
||||
fmt.Printf("Chain Period: %d\n", cd.CurrentEpoch/miner.WPoStProvingPeriod)
|
||||
fmt.Printf("Chain Period Start: %s\n", epochTime(cd.CurrentEpoch, (cd.CurrentEpoch/miner.WPoStProvingPeriod)*miner.WPoStProvingPeriod))
|
||||
@@ -116,7 +111,7 @@ var provingInfoCmd = &cli.Command{
|
||||
fmt.Printf("Proving Period Start: %s\n", epochTime(cd.CurrentEpoch, cd.PeriodStart))
|
||||
fmt.Printf("Next Period Start: %s\n\n", epochTime(cd.CurrentEpoch, cd.PeriodStart+miner.WPoStProvingPeriod))
|
||||
|
||||
fmt.Printf("Faults: %d (%.2f%%)\n", faults, faultPerc)
|
||||
fmt.Printf("Faults: %d (%.2f%%)\n", faults, float64(faults*10000/provenSectors)/100)
|
||||
fmt.Printf("Recovering: %d\n", recoveries)
|
||||
fmt.Printf("New Sectors: %d\n\n", newSectors)
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/metrics"
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/filecoin-project/lotus/node/modules"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/testing"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
@@ -87,10 +86,6 @@ var DaemonCmd = &cli.Command{
|
||||
Name: "pprof",
|
||||
Usage: "specify name of file for writing cpu profile to",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "profile",
|
||||
Usage: "specify type of node",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if prof := cctx.String("pprof"); prof != "" {
|
||||
@@ -105,16 +100,6 @@ var DaemonCmd = &cli.Command{
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
var isBootstrapper dtypes.Bootstrapper
|
||||
switch profile := cctx.String("profile"); profile {
|
||||
case "bootstrapper":
|
||||
isBootstrapper = true
|
||||
case "":
|
||||
// do nothing
|
||||
default:
|
||||
return fmt.Errorf("unrecognized profile type: %q", profile)
|
||||
}
|
||||
|
||||
ctx, _ := tag.New(context.Background(), tag.Insert(metrics.Version, build.BuildVersion), tag.Insert(metrics.Commit, build.CurrentCommit))
|
||||
{
|
||||
dir, err := homedir.Expand(cctx.String("repo"))
|
||||
@@ -175,7 +160,6 @@ var DaemonCmd = &cli.Command{
|
||||
stop, err := node.New(ctx,
|
||||
node.FullAPI(&api),
|
||||
|
||||
node.Override(new(dtypes.Bootstrapper), isBootstrapper),
|
||||
node.Online(),
|
||||
node.Repo(r),
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ import (
|
||||
var AdvanceBlockCmd *cli.Command
|
||||
|
||||
func main() {
|
||||
os.Setenv("BELLMAN_NO_GPU", "1")
|
||||
|
||||
lotuslog.SetupLogLevels()
|
||||
|
||||
local := []*cli.Command{
|
||||
|
||||
@@ -163,6 +163,13 @@
|
||||
"value": null,
|
||||
"posts": []
|
||||
},
|
||||
{
|
||||
"title": "Pond UI",
|
||||
"slug": "en+dev-tools-pond-ui",
|
||||
"github": "en/dev-tools-pond-ui.md",
|
||||
"value": null,
|
||||
"posts": []
|
||||
},
|
||||
{
|
||||
"title": "Jaeger Tracing",
|
||||
"slug": "en+dev-tools-jaeger-tracing",
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Developer Tools
|
||||
# Development Tools
|
||||
|
||||
> Running a local network can be a great way to understand how Lotus works and test your setup.
|
||||
> This page is a work in progress
|
||||
|
||||
@@ -73,7 +73,7 @@ Information on how to send a `cURL` request to the JSON-RPC API can be found
|
||||
### What are the requests I can send over the JSON-RPC API?
|
||||
|
||||
Please have a look at the
|
||||
[source code](https://github.com/filecoin-project/lotus/blob/master/api/api_full.go)
|
||||
[source code](https://github.com/filecoin-project/lotus/blob/master/api/api_common.go)
|
||||
for a list of methods supported by the JSON-RPC API.
|
||||
## The Test Network
|
||||
|
||||
@@ -88,6 +88,12 @@ community for testing purposes.
|
||||
Nothing at all! Real-world incentives may be provided in a future phase of Testnet, but this is
|
||||
yet to be confirmed.
|
||||
|
||||
### Will there be future phases of Testnet?
|
||||
|
||||
Yes, there will be at least one more phase of Testnet. We plan on introducing interoperable
|
||||
[go-filecoin nodes](https://github.com/filecoin-project/go-filecoin#filecoin-go-filecoin)
|
||||
in a future phase.
|
||||
|
||||
### How can I see the status of Testnet?
|
||||
|
||||
The [dashboard](https://stats.testnet.filecoin.io/) displays the status of the network as
|
||||
@@ -130,9 +136,4 @@ You can do so by changing the storage path variable for the second miner, e.g.,
|
||||
|
||||
### How do I setup my own local devnet?
|
||||
|
||||
Follow the instructions found [here](https://lotu.sh/en+setup-local-dev-net).
|
||||
|
||||
### Are there any other implementations of Filecoin?
|
||||
|
||||
Yes! Check out the [go-filecoin](https://github.com/filecoin-project/go-filecoin#filecoin-go-filecoin)
|
||||
implementation, which is fully interoperable with Lotus!
|
||||
Follow the instructions found [here](https://lotu.sh/en+setup-local-dev-net).
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Lotus is an implementation of the **Filecoin Distributed Storage Network**. You can run the Lotus software client to join the **Filecoin Testnet**.
|
||||
|
||||
For more details about Filecoin, check out the [Filecoin Docs](https://docs.filecoin.io) and [Filecoin Spec](https://filecoin-project.github.io/specs/).
|
||||
For more details about Filecoin, check out the [Filecoin Docs](https://docs.filecoin.io) and [Filecoin Spec](https://github.com/filecoin-project/specs).
|
||||
|
||||
## What can I learn here?
|
||||
|
||||
@@ -11,7 +11,7 @@ For more details about Filecoin, check out the [Filecoin Docs](https://docs.file
|
||||
- [Storing](https://docs.lotu.sh/en+storing-data) or [retrieving](https://docs.lotu.sh/en+retrieving-data) data.
|
||||
- Mining Filecoin using the **Lotus Storage Miner** in your [CLI](https://docs.lotu.sh/en+mining).
|
||||
|
||||
## How is Lotus designed?
|
||||
## What makes Lotus different?
|
||||
|
||||
Lotus is architected modularly to keep clean API boundaries while using the same process. Installing Lotus will include two separate programs:
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
|
||||
Anyone can set up a **Lotus Node** and connect to the **Lotus Testnet**. This is the best way to explore the current CLI and the **Filecoin Decentralized Storage Market**.
|
||||
|
||||
If you have installed older versions, you may need to clear existing chain data, stored wallets and miners if you run into any errors. You can use this command:
|
||||
|
||||
```sh
|
||||
rm -rf ~/.lotus ~/.lotusstorage
|
||||
```
|
||||
|
||||
## Note: Using the Lotus Node from China
|
||||
|
||||
If you are trying to use `lotus` from China. You should set this **environment variable** on your machine:
|
||||
@@ -55,7 +61,7 @@ Here is an example of the response:
|
||||
t1aswwvjsae63tcrniz6x5ykvsuotlgkvlulnqpsi
|
||||
```
|
||||
|
||||
- Visit the [faucet](https://facuet.testnet.filecoin.io) to add funds.
|
||||
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/funds.html) to add funds.
|
||||
- Paste the address you created.
|
||||
- Press the send button.
|
||||
|
||||
@@ -71,7 +77,7 @@ You will not see any attoFIL in your wallet if your **chain** is not fully synce
|
||||
|
||||
## Send FIL to another wallet
|
||||
|
||||
To send FIL to another wallet from your default account, use this command:
|
||||
To send FIL to another wallet, use this command:
|
||||
|
||||
```
|
||||
lotus send <target> <amount>
|
||||
|
||||
@@ -12,6 +12,8 @@ lotus-storage-miner set-price <price>
|
||||
This command will set up your miner to accept deal proposals that meet the input price.
|
||||
The price is inputted in FIL per GiB per epoch, and the default is 0.0000000005.
|
||||
|
||||
<!-- TODO: Add info about setting min piece size, max piece size, duration -->
|
||||
|
||||
## Ensure you can be discovered
|
||||
|
||||
Clients need to be able to find you in order to make storage deals with you.
|
||||
|
||||
@@ -28,7 +28,7 @@ lotus wallet new bls
|
||||
|
||||
With your wallet address:
|
||||
|
||||
- Visit the [faucet](https://facuet.testnet.filecoin.io)
|
||||
- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/miner.html)
|
||||
- Click "Create Miner"
|
||||
- DO NOT REFRESH THE PAGE. THIS OPERATION CAN TAKE SOME TIME.
|
||||
|
||||
|
||||
@@ -29,4 +29,15 @@ ERROR hello hello/hello.go:81 other peer has different genesis!
|
||||
- repo is already locked
|
||||
```
|
||||
|
||||
- You already have another lotus daemon running.
|
||||
- You already have another lotus deamon running.
|
||||
|
||||
## Warning: get message get failed
|
||||
|
||||
Some errors will occur that do not prevent Lotus from working:
|
||||
|
||||
```sh
|
||||
ERROR chainstore store/store.go:564 get message get failed: <Data CID>: blockstore: block not found
|
||||
|
||||
```
|
||||
|
||||
- Someone is requesting a **Data CID** from you that you don't have.
|
||||
|
||||
@@ -55,7 +55,7 @@ Check the status of a deal:
|
||||
lotus client list-deals
|
||||
```
|
||||
|
||||
- The `duration`, which represents how long the miner will keep your file hosted, is represented in blocks. Each block represents 25 seconds.
|
||||
- The `duration`, which represents how long the miner will keep your file hosted, is represented in blocks. Each block represents 45 seconds.
|
||||
|
||||
Upon success, this command will return a **Deal CID**.
|
||||
|
||||
|
||||
@@ -8,4 +8,14 @@ git pull origin master
|
||||
|
||||
# clean and remake the binaries
|
||||
make clean && make build
|
||||
```
|
||||
```
|
||||
|
||||
Sometimes when you run Lotus after a pull, certain commands such as `lotus daemon` may break.
|
||||
|
||||
Here is a command that will delete your chain data, stored wallets and any miners you have set up:
|
||||
|
||||
```sh
|
||||
rm -rf ~/.lotus ~/.lotusstorage
|
||||
```
|
||||
|
||||
This command usually resolves any issues with running `lotus` commands but it is not always required for updates. We will share information about when resetting your chain data and miners is required for an update in the future.
|
||||
|
||||
@@ -27,8 +27,8 @@ require (
|
||||
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200505180321-973f8949ea8e
|
||||
github.com/filecoin-project/go-statestore v0.1.0
|
||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200513185232-4051533cc4bd
|
||||
github.com/filecoin-project/specs-actors v0.5.3
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200509005126-ebc27d314ba4
|
||||
github.com/filecoin-project/specs-actors v0.5.2
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200427182014-01487d5ad3c8
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||
|
||||
@@ -185,8 +185,8 @@ github.com/filecoin-project/lotus v0.2.10/go.mod h1:om5PQA9ZT0lf16qI7Fz/ZGLn4LDC
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200411000242-61616264b16d/go.mod h1:/yueJueMh0Yc+0G1adS0lhnedcSnjY86EjKsA20+DVY=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200508203401-a74812ba12f3 h1:WezmdxkWlnTe9xLzIitUrsvUVmjmWDEEuAe9l8A+Os0=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200508203401-a74812ba12f3/go.mod h1:B+xzopr/oWZJz2hBL5Ekb7Obcum5ntmfbaAUlaaho28=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200513185232-4051533cc4bd h1:CPzpRRooX7cI0g04GJo5mHTE8PpnUwCJBC1ZPGd2kRA=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200513185232-4051533cc4bd/go.mod h1:AeiT6Szz4XSnSJwHF1+flTRMspkwekbTP8zX8/wlhbY=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200509005126-ebc27d314ba4 h1:/o1hc/L+PQBIgWzmna0UwyiIUFeEo+dUuU6gyLL1ItU=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200509005126-ebc27d314ba4/go.mod h1:AeiT6Szz4XSnSJwHF1+flTRMspkwekbTP8zX8/wlhbY=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA=
|
||||
github.com/filecoin-project/specs-actors v0.2.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y=
|
||||
@@ -197,8 +197,6 @@ github.com/filecoin-project/specs-actors v0.5.1 h1:uBPdtCnGRuBo/BNw9nrnf5NCdsaVJ
|
||||
github.com/filecoin-project/specs-actors v0.5.1/go.mod h1:r5btrNzZD0oBkEz1pohv80gSCXQnqGrD0kYwOTiExyE=
|
||||
github.com/filecoin-project/specs-actors v0.5.2 h1:9Y11ctTaD5ul4L2imC2moPMVEUyIOWT88s9WD3VMj0I=
|
||||
github.com/filecoin-project/specs-actors v0.5.2/go.mod h1:r5btrNzZD0oBkEz1pohv80gSCXQnqGrD0kYwOTiExyE=
|
||||
github.com/filecoin-project/specs-actors v0.5.3 h1:fdq8Gx0izhnUKl6sYEtI4SUEjT2U6W2w06HeqLz5vmw=
|
||||
github.com/filecoin-project/specs-actors v0.5.3/go.mod h1:r5btrNzZD0oBkEz1pohv80gSCXQnqGrD0kYwOTiExyE=
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275 h1:6OTcpsTQBQM0f/A67oEi4E4YtYd6fzkMqbU8cPIWMMs=
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE=
|
||||
github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102 h1:T3f/zkuvgtgqcXrb0NO3BicuveGOxxUAMPa/Yif2kuE=
|
||||
|
||||
+54
-58
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -160,60 +161,14 @@ func (c *client) makeOutChan(ctx context.Context, ftyp reflect.Type, valOut int)
|
||||
chCtx, chCancel := context.WithCancel(ctx)
|
||||
retVal = ch.Convert(ftyp.Out(valOut))
|
||||
|
||||
incoming := make(chan reflect.Value, 32)
|
||||
|
||||
// gorotuine to handle buffering of items
|
||||
go func() {
|
||||
buf := (&list.List{}).Init()
|
||||
|
||||
for {
|
||||
front := buf.Front()
|
||||
|
||||
cases := []reflect.SelectCase{
|
||||
{
|
||||
Dir: reflect.SelectRecv,
|
||||
Chan: reflect.ValueOf(chCtx.Done()),
|
||||
},
|
||||
{
|
||||
Dir: reflect.SelectRecv,
|
||||
Chan: reflect.ValueOf(incoming),
|
||||
},
|
||||
}
|
||||
|
||||
if front != nil {
|
||||
cases = append(cases, reflect.SelectCase{
|
||||
Dir: reflect.SelectSend,
|
||||
Chan: ch,
|
||||
Send: front.Value.(reflect.Value).Elem(),
|
||||
})
|
||||
}
|
||||
|
||||
chosen, val, _ := reflect.Select(cases)
|
||||
|
||||
switch chosen {
|
||||
case 0:
|
||||
ch.Close()
|
||||
return
|
||||
case 1:
|
||||
vvval := val.Interface().(reflect.Value)
|
||||
buf.PushBack(vvval)
|
||||
if buf.Len() > 1 {
|
||||
if buf.Len() > 10 {
|
||||
log.Warnw("rpc output message buffer", "n", buf.Len())
|
||||
} else {
|
||||
log.Infow("rpc output message buffer", "n", buf.Len())
|
||||
}
|
||||
}
|
||||
|
||||
case 2:
|
||||
buf.Remove(front)
|
||||
}
|
||||
}
|
||||
}()
|
||||
buf := (&list.List{}).Init()
|
||||
var bufLk sync.Mutex
|
||||
|
||||
return ctx, func(result []byte, ok bool) {
|
||||
if !ok {
|
||||
chCancel()
|
||||
// remote channel closed, close ours too
|
||||
ch.Close()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -223,15 +178,56 @@ func (c *client) makeOutChan(ctx context.Context, ftyp reflect.Type, valOut int)
|
||||
return
|
||||
}
|
||||
|
||||
bufLk.Lock()
|
||||
if ctx.Err() != nil {
|
||||
log.Errorf("got rpc message with cancelled context: %s", ctx.Err())
|
||||
bufLk.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case incoming <- val:
|
||||
case <-chCtx.Done():
|
||||
buf.PushBack(val)
|
||||
|
||||
if buf.Len() > 1 {
|
||||
if buf.Len() > 10 {
|
||||
log.Warnw("rpc output message buffer", "n", buf.Len())
|
||||
} else {
|
||||
log.Infow("rpc output message buffer", "n", buf.Len())
|
||||
}
|
||||
bufLk.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
for buf.Len() > 0 {
|
||||
front := buf.Front()
|
||||
bufLk.Unlock()
|
||||
|
||||
cases := []reflect.SelectCase{
|
||||
{
|
||||
Dir: reflect.SelectRecv,
|
||||
Chan: reflect.ValueOf(chCtx.Done()),
|
||||
},
|
||||
{
|
||||
Dir: reflect.SelectSend,
|
||||
Chan: ch,
|
||||
Send: front.Value.(reflect.Value).Elem(),
|
||||
},
|
||||
}
|
||||
|
||||
chosen, _, _ := reflect.Select(cases)
|
||||
bufLk.Lock()
|
||||
|
||||
switch chosen {
|
||||
case 0:
|
||||
buf.Init()
|
||||
case 1:
|
||||
buf.Remove(front)
|
||||
}
|
||||
}
|
||||
|
||||
bufLk.Unlock()
|
||||
}()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,8 +292,8 @@ type rpcFunc struct {
|
||||
valOut int
|
||||
errOut int
|
||||
|
||||
hasCtx int
|
||||
returnValueIsChannel bool
|
||||
hasCtx int
|
||||
retCh bool
|
||||
|
||||
retry bool
|
||||
}
|
||||
@@ -354,7 +350,7 @@ func (fn *rpcFunc) handleRpcCall(args []reflect.Value) (results []reflect.Value)
|
||||
// if the function returns a channel, we need to provide a sink for the
|
||||
// messages
|
||||
var chCtor makeChanSink
|
||||
if fn.returnValueIsChannel {
|
||||
if fn.retCh {
|
||||
retVal, chCtor = fn.client.makeOutChan(ctx, fn.ftyp, fn.valOut)
|
||||
}
|
||||
|
||||
@@ -389,7 +385,7 @@ func (fn *rpcFunc) handleRpcCall(args []reflect.Value) (results []reflect.Value)
|
||||
return fn.processError(xerrors.New("request and response id didn't match"))
|
||||
}
|
||||
|
||||
if fn.valOut != -1 && !fn.returnValueIsChannel {
|
||||
if fn.valOut != -1 && !fn.retCh {
|
||||
val := reflect.New(fn.ftyp.Out(fn.valOut))
|
||||
|
||||
if resp.Result != nil {
|
||||
@@ -429,7 +425,7 @@ func (c *client) makeRpcFunc(f reflect.StructField) (reflect.Value, error) {
|
||||
if ftyp.NumIn() > 0 && ftyp.In(0) == contextType {
|
||||
fun.hasCtx = 1
|
||||
}
|
||||
fun.returnValueIsChannel = fun.valOut != -1 && ftyp.Out(fun.valOut).Kind() == reflect.Chan
|
||||
fun.retCh = fun.valOut != -1 && ftyp.Out(fun.valOut).Kind() == reflect.Chan
|
||||
|
||||
return reflect.MakeFunc(ftyp, fun.handleRpcCall), nil
|
||||
}
|
||||
|
||||
+2
-27
@@ -13,14 +13,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func init() {
|
||||
logging.SetLogLevel("rpc", "DEBUG")
|
||||
}
|
||||
|
||||
type SimpleServerHandler struct {
|
||||
n int
|
||||
}
|
||||
@@ -288,9 +283,6 @@ func (h *ChanHandler) Sub(ctx context.Context, i int, eq int) (<-chan int, error
|
||||
out := make(chan int)
|
||||
h.ctxdone = ctx.Done()
|
||||
|
||||
wait := h.wait
|
||||
|
||||
log.Warnf("SERVER SUB!")
|
||||
go func() {
|
||||
defer close(out)
|
||||
var n int
|
||||
@@ -300,7 +292,7 @@ func (h *ChanHandler) Sub(ctx context.Context, i int, eq int) (<-chan int, error
|
||||
case <-ctx.Done():
|
||||
fmt.Println("ctxdone1")
|
||||
return
|
||||
case <-wait:
|
||||
case <-h.wait:
|
||||
}
|
||||
|
||||
n += i
|
||||
@@ -373,19 +365,15 @@ func TestChan(t *testing.T) {
|
||||
|
||||
// sub (again)
|
||||
|
||||
serverHandler.wait = make(chan struct{}, 5)
|
||||
serverHandler.wait <- struct{}{}
|
||||
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
log.Warnf("last sub")
|
||||
sub, err = client.Sub(ctx, 3, 6)
|
||||
require.NoError(t, err)
|
||||
|
||||
log.Warnf("waiting for value now")
|
||||
require.Equal(t, 3, <-sub)
|
||||
log.Warnf("not equal")
|
||||
|
||||
// close (remote)
|
||||
serverHandler.wait <- struct{}{}
|
||||
@@ -547,25 +535,12 @@ func testControlChanDeadlock(t *testing.T) {
|
||||
sub, err := client.Sub(ctx, 1, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
done := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
defer close(done)
|
||||
for i := 0; i < n; i++ {
|
||||
if <-sub != i+1 {
|
||||
panic("bad!")
|
||||
//require.Equal(t, i+1, <-sub)
|
||||
}
|
||||
require.Equal(t, i+1, <-sub)
|
||||
}
|
||||
}()
|
||||
|
||||
// reset this channel so its not shared between the sub requests...
|
||||
serverHandler.wait = make(chan struct{}, n)
|
||||
for i := 0; i < n; i++ {
|
||||
serverHandler.wait <- struct{}{}
|
||||
}
|
||||
|
||||
_, err = client.Sub(ctx, 2, -1)
|
||||
require.NoError(t, err)
|
||||
<-done
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"go.opencensus.io/trace"
|
||||
@@ -422,12 +421,6 @@ func SelectMessages(ctx context.Context, al ActorLookup, ts *types.TipSet, msgs
|
||||
|
||||
for _, msg := range msgs {
|
||||
|
||||
minGas := vm.PricelistByEpoch(ts.Height()).OnChainMessage(msg.ChainLength()) // TODO: really should be doing just msg.ChainLength() but the sync side of this code doesnt seem to have access to that
|
||||
if err := msg.VMMessage().ValidForBlockInclusion(minGas); err != nil {
|
||||
log.Warnf("invalid message in message pool: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: this should be in some more general 'validate message' call
|
||||
if msg.Message.GasLimit > build.BlockGasLimit {
|
||||
log.Warnf("message in mempool had too high of a gas limit (%d)", msg.Message.GasLimit)
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ func TestMessageFiltering(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
outmsgs, err := SelectMessages(ctx, af, &types.TipSet{}, wrapMsgs(msgs))
|
||||
outmsgs, err := SelectMessages(ctx, af, nil, wrapMsgs(msgs))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
+2
-10
@@ -142,14 +142,12 @@ type Settings struct {
|
||||
|
||||
Online bool // Online option applied
|
||||
Config bool // Config option applied
|
||||
|
||||
}
|
||||
|
||||
func defaults() []Option {
|
||||
return []Option{
|
||||
Override(new(helpers.MetricsCtx), context.Background),
|
||||
Override(new(record.Validator), modules.RecordValidator),
|
||||
Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(false)),
|
||||
|
||||
// Filecoin modules
|
||||
|
||||
@@ -180,12 +178,7 @@ func libp2p() Option {
|
||||
Override(ConnectionManagerKey, lp2p.ConnectionManager(50, 200, 20*time.Second, nil)),
|
||||
Override(AutoNATSvcKey, lp2p.AutoNATService),
|
||||
|
||||
Override(new(*pubsub.PubSub), lp2p.GossipSub),
|
||||
Override(new(*config.Pubsub), func(bs dtypes.Bootstrapper) *config.Pubsub {
|
||||
return &config.Pubsub{
|
||||
Bootstrapper: bool(bs),
|
||||
}
|
||||
}),
|
||||
Override(new(*pubsub.PubSub), lp2p.GossipSub(&config.Pubsub{})),
|
||||
|
||||
Override(PstoreAddSelfKeysKey, lp2p.PstoreAddSelfKeys),
|
||||
Override(StartListeningKey, lp2p.StartListening(config.DefaultFullNode().Libp2p.ListenAddresses)),
|
||||
@@ -361,8 +354,7 @@ func ConfigCommon(cfg *config.Common) Option {
|
||||
cfg.Libp2p.ConnMgrHigh,
|
||||
time.Duration(cfg.Libp2p.ConnMgrGrace),
|
||||
cfg.Libp2p.ProtectedPeers)),
|
||||
Override(new(*pubsub.PubSub), lp2p.GossipSub),
|
||||
Override(new(*config.Pubsub), &cfg.Pubsub),
|
||||
Override(new(*pubsub.PubSub), lp2p.GossipSub(&cfg.Pubsub)),
|
||||
|
||||
ApplyIf(func(s *Settings) bool { return len(cfg.Libp2p.BootstrapPeers) > 0 },
|
||||
Override(new(dtypes.BootstrapPeers), modules.ConfigBootstrap(cfg.Libp2p.BootstrapPeers)),
|
||||
|
||||
@@ -3,5 +3,3 @@ package dtypes
|
||||
import "github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
type BootstrapPeers []peer.AddrInfo
|
||||
|
||||
type Bootstrapper bool
|
||||
|
||||
@@ -71,23 +71,19 @@ func MockHost(mn mocknet.Mocknet, id peer.ID, ps peerstore.Peerstore) (RawHost,
|
||||
}
|
||||
|
||||
func DHTRouting(mode dht.ModeOpt) interface{} {
|
||||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host RawHost, dstore dtypes.MetadataDS, validator record.Validator, nn dtypes.NetworkName, bs dtypes.Bootstrapper) (BaseIpfsRouting, error) {
|
||||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host RawHost, dstore dtypes.MetadataDS, validator record.Validator, nn dtypes.NetworkName) (BaseIpfsRouting, error) {
|
||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||
|
||||
if bs {
|
||||
mode = dht.ModeServer
|
||||
}
|
||||
|
||||
opts := []dht.Option{dht.Mode(mode),
|
||||
d, err := dht.New(
|
||||
ctx, host,
|
||||
dht.Mode(mode),
|
||||
dht.Datastore(dstore),
|
||||
dht.Validator(validator),
|
||||
dht.ProtocolPrefix(build.DhtProtocolName(nn)),
|
||||
dht.QueryFilter(dht.PublicQueryFilter),
|
||||
dht.RoutingTableFilter(dht.PublicRoutingTableFilter),
|
||||
dht.DisableProviders(),
|
||||
dht.DisableValues()}
|
||||
d, err := dht.New(
|
||||
ctx, host, opts...,
|
||||
dht.DisableValues(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
+153
-151
@@ -28,141 +28,160 @@ func init() {
|
||||
pubsub.GossipSubDirectConnectInitialDelay = 30 * time.Second
|
||||
}
|
||||
|
||||
func GossipSub(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, nn dtypes.NetworkName, bp dtypes.BootstrapPeers, cfg *config.Pubsub) (service *pubsub.PubSub, err error) {
|
||||
bootstrappers := make(map[peer.ID]struct{})
|
||||
for _, pi := range bp {
|
||||
bootstrappers[pi.ID] = struct{}{}
|
||||
}
|
||||
isBootstrapNode := cfg.Bootstrapper
|
||||
func GossipSub(cfg *config.Pubsub) interface{} {
|
||||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, nn dtypes.NetworkName, bp dtypes.BootstrapPeers) (service *pubsub.PubSub, err error) {
|
||||
bootstrappers := make(map[peer.ID]struct{})
|
||||
for _, pi := range bp {
|
||||
bootstrappers[pi.ID] = struct{}{}
|
||||
}
|
||||
isBootstrapNode := cfg.Bootstrapper
|
||||
|
||||
options := []pubsub.Option{
|
||||
// Gossipsubv1.1 configuration
|
||||
pubsub.WithFloodPublish(true),
|
||||
pubsub.WithPeerScore(
|
||||
&pubsub.PeerScoreParams{
|
||||
AppSpecificScore: func(p peer.ID) float64 {
|
||||
// return a heavy positive score for bootstrappers so that we don't unilaterally prune
|
||||
// them and accept PX from them.
|
||||
// we don't do that in the bootstrappers themselves to avoid creating a closed mesh
|
||||
// between them (however we might want to consider doing just that)
|
||||
_, ok := bootstrappers[p]
|
||||
if ok && !isBootstrapNode {
|
||||
return 2500
|
||||
}
|
||||
options := []pubsub.Option{
|
||||
// Gossipsubv1.1 configuration
|
||||
pubsub.WithFloodPublish(true),
|
||||
pubsub.WithPeerScore(
|
||||
&pubsub.PeerScoreParams{
|
||||
AppSpecificScore: func(p peer.ID) float64 {
|
||||
// return a heavy positive score for bootstrappers so that we don't unilaterally prune
|
||||
// them and accept PX from them.
|
||||
// we don't do that in the bootstrappers themselves to avoid creating a closed mesh
|
||||
// between them (however we might want to consider doing just that)
|
||||
_, ok := bootstrappers[p]
|
||||
if ok && !isBootstrapNode {
|
||||
return 2500
|
||||
}
|
||||
|
||||
// TODO: we want to plug the application specific score to the node itself in order
|
||||
// to provide feedback to the pubsub system based on observed behaviour
|
||||
return 0
|
||||
},
|
||||
AppSpecificWeight: 1,
|
||||
|
||||
// This sets the IP colocation threshold to 1 peer per
|
||||
IPColocationFactorThreshold: 1,
|
||||
IPColocationFactorWeight: -100,
|
||||
// TODO we want to whitelist IPv6 /64s that belong to datacenters etc
|
||||
// IPColocationFactorWhitelist: map[string]struct{}{},
|
||||
|
||||
DecayInterval: pubsub.DefaultDecayInterval,
|
||||
DecayToZero: pubsub.DefaultDecayToZero,
|
||||
|
||||
// this retains non-positive scores for 6 hours
|
||||
RetainScore: 6 * time.Hour,
|
||||
|
||||
// topic parameters
|
||||
Topics: map[string]*pubsub.TopicScoreParams{
|
||||
build.BlocksTopic(nn): {
|
||||
// expected 10 blocks/min
|
||||
TopicWeight: 0.1, // max is 50, max mesh penalty is -10, single invalid message is -100
|
||||
|
||||
// 1 tick per second, maxes at 1 after 1 hour
|
||||
TimeInMeshWeight: 0.00027, // ~1/3600
|
||||
TimeInMeshQuantum: time.Second,
|
||||
TimeInMeshCap: 1,
|
||||
|
||||
// deliveries decay after 1 hour, cap at 100 blocks
|
||||
FirstMessageDeliveriesWeight: 5, // max value is 500
|
||||
FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
FirstMessageDeliveriesCap: 100, // 100 blocks in an hour
|
||||
|
||||
// tracks deliveries in the last minute
|
||||
// penalty activates at 1 minute and expects ~0.4 blocks
|
||||
MeshMessageDeliveriesWeight: -576, // max penalty is -100
|
||||
MeshMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Minute),
|
||||
MeshMessageDeliveriesCap: 10, // 10 blocks in a minute
|
||||
MeshMessageDeliveriesThreshold: 0.41666, // 10/12/2 blocks/min
|
||||
MeshMessageDeliveriesWindow: 10 * time.Millisecond,
|
||||
MeshMessageDeliveriesActivation: time.Minute,
|
||||
|
||||
// decays after 15 min
|
||||
MeshFailurePenaltyWeight: -576,
|
||||
MeshFailurePenaltyDecay: pubsub.ScoreParameterDecay(15 * time.Minute),
|
||||
|
||||
// invalid messages decay after 1 hour
|
||||
InvalidMessageDeliveriesWeight: -1000,
|
||||
InvalidMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
// TODO: we want to plug the application specific score to the node itself in order
|
||||
// to provide feedback to the pubsub system based on observed behaviour
|
||||
return 0
|
||||
},
|
||||
build.MessagesTopic(nn): {
|
||||
// expected > 1 tx/second
|
||||
TopicWeight: 0.05, // max is 25, max mesh penalty is -5, single invalid message is -100
|
||||
AppSpecificWeight: 1,
|
||||
|
||||
// 1 tick per second, maxes at 1 hour
|
||||
TimeInMeshWeight: 0.0002778, // ~1/3600
|
||||
TimeInMeshQuantum: time.Second,
|
||||
TimeInMeshCap: 1,
|
||||
// This sets the IP colocation threshold to 1 peer per
|
||||
IPColocationFactorThreshold: 1,
|
||||
IPColocationFactorWeight: -100,
|
||||
// TODO we want to whitelist IPv6 /64s that belong to datacenters etc
|
||||
// IPColocationFactorWhitelist: map[string]struct{}{},
|
||||
|
||||
// deliveries decay after 10min, cap at 1000 tx
|
||||
FirstMessageDeliveriesWeight: 0.5, // max value is 500
|
||||
FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(10 * time.Minute),
|
||||
FirstMessageDeliveriesCap: 1000,
|
||||
DecayInterval: pubsub.DefaultDecayInterval,
|
||||
DecayToZero: pubsub.DefaultDecayToZero,
|
||||
|
||||
// tracks deliveries in the last minute
|
||||
// penalty activates at 1 min and expects 2.5 txs
|
||||
MeshMessageDeliveriesWeight: -16, // max penalty is -100
|
||||
MeshMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Minute),
|
||||
MeshMessageDeliveriesCap: 100, // 100 txs in a minute
|
||||
MeshMessageDeliveriesThreshold: 2.5, // 60/12/2 txs/minute
|
||||
MeshMessageDeliveriesWindow: 10 * time.Millisecond,
|
||||
MeshMessageDeliveriesActivation: time.Minute,
|
||||
// this retains non-positive scores for 6 hours
|
||||
RetainScore: 6 * time.Hour,
|
||||
|
||||
// decays after 5min
|
||||
MeshFailurePenaltyWeight: -16,
|
||||
MeshFailurePenaltyDecay: pubsub.ScoreParameterDecay(5 * time.Minute),
|
||||
// topic parameters
|
||||
Topics: map[string]*pubsub.TopicScoreParams{
|
||||
build.BlocksTopic(nn): {
|
||||
// expected 10 blocks/min
|
||||
TopicWeight: 0.1, // max is 50, max mesh penalty is -10, single invalid message is -100
|
||||
|
||||
// invalid messages decay after 1 hour
|
||||
InvalidMessageDeliveriesWeight: -2000,
|
||||
InvalidMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
// 1 tick per second, maxes at 1 after 1 hour
|
||||
TimeInMeshWeight: 0.00027, // ~1/3600
|
||||
TimeInMeshQuantum: time.Second,
|
||||
TimeInMeshCap: 1,
|
||||
|
||||
// deliveries decay after 1 hour, cap at 100 blocks
|
||||
FirstMessageDeliveriesWeight: 5, // max value is 500
|
||||
FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
FirstMessageDeliveriesCap: 100, // 100 blocks in an hour
|
||||
|
||||
// tracks deliveries in the last minute
|
||||
// penalty activates at 1 minute and expects ~0.4 blocks
|
||||
MeshMessageDeliveriesWeight: -576, // max penalty is -100
|
||||
MeshMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Minute),
|
||||
MeshMessageDeliveriesCap: 10, // 10 blocks in a minute
|
||||
MeshMessageDeliveriesThreshold: 0.41666, // 10/12/2 blocks/min
|
||||
MeshMessageDeliveriesWindow: 10 * time.Millisecond,
|
||||
MeshMessageDeliveriesActivation: time.Minute,
|
||||
|
||||
// decays after 15 min
|
||||
MeshFailurePenaltyWeight: -576,
|
||||
MeshFailurePenaltyDecay: pubsub.ScoreParameterDecay(15 * time.Minute),
|
||||
|
||||
// invalid messages decay after 1 hour
|
||||
InvalidMessageDeliveriesWeight: -1000,
|
||||
InvalidMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
},
|
||||
build.MessagesTopic(nn): {
|
||||
// expected > 1 tx/second
|
||||
TopicWeight: 0.05, // max is 25, max mesh penalty is -5, single invalid message is -100
|
||||
|
||||
// 1 tick per second, maxes at 1 hour
|
||||
TimeInMeshWeight: 0.0002778, // ~1/3600
|
||||
TimeInMeshQuantum: time.Second,
|
||||
TimeInMeshCap: 1,
|
||||
|
||||
// deliveries decay after 10min, cap at 1000 tx
|
||||
FirstMessageDeliveriesWeight: 0.5, // max value is 500
|
||||
FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(10 * time.Minute),
|
||||
FirstMessageDeliveriesCap: 1000,
|
||||
|
||||
// tracks deliveries in the last minute
|
||||
// penalty activates at 1 min and expects 2.5 txs
|
||||
MeshMessageDeliveriesWeight: -16, // max penalty is -100
|
||||
MeshMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Minute),
|
||||
MeshMessageDeliveriesCap: 100, // 100 txs in a minute
|
||||
MeshMessageDeliveriesThreshold: 2.5, // 60/12/2 txs/minute
|
||||
MeshMessageDeliveriesWindow: 10 * time.Millisecond,
|
||||
MeshMessageDeliveriesActivation: time.Minute,
|
||||
|
||||
// decays after 5min
|
||||
MeshFailurePenaltyWeight: -16,
|
||||
MeshFailurePenaltyDecay: pubsub.ScoreParameterDecay(5 * time.Minute),
|
||||
|
||||
// invalid messages decay after 1 hour
|
||||
InvalidMessageDeliveriesWeight: -2000,
|
||||
InvalidMessageDeliveriesDecay: pubsub.ScoreParameterDecay(time.Hour),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&pubsub.PeerScoreThresholds{
|
||||
GossipThreshold: -500,
|
||||
PublishThreshold: -1000,
|
||||
GraylistThreshold: -2500,
|
||||
AcceptPXThreshold: 1000,
|
||||
OpportunisticGraftThreshold: 2.5,
|
||||
},
|
||||
),
|
||||
}
|
||||
&pubsub.PeerScoreThresholds{
|
||||
GossipThreshold: -500,
|
||||
PublishThreshold: -1000,
|
||||
GraylistThreshold: -2500,
|
||||
AcceptPXThreshold: 1000,
|
||||
OpportunisticGraftThreshold: 2.5,
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
// enable Peer eXchange on bootstrappers
|
||||
if isBootstrapNode {
|
||||
// turn off the mesh in bootstrappers -- only do gossip and PX
|
||||
pubsub.GossipSubD = 0
|
||||
pubsub.GossipSubDscore = 0
|
||||
pubsub.GossipSubDlo = 0
|
||||
pubsub.GossipSubDhi = 0
|
||||
pubsub.GossipSubDlazy = 1024
|
||||
pubsub.GossipSubGossipFactor = 0.5
|
||||
// turn on PX
|
||||
options = append(options, pubsub.WithPeerExchange(true))
|
||||
}
|
||||
// enable Peer eXchange on bootstrappers
|
||||
if isBootstrapNode {
|
||||
// turn off the mesh in bootstrappers -- only do gossip and PX
|
||||
pubsub.GossipSubD = 0
|
||||
pubsub.GossipSubDscore = 0
|
||||
pubsub.GossipSubDlo = 0
|
||||
pubsub.GossipSubDhi = 0
|
||||
pubsub.GossipSubDlazy = 1024
|
||||
pubsub.GossipSubGossipFactor = 0.5
|
||||
// turn on PX
|
||||
options = append(options, pubsub.WithPeerExchange(true))
|
||||
}
|
||||
|
||||
// direct peers
|
||||
if cfg.DirectPeers != nil {
|
||||
var directPeerInfo []peer.AddrInfo
|
||||
// direct peers
|
||||
if cfg.DirectPeers != nil {
|
||||
var directPeerInfo []peer.AddrInfo
|
||||
|
||||
for _, addr := range cfg.DirectPeers {
|
||||
a, err := ma.NewMultiaddr(addr)
|
||||
for _, addr := range cfg.DirectPeers {
|
||||
a, err := ma.NewMultiaddr(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pi, err := peer.AddrInfoFromP2pAddr(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
directPeerInfo = append(directPeerInfo, *pi)
|
||||
}
|
||||
|
||||
options = append(options, pubsub.WithDirectPeers(directPeerInfo))
|
||||
}
|
||||
|
||||
// tracer
|
||||
if cfg.RemoteTracer != "" {
|
||||
a, err := ma.NewMultiaddr(cfg.RemoteTracer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -172,38 +191,21 @@ func GossipSub(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, nn dtyp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
directPeerInfo = append(directPeerInfo, *pi)
|
||||
tr, err := pubsub.NewRemoteTracer(context.TODO(), host, *pi)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
trw := newTracerWrapper(tr)
|
||||
options = append(options, pubsub.WithEventTracer(trw))
|
||||
}
|
||||
|
||||
options = append(options, pubsub.WithDirectPeers(directPeerInfo))
|
||||
// TODO: we want to hook the peer score inspector so that we can gain visibility
|
||||
// in peer scores for debugging purposes -- this might be trigged by metrics collection
|
||||
// options = append(options, pubsub.WithPeerScoreInspect(XXX, time.Second))
|
||||
|
||||
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, options...)
|
||||
}
|
||||
|
||||
// tracer
|
||||
if cfg.RemoteTracer != "" {
|
||||
a, err := ma.NewMultiaddr(cfg.RemoteTracer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pi, err := peer.AddrInfoFromP2pAddr(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tr, err := pubsub.NewRemoteTracer(context.TODO(), host, *pi)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
trw := newTracerWrapper(tr)
|
||||
options = append(options, pubsub.WithEventTracer(trw))
|
||||
}
|
||||
|
||||
// TODO: we want to hook the peer score inspector so that we can gain visibility
|
||||
// in peer scores for debugging purposes -- this might be trigged by metrics collection
|
||||
// options = append(options, pubsub.WithPeerScoreInspect(XXX, time.Second))
|
||||
|
||||
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, options...)
|
||||
}
|
||||
|
||||
func HashMsgId(m *pubsub_pb.Message) string {
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/client"
|
||||
@@ -56,7 +55,6 @@ func init() {
|
||||
saminer.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
|
||||
abi.RegisteredProof_StackedDRG2KiBSeal: {},
|
||||
}
|
||||
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
||||
}
|
||||
|
||||
func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, act address.Address, pk crypto.PrivKey, tnd test.TestNode, mn mocknet.Mocknet, opts node.Option) test.TestStorageNode {
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
org=filecoin-project
|
||||
repo=lotus
|
||||
arch_repo="$org/lotus-archived"
|
||||
api_repo="repos/$org/$repo"
|
||||
|
||||
exclusions=(
|
||||
'master'
|
||||
)
|
||||
|
||||
gh_api_next() {
|
||||
links=$(grep '^Link:' | sed -e 's/Link: //' -e 's/, /\n/g')
|
||||
echo "$links" | grep '; rel="next"' >/dev/null || return
|
||||
link=$(echo "$links" | grep '; rel="next"' | sed -e 's/^<//' -e 's/>.*//')
|
||||
|
||||
curl -n -f -sD >(gh_api_next) "$link"
|
||||
}
|
||||
|
||||
gh_api() {
|
||||
curl -n -f -sD >(gh_api_next) "https://api.github.com/$1" | jq -s '[.[] | .[]]'
|
||||
}
|
||||
|
||||
pr_branches() {
|
||||
gh_api "$api_repo/pulls" | jq -r '.[].head.label | select(test("^'"$org"':"))' \
|
||||
| sed 's/^'"$org"'://'
|
||||
}
|
||||
|
||||
origin_refs() {
|
||||
format=${1-'%(refname:short)'}
|
||||
|
||||
git for-each-ref --format "$format" refs/remotes/origin | sed 's|^origin/||'
|
||||
}
|
||||
|
||||
active_branches() {
|
||||
origin_refs '%(refname:short) %(committerdate:unix)' |awk \
|
||||
' BEGIN { monthAgo = systime() - 31*24*60*60 }
|
||||
{ if ($2 > monthAgo) print $1 }
|
||||
'
|
||||
}
|
||||
|
||||
git remote add archived "git@github.com:$arch_repo.git" || true
|
||||
|
||||
branches_to_move="$(cat <(active_branches) <(pr_branches) <((IFS=$'\n'; echo "${exclusions[*]}")) | sort -u | comm - <(origin_refs | sort) -13)"
|
||||
|
||||
echo "================"
|
||||
printf "%s\n" "$branches_to_move"
|
||||
echo "================"
|
||||
|
||||
echo "Please confirm move of above branches [y/N]:"
|
||||
|
||||
read -r line
|
||||
case "$line" in
|
||||
[Yy]|[Yy][Ee][Ss]) ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
|
||||
printf "%s\n" "$branches_to_move" | \
|
||||
while read -r ref; do
|
||||
git push archived "origin/$ref:refs/heads/$ref/$(date --rfc-3339=date)"
|
||||
git push origin --delete "$ref"
|
||||
done
|
||||
|
||||
@@ -68,7 +68,6 @@ type storageMinerApi interface {
|
||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error)
|
||||
|
||||
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
|
||||
Reference in New Issue
Block a user