Skip to content

Commit f1d8388

Browse files
committed
Renaming qibft to qbft for consistency
1 parent 648b419 commit f1d8388

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+134
-134
lines changed

cmd/utils/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readOnly bool, useExist bool)
21912191
}
21922192
istanbulConfig.ProposerPolicy = istanbul.NewProposerPolicy(istanbul.ProposerPolicyId(config.Istanbul.ProposerPolicy))
21932193
istanbulConfig.Ceil2Nby3Block = config.Istanbul.Ceil2Nby3Block
2194-
istanbulConfig.QibftBlock = config.Istanbul.QibftBlock
2194+
istanbulConfig.QbftBlock = config.Istanbul.QbftBlock
21952195
engine = istanbulBackend.New(istanbulConfig, stack.GetNodeKey(), chainDb)
21962196
} else if config.IsQuorum {
21972197
// for Raft

consensus/istanbul/backend.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ type Backend interface {
7171
// ParentValidators returns the validator set of the given proposal's parent block
7272
ParentValidators(proposal Proposal) ValidatorSet
7373

74-
// HasBadBlock returns whether the block with the hash is a bad block
74+
// HasBadProposal returns whether the block with the hash is a bad block
7575
HasBadProposal(hash common.Hash) bool
7676

7777
Close() error
7878

79-
// IsQIBFTConsensus checks qibftBlock fork block and returns if it should be enabled
80-
IsQIBFTConsensus() bool
79+
// IsQBFTConsensus checks qbftBlock fork block and returns if it should be enabled
80+
IsQBFTConsensus() bool
8181

82-
// StartQBFTConsensus stops existing legacy ibft consensus and starts the new qibft consensus
83-
StartQIBFTConsensus() error
82+
// StartQBFTConsensus stops existing legacy ibft consensus and starts the new qbft consensus
83+
StartQBFTConsensus() error
8484
}

consensus/istanbul/backend/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (api *API) signers(header *types.Header) (*BlockSigners, error) {
8383
return nil, err
8484
}
8585

86-
committers, err := api.istanbul.Signers(header, api.istanbul.IsQIBFTConsensusForHeader(header))
86+
committers, err := api.istanbul.Signers(header, api.istanbul.IsQBFTConsensusForHeader(header))
8787
if err != nil {
8888
return nil, err
8989
}

consensus/istanbul/backend/backend.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"github.com/ethereum/go-ethereum/consensus/istanbul"
2828
istanbulCore "github.com/ethereum/go-ethereum/consensus/istanbul/core"
2929
"github.com/ethereum/go-ethereum/consensus/istanbul/validator"
30-
qibftCore "github.com/ethereum/go-ethereum/consensus/qibft/core"
31-
qibftMessage "github.com/ethereum/go-ethereum/consensus/qibft/message"
30+
qbftCore "github.com/ethereum/go-ethereum/consensus/qbft/core"
31+
qbftMessage "github.com/ethereum/go-ethereum/consensus/qbft/message"
3232
"github.com/ethereum/go-ethereum/core"
3333
"github.com/ethereum/go-ethereum/core/types"
3434
"github.com/ethereum/go-ethereum/crypto"
@@ -102,7 +102,7 @@ type backend struct {
102102
recentMessages *lru.ARCCache // the cache of peer's messages
103103
knownMessages *lru.ARCCache // the cache of self messages
104104

105-
qibftConsensusEnabled bool // qibft consensus
105+
qbftConsensusEnabled bool // qbft consensus
106106
}
107107

108108
// zekun: HACK
@@ -163,10 +163,10 @@ func (sb *backend) Gossip(valSet istanbul.ValidatorSet, code uint64, payload []b
163163
sb.recentMessages.Add(addr, m)
164164

165165
var outboundCode uint64 = istanbulMsg
166-
if _, ok := qibftMessage.MessageCodes()[code]; ok {
166+
if _, ok := qbftMessage.MessageCodes()[code]; ok {
167167
outboundCode = code
168168
}
169-
if sb.IsQIBFTConsensus() {
169+
if sb.IsQBFTConsensus() {
170170
go p.SendQbftConsensus(outboundCode, payload)
171171
} else {
172172
go p.SendConsensus(outboundCode, payload)
@@ -188,7 +188,7 @@ func (sb *backend) Commit(proposal istanbul.Proposal, seals [][]byte, round *big
188188
h := block.Header()
189189

190190
// Append Round Number and seals into extra-data of qbft consensus
191-
if sb.IsQIBFTConsensus() {
191+
if sb.IsQBFTConsensus() {
192192
err := writeQBFTCommittedSeals(h, seals)
193193
if err != nil {
194194
return err
@@ -353,63 +353,63 @@ func (sb *backend) Close() error {
353353
return nil
354354
}
355355

356-
// IsQIBFTConsensus returns whether qbft consensus should be used
357-
func (sb *backend) IsQIBFTConsensus() bool {
358-
// If qibftBlock is not defined in genesis, then use legacy ibft
359-
if sb.qibftConsensusEnabled {
356+
// IsQBFTConsensus returns whether qbft consensus should be used
357+
func (sb *backend) IsQBFTConsensus() bool {
358+
// If qbftBlock is not defined in genesis, then use legacy ibft
359+
if sb.qbftConsensusEnabled {
360360
return true
361361
}
362362
if sb.chain != nil {
363-
return sb.IsQIBFTConsensusForHeader(sb.chain.CurrentHeader())
363+
return sb.IsQBFTConsensusForHeader(sb.chain.CurrentHeader())
364364
}
365365
return false
366366
}
367367

368-
// IsQIBFTConsensusForHeader checks if qbft consensus is enabled for the block height identified by the given header
369-
func (sb *backend) IsQIBFTConsensusForHeader(header *types.Header) bool {
370-
// If qibftBlock is not defined in genesis, then use legacy ibft
371-
if sb.config.QibftBlock == nil {
368+
// IsQBFTConsensusForHeader checks if qbft consensus is enabled for the block height identified by the given header
369+
func (sb *backend) IsQBFTConsensusForHeader(header *types.Header) bool {
370+
// If qbftBlock is not defined in genesis, then use legacy ibft
371+
if sb.config.QbftBlock == nil {
372372
return false
373373
}
374-
if sb.config.QibftBlock.Uint64() == 0 {
374+
if sb.config.QbftBlock.Uint64() == 0 {
375375
return true
376376
}
377377

378-
if sb.chain != nil && header.Number.Cmp(sb.config.QibftBlock) >= 0 {
378+
if sb.chain != nil && header.Number.Cmp(sb.config.QbftBlock) >= 0 {
379379
return true
380380
}
381381
return false
382382
}
383383

384-
// qbftBlockNumber returns the qibftBlock fork block number
384+
// qbftBlockNumber returns the qbftBlock fork block number
385385
func (sb *backend) qbftBlockNumber() uint64 {
386-
if sb.config.QibftBlock == nil {
386+
if sb.config.QbftBlock == nil {
387387
return 0
388388
}
389-
return sb.config.QibftBlock.Uint64()
389+
return sb.config.QbftBlock.Uint64()
390390
}
391391

392-
// StartQBFTConsensus stops existing legacy ibft consensus and starts the new qibft consensus
393-
func (sb *backend) StartQIBFTConsensus() error {
394-
sb.logger.Trace("Starting QIBFT Consensus")
392+
// StartQBFTConsensus stops existing legacy ibft consensus and starts the new qbft consensus
393+
func (sb *backend) StartQBFTConsensus() error {
394+
sb.logger.Trace("Starting QBFT Consensus")
395395
if err := sb.Stop(); err != nil {
396396
return err
397397
}
398398
sb.logger.Trace("Stopped legacy IBFT consensus")
399399
sb.coreMu.Lock()
400400
defer sb.coreMu.Unlock()
401-
// Set the core to qibft
402-
sb.core = qibftCore.New(sb, sb.config)
401+
// Set the core to qbft
402+
sb.core = qbftCore.New(sb, sb.config)
403403

404-
sb.logger.Trace("Starting qibft")
404+
sb.logger.Trace("Starting qbft")
405405
sb.config.ProposerPolicy.Use(istanbul.ValidatorSortByByteFunc)
406406
if err := sb.core.Start(); err != nil {
407407
return err
408408
}
409409

410-
sb.logger.Trace("Started qibft consensus")
410+
sb.logger.Trace("Started qbft consensus")
411411
sb.coreStarted = true
412-
sb.qibftConsensusEnabled = true
412+
sb.qbftConsensusEnabled = true
413413

414414
return nil
415415
}

consensus/istanbul/backend/backend_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,20 @@ func TestGetProposer(t *testing.T) {
185185
}
186186
}
187187

188-
func TestIsQIBFTConsensus(t *testing.T) {
189-
// Uses Istanbul DefaultConfig which has qibftBlock set to 0
188+
func TestIsQBFTConsensus(t *testing.T) {
189+
// Uses Istanbul DefaultConfig which has qbftBlock set to 0
190190
chain, engine := newLegacyBlockChain(1)
191191

192-
qibftConsensus := engine.IsQIBFTConsensus()
193-
if qibftConsensus {
194-
t.Errorf("IsQIBFTConsensus() should return false")
192+
qbftConsensus := engine.IsQBFTConsensus()
193+
if qbftConsensus {
194+
t.Errorf("IsQBFTConsensus() should return false")
195195
}
196196

197-
// Set the value of qibftBlock to 1
198-
engine.config.QibftBlock = big.NewInt(1)
199-
qibftConsensus = engine.IsQIBFTConsensus()
200-
if qibftConsensus {
201-
t.Errorf("IsQIBFTConsensus() should return false")
197+
// Set the value of qbftBlock to 1
198+
engine.config.QbftBlock = big.NewInt(1)
199+
qbftConsensus = engine.IsQBFTConsensus()
200+
if qbftConsensus {
201+
t.Errorf("IsQBFTConsensus() should return false")
202202
}
203203

204204
// Create an insert a new block into the chain.
@@ -208,9 +208,9 @@ func TestIsQIBFTConsensus(t *testing.T) {
208208
t.Errorf("Error inserting block: %v", err)
209209
}
210210

211-
qibftConsensus = engine.IsQIBFTConsensus()
212-
if !qibftConsensus {
213-
t.Errorf("IsQIBFTConsensus() should return true after block insertion")
211+
qbftConsensus = engine.IsQBFTConsensus()
212+
if !qbftConsensus {
213+
t.Errorf("IsQBFTConsensus() should return true after block insertion")
214214
}
215215
}
216216

consensus/istanbul/backend/engine.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/ethereum/go-ethereum/consensus/istanbul"
3030
istanbulCore "github.com/ethereum/go-ethereum/consensus/istanbul/core"
3131
"github.com/ethereum/go-ethereum/consensus/istanbul/validator"
32-
qibftCore "github.com/ethereum/go-ethereum/consensus/qibft/core"
32+
qbftCore "github.com/ethereum/go-ethereum/consensus/qbft/core"
3333
"github.com/ethereum/go-ethereum/core/state"
3434
"github.com/ethereum/go-ethereum/core/types"
3535
"github.com/ethereum/go-ethereum/log"
@@ -102,7 +102,7 @@ var (
102102
// block, which may be different from the header's coinbase if a consensus
103103
// engine is based on signatures.
104104
func (sb *backend) Author(header *types.Header) (common.Address, error) {
105-
if sb.IsQIBFTConsensus() {
105+
if sb.IsQBFTConsensus() {
106106
return ecrecoverFromCoinbase(header)
107107
}
108108
return ecrecoverFromSignedHeader(header)
@@ -120,7 +120,7 @@ func (sb *backend) Signers(header *types.Header, isQbft bool) ([]common.Address,
120120
return []common.Address{}, err
121121
}
122122
committedSeal = extra.CommittedSeal
123-
proposalSeal = qibftCore.PrepareCommittedSeal(header, extra.Round)
123+
proposalSeal = qbftCore.PrepareCommittedSeal(header, extra.Round)
124124
} else {
125125
extra, err := types.ExtractIstanbulExtra(header)
126126
if err != nil {
@@ -178,7 +178,7 @@ func (sb *backend) verifyHeader(chain consensus.ChainHeaderReader, header *types
178178
}
179179

180180
// Ensure that the extra data format is satisfied
181-
if sb.IsQIBFTConsensus() {
181+
if sb.IsQBFTConsensus() {
182182
if _, err := types.ExtractQbftExtra(header); err != nil {
183183
return errInvalidExtraDataFormat
184184
}
@@ -328,7 +328,7 @@ func (sb *backend) verifyCommittedSeals(chain consensus.ChainHeaderReader, heade
328328
}
329329

330330
var committedSeal [][]byte
331-
if sb.IsQIBFTConsensus() {
331+
if sb.IsQBFTConsensus() {
332332
extra, err := types.ExtractQbftExtra(header)
333333
if err != nil {
334334
return err
@@ -350,7 +350,7 @@ func (sb *backend) verifyCommittedSeals(chain consensus.ChainHeaderReader, heade
350350
validators := snap.ValSet.Copy()
351351
// Check whether the committed seals are generated by parent's validators
352352
validSeal := 0
353-
committers, err := sb.Signers(header, sb.IsQIBFTConsensus())
353+
committers, err := sb.Signers(header, sb.IsQBFTConsensus())
354354
if err != nil {
355355
return err
356356
}
@@ -389,8 +389,8 @@ func (sb *backend) VerifySeal(chain consensus.ChainHeaderReader, header *types.H
389389
// Prepare initializes the consensus fields of a block header according to the
390390
// rules of a particular engine. The changes are executed inline.
391391
func (sb *backend) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
392-
// Check if QiBFT Consensus is used, call the QbftPrepare() is that is the case
393-
if sb.IsQIBFTConsensus() {
392+
// Check if QBFT Consensus is used, call the QbftPrepare() is that is the case
393+
if sb.IsQBFTConsensus() {
394394
return sb.QbftPrepare(chain, header)
395395
}
396396
// unused fields, force to set to empty
@@ -606,7 +606,7 @@ func (sb *backend) Seal(chain consensus.ChainHeaderReader, block *types.Block, r
606606
// update timestamp and signature of the block based on its number of transactions
607607
func (sb *backend) updateBlock(parent *types.Header, block *types.Block) (*types.Block, error) {
608608
header := block.Header()
609-
if sb.IsQIBFTConsensus() {
609+
if sb.IsQBFTConsensus() {
610610
header.Coinbase = sb.address
611611
} else {
612612
// sign the hash
@@ -653,9 +653,9 @@ func (sb *backend) Start(chain consensus.ChainHeaderReader, currentBlock func()
653653
sb.currentBlock = currentBlock
654654
sb.hasBadBlock = hasBadBlock
655655

656-
// Check if qibft Consensus needs to be used after chain is set
657-
if sb.IsQIBFTConsensus() {
658-
sb.core = qibftCore.New(sb, sb.config)
656+
// Check if qbft Consensus needs to be used after chain is set
657+
if sb.IsQBFTConsensus() {
658+
sb.core = qbftCore.New(sb, sb.config)
659659
sb.logger.Trace("Setting ProposerPolicy sorter to ValidatorSortByByteFunc and sort")
660660
sb.config.ProposerPolicy.Use(istanbul.ValidatorSortByByteFunc)
661661
} else {
@@ -668,9 +668,9 @@ func (sb *backend) Start(chain consensus.ChainHeaderReader, currentBlock func()
668668

669669
sb.coreStarted = true
670670

671-
if sb.IsQIBFTConsensus() {
672-
sb.logger.Trace("Started qibft consensus")
673-
sb.qibftConsensusEnabled = true
671+
if sb.IsQBFTConsensus() {
672+
sb.logger.Trace("Started qbft consensus")
673+
sb.qbftConsensusEnabled = true
674674
}
675675

676676
return nil
@@ -688,8 +688,8 @@ func (sb *backend) Stop() error {
688688
}
689689
sb.coreStarted = false
690690

691-
if sb.IsQIBFTConsensus() {
692-
sb.qibftConsensusEnabled = false
691+
if sb.IsQBFTConsensus() {
692+
sb.qbftConsensusEnabled = false
693693
}
694694

695695
return nil
@@ -724,7 +724,7 @@ func (sb *backend) snapshot(chain consensus.ChainHeaderReader, number uint64, ha
724724
}
725725
// Get the validators from genesis to create a snapshot
726726
var validators []common.Address
727-
if sb.IsQIBFTConsensus() {
727+
if sb.IsQBFTConsensus() {
728728
qbftExtra, err := types.ExtractQbftExtra(genesis)
729729
if err != nil {
730730
return nil, err
@@ -768,7 +768,7 @@ func (sb *backend) snapshot(chain consensus.ChainHeaderReader, number uint64, ha
768768
for i := 0; i < len(headers)/2; i++ {
769769
headers[i], headers[len(headers)-1-i] = headers[len(headers)-1-i], headers[i]
770770
}
771-
snap, err := snap.apply(headers, sb.IsQIBFTConsensus(), sb.qbftBlockNumber())
771+
snap, err := snap.apply(headers, sb.IsQBFTConsensus(), sb.qbftBlockNumber())
772772
if err != nil {
773773
return nil, err
774774
}
@@ -808,10 +808,10 @@ func sigHash(header *types.Header, isQbftConsensus bool) (hash common.Hash) {
808808

809809
// SealHash returns the hash of a block prior to it being sealed.
810810
func (sb *backend) SealHash(header *types.Header) common.Hash {
811-
if sb.IsQIBFTConsensus() {
811+
if sb.IsQBFTConsensus() {
812812
header.Coinbase = sb.address
813813
}
814-
return sigHash(header, sb.IsQIBFTConsensus())
814+
return sigHash(header, sb.IsQBFTConsensus())
815815
}
816816

817817
// ecrecoverFromCoinbase extracts the Ethereum account address from coinbase.

consensus/istanbul/backend/engine_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func newBlockChain(n int) (*core.BlockChain, *backend) {
4646
config := istanbul.DefaultConfig
4747
// Use the first key as private key
4848
b, _ := New(config, nodeKeys[0], memDB).(*backend)
49-
// set the qibft consensus enabled to true
50-
b.qibftConsensusEnabled = true
49+
// set the qbft consensus enabled to true
50+
b.qbftConsensusEnabled = true
5151
genesis.MustCommit(memDB)
5252
blockchain, err := core.NewBlockChain(memDB, nil, genesis.Config, b, vm.Config{}, nil, nil)
5353
if err != nil {
@@ -85,7 +85,7 @@ func newLegacyBlockChain(n int) (*core.BlockChain, *backend) {
8585
// Use the first key as private key
8686
b, _ := New(config, nodeKeys[0], memDB).(*backend)
8787

88-
config.QibftBlock = nil
88+
config.QbftBlock = nil
8989

9090
genesis.MustCommit(memDB)
9191
blockchain, err := core.NewBlockChain(memDB, nil, genesis.Config, b, vm.Config{}, nil, nil)
@@ -210,7 +210,7 @@ func makeBlockWithoutSeal(chain *core.BlockChain, engine *backend, parent *types
210210

211211
func TestLegacyPrepare(t *testing.T) {
212212
chain, engine := newBlockChain(1)
213-
chain.Config().Istanbul.QibftBlock = nil
213+
chain.Config().Istanbul.QbftBlock = nil
214214
header := makeHeader(chain.Genesis(), engine.config)
215215
err := engine.Prepare(chain, header)
216216
if err != nil {

0 commit comments

Comments
 (0)