Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBFT 2.0 #650

Merged
merged 160 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
f7a83d5
Remove v1 code
Kourin1996 Jun 15, 2022
30a374c
Add skelton code of syncer v2
Kourin1996 Jun 15, 2022
8476fec
Add PeerHeap in syncer package
Kourin1996 Jun 15, 2022
d568bd9
Fix build error
Kourin1996 Jun 15, 2022
872f785
Separate syncer and gRPC client to improve extensibility
Kourin1996 Jun 15, 2022
17fd0aa
Remove NotifyStatus RPC call and add gossip
Kourin1996 Jun 17, 2022
65ccd2e
Removed UpdateLatestBlock from IBFT
Kourin1996 Jun 17, 2022
08f8475
Add retry mechanism in bulk sync
Kourin1996 Jun 17, 2022
04c9f7b
Remove peer that failed to sync in bulk sync
Kourin1996 Jun 17, 2022
c5334fd
Add ID in gossip handler & remove peer from map on disconnection in s…
Kourin1996 Jun 17, 2022
fc609e1
Add timeout in GettingStatuses
Kourin1996 Jun 17, 2022
926a65e
Remove error check from stream.Recv
Kourin1996 Jun 17, 2022
9865ceb
Rename method
Kourin1996 Jun 17, 2022
fb1fd14
Fix lint error
Kourin1996 Jun 17, 2022
074b472
Fix minor issue
Kourin1996 Jun 17, 2022
2962553
Subscribe connected event in syncer
Kourin1996 Jun 17, 2022
6cb74b2
Clean up code
Kourin1996 Jun 17, 2022
ef8b18e
Rename Status to SyncPeerStatus in proto
Kourin1996 Jun 17, 2022
67e14ff
Fix wrong order of checks in syncer
Kourin1996 Jun 17, 2022
5b48103
Fix peerID type in syncer
Kourin1996 Jun 17, 2022
a03539d
Fix build error
Kourin1996 Jun 21, 2022
4b50a04
Rename method in syncer
Kourin1996 Jun 22, 2022
0bce284
Fix key in PeerMap of Syncer package
Kourin1996 Jun 22, 2022
8a77787
Fix start progression in BulkSync
Kourin1996 Jun 22, 2022
71b37cc
Remove GetBlock from SyncPeerService
Kourin1996 Jun 22, 2022
5a684c8
Filter peer event in syncPeerClient
Kourin1996 Jun 22, 2022
18c87c2
Fix peer.ID conversion
Kourin1996 Jun 22, 2022
a052a6f
Fix lint error
Kourin1996 Jun 23, 2022
4f7eaa5
Feature/sync v2 watch sync implementation (#598)
0xAleksaOpacic Jun 24, 2022
8e361fd
Syncer V2 Unit Tests (#605)
Kourin1996 Jun 24, 2022
57f7d9b
Remove GetBlock from gRPC in syncer
Kourin1996 Jun 27, 2022
85c8b68
Rename logger name
Kourin1996 Jul 1, 2022
8f801c4
Add more logs revert later
0xAleksaOpacic Jul 1, 2022
09e9787
Add more logs revert later
0xAleksaOpacic Jul 1, 2022
1d536eb
Fix initialization of sync.Mutex
Kourin1996 Jul 4, 2022
3b6097c
Merge remote-tracking branch 'origin/feature/sync-v2' into feature/sy…
Kourin1996 Jul 4, 2022
d75dc06
Fix codes based on reviews
Kourin1996 Jul 4, 2022
02c0803
Add comments in Syncer
Kourin1996 Jul 4, 2022
e570684
Add syncer close
Kourin1996 Jul 4, 2022
cb1ec52
Add timeout per block in GetBlocks
Kourin1996 Jul 5, 2022
de1f1cd
Fix lint error
Kourin1996 Jul 5, 2022
b51dc66
Add comments in syncer
Kourin1996 Jul 5, 2022
03dc08a
Remove nolint
Kourin1996 Jul 5, 2022
e8fa917
fix linter issues
0xAleksaOpacic Jul 6, 2022
3a189f2
Add comment in protoc
Kourin1996 Jul 7, 2022
591f7b7
Merge remote-tracking branch 'origin/feature/sync-v2' into feature/sy…
Kourin1996 Jul 7, 2022
b8e00b0
add todo
dbrajovic Jul 9, 2022
f573d75
indentation
dbrajovic Jul 9, 2022
4739aa3
add todo
dbrajovic Jul 10, 2022
4f183ff
add todo
dbrajovic Jul 10, 2022
ade51c6
add todo
dbrajovic Jul 10, 2022
c27185f
add todo
dbrajovic Jul 11, 2022
5cd32a1
add todo
dbrajovic Jul 11, 2022
c39e94b
add todo
dbrajovic Jul 11, 2022
49c09c2
add todo
dbrajovic Jul 11, 2022
31d6212
add todo
dbrajovic Jul 11, 2022
ffa255d
add todo
dbrajovic Jul 11, 2022
7a747dd
add todo
dbrajovic Jul 11, 2022
cadaeee
add todo
dbrajovic Jul 11, 2022
bca800c
add todo
dbrajovic Jul 11, 2022
7a27fb3
add todo
dbrajovic Jul 11, 2022
e9c4a34
add todo
dbrajovic Jul 11, 2022
923aa5b
add todo
dbrajovic Jul 11, 2022
fe33631
add todo
dbrajovic Jul 11, 2022
65ea653
add todo
dbrajovic Jul 11, 2022
f982370
add todo
dbrajovic Jul 11, 2022
2f230b6
add todo
dbrajovic Jul 11, 2022
3413048
add todo
dbrajovic Jul 11, 2022
bb0d493
add todo
dbrajovic Jul 12, 2022
dcebabc
add todo
dbrajovic Jul 12, 2022
b072efe
add todo
dbrajovic Jul 12, 2022
37b8b17
add todo
dbrajovic Jul 12, 2022
fac1192
add todo
dbrajovic Jul 12, 2022
e08e0f7
add todo
dbrajovic Jul 12, 2022
52ff1a9
add todo
dbrajovic Jul 12, 2022
5d80535
remove todo
dbrajovic Jul 12, 2022
667c8d4
rename symbol
dbrajovic Jul 12, 2022
4d4c58c
add todo
dbrajovic Jul 12, 2022
a228134
add todo
dbrajovic Jul 12, 2022
80db09f
add todo
dbrajovic Jul 12, 2022
f1dfa25
add todo
dbrajovic Jul 12, 2022
a40618b
add todo
dbrajovic Jul 12, 2022
0dff511
add todo
dbrajovic Jul 12, 2022
bfe8ba8
rename package: backend
dbrajovic Jul 12, 2022
ecef000
rename interface
dbrajovic Jul 12, 2022
c95e21c
rename struct
dbrajovic Jul 12, 2022
962731a
rename file
dbrajovic Jul 12, 2022
5e5c352
rename field
dbrajovic Jul 12, 2022
830ab49
reorder fields
dbrajovic Jul 12, 2022
ca81d95
reorder func
dbrajovic Jul 12, 2022
f5c27fc
init syncer field in ctor
dbrajovic Jul 12, 2022
aab2f41
remove description
dbrajovic Jul 12, 2022
960fe4d
add stub file: backend_dummy.go
dbrajovic Jul 12, 2022
723364b
add todo
dbrajovic Jul 12, 2022
f9f8eee
write BuildProposal
dbrajovic Jul 12, 2022
71d0fe4
write ID
dbrajovic Jul 12, 2022
0b82009
write MaxFaultyNodes
dbrajovic Jul 12, 2022
d166dea
add field currentValidatorset to Ibft
dbrajovic Jul 12, 2022
f622139
write Quorum/MaxFaultyNodes
dbrajovic Jul 12, 2022
7c05662
add todo
dbrajovic Jul 12, 2022
775dc7f
add Verifier impl/IsValidBlock
dbrajovic Jul 12, 2022
46cfd9f
write IsProposer
dbrajovic Jul 13, 2022
d21fd54
write IsValidProposalHash
dbrajovic Jul 13, 2022
6420bf0
write IsValidCommittedSeal
dbrajovic Jul 13, 2022
86eea5e
add todo
dbrajovic Jul 13, 2022
6d5148f
import go-ibft
dbrajovic Jul 13, 2022
aaa48c6
add todo
dbrajovic Jul 13, 2022
fa2a2f7
add todo
dbrajovic Jul 13, 2022
46e07ea
implement MessageCOnstructor interface
dbrajovic Jul 13, 2022
7bd0671
implement IsValidSender
dbrajovic Jul 13, 2022
fde304c
implement InsertBlock
dbrajovic Jul 13, 2022
f3a0ca3
add todo
dbrajovic Jul 13, 2022
3299454
Merge branch 'develop' into experimental/backend-stub
dbrajovic Jul 13, 2022
e25bf47
add todo
dbrajovic Jul 13, 2022
342ae3f
add consensus field (go-ibft)
dbrajovic Jul 14, 2022
2e0a832
add new start method
dbrajovic Jul 14, 2022
667ba54
add RunSequence in start method
dbrajovic Jul 14, 2022
bd8097c
update currentValidatorSet on init
dbrajovic Jul 14, 2022
ea94053
update currentValidatorSet when processing headers
dbrajovic Jul 14, 2022
ec8591a
block time based transaciton execution
dbrajovic Jul 14, 2022
e1cf813
setup transport protocol with new ibft
dbrajovic Jul 14, 2022
0894fe2
gossip protoIBFT messages
dbrajovic Jul 14, 2022
5d24d87
rewire logic for new consensus
dbrajovic Jul 14, 2022
5cfb55e
working impl
dbrajovic Jul 18, 2022
fafac7e
add cache to snapshot store and rewrite ibft start method
dbrajovic Jul 18, 2022
58486cd
refactor consensus into separate struct
dbrajovic Jul 18, 2022
5878f11
cleanup
dbrajovic Jul 19, 2022
139a743
clean up verifier.go
dbrajovic Jul 19, 2022
826551c
remove todo
dbrajovic Jul 19, 2022
98fe221
clean up ibft wrapper
dbrajovic Jul 19, 2022
9f0f3b5
clean up messages.go
dbrajovic Jul 19, 2022
4d0c9ba
cleanup
dbrajovic Jul 19, 2022
b7faf4d
clean up package
dbrajovic Jul 19, 2022
2be77ba
upgrade buildPrePrepareMessage
dbrajovic Jul 22, 2022
887d0fd
upgrade buildPrepareMessage
dbrajovic Jul 22, 2022
21037bb
upgrade BuildCommitMessage
dbrajovic Jul 22, 2022
aa22128
upgrade buildRoundChangeMessage
dbrajovic Jul 22, 2022
c8d2dce
remove log
dbrajovic Jul 22, 2022
5444282
improve log
dbrajovic Jul 22, 2022
609f931
update interface signature
dbrajovic Jul 22, 2022
6a562d7
remove backend logger name
dbrajovic Jul 22, 2022
6fd302d
Cleanup after package import
zivkovicmilos Jul 24, 2022
41599fe
Revise the test server ready condition
zivkovicmilos Jul 24, 2022
267513a
Merge branch 'develop' into feature/backend-m2
zivkovicmilos Jul 26, 2022
3e1222d
Resolve commit message seal issue
zivkovicmilos Jul 26, 2022
3c7215e
Resolve failing E2E tests
zivkovicmilos Jul 26, 2022
f4f6e66
Provide backwards compatibility with the legacy seals
zivkovicmilos Jul 27, 2022
a0e43a3
Resolve linting errors
zivkovicmilos Jul 27, 2022
addcf45
Add source for dev consensus
zivkovicmilos Jul 29, 2022
e089b5c
Add constant for restore
zivkovicmilos Jul 29, 2022
24b99b1
Add constant for the syncer
zivkovicmilos Jul 29, 2022
375a01e
Drop BulkSync
zivkovicmilos Jul 29, 2022
e9595a8
Add error log for block building
zivkovicmilos Jul 29, 2022
8769ea2
Upgrade the go-ibft package version
zivkovicmilos Jul 29, 2022
97367fb
Add filter for stale insertion events
zivkovicmilos Jul 29, 2022
1a24015
Merge branch 'develop' into feature/backend-m2
zivkovicmilos Jul 29, 2022
295c895
Merge
zivkovicmilos Jul 29, 2022
1e97c21
Add signer extraction in the txpool
zivkovicmilos Aug 2, 2022
e4f7f76
Remove unused hooks
zivkovicmilos Aug 3, 2022
6e4c0a9
Deprecate legacy round timeout flag
zivkovicmilos Aug 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions archive/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import (
"github.com/0xPolygon/polygon-edge/types"
)

const (
restore = "restore"
)

type blockchainInterface interface {
SubscribeEvents() blockchain.Subscription
Genesis() types.Hash
GetBlockByNumber(uint64, bool) (*types.Block, bool)
GetHashByNumber(uint64) types.Hash
WriteBlock(*types.Block) error
WriteBlock(*types.Block, string) error
VerifyFinalizedBlock(*types.Block) error
}

Expand Down Expand Up @@ -78,7 +82,7 @@ func importBlocks(chain blockchainInterface, blockStream *blockStream, progressi
return err
}

if err := chain.WriteBlock(nextBlock); err != nil {
if err := chain.WriteBlock(nextBlock, restore); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion archive/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *mockChain) GetHashByNumber(num uint64) types.Hash {
return b.Hash()
}

func (m *mockChain) WriteBlock(block *types.Block) error {
func (m *mockChain) WriteBlock(block *types.Block, _ string) error {
m.blocks = append(m.blocks, block)

return nil
Expand Down
26 changes: 15 additions & 11 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Blockchain struct {
stream *eventStream // Event subscriptions

gpAverage *gasPriceAverage // A reference to the average gas price

writeLock sync.Mutex
}

// gasPriceAverage keeps track of the average gas price (rolling average)
Expand All @@ -88,6 +90,7 @@ type Verifier interface {
PreStateCommit(header *types.Header, txn *state.Transition) error
}

// TODO: this should be part of Verifier (consensus)
type Executor interface {
ProcessBlock(parentRoot types.Hash, block *types.Block, blockCreator types.Address) (*state.Transition, error)
}
Expand Down Expand Up @@ -859,15 +862,15 @@ func (b *Blockchain) executeBlockTransactions(block *types.Block) (*BlockResult,

// WriteBlock writes a single block to the local blockchain.
// It doesn't do any kind of verification, only commits the block to the DB
func (b *Blockchain) WriteBlock(block *types.Block) error {
// Log the information
b.logger.Info(
"write block",
"num",
block.Number(),
"parent",
block.ParentHash(),
)
func (b *Blockchain) WriteBlock(block *types.Block, source string) error {
zivkovicmilos marked this conversation as resolved.
Show resolved Hide resolved
b.writeLock.Lock()
defer b.writeLock.Unlock()

if block.Number() <= b.Header().Number {
b.logger.Info("block already inserted", "block", block.Number(), "source", source)

return nil
}
Kourin1996 marked this conversation as resolved.
Show resolved Hide resolved

header := block.Header

Expand All @@ -876,7 +879,7 @@ func (b *Blockchain) WriteBlock(block *types.Block) error {
}

// Write the header to the chain
evnt := &Event{}
evnt := &Event{Source: source}
if err := b.writeHeaderImpl(evnt, header); err != nil {
return err
}
Expand Down Expand Up @@ -906,8 +909,9 @@ func (b *Blockchain) WriteBlock(block *types.Block) error {

logArgs := []interface{}{
"number", header.Number,
"txs", len(block.Transactions),
"hash", header.Hash,
"txns", len(block.Transactions),
"parent", header.ParentHash,
}

if prevHeader, ok := b.GetHeaderByNumber(header.Number - 1); ok {
Expand Down
6 changes: 0 additions & 6 deletions blockchain/storage/testing.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package storage

import (
"fmt"
"math/big"
"reflect"
"testing"
Expand Down Expand Up @@ -416,11 +415,6 @@ func testWriteCanonicalHeader(t *testing.T, m PlaceholderStorage) {
assert.NoError(t, err)

if !reflect.DeepEqual(h, hh) {
fmt.Println("-- valid --")
fmt.Println(h)
fmt.Println("-- found --")
fmt.Println(hh)

t.Fatal("bad header")
}

Expand Down
1 change: 0 additions & 1 deletion command/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package genesis

import (
"fmt"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
Expand Down
2 changes: 1 addition & 1 deletion command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (p *genesisParams) initIBFTExtraData() {

ibftExtra := &ibft.IstanbulExtra{
Validators: p.ibftValidators,
Seal: []byte{},
ProposerSeal: []byte{},
CommittedSeal: [][]byte{},
}

Expand Down
2 changes: 1 addition & 1 deletion command/ibft/propose/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package propose
import (
"context"
"errors"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
"github.com/0xPolygon/polygon-edge/types"
)

Expand Down
11 changes: 3 additions & 8 deletions command/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Config struct {
LogLevel string `json:"log_level" yaml:"log_level"`
RestoreFile string `json:"restore_file" yaml:"restore_file"`
BlockTime uint64 `json:"block_time_s" yaml:"block_time_s"`
IBFTBaseTimeout uint64 `json:"ibft_base_time_s" yaml:"ibft_base_time_s"`
Headers *Headers `json:"headers" yaml:"headers"`
LogFilePath string `json:"log_to" yaml:"log_to"`
JSONRPCBatchRequestLimit uint64 `json:"json_rpc_batch_request_limit" yaml:"json_rpc_batch_request_limit"`
Expand Down Expand Up @@ -65,9 +64,6 @@ const (
// minimum block generation time in seconds
DefaultBlockTime uint64 = 2

// IBFT timeout in seconds
DefaultIBFTBaseTimeout uint64 = 10

// Multiplier to get IBFT timeout from block time
// timeout is calculated when IBFT timeout is not specified
BlockTimeMultiplierForTimeout uint64 = 5
Expand Down Expand Up @@ -103,10 +99,9 @@ func DefaultConfig() *Config {
PriceLimit: 0,
MaxSlots: 4096,
},
LogLevel: "INFO",
RestoreFile: "",
BlockTime: DefaultBlockTime,
IBFTBaseTimeout: DefaultIBFTBaseTimeout,
LogLevel: "INFO",
RestoreFile: "",
BlockTime: DefaultBlockTime,
Headers: &Headers{
AccessControlAllowOrigins: []string{"*"},
},
Expand Down
20 changes: 0 additions & 20 deletions command/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

var (
errInvalidBlockTime = errors.New("invalid block time specified")
errWrongIBFTBaseTimeout = errors.New("IBFT base timeout needs to be higher than block time")
errDataDirectoryUndefined = errors.New("data directory not defined")
)

Expand Down Expand Up @@ -55,10 +54,6 @@ func (p *serverParams) initRawParams() error {
return err
}

if err := p.initIBFTBaseTimeout(); err != nil {
return err
}

if p.isDevMode {
p.initDevMode()
}
Expand All @@ -77,21 +72,6 @@ func (p *serverParams) initBlockTime() error {
return nil
}

func (p *serverParams) initIBFTBaseTimeout() error {
if p.rawConfig.IBFTBaseTimeout == 0 {
// Calculate from block time
p.rawConfig.IBFTBaseTimeout = p.rawConfig.BlockTime * config.BlockTimeMultiplierForTimeout

return nil
}

if p.rawConfig.IBFTBaseTimeout <= p.rawConfig.BlockTime {
return errWrongIBFTBaseTimeout
}

return nil
}

func (p *serverParams) initDataDirLocation() error {
if p.rawConfig.DataDir == "" {
return errDataDirectoryUndefined
Expand Down
28 changes: 17 additions & 11 deletions command/server/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ const (
secretsConfigFlag = "secrets-config"
restoreFlag = "restore"
blockTimeFlag = "block-time"
ibftBaseTimeoutFlag = "ibft-base-timeout"
devIntervalFlag = "dev-interval"
devFlag = "dev"
corsOriginFlag = "access-control-allow-origins"
logFileLocationFlag = "log-to"
)

// Flags that are deprecated, but need to be preserved for
// backwards compatibility with existing scripts
const (
ibftBaseTimeoutFlagLEGACY = "ibft-base-timeout"
)

const (
unsetPeersValue = -1
)
Expand Down Expand Up @@ -78,6 +83,8 @@ type serverParams struct {
jsonRPCBatchLengthLimit uint64
jsonRPCBlockRangeLimit uint64

ibftBaseTimeoutLegacy uint64

genesisConfig *chain.Chain
secretsConfig *secrets.SecretsManagerConfig

Expand Down Expand Up @@ -158,15 +165,14 @@ func (p *serverParams) generateConfig() *server.Config {
MaxOutboundPeers: p.rawConfig.Network.MaxOutboundPeers,
Chain: p.genesisConfig,
},
DataDir: p.rawConfig.DataDir,
Seal: p.rawConfig.ShouldSeal,
PriceLimit: p.rawConfig.TxPool.PriceLimit,
MaxSlots: p.rawConfig.TxPool.MaxSlots,
SecretsManager: p.secretsConfig,
RestoreFile: p.getRestoreFilePath(),
BlockTime: p.rawConfig.BlockTime,
IBFTBaseTimeout: p.rawConfig.IBFTBaseTimeout,
LogLevel: hclog.LevelFromString(p.rawConfig.LogLevel),
LogFilePath: p.logFileLocation,
DataDir: p.rawConfig.DataDir,
Seal: p.rawConfig.ShouldSeal,
PriceLimit: p.rawConfig.TxPool.PriceLimit,
MaxSlots: p.rawConfig.TxPool.MaxSlots,
SecretsManager: p.secretsConfig,
RestoreFile: p.getRestoreFilePath(),
BlockTime: p.rawConfig.BlockTime,
LogLevel: hclog.LevelFromString(p.rawConfig.LogLevel),
LogFilePath: p.logFileLocation,
}
}
26 changes: 15 additions & 11 deletions command/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,6 @@ func setFlags(cmd *cobra.Command) {
"minimum block time in seconds (at least 1s)",
)

cmd.Flags().Uint64Var(
&params.rawConfig.IBFTBaseTimeout,
ibftBaseTimeoutFlag,
// Calculate from block time if it is not given
0,
fmt.Sprintf(
"base IBFT timeout in seconds, it needs to be larger than block time. (block time * %d) is set if it's zero",
config.BlockTimeMultiplierForTimeout,
),
)

cmd.Flags().StringArrayVar(
&params.corsAllowedOrigins,
corsOriginFlag,
Expand Down Expand Up @@ -226,9 +215,24 @@ func setFlags(cmd *cobra.Command) {
"write all logs to the file at specified location instead of writing them to console",
)

setLegacyFlags(cmd)
setDevFlags(cmd)
}

// setLegacyFlags sets the legacy flags to preserve backwards compatibility
// with running partners
func setLegacyFlags(cmd *cobra.Command) {
// Legacy IBFT base timeout flag
cmd.Flags().Uint64Var(
&params.ibftBaseTimeoutLegacy,
ibftBaseTimeoutFlagLEGACY,
0,
"",
)

_ = cmd.Flags().MarkHidden(ibftBaseTimeoutFlagLEGACY)
}

func setDevFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(
&params.isDevMode,
Expand Down
37 changes: 17 additions & 20 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,33 @@ type Consensus interface {

// Config is the configuration for the consensus
type Config struct {
// Logger to be used by the backend
// Logger to be used by the consensus
Logger *log.Logger

// Params are the params of the chain and the consensus
Params *chain.Params

// Config defines specific configuration parameters for the backend
// Config defines specific configuration parameters for the consensus
Config map[string]interface{}

// Path is the directory path for the consensus protocol tos tore information
Path string
}

type ConsensusParams struct {
Context context.Context
Seal bool
Config *Config
Txpool *txpool.TxPool
Network *network.Server
Blockchain *blockchain.Blockchain
Executor *state.Executor
Grpc *grpc.Server
Logger hclog.Logger
Metrics *Metrics
SecretsManager secrets.SecretsManager
BlockTime uint64
IBFTBaseTimeout uint64
type Params struct {
Context context.Context
Seal bool
Config *Config
TxPool *txpool.TxPool
Network *network.Server
Blockchain *blockchain.Blockchain
Executor *state.Executor
Grpc *grpc.Server
Logger hclog.Logger
Metrics *Metrics
SecretsManager secrets.SecretsManager
BlockTime uint64
}

// Factory is the factory function to create a discovery backend
type Factory func(
*ConsensusParams,
) (Consensus, error)
// Factory is the factory function to create a discovery consensus
type Factory func(*Params) (Consensus, error)
Loading