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 1 commit
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
Prev Previous commit
Next Next commit
rename package: backend
  • Loading branch information
dbrajovic committed Jul 12, 2022
commit bfe8ba8cc2e9fbfa9060a9ea5817500b963fa5d8
16 changes: 8 additions & 8 deletions consensus/consensus.go → backend/consensus.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package consensus
package backend

import (
"context"
Expand All @@ -17,8 +17,8 @@ import (
)

// TODO: rename to Backend
// Consensus is the public interface for consensus mechanism
// Each consensus mechanism must implement this interface in order to be valid
// Consensus is the public interface for backend mechanism
// Each backend mechanism must implement this interface in order to be valid
type Consensus interface {
// VerifyHeader verifies the header is correct
VerifyHeader(header *types.Header) error
Expand All @@ -36,28 +36,28 @@ type Consensus interface {
// GetSyncProgression retrieves the current sync progression, if any
GetSyncProgression() *progress.Progression

// Initialize initializes the consensus (e.g. setup data)
// Initialize initializes the backend (e.g. setup data)
Initialize() error

// Start starts the consensus and servers
// Start starts the backend and servers
Start() error

// Close closes the connection
Close() error
}

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

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

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

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

Expand Down
16 changes: 8 additions & 8 deletions consensus/dev/dev.go → backend/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
"fmt"
"time"

"github.com/0xPolygon/polygon-edge/backend"
"github.com/0xPolygon/polygon-edge/blockchain"
"github.com/0xPolygon/polygon-edge/consensus"
"github.com/0xPolygon/polygon-edge/helper/progress"
"github.com/0xPolygon/polygon-edge/state"
"github.com/0xPolygon/polygon-edge/txpool"
"github.com/0xPolygon/polygon-edge/types"
"github.com/hashicorp/go-hclog"
)

// Dev consensus protocol seals any new transaction immediately
// Dev backend protocol seals any new transaction immediately
type Dev struct {
logger hclog.Logger

Expand All @@ -30,8 +30,8 @@ type Dev struct {

// Factory implements the base factory method
func Factory(
params *consensus.ConsensusParams,
) (consensus.Consensus, error) {
params *backend.ConsensusParams,
) (backend.Consensus, error) {
logger := params.Logger.Named("dev")

d := &Dev{
Expand All @@ -56,12 +56,12 @@ func Factory(
return d, nil
}

// Initialize initializes the consensus
// Initialize initializes the backend
func (d *Dev) Initialize() error {
return nil
}

// Start starts the consensus mechanism
// Start starts the backend mechanism
func (d *Dev) Start() error {
go d.run()

Expand All @@ -82,7 +82,7 @@ func (d *Dev) nextNotify() chan struct{} {
}

func (d *Dev) run() {
d.logger.Info("consensus started")
d.logger.Info("backend started")

for {
// wait until there is a new txn
Expand Down Expand Up @@ -186,7 +186,7 @@ func (d *Dev) writeNewBlock(parent *types.Header) error {

// Build the actual block
// The header hash is computed inside buildBlock
block := consensus.BuildBlock(consensus.BuildBlockParams{
block := backend.BuildBlock(backend.BuildBlockParams{
Header: header,
Txns: txns,
Receipts: transition.Receipts(),
Expand Down
6 changes: 3 additions & 3 deletions consensus/dummy/dummy.go → backend/dummy/dummy.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dummy

import (
"github.com/0xPolygon/polygon-edge/backend"
"github.com/0xPolygon/polygon-edge/blockchain"
"github.com/0xPolygon/polygon-edge/consensus"
"github.com/0xPolygon/polygon-edge/helper/progress"
"github.com/0xPolygon/polygon-edge/state"
"github.com/0xPolygon/polygon-edge/txpool"
Expand All @@ -20,7 +20,7 @@ type Dummy struct {
executor *state.Executor
}

func Factory(params *consensus.ConsensusParams) (consensus.Consensus, error) {
func Factory(params *backend.ConsensusParams) (backend.Consensus, error) {
logger := params.Logger.Named("dummy")

d := &Dummy{
Expand All @@ -36,7 +36,7 @@ func Factory(params *consensus.ConsensusParams) (consensus.Consensus, error) {
return d, nil
}

// Initialize initializes the consensus
// Initialize initializes the backend
func (d *Dummy) Initialize() error {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/ibft/extra.go → backend/ibft/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

var (
// IstanbulDigest represents a hash of "Istanbul practical byzantine fault tolerance"
// to identify whether the block is from Istanbul consensus engine
// to identify whether the block is from Istanbul backend engine
IstanbulDigest = types.StringToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365")

// IstanbulExtraVanity represents a fixed number of extra-data bytes reserved for proposer vanity
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions consensus/ibft/hooks.go → backend/ibft/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/0xPolygon/polygon-edge/helper/common"
)

// Define the type of the IBFT consensus
// Define the type of the IBFT backend

type MechanismType string

Expand Down Expand Up @@ -85,10 +85,10 @@ const (
)

type ConsensusMechanism interface {
// GetType returns the type of IBFT consensus mechanism (PoA / PoS)
// GetType returns the type of IBFT backend mechanism (PoA / PoS)
GetType() MechanismType

// GetHookMap returns the hooks registered with the specific consensus mechanism
// GetHookMap returns the hooks registered with the specific backend mechanism
GetHookMap() map[HookType]func(interface{}) error

// IsAvailable returns whether the corresponding hook is available
Expand Down Expand Up @@ -175,7 +175,7 @@ type IBFTFork struct {
MinValidatorCount *common.JSONNumber `json:"minValidatorCount,omitempty"`
}

// ConsensusMechanismFactory is the factory function to create a consensus mechanism
// ConsensusMechanismFactory is the factory function to create a backend mechanism
type ConsensusMechanismFactory func(ibft *Ibft, params *IBFTFork) (ConsensusMechanism, error)

var mechanismBackends = map[MechanismType]ConsensusMechanismFactory{
Expand Down
50 changes: 25 additions & 25 deletions consensus/ibft/ibft.go → backend/ibft/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"reflect"
"time"

"github.com/0xPolygon/polygon-edge/consensus"
"github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
"github.com/0xPolygon/polygon-edge/backend"
"github.com/0xPolygon/polygon-edge/backend/ibft/proto"
"github.com/0xPolygon/polygon-edge/crypto"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/hex"
Expand All @@ -32,8 +32,8 @@ const (

var (
ErrInvalidHookParam = errors.New("invalid IBFT hook param passed in")
ErrInvalidMechanismType = errors.New("invalid consensus mechanism type in params")
ErrMissingMechanismType = errors.New("missing consensus mechanism type in params")
ErrInvalidMechanismType = errors.New("invalid backend mechanism type in params")
ErrMissingMechanismType = errors.New("missing backend mechanism type in params")
)

type blockchainInterface interface {
Expand All @@ -54,14 +54,14 @@ type txPoolInterface interface {
ResetWithHeaders(headers ...*types.Header)
}

// Ibft represents the IBFT consensus mechanism object
// Ibft represents the IBFT backend mechanism object
type Ibft struct {
sealing bool // Flag indicating if the node is a sealer

logger hclog.Logger // Output logger
config *consensus.Config // Consensus configuration
Grpc *grpc.Server // gRPC configuration
state *currentState // Reference to the current state
logger hclog.Logger // Output logger
config *backend.Config // Consensus configuration
Grpc *grpc.Server // gRPC configuration
state *currentState // Reference to the current state

blockchain blockchainInterface // Interface exposed by the blockchain layer
executor *state.Executor // Reference to the state executor
Expand Down Expand Up @@ -89,7 +89,7 @@ type Ibft struct {
// aux test methods
forceTimeoutCh bool

metrics *consensus.Metrics
metrics *backend.Metrics

secretsManager secrets.SecretsManager

Expand Down Expand Up @@ -124,10 +124,10 @@ func (i *Ibft) runHook(hookName HookType, height uint64, hookParam interface{})
return nil
}

// Factory implements the base consensus Factory method
// Factory implements the base backend Factory method
func Factory(
params *consensus.ConsensusParams,
) (consensus.Consensus, error) {
params *backend.ConsensusParams,
) (backend.Consensus, error) {
// defaults for user set fields in genesis
var (
epochSize = uint64(DefaultEpochSize)
Expand Down Expand Up @@ -185,7 +185,7 @@ func Factory(
return p, nil
}

// Start starts the IBFT consensus
// Start starts the IBFT backend
func (i *Ibft) Initialize() error {
// Set up the snapshots
if err := i.setupSnapshot(); err != nil {
Expand All @@ -195,7 +195,7 @@ func (i *Ibft) Initialize() error {
return nil
}

// Start starts the IBFT consensus
// Start starts the IBFT backend
func (i *Ibft) Start() error {
// register the grpc operator
if i.Grpc != nil {
Expand Down Expand Up @@ -284,7 +284,7 @@ func GetIBFTForks(ibftConfig map[string]interface{}) ([]IBFTFork, error) {
return nil, errors.New("current IBFT type not found")
}

// setupTransport read current mechanism in params and sets up consensus mechanism
// setupTransport read current mechanism in params and sets up backend mechanism
func (i *Ibft) setupMechanism() error {
ibftForks, err := GetIBFTForks(i.config.Config)
if err != nil {
Expand All @@ -296,7 +296,7 @@ func (i *Ibft) setupMechanism() error {
for idx, fork := range ibftForks {
factory, ok := mechanismBackends[fork.Type]
if !ok {
return fmt.Errorf("consensus mechanism doesn't define: %s", fork.Type)
return fmt.Errorf("backend mechanism doesn't define: %s", fork.Type)
}

fork := fork
Expand Down Expand Up @@ -399,9 +399,9 @@ func (i *Ibft) createKey() error {

const IbftKeyName = "validator.key"

// start starts the IBFT consensus state machine
// start starts the IBFT backend state machine
func (i *Ibft) start() {
// consensus always starts in SyncState mode in case it needs
// backend always starts in SyncState mode in case it needs
// to sync with other nodes.
i.setState(SyncState)

Expand Down Expand Up @@ -563,7 +563,7 @@ func (i *Ibft) runSyncState() {
}
}

// shouldWriteTransactions checks if each consensus mechanism accepts a block with transactions at given height
// shouldWriteTransactions checks if each backend mechanism accepts a block with transactions at given height
// returns true if all mechanisms accept
// otherwise return false
func (i *Ibft) shouldWriteTransactions(height uint64) bool {
Expand Down Expand Up @@ -640,7 +640,7 @@ func (i *Ibft) buildBlock(snap *Snapshot, parent *types.Header) (*types.Block, e
header.GasUsed = transition.TotalGas()

// build the block
block := consensus.BuildBlock(consensus.BuildBlockParams{
block := backend.BuildBlock(backend.BuildBlockParams{
Header: header,
Txns: txns,
Receipts: transition.Receipts(),
Expand Down Expand Up @@ -754,7 +754,7 @@ func (i *Ibft) runAcceptState() { // start new round
return
}

// TODO: this will affect is the node is even running consensus for some round
// TODO: this will affect is the node is even running backend for some round
snap, err := i.getSnapshot(parent.Number)
if err != nil {
i.logger.Error("cannot find snapshot", "num", parent.Number)
Expand All @@ -763,7 +763,7 @@ func (i *Ibft) runAcceptState() { // start new round
return
}

// TODO: this will affect is the node is even running consensus for some round
// TODO: this will affect is the node is even running backend for some round
if !snap.Set.Includes(i.validatorKeyAddr) {
// we are not a validator anymore, move back to sync state
i.logger.Info("we are not a validator anymore")
Expand Down Expand Up @@ -1054,7 +1054,7 @@ func (i *Ibft) insertBlock(block *types.Block) error {
block.Header = header
block.Header.ComputeHash() // TODO: this is not needed

// TODO: this is also not needed, consensus has already verified everything
// TODO: this is also not needed, backend has already verified everything
// Verify the header only, since the block body is already verified
if err := i.VerifyHeader(block.Header); err != nil {
return err
Expand Down Expand Up @@ -1378,7 +1378,7 @@ func (i *Ibft) IsLastOfEpoch(number uint64) bool {
return number > 0 && number%i.epochSize == 0
}

// Close closes the IBFT consensus mechanism, and does write back to disk
// Close closes the IBFT backend mechanism, and does write back to disk
func (i *Ibft) Close() error {
close(i.closeCh)

Expand Down
12 changes: 6 additions & 6 deletions consensus/ibft/ibft_test.go → backend/ibft/ibft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"
"time"

"github.com/0xPolygon/polygon-edge/backend"
"github.com/0xPolygon/polygon-edge/backend/ibft/proto"
"github.com/0xPolygon/polygon-edge/blockchain"
"github.com/0xPolygon/polygon-edge/consensus"
"github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/helper/progress"
Expand Down Expand Up @@ -1204,7 +1204,7 @@ func newMockIbft(t *testing.T, accounts []string, account string) *mockIbft {

ibft := &Ibft{
logger: hclog.NewNullLogger(),
config: &consensus.Config{},
config: &backend.Config{},
blockchain: m,
validatorKey: addr.priv,
validatorKeyAddr: addr.Address(),
Expand All @@ -1213,7 +1213,7 @@ func newMockIbft(t *testing.T, accounts []string, account string) *mockIbft {
operator: &operator{},
state: newState(),
epochSize: DefaultEpochSize,
metrics: consensus.NilMetrics(),
metrics: backend.NilMetrics(),
}

initIbftMechanism(PoA, ibft)
Expand Down Expand Up @@ -1262,7 +1262,7 @@ func newMockIBFTWithMockBlockchain(

ibft := &Ibft{
logger: hclog.NewNullLogger(),
config: &consensus.Config{},
config: &backend.Config{},
blockchain: m,
validatorKey: addr.priv,
validatorKeyAddr: addr.Address(),
Expand All @@ -1271,7 +1271,7 @@ func newMockIBFTWithMockBlockchain(
operator: &operator{},
state: newState(),
epochSize: DefaultEpochSize,
metrics: consensus.NilMetrics(),
metrics: backend.NilMetrics(),
}

initIbftMechanism(PoA, ibft)
Expand Down
Loading