Merge branch 'master' into docs-ux-updates

This commit is contained in:
Pooja 2019-10-15 09:33:11 +09:00 committed by GitHub
commit 74a005b80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 13 deletions

View File

@ -48,6 +48,10 @@ The following sections describe how to use the lotus CLI. All these commands sho
The current lotus build will automatically join the lotus Devnet using the genesis and bootstrap files in the `build/` directory. No configuration is needed. The current lotus build will automatically join the lotus Devnet using the genesis and bootstrap files in the `build/` directory. No configuration is needed.
### Genesis & Bootstrap
The current lotus build will automatically join the lotus Devnet using the genesis and bootstrap files in the `build/` directory. No configuration is needed.
### Start Daemon ### Start Daemon
From within the lotus source directory: From within the lotus source directory:

View File

@ -65,7 +65,7 @@ func TestVMInvokeMethod(t *testing.T) {
from := addrs[0] from := addrs[0]
var err error var err error
cenc, err := SerializeParams(&StorageMinerConstructorParams{}) cenc, err := SerializeParams(&StorageMinerConstructorParams{Owner: from, Worker: from})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -116,6 +116,7 @@ func TestStorageMarketActorCreateMiner(t *testing.T) {
cheatStorageMarketTotal(t, vm, bs) cheatStorageMarketTotal(t, vm, bs)
params := &StorageMinerConstructorParams{ params := &StorageMinerConstructorParams{
Owner: maddr,
Worker: maddr, Worker: maddr,
SectorSize: types.NewInt(build.SectorSize), SectorSize: types.NewInt(build.SectorSize),
PeerID: "fakepeerid", PeerID: "fakepeerid",

View File

@ -325,6 +325,10 @@ func hash(ingest []byte, cfg *blake2b.Config) []byte {
} }
func (a Address) MarshalCBOR(w io.Writer) error { func (a Address) MarshalCBOR(w io.Writer) error {
if a == Undef {
return fmt.Errorf("cannot marshal undefined address")
}
abytes := a.Bytes() abytes := a.Bytes()
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(abytes)))); err != nil { if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(abytes)))); err != nil {
return err return err
@ -360,6 +364,9 @@ func (a *Address) UnmarshalCBOR(br io.Reader) error {
if err != nil { if err != nil {
return err return err
} }
if addr == Undef {
return fmt.Errorf("cbor input should not contain empty addresses")
}
*a = addr *a = addr

View File

@ -121,8 +121,8 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
// //
// ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null // ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error { func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error {
e.lk.Lock()
defer e.lk.Unlock() e.lk.Lock() // Tricky locking, check your locks if you modify this function!
bestH := e.tsc.best().Height() bestH := e.tsc.best().Height()
@ -140,6 +140,8 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence
bestH = e.tsc.best().Height() bestH = e.tsc.best().Height()
} }
defer e.lk.Unlock()
if bestH >= h+uint64(confidence)+e.gcConfidence { if bestH >= h+uint64(confidence)+e.gcConfidence {
return nil return nil
} }

View File

@ -45,9 +45,11 @@ func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet
} }
func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet { func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
a, _ := address.NewFromString("t00")
ts, err := types.NewTipSet([]*types.BlockHeader{ ts, err := types.NewTipSet([]*types.BlockHeader{
{ {
Height: h, Height: h,
Miner: a,
ParentStateRoot: dummyCid, ParentStateRoot: dummyCid,
Messages: msgcid, Messages: msgcid,
@ -479,7 +481,7 @@ func TestCalled(t *testing.T) {
fcs.advance(0, 3, map[int]cid.Cid{ // msg at H=6; H=8 (confidence=2) fcs.advance(0, 3, map[int]cid.Cid{ // msg at H=6; H=8 (confidence=2)
0: fcs.fakeMsgs(fakeMsg{ 0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 1}, {To: t0123, From: t0123, Method: 5, Nonce: 1},
}, },
}), }),
}) })
@ -520,7 +522,7 @@ func TestCalled(t *testing.T) {
n2msg := fcs.fakeMsgs(fakeMsg{ n2msg := fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 2}, {To: t0123, From: t0123, Method: 5, Nonce: 2},
}, },
}) })
@ -574,7 +576,7 @@ func TestCalled(t *testing.T) {
fcs.advance(0, 1, map[int]cid.Cid{ // msg at H=16; H=16 fcs.advance(0, 1, map[int]cid.Cid{ // msg at H=16; H=16
0: fcs.fakeMsgs(fakeMsg{ 0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 3}, {To: t0123, From: t0123, Method: 5, Nonce: 3},
}, },
}), }),
}) })
@ -597,7 +599,7 @@ func TestCalled(t *testing.T) {
fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29 fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29
0: fcs.fakeMsgs(fakeMsg{ 0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 4}, // this signals we don't want more {To: t0123, From: t0123, Method: 5, Nonce: 4}, // this signals we don't want more
}, },
}), }),
}) })
@ -609,7 +611,7 @@ func TestCalled(t *testing.T) {
fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29 fcs.advance(0, 4, map[int]cid.Cid{ // msg at H=26; H=29
0: fcs.fakeMsgs(fakeMsg{ 0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 5}, {To: t0123, From: t0123, Method: 5, Nonce: 5},
}, },
}), }),
}) })
@ -754,12 +756,12 @@ func TestCalledOrder(t *testing.T) {
fcs.advance(0, 10, map[int]cid.Cid{ fcs.advance(0, 10, map[int]cid.Cid{
1: fcs.fakeMsgs(fakeMsg{ 1: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 1}, {To: t0123, From: t0123, Method: 5, Nonce: 1},
}, },
}), }),
2: fcs.fakeMsgs(fakeMsg{ 2: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{ bmsgs: []*types.Message{
{To: t0123, Method: 5, Nonce: 2}, {To: t0123, From: t0123, Method: 5, Nonce: 2},
}, },
}), }),
}) })

