Merge pull request #74 from filecoin-project/bug-fixes
A couple of bug fixes
This commit is contained in:
commit
2256a7237c
@ -2,8 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/testground/sdk-go/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runBootstrapper(t *TestEnvironment) error {
|
func runBootstrapper(t *TestEnvironment) error {
|
||||||
@ -35,10 +38,12 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
for mine {
|
var i int
|
||||||
|
for i = 0; mine; i++ {
|
||||||
|
|
||||||
// synchronize all miners to mine the next block
|
// synchronize all miners to mine the next block
|
||||||
t.RecordMessage("synchronizing all miners to mine next block")
|
t.RecordMessage("synchronizing all miners to mine next block [%d]", i)
|
||||||
|
stateMineNext := sync.State(fmt.Sprintf("mine-block-%d", i))
|
||||||
t.SyncClient.MustSignalAndWait(ctx, stateMineNext, miners)
|
t.SyncClient.MustSignalAndWait(ctx, stateMineNext, miners)
|
||||||
|
|
||||||
// add some random delay to encourage a different miner winning each round
|
// add some random delay to encourage a different miner winning each round
|
||||||
@ -51,6 +56,11 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// signal the last block to make sure no miners are left stuck waiting for the next block signal
|
||||||
|
// while the others have stopped
|
||||||
|
stateMineLast := sync.State(fmt.Sprintf("mine-block-%d", i))
|
||||||
|
t.SyncClient.MustSignalEntry(ctx, stateMineLast)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// wait for a signal from all clients to stop mining
|
// wait for a signal from all clients to stop mining
|
||||||
|
@ -4,12 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
//"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -31,6 +30,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/modules/lp2p"
|
"github.com/filecoin-project/lotus/node/modules/lp2p"
|
||||||
modtest "github.com/filecoin-project/lotus/node/modules/testing"
|
modtest "github.com/filecoin-project/lotus/node/modules/testing"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"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"
|
||||||
@ -38,11 +38,13 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"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/builtin/verifreg"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
|
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto"
|
libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
"github.com/testground/sdk-go/run"
|
"github.com/testground/sdk-go/run"
|
||||||
"github.com/testground/sdk-go/runtime"
|
"github.com/testground/sdk-go/runtime"
|
||||||
"github.com/testground/sdk-go/sync"
|
"github.com/testground/sdk-go/sync"
|
||||||
@ -75,7 +77,6 @@ var (
|
|||||||
|
|
||||||
stateReady = sync.State("ready")
|
stateReady = sync.State("ready")
|
||||||
stateDone = sync.State("done")
|
stateDone = sync.State("done")
|
||||||
stateMineNext = sync.State("mine-next")
|
|
||||||
stateStopMining = sync.State("stop-mining")
|
stateStopMining = sync.State("stop-mining")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ type InitialBalanceMsg struct {
|
|||||||
|
|
||||||
type PresealMsg struct {
|
type PresealMsg struct {
|
||||||
Miner genesis.Miner
|
Miner genesis.Miner
|
||||||
|
Seqno int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenesisMsg struct {
|
type GenesisMsg struct {
|
||||||
@ -306,7 +308,7 @@ func prepareMiner(t *TestEnvironment) (*Node, error) {
|
|||||||
|
|
||||||
t.RecordMessage("Miner Info: Owner: %s Worker: %s", genMiner.Owner, genMiner.Worker)
|
t.RecordMessage("Miner Info: Owner: %s Worker: %s", genMiner.Owner, genMiner.Worker)
|
||||||
|
|
||||||
presealMsg := &PresealMsg{Miner: *genMiner}
|
presealMsg := &PresealMsg{Miner: *genMiner, Seqno: t.GroupSeq}
|
||||||
t.SyncClient.Publish(ctx, presealTopic, presealMsg)
|
t.SyncClient.Publish(ctx, presealTopic, presealMsg)
|
||||||
|
|
||||||
// then collect the genesis block and bootstrapper address
|
// then collect the genesis block and bootstrapper address
|
||||||
@ -636,6 +638,10 @@ func collectPreseals(t *TestEnvironment, ctx context.Context, miners int) ([]*Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Slice(preseals, func(i, j int) bool {
|
||||||
|
return preseals[i].Seqno < preseals[j].Seqno
|
||||||
|
})
|
||||||
|
|
||||||
return preseals, nil
|
return preseals, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user