Skip to content

Commit

Permalink
Merge pull request #229 from ipfs-force-community/chore/bump-v1.13.1
Browse files Browse the repository at this point in the history
Chore/bump v1.13.1
  • Loading branch information
LinZexiao authored Sep 21, 2023
2 parents 1ccad85 + 464bce9 commit da99eb0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/client/submitblock_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
v1 "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
)

func NewSubmitBlockRPC(ctx context.Context, apiInfo *config.APIInfo) (v1.FullNode, jsonrpc.ClientCloser, error) {
func NewFullNodeRPC(ctx context.Context, apiInfo *config.APIInfo) (v1.FullNode, jsonrpc.ClientCloser, error) {
addr, err := apiInfo.DialArgs("v1")
if err != nil {
return nil, nil, fmt.Errorf("could not get DialArgs: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package build
var CurrentCommit string

// BuildVersion is the local build version, set by build system
const BuildVersion = "1.13.0"
const Version = "1130"
const BuildVersion = "1.13.1"
const Version = "1131"

func UserVersion() string {
return BuildVersion + CurrentCommit
Expand Down
57 changes: 56 additions & 1 deletion miner/multiminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ func (m *Miner) mine(ctx context.Context) {
log.Info("no block and increase nullround")
}

go m.tryGetBeacon(ctx, *base)

// Wait until the next epoch, plus the propagation delay, so a new tipset
// has enough time to form.
m.untilNextEpoch(base)
Expand All @@ -473,8 +475,56 @@ func (m *Miner) mine(ctx context.Context) {
}
}

func (m *Miner) tryGetBeacon(ctx context.Context, base MiningBase) {
delay := 3
next := time.Unix(int64(base.TipSet.MinTimestamp()+m.networkParams.BlockDelaySecs*uint64(base.NullRounds+1))+int64(delay), 0)

select {
case <-build.Clock.After(build.Clock.Until(next)):
head, err := m.api.ChainHead(ctx)
if err != nil {
log.Infof("got head failed: %v", err)
return
}

round := head.Height() + 1
nodes := m.submitNodes

log.Infof("try get beacon at: %d", round)

call := func(api v1api.FullNode) {
start := time.Now()
// Nodes will cache beacons to avoid slow beacon acquisition
if _, err = api.StateGetBeaconEntry(ctx, round); err != nil {
log.Infof("got beacon failed: %v", err)
return
}
took := time.Since(start)
if took > time.Second*6 {
log.Infof("got beacon slow: %v", took)
}
}

go call(m.api)

for _, node := range nodes {
api, closer, err := client.NewFullNodeRPC(ctx, node)
if err != nil {
log.Warnf("new node rpc failed: %v", err)
continue
}
go func() {
defer closer()

call(api)
}()
}
case <-ctx.Done():
}
}

func (m *Miner) submitBlock(ctx context.Context, bm *sharedTypes.BlockMsg, apiInfo *config.APIInfo) error {
submitAPI, closer, err := client.NewSubmitBlockRPC(ctx, apiInfo)
submitAPI, closer, err := client.NewFullNodeRPC(ctx, apiInfo)
if err != nil {
return fmt.Errorf("conn to submit-node %v failed: %w", apiInfo.Addr, err)
}
Expand Down Expand Up @@ -573,11 +623,16 @@ func (m *Miner) getLatestBase(ctx context.Context) (*MiningBase, time.Duration,
continue
}

start := time.Now()
// just wait for the beacon entry to become available before we select our final mining base
_, err = m.api.StateGetBeaconEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1)
if err != nil {
return nil, time.Second, fmt.Errorf("getting beacon entry: %w", err)
}
took := time.Since(start)
if took > time.Second*3 {
log.Infof("got beacon slow: %v", took)
}

base = prebase
}
Expand Down

0 comments on commit da99eb0

Please sign in to comment.