View File

@ -2,9 +2,11 @@ package events
import ( import (
"context" "context"
"github.com/stretchr/testify/require"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/types" "github.com/filecoin-project/go-lotus/chain/types"
) )
@ -16,8 +18,11 @@ func TestTsCache(t *testing.T) {
h := uint64(75) h := uint64(75)
a, _ := address.NewFromString("t00")
add := func() { add := func() {
ts, err := types.NewTipSet([]*types.BlockHeader{{ ts, err := types.NewTipSet([]*types.BlockHeader{{
Miner: a,
Height: h, Height: h,
ParentStateRoot: dummyCid, ParentStateRoot: dummyCid,
Messages: dummyCid, Messages: dummyCid,
@ -54,8 +59,10 @@ func TestTsCacheNulls(t *testing.T) {
h := uint64(75) h := uint64(75)
a, _ := address.NewFromString("t00")
add := func() { add := func() {
ts, err := types.NewTipSet([]*types.BlockHeader{{ ts, err := types.NewTipSet([]*types.BlockHeader{{
Miner: a,
Height: h, Height: h,
ParentStateRoot: dummyCid, ParentStateRoot: dummyCid,
Messages: dummyCid, Messages: dummyCid,

View File

@ -133,6 +133,10 @@ func (bi *BigInt) cborBytes() []byte {
} }
func fromCborBytes(buf []byte) (BigInt, error) { func fromCborBytes(buf []byte) (BigInt, error) {
if len(buf) == 0 {
return NewInt(0), nil
}
var negative bool var negative bool
switch buf[0] { switch buf[0] {
case 0: case 0:

View File

@ -7,7 +7,7 @@ import (
func TestBigIntSerializationRoundTrip(t *testing.T) { func TestBigIntSerializationRoundTrip(t *testing.T) {
testValues := []string{ testValues := []string{
"0", "1", "10", "9999", "12345678901234567891234567890123456789012345678901234567890", "0", "1", "10", "-10", "9999", "12345678901234567891234567890123456789012345678901234567890",
} }
for _, v := range testValues { for _, v := range testValues {
@ -29,5 +29,6 @@ func TestBigIntSerializationRoundTrip(t *testing.T) {
if BigCmp(out, bi) != 0 { if BigCmp(out, bi) != 0 {
t.Fatal("failed to round trip BigInt through cbor") t.Fatal("failed to round trip BigInt through cbor")
} }
} }
} }

View File

@ -179,7 +179,8 @@ func (m *Miner) mine(ctx context.Context) {
if time.Now().Before(btime) { if time.Now().Before(btime) {
time.Sleep(time.Until(btime)) time.Sleep(time.Until(btime))
} else { } else {
log.Warnf("Mined block in the past: b.T: %s, T: %s, dT: %s", btime, time.Now(), time.Now().Sub(btime)) log.Warnw("mined block in the past", "block-time", btime,
"time", time.Now(), "duration", time.Now().Sub(btime))
} }
if err := m.api.ChainSubmitBlock(ctx, b); err != nil { if err := m.api.ChainSubmitBlock(ctx, b); err != nil {