Skip to content

Commit 03c109e

Browse files
committed
stop broadcasting node info for non-active node
1 parent 78c38e5 commit 03c109e

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

blockchain/blockchain.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ func (bc *blockchain) MintNewBlock(timestamp time.Time, opts ...MintOption) (*bl
449449
producerPrivateKey = privateKeys[0]
450450
}
451451
minterAddress := producerPrivateKey.PublicKey().Address()
452+
log.L().Info("Minting a new block.", zap.Uint64("height", newblockHeight), zap.String("minter", minterAddress.String()))
452453
ctx = bc.contextWithBlock(ctx, minterAddress, newblockHeight, timestamp, protocol.CalcBaseFee(genesis.MustExtractGenesisContext(ctx).Blockchain, &tip), protocol.CalcExcessBlobGas(tip.ExcessBlobGas, tip.BlobGasUsed))
453454
ctx = protocol.WithFeatureCtx(ctx)
454455
// run execution and update state trie root hash

chainservice/builder.go

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -528,24 +528,29 @@ func (builder *Builder) buildNodeInfoManager() error {
528528
return errors.New("cannot find staking protocol")
529529
}
530530
chain := builder.cs.chain
531-
dm := nodeinfo.NewInfoManager(&builder.cfg.NodeInfo, cs.p2pAgent, cs.chain, func() []string {
532-
ctx := protocol.WithFeatureCtx(
533-
protocol.WithBlockCtx(
534-
genesis.WithGenesisContext(context.Background(), chain.Genesis()),
535-
protocol.BlockCtx{BlockHeight: chain.TipHeight()},
536-
),
537-
)
538-
candidates, err := stk.ActiveCandidates(ctx, cs.factory, 0)
539-
if err != nil {
540-
log.L().Error("failed to get active candidates", zap.Error(errors.WithStack(err)))
541-
return nil
542-
}
543-
whiteList := make([]string, len(candidates))
544-
for i := range whiteList {
545-
whiteList[i] = candidates[i].Address
546-
}
547-
return whiteList
548-
}, builder.cfg.Chain.ProducerPrivateKeys()...)
531+
var dm *nodeinfo.InfoManager
532+
if builder.cfg.System.Active {
533+
dm = nodeinfo.NewInfoManager(&builder.cfg.NodeInfo, cs.p2pAgent, cs.chain, func() []string {
534+
ctx := protocol.WithFeatureCtx(
535+
protocol.WithBlockCtx(
536+
genesis.WithGenesisContext(context.Background(), chain.Genesis()),
537+
protocol.BlockCtx{BlockHeight: chain.TipHeight()},
538+
),
539+
)
540+
candidates, err := stk.ActiveCandidates(ctx, cs.factory, 0)
541+
if err != nil {
542+
log.L().Error("failed to get active candidates", zap.Error(errors.WithStack(err)))
543+
return nil
544+
}
545+
whiteList := make([]string, len(candidates))
546+
for i := range whiteList {
547+
whiteList[i] = candidates[i].Address
548+
}
549+
return whiteList
550+
}, builder.cfg.Chain.ProducerPrivateKeys()...)
551+
} else {
552+
dm = nodeinfo.NewInfoManager(&builder.cfg.NodeInfo, cs.p2pAgent, cs.chain, nil)
553+
}
549554
builder.cs.nodeInfoManager = dm
550555
builder.cs.lifecycle.Add(dm)
551556
return nil

0 commit comments

Comments
 (0)