Skip to content

Commit bf29b79

Browse files
authored
Merge pull request #73 from getamis/feature/rename-pbft-to-istanbul
All hail Istanbul
2 parents 9c14f8f + bdf8ece commit bf29b79

Some content is hidden

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

57 files changed

+489
-497
lines changed

cmd/geth/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ var (
103103
utils.GpoPercentileFlag,
104104
utils.ExtraDataFlag,
105105
configFileFlag,
106-
utils.PBFTRequestTimeoutFlag,
107-
utils.PBFTBlockPeriodFlag,
108-
utils.PBFTBlockPauseTimeFlag,
109-
utils.PBFTProposerPolicyFlag,
110-
utils.PBFTCheckPointPeriodFlag,
106+
utils.IstanbulRequestTimeoutFlag,
107+
utils.IstanbulBlockPeriodFlag,
108+
utils.IstanbulBlockPauseTimeFlag,
109+
utils.IstanbulProposerPolicyFlag,
110+
utils.IstanbulCheckPointPeriodFlag,
111111
}
112112

113113
rpcFlags = []cli.Flag{

cmd/geth/usage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ var AppHelpFlagGroups = []flagGroup{
188188
},
189189
},
190190
{
191-
Name: "PBFT",
191+
Name: "Istanbul",
192192
Flags: []cli.Flag{
193-
utils.PBFTRequestTimeoutFlag,
194-
utils.PBFTBlockPeriodFlag,
195-
utils.PBFTBlockPauseTimeFlag,
196-
utils.PBFTProposerPolicyFlag,
197-
utils.PBFTCheckPointPeriodFlag,
193+
utils.IstanbulRequestTimeoutFlag,
194+
utils.IstanbulBlockPeriodFlag,
195+
utils.IstanbulBlockPauseTimeFlag,
196+
utils.IstanbulProposerPolicyFlag,
197+
utils.IstanbulCheckPointPeriodFlag,
198198
},
199199
},
200200
}

cmd/utils/flags.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/ethereum/go-ethereum/accounts/keystore"
3333
"github.com/ethereum/go-ethereum/common"
3434
"github.com/ethereum/go-ethereum/consensus/ethash"
35-
"github.com/ethereum/go-ethereum/consensus/pbft"
35+
"github.com/ethereum/go-ethereum/consensus/istanbul"
3636
"github.com/ethereum/go-ethereum/core"
3737
"github.com/ethereum/go-ethereum/core/state"
3838
"github.com/ethereum/go-ethereum/core/vm"
@@ -424,31 +424,31 @@ var (
424424
Value: eth.DefaultConfig.GPO.Percentile,
425425
}
426426

427-
// PBFT settings
428-
PBFTRequestTimeoutFlag = cli.Uint64Flag{
429-
Name: "pbft_request_timeout",
430-
Usage: "The timeout for each PBFT round in millisecond",
431-
Value: eth.DefaultConfig.PBFT.RequestTimeoutMsec,
427+
// Istanbul settings
428+
IstanbulRequestTimeoutFlag = cli.Uint64Flag{
429+
Name: "istanbul_request_timeout",
430+
Usage: "The timeout for each Istanbul round in millisecond",
431+
Value: eth.DefaultConfig.Istanbul.RequestTimeoutMsec,
432432
}
433-
PBFTBlockPeriodFlag = cli.Uint64Flag{
434-
Name: "pbft_block_period",
433+
IstanbulBlockPeriodFlag = cli.Uint64Flag{
434+
Name: "istanbul_block_period",
435435
Usage: "Default minimum difference between two consecutive block's timestamps in second",
436-
Value: eth.DefaultConfig.PBFT.BlockPeriod,
436+
Value: eth.DefaultConfig.Istanbul.BlockPeriod,
437437
}
438-
PBFTBlockPauseTimeFlag = cli.Uint64Flag{
439-
Name: "pbft_block_pause_time",
440-
Usage: "Pause time when zero tx in previous block, values should be larger than pbft_block_period",
441-
Value: eth.DefaultConfig.PBFT.BlockPauseTime,
438+
IstanbulBlockPauseTimeFlag = cli.Uint64Flag{
439+
Name: "istanbul_block_pause_time",
440+
Usage: "Pause time when zero tx in previous block, values should be larger than istanbul_block_period",
441+
Value: eth.DefaultConfig.Istanbul.BlockPauseTime,
442442
}
443-
PBFTProposerPolicyFlag = cli.IntFlag{
444-
Name: "pbft_proposer_policy",
443+
IstanbulProposerPolicyFlag = cli.IntFlag{
444+
Name: "istanbul_proposer_policy",
445445
Usage: "The policy for proposer, the detail is not determined",
446-
Value: int(eth.DefaultConfig.PBFT.ProposerPolicy),
446+
Value: int(eth.DefaultConfig.Istanbul.ProposerPolicy),
447447
}
448-
PBFTCheckPointPeriodFlag = cli.IntFlag{
449-
Name: "pbft_cp_period",
448+
IstanbulCheckPointPeriodFlag = cli.IntFlag{
449+
Name: "istanbul_cp_period",
450450
Usage: "Synchronizes the mapping's checkpoint to the blocks on each round",
451-
Value: eth.DefaultConfig.PBFT.CheckPointPeriod,
451+
Value: eth.DefaultConfig.Istanbul.CheckPointPeriod,
452452
}
453453
)
454454

@@ -829,21 +829,21 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) {
829829
}
830830
}
831831

832-
func setPBFT(ctx *cli.Context, cfg *eth.Config) {
833-
if ctx.GlobalIsSet(PBFTRequestTimeoutFlag.Name) {
834-
cfg.PBFT.RequestTimeoutMsec = ctx.GlobalUint64(PBFTRequestTimeoutFlag.Name)
832+
func setIstanbul(ctx *cli.Context, cfg *eth.Config) {
833+
if ctx.GlobalIsSet(IstanbulRequestTimeoutFlag.Name) {
834+
cfg.Istanbul.RequestTimeoutMsec = ctx.GlobalUint64(IstanbulRequestTimeoutFlag.Name)
835835
}
836-
if ctx.GlobalIsSet(PBFTBlockPeriodFlag.Name) {
837-
cfg.PBFT.BlockPeriod = ctx.GlobalUint64(PBFTBlockPeriodFlag.Name)
836+
if ctx.GlobalIsSet(IstanbulBlockPeriodFlag.Name) {
837+
cfg.Istanbul.BlockPeriod = ctx.GlobalUint64(IstanbulBlockPeriodFlag.Name)
838838
}
839-
if ctx.GlobalIsSet(PBFTBlockPauseTimeFlag.Name) {
840-
cfg.PBFT.BlockPauseTime = ctx.GlobalUint64(PBFTBlockPauseTimeFlag.Name)
839+
if ctx.GlobalIsSet(IstanbulBlockPauseTimeFlag.Name) {
840+
cfg.Istanbul.BlockPauseTime = ctx.GlobalUint64(IstanbulBlockPauseTimeFlag.Name)
841841
}
842-
if ctx.GlobalIsSet(PBFTProposerPolicyFlag.Name) {
843-
cfg.PBFT.ProposerPolicy = pbft.ProposerPolicy(ctx.GlobalInt(PBFTProposerPolicyFlag.Name))
842+
if ctx.GlobalIsSet(IstanbulProposerPolicyFlag.Name) {
843+
cfg.Istanbul.ProposerPolicy = istanbul.ProposerPolicy(ctx.GlobalInt(IstanbulProposerPolicyFlag.Name))
844844
}
845-
if ctx.GlobalIsSet(PBFTCheckPointPeriodFlag.Name) {
846-
cfg.PBFT.CheckPointPeriod = ctx.GlobalInt(PBFTCheckPointPeriodFlag.Name)
845+
if ctx.GlobalIsSet(IstanbulCheckPointPeriodFlag.Name) {
846+
cfg.Istanbul.CheckPointPeriod = ctx.GlobalInt(IstanbulCheckPointPeriodFlag.Name)
847847
}
848848
}
849849

@@ -869,7 +869,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
869869
setEtherbase(ctx, ks, cfg)
870870
setGPO(ctx, &cfg.GPO)
871871
setEthash(ctx, cfg)
872-
setPBFT(ctx, cfg)
872+
setIstanbul(ctx, cfg)
873873
switch {
874874
case ctx.GlobalIsSet(SyncModeFlag.Name):
875875
cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)

consensus/consensus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ type PoW interface {
103103
Hashrate() float64
104104
}
105105

106-
// PBFT is a consensus engine to avoid byzantine failure
107-
type PBFT interface {
106+
// Istanbul is a consensus engine to avoid byzantine failure
107+
type Istanbul interface {
108108
Engine
109109

110110
// Add a peer

consensus/pbft/backend.go renamed to consensus/istanbul/backend.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package pbft
17+
package istanbul
1818

1919
import (
2020
"github.com/ethereum/go-ethereum/common"
2121
"github.com/ethereum/go-ethereum/event"
2222
)
2323

24-
// Backend provides application specific functions for PBFT core
24+
// Backend provides application specific functions for Istanbul core
2525
type Backend interface {
2626
// Address returns self address
2727
Address() common.Address
@@ -62,7 +62,7 @@ type Backend interface {
6262
Persistence
6363
}
6464

65-
// Persistence provides persistence data storage for PBFT core
65+
// Persistence provides persistence data storage for Istanbul core
6666
type Persistence interface {
6767
// Save an object into database
6868
Save(key string, val interface{}) error

consensus/pbft/backends/simple/api.go renamed to consensus/istanbul/backends/simple/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/ethereum/go-ethereum/log"
2525
)
2626

27-
// API is a user facing RPC API to dump PBFT state
27+
// API is a user facing RPC API to dump Istanbul state
2828
type API struct {
2929
chain consensus.ChainReader
3030
backend *simpleBackend

consensus/pbft/backends/simple/backend.go renamed to consensus/istanbul/backends/simple/backend.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
"github.com/ethereum/go-ethereum/common"
2424
"github.com/ethereum/go-ethereum/consensus"
25-
"github.com/ethereum/go-ethereum/consensus/pbft"
26-
pbftCore "github.com/ethereum/go-ethereum/consensus/pbft/core"
25+
"github.com/ethereum/go-ethereum/consensus/istanbul"
26+
istanbulCore "github.com/ethereum/go-ethereum/consensus/istanbul/core"
2727
"github.com/ethereum/go-ethereum/core"
2828
"github.com/ethereum/go-ethereum/core/types"
2929
"github.com/ethereum/go-ethereum/crypto"
@@ -32,53 +32,53 @@ import (
3232
"github.com/ethereum/go-ethereum/log"
3333
)
3434

35-
// New creates an Ethereum backend for PBFT core engine.
36-
func New(config *pbft.Config, eventMux *event.TypeMux, privateKey *ecdsa.PrivateKey, db ethdb.Database) consensus.PBFT {
35+
// New creates an Ethereum backend for Istanbul core engine.
36+
func New(config *istanbul.Config, eventMux *event.TypeMux, privateKey *ecdsa.PrivateKey, db ethdb.Database) consensus.Istanbul {
3737
backend := &simpleBackend{
38-
config: config,
39-
peerSet: newPeerSet(),
40-
eventMux: eventMux,
41-
pbftEventMux: new(event.TypeMux),
42-
privateKey: privateKey,
43-
address: crypto.PubkeyToAddress(privateKey.PublicKey),
44-
logger: log.New("backend", "simple"),
45-
db: db,
46-
commitCh: make(chan common.Hash, 1),
38+
config: config,
39+
peerSet: newPeerSet(),
40+
eventMux: eventMux,
41+
istanbulEventMux: new(event.TypeMux),
42+
privateKey: privateKey,
43+
address: crypto.PubkeyToAddress(privateKey.PublicKey),
44+
logger: log.New("backend", "simple"),
45+
db: db,
46+
commitCh: make(chan common.Hash, 1),
4747
}
4848
return backend
4949
}
5050

5151
// ----------------------------------------------------------------------------
5252

5353
type simpleBackend struct {
54-
config *pbft.Config
55-
peerSet *peerSet
56-
valSet pbft.ValidatorSet
57-
eventMux *event.TypeMux
58-
pbftEventMux *event.TypeMux
59-
privateKey *ecdsa.PrivateKey
60-
address common.Address
61-
core pbftCore.Engine
62-
logger log.Logger
63-
quitSync chan struct{}
64-
db ethdb.Database
65-
timeout uint64
66-
chain consensus.ChainReader
67-
inserter func(block *types.Block) error
68-
69-
// the channels for pbft engine notifications
54+
config *istanbul.Config
55+
peerSet *peerSet
56+
valSet istanbul.ValidatorSet
57+
eventMux *event.TypeMux
58+
istanbulEventMux *event.TypeMux
59+
privateKey *ecdsa.PrivateKey
60+
address common.Address
61+
core istanbulCore.Engine
62+
logger log.Logger
63+
quitSync chan struct{}
64+
db ethdb.Database
65+
timeout uint64
66+
chain consensus.ChainReader
67+
inserter func(block *types.Block) error
68+
69+
// the channels for istanbul engine notifications
7070
commitCh chan common.Hash
7171
proposedBlockHash common.Hash
7272
sealMu sync.Mutex
7373
}
7474

75-
// Address implements pbft.Backend.Address
75+
// Address implements istanbul.Backend.Address
7676
func (sb *simpleBackend) Address() common.Address {
7777
return sb.address
7878
}
7979

80-
// Validators implements pbft.Backend.Validators
81-
func (sb *simpleBackend) Validators() pbft.ValidatorSet {
80+
// Validators implements istanbul.Backend.Validators
81+
func (sb *simpleBackend) Validators() istanbul.ValidatorSet {
8282
return sb.valSet
8383
}
8484

@@ -88,34 +88,34 @@ func (sb *simpleBackend) Send(payload []byte, target common.Address) error {
8888
return errInvalidPeer
8989
}
9090

91-
go sb.eventMux.Post(pbft.ConsensusDataEvent{
91+
go sb.eventMux.Post(istanbul.ConsensusDataEvent{
9292
PeerID: peer.ID(),
9393
Data: payload,
9494
})
9595
return nil
9696
}
9797

98-
// Broadcast implements pbft.Backend.Send
98+
// Broadcast implements istanbul.Backend.Send
9999
func (sb *simpleBackend) Broadcast(payload []byte) error {
100-
pbftMsg := pbft.MessageEvent{
100+
istanbulMsg := istanbul.MessageEvent{
101101
Payload: payload,
102102
}
103103

104104
// send to self
105-
go sb.pbftEventMux.Post(pbftMsg)
105+
go sb.istanbulEventMux.Post(istanbulMsg)
106106

107107
// send to other peers
108108
for _, peer := range sb.peerSet.List() {
109-
go sb.eventMux.Post(pbft.ConsensusDataEvent{
109+
go sb.eventMux.Post(istanbul.ConsensusDataEvent{
110110
PeerID: peer.ID(),
111111
Data: payload,
112112
})
113113
}
114114
return nil
115115
}
116116

117-
// Commit implements pbft.Backend.Commit
118-
func (sb *simpleBackend) Commit(proposal pbft.Proposal) error {
117+
// Commit implements istanbul.Backend.Commit
118+
func (sb *simpleBackend) Commit(proposal istanbul.Proposal) error {
119119
// Check if the proposal is a valid block
120120
block := &types.Block{}
121121
block, ok := proposal.(*types.Block)
@@ -148,13 +148,13 @@ func (sb *simpleBackend) NextRound() error {
148148
return nil
149149
}
150150

151-
// EventMux implements pbft.Backend.EventMux
151+
// EventMux implements istanbul.Backend.EventMux
152152
func (sb *simpleBackend) EventMux() *event.TypeMux {
153-
return sb.pbftEventMux
153+
return sb.istanbulEventMux
154154
}
155155

156-
// Verify implements pbft.Backend.Verify
157-
func (sb *simpleBackend) Verify(proposal pbft.Proposal) error {
156+
// Verify implements istanbul.Backend.Verify
157+
func (sb *simpleBackend) Verify(proposal istanbul.Proposal) error {
158158
// Check if the proposal is a valid block
159159
block := &types.Block{}
160160
block, ok := proposal.(*types.Block)
@@ -166,13 +166,13 @@ func (sb *simpleBackend) Verify(proposal pbft.Proposal) error {
166166
return sb.VerifyHeader(sb.chain, block.Header(), false)
167167
}
168168

169-
// Sign implements pbft.Backend.Sign
169+
// Sign implements istanbul.Backend.Sign
170170
func (sb *simpleBackend) Sign(data []byte) ([]byte, error) {
171171
hashData := crypto.Keccak256([]byte(data))
172172
return crypto.Sign(hashData, sb.privateKey)
173173
}
174174

175-
// CheckSignature implements pbft.Backend.CheckSignature
175+
// CheckSignature implements istanbul.Backend.CheckSignature
176176
func (sb *simpleBackend) CheckSignature(data []byte, address common.Address, sig []byte) error {
177177
signer, err := sb.getSignatureAddress(data, sig)
178178
if err != nil {
@@ -186,7 +186,7 @@ func (sb *simpleBackend) CheckSignature(data []byte, address common.Address, sig
186186
return nil
187187
}
188188

189-
// CheckValidatorSignature implements pbft.Backend.CheckValidatorSignature
189+
// CheckValidatorSignature implements istanbul.Backend.CheckValidatorSignature
190190
func (sb *simpleBackend) CheckValidatorSignature(data []byte, sig []byte) (common.Address, error) {
191191
// 1. Get signature address
192192
signer, err := sb.getSignatureAddress(data, sig)
@@ -200,7 +200,7 @@ func (sb *simpleBackend) CheckValidatorSignature(data []byte, sig []byte) (commo
200200
return val.Address(), nil
201201
}
202202

203-
return common.Address{}, pbft.ErrUnauthorizedAddress
203+
return common.Address{}, istanbul.ErrUnauthorizedAddress
204204
}
205205

206206
// get the signer address from the signature

0 commit comments

Comments
 (0)