Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Oct 9, 2019
1 parent bd22e2c commit 33b4b3a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
11 changes: 5 additions & 6 deletions chain/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (syncer *Syncer) syncOne(ctx context.Context, grandParent, parent, next typ
heavier, err := syncer.chainSelector.IsHeavier(ctx, next, headTipSet, nextParentStateID, headParentStateID)
if err != nil {
return err
}
}

// If it is the heaviest update the chainStore.
if heavier {
Expand All @@ -240,7 +240,7 @@ func (syncer *Syncer) syncOne(ctx context.Context, grandParent, parent, next typ
// Gather the entire new chain for reorg comparison and logging.
syncer.logReorg(ctx, headTipSet, next)
}

return nil
}

Expand Down Expand Up @@ -274,7 +274,7 @@ func (syncer *Syncer) familyFromStore(ts types.TipSet) (types.TipSet, types.TipS
if grandParentCids.Empty() {
// parent == genesis ==> grandParent undef
return parent, types.UndefTipSet, nil
}
}
grandParent, err := syncer.chainStore.GetTipSet(grandParentCids)
if err != nil {
return types.UndefTipSet, types.UndefTipSet, err
Expand Down Expand Up @@ -428,12 +428,11 @@ func (syncer *Syncer) HandleNewTipSet(ctx context.Context, ci *types.ChainInfo,
// Fetcher returns chain in Traversal order, reverse it to height order
Reverse(chain)


parent, grandParent, err := syncer.familyFromStore(chain[0])
if err != nil {
return err
}

// Try adding the tipsets of the chain to the store, checking for new
// heaviest tipsets.
for i, ts := range chain {
Expand Down Expand Up @@ -469,7 +468,7 @@ func (syncer *Syncer) HandleNewTipSet(ctx context.Context, ci *types.ChainInfo,
// so we don't really lose anything with this simplification.
syncer.badTipSets.AddChain(chain[i:])
return err
}
}
}
if i%500 == 0 {
logSyncer.Infof("processing block %d of %v for chain with head at %v", i, len(chain), ci.Head.String())
Expand Down
2 changes: 1 addition & 1 deletion chain/syncer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
4 changes: 2 additions & 2 deletions consensus/block_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/filecoin-project/go-filecoin/clock"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

// BlockValidator defines an interface used to validate a blocks syntax and
Expand Down Expand Up @@ -82,7 +82,7 @@ func (dv *DefaultBlockValidator) ValidateSemantic(ctx context.Context, child *ty
fmt.Printf("consensus fault: parentweight (%d) != expected parentweight (%d)\n", uint64(child.ParentWeight), parentWeight)
return fmt.Errorf("block %s has invalid parent weight %d", child.Cid().String(), parentWeight)
}
fmt.Printf("Validated parent weight is correct\n")
fmt.Printf("Validated parent weight is correct\n")
}

if uint64(child.Height) <= ph {
Expand Down
8 changes: 4 additions & 4 deletions consensus/block_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

func TestBlockValidSemantic(t *testing.T) {
Expand All @@ -25,7 +25,7 @@ func TestBlockValidSemantic(t *testing.T) {
mclock := th.NewFakeClock(ts)
ctx := context.Background()
pvt, err := version.ConfigureProtocolVersions(version.TEST)
require.NoError(t, err)
require.NoError(t, err)

validator := consensus.NewDefaultBlockValidator(blockTime, mclock, pvt)

Expand Down Expand Up @@ -91,7 +91,7 @@ func TestBlockValidSemantic(t *testing.T) {

err := validator.ValidateSemantic(ctx, c, &parents, 30)
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid parent weight")
assert.Contains(t, err.Error(), "invalid parent weight")
})

t.Run("accept block mined with invalid parent weight before alphanet upgrade", func(t *testing.T) {
Expand All @@ -112,7 +112,7 @@ func TestBlockValidSyntax(t *testing.T) {
mclock := th.NewFakeClock(ts)
ctx := context.Background()
pvt, err := version.ConfigureProtocolVersions(version.TEST)
require.NoError(t, err)
require.NoError(t, err)

validator := consensus.NewDefaultBlockValidator(blockTime, mclock, pvt)

Expand Down
2 changes: 1 addition & 1 deletion consensus/chain_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/filecoin-project/go-filecoin/state"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

// Parameters used by the latest weight function "NewWeight"
Expand Down
4 changes: 2 additions & 2 deletions consensus/weight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/filecoin-project/go-filecoin/consensus"
"github.com/filecoin-project/go-filecoin/state"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

func TestNewWeight(t *testing.T) {
Expand All @@ -23,7 +23,7 @@ func TestNewWeight(t *testing.T) {
fakeRoot, err := fakeTree.Flush(ctx)
require.NoError(t, err)
pvt, err := version.ConfigureProtocolVersions(version.TEST)
require.NoError(t, err)
require.NoError(t, err)
// We only care about total power for the weight function
// Total is 16, so bitlen is 5
as := consensus.NewFakeActorStateStore(types.NewBytesAmount(1), types.NewBytesAmount(16), make(map[address.Address]address.Address))
Expand Down
2 changes: 1 addition & 1 deletion net/graphsync_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

const visitsPerBlock = 4
Expand Down
2 changes: 1 addition & 1 deletion net/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

func TestBlockTopicValidator(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (b *Builder) buildBlockservice(ctx context.Context, blockstore *BlockstoreS
}, nil
}

func (b *Builder) buildChain(ctx context.Context, blockstore *BlockstoreSubmodule, network *NetworkSubmodule, ptv *version.ProtocolVersionTable) (ChainSubmodule, error) {
func (b *Builder) buildChain(ctx context.Context, blockstore *BlockstoreSubmodule, network *NetworkSubmodule, pvt *version.ProtocolVersionTable) (ChainSubmodule, error) {
// initialize chain store
chainStatusReporter := chain.NewStatusReporter()
chainStore := chain.NewStore(b.Repo.ChainDatastore(), blockstore.cborStore, &state.TreeStateLoader{}, chainStatusReporter, b.genCid)
Expand All @@ -416,7 +416,7 @@ func (b *Builder) buildChain(ctx context.Context, blockstore *BlockstoreSubmodul

// setup block validation
// TODO when #2961 is resolved do the needful here.
blkValid := consensus.NewDefaultBlockValidator(b.BlockTime, b.Clock, ptv)
blkValid := consensus.NewDefaultBlockValidator(b.BlockTime, b.Clock, pvt)

// register block validation on floodsub
btv := net.NewBlockTopicValidator(blkValid)
Expand All @@ -427,7 +427,7 @@ func (b *Builder) buildChain(ctx context.Context, blockstore *BlockstoreSubmodul
// set up consensus
actorState := consensus.NewActorStateStore(chainStore, blockstore.cborStore, blockstore.Blockstore, processor)
nodeConsensus := consensus.NewExpected(blockstore.cborStore, blockstore.Blockstore, processor, blkValid, actorState, b.genCid, b.BlockTime, consensus.ElectionMachine{}, consensus.TicketMachine{})
nodeChainSelector := consensus.NewChainSelector(blockstore.cborStore, actorState, b.genCid, ptv)
nodeChainSelector := consensus.NewChainSelector(blockstore.cborStore, actorState, b.genCid, pvt)

// setup fecher
graphsyncNetwork := gsnet.NewFromLibp2pHost(network.host)
Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func (node *Node) StartMining(ctx context.Context) error {
log.Errorf("failed to get worker address %s", err)
continue
}

// This call can fail due to, e.g. nonce collisions. Our miners existence depends on this.
// We should deal with this, but MessageSendWithRetry is problematic.
msgCid, err := node.PorcelainAPI.MessageSend(
Expand Down Expand Up @@ -569,7 +569,7 @@ func (node *Node) StartMining(ctx context.Context) error {
case <-miningCtx.Done():
return
case <-time.After(time.Duration(node.Repo.Config().Mining.AutoSealIntervalSeconds) * time.Second):
// log.Info("auto-seal has been triggered")
log.Info("auto-seal has been triggered")
if err := node.SectorBuilder().SealAllStagedSectors(miningCtx); err != nil {
log.Errorf("scheduler received error from node.SectorStorage.sectorBuilder.SealAllStagedSectors (%s) - exiting", err.Error())
return
Expand Down Expand Up @@ -810,7 +810,7 @@ func (node *Node) getWeight(ctx context.Context, ts types.TipSet) (uint64, error
} else {
wFun = node.Chain.ChainSelector.Weight
}

parent, err := ts.Parents()
if err != nil {
return uint64(0), err
Expand Down
1 change: 0 additions & 1 deletion protocol/storage/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ func (sm *Miner) OnNewHeaviestTipSet(ts types.TipSet) (*moresync.Latch, error) {
}

commitments, err := sm.getActorSectorCommitments(ctx)
fmt.Printf("OHT: number of commitments: %d\n", len(commitments))
if err != nil {
return doneLatch, errors.Errorf("failed to get miner actor commitments: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions testhelpers/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/filecoin-project/go-filecoin/consensus"
"github.com/filecoin-project/go-filecoin/repo"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/version"
"github.com/filecoin-project/go-filecoin/version"
)

type chainWeighter interface {
Expand Down Expand Up @@ -56,7 +56,7 @@ func MkFakeChild(params FakeChildParams) (*types.Block, error) {
if err != nil {
return nil, err
}

actorState := consensus.NewActorStateStore(nil, cst, bs, processor)
selector := consensus.NewChainSelector(cst,
actorState,
Expand Down
2 changes: 1 addition & 1 deletion version/protocol_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func ConfigureProtocolVersions(network string) (*ProtocolVersionTable, error) {
Add(USER, Protocol1, types.NewBlockHeight(40000)).
Add(DEVNET4, Protocol1, types.NewBlockHeight(300)).
Add(LOCALNET, Protocol1, types.NewBlockHeight(300)).
Add(TEST, Protocol1, types.NewBlockHeight(300)).
Add(TEST, Protocol1, types.NewBlockHeight(300)).
Build()
}

0 comments on commit 33b4b3a

Please sign in to comment.