Merge pull request #1541 from filecoin-project/feat/drand-2
real drand network integration
This commit is contained in:
@@ -283,6 +283,7 @@ func Online() Option {
|
||||
Override(new(sealing.TicketFn), modules.SealTicketGen),
|
||||
Override(new(*storage.Miner), modules.StorageMiner),
|
||||
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
||||
Override(new(beacon.RandomBeacon), modules.MinerRandomBeacon),
|
||||
|
||||
Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
|
||||
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
||||
@@ -485,5 +486,6 @@ func Test() Option {
|
||||
return Options(
|
||||
Unset(RunPeerMgrKey),
|
||||
Unset(new(*peermgr.PeerMgr)),
|
||||
Override(new(beacon.RandomBeacon), testing.RandomBeacon),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package modules
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
eventbus "github.com/libp2p/go-eventbus"
|
||||
event "github.com/libp2p/go-libp2p-core/event"
|
||||
@@ -18,8 +17,10 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/beacon"
|
||||
"github.com/filecoin-project/lotus/chain/beacon/drand"
|
||||
"github.com/filecoin-project/lotus/chain/blocksync"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/sub"
|
||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||
"github.com/filecoin-project/lotus/node/hello"
|
||||
@@ -117,6 +118,12 @@ func RetrievalResolver(l *discovery.Local) retrievalmarket.PeerResolver {
|
||||
return discovery.Multi(l)
|
||||
}
|
||||
|
||||
func RandomBeacon() beacon.RandomBeacon {
|
||||
return beacon.NewMockBeacon(build.BlockDelay * time.Second)
|
||||
func RandomBeacon(cs *store.ChainStore, _ dtypes.AfterGenesisSet) (beacon.RandomBeacon, error) {
|
||||
gen, err := cs.GetGenesis()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//return beacon.NewMockBeacon(build.BlockDelay * time.Second)
|
||||
return drand.NewDrandBeacon(gen.Timestamp, build.BlockDelay)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/beacon"
|
||||
"github.com/filecoin-project/lotus/chain/beacon/drand"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/markets/retrievaladapter"
|
||||
@@ -375,3 +376,12 @@ func StorageAuth(ctx helpers.MetricsCtx, ca lapi.Common) (sectorstorage.StorageA
|
||||
headers.Add("Authorization", "Bearer "+string(token))
|
||||
return sectorstorage.StorageAuth(headers), nil
|
||||
}
|
||||
|
||||
func MinerRandomBeacon(api lapi.FullNode) (beacon.RandomBeacon, error) {
|
||||
gents, err := api.ChainGetGenesis(context.TODO())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return drand.NewDrandBeacon(gents.Blocks()[0].Timestamp, build.BlockDelay)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/beacon"
|
||||
)
|
||||
|
||||
func RandomBeacon() (beacon.RandomBeacon, error) {
|
||||
return beacon.NewMockBeacon(build.BlockDelay * time.Second), nil
|
||||
}
|
||||
+6
-4
@@ -206,8 +206,9 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
|
||||
}
|
||||
|
||||
templ := &genesis.Template{
|
||||
Accounts: genaccs,
|
||||
Miners: genms,
|
||||
Accounts: genaccs,
|
||||
Miners: genms,
|
||||
Timestamp: uint64(time.Now().Unix() - 1000), // some time sufficiently far in the past
|
||||
}
|
||||
|
||||
// END PRESEAL SECTION
|
||||
@@ -335,8 +336,9 @@ func mockSbBuilder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []t
|
||||
genms = append(genms, *genm)
|
||||
}
|
||||
templ := &genesis.Template{
|
||||
Accounts: genaccs,
|
||||
Miners: genms,
|
||||
Accounts: genaccs,
|
||||
Miners: genms,
|
||||
Timestamp: uint64(time.Now().Unix() - 1000),
|
||||
}
|
||||
|
||||
// END PRESEAL SECTION
|
||||
|
||||
Reference in New Issue
Block a user