Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Comments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Sep 8, 2023
1 parent e35e2eb commit f47c9ae
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
3 changes: 1 addition & 2 deletions command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ var (
errReserveAccMustBePremined = errors.New("it is mandatory to premine reserve account (0x0 address)")
errInvalidVotingPeriod = errors.New("voting period can not be zero")
errInvalidGovernorAdmin = errors.New("governor admin address must be defined")
errBlockTrackerPollInterval = errors.New("block tracker poll interval must be greater than 0")
)

type genesisParams struct {
Expand Down Expand Up @@ -556,7 +555,7 @@ func (p *genesisParams) validateGovernorAdminAddr() error {
// which can not be 0
func (p *genesisParams) validateBlockTrackerPollInterval() error {
if p.blockTrackerPollInterval == 0 {
return errBlockTrackerPollInterval
return helper.ErrBlockTrackerPollInterval
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions command/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

var ErrBlockTrackerPollInterval = errors.New("block tracker poll interval must be greater than 0")

type ClientCloseResult struct {
Message string `json:"message"`
}
Expand Down
7 changes: 3 additions & 4 deletions command/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ type Config struct {
JSONLogFormat bool `json:"json_log_format" yaml:"json_log_format"`
CorsAllowedOrigins []string `json:"cors_allowed_origins" yaml:"cors_allowed_origins"`

Relayer bool `json:"relayer" yaml:"relayer"`
NumBlockConfirmations uint64 `json:"num_block_confirmations" yaml:"num_block_confirmations"`
Relayer bool `json:"relayer" yaml:"relayer"`
NumBlockConfirmations uint64 `json:"num_block_confirmations" yaml:"num_block_confirmations"`
RelayerTrackerPollInterval time.Duration `json:"relayer_tracker_poll_interval" yaml:"relayer_tracker_poll_interval"`

ConcurrentRequestsDebug uint64 `json:"concurrent_requests_debug" yaml:"concurrent_requests_debug"`
WebSocketReadLimit uint64 `json:"web_socket_read_limit" yaml:"web_socket_read_limit"`

RelayerTrackerPollInterval time.Duration `json:"relayer_tracker_poll_interval" yaml:"relayer_tracker_poll_interval"`
}

// Telemetry holds the config details for metric services.
Expand Down
4 changes: 4 additions & 0 deletions command/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (p *serverParams) initRawParams() error {

p.relayer = p.rawConfig.Relayer

if p.relayer && p.rawConfig.RelayerTrackerPollInterval == 0 {
return helper.ErrBlockTrackerPollInterval
}

return p.initAddresses()
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/polybft/consensus_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (c *consensusRuntime) initStateSyncManager(logger hcf.Logger) error {
topic: c.config.bridgeTopic,
maxCommitmentSize: maxCommitmentSize,
numBlockConfirmations: c.config.numBlockConfirmations,
blockTrackerPollInterval: c.config.GenesisPolyBFTConfig.BlockTrackerPollInterval,
blockTrackerPollInterval: c.config.GenesisPolyBFTConfig.BlockTrackerPollInterval.Duration,
},
c,
)
Expand Down
4 changes: 2 additions & 2 deletions consensus/polybft/state_sync_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"path"
"sync"
"time"

"github.com/0xPolygon/polygon-edge/consensus/polybft/bitmap"
polybftCommon "github.com/0xPolygon/polygon-edge/consensus/polybft/common"
Expand All @@ -16,7 +17,6 @@ import (
bls "github.com/0xPolygon/polygon-edge/consensus/polybft/signer"
"github.com/0xPolygon/polygon-edge/consensus/polybft/validator"
"github.com/0xPolygon/polygon-edge/consensus/polybft/wallet"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/tracker"
"github.com/0xPolygon/polygon-edge/types"
"github.com/hashicorp/go-hclog"
Expand Down Expand Up @@ -70,7 +70,7 @@ type stateSyncConfig struct {
key *wallet.Key
maxCommitmentSize uint64
numBlockConfirmations uint64
blockTrackerPollInterval common.Duration
blockTrackerPollInterval time.Duration
}

var _ StateSyncManager = (*stateSyncManager)(nil)
Expand Down
5 changes: 2 additions & 3 deletions consensus/polybft/statesyncrelayer/state_sync_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/tracker"
"github.com/0xPolygon/polygon-edge/txrelayer"
"github.com/0xPolygon/polygon-edge/types"
Expand All @@ -32,7 +31,7 @@ type StateSyncRelayer struct {
txRelayer txrelayer.TxRelayer
key ethgo.Key
closeCh chan struct{}
pollInterval common.Duration
pollInterval time.Duration
}

func sanitizeRPCEndpoint(rpcEndpoint string) string {
Expand Down Expand Up @@ -82,7 +81,7 @@ func NewRelayer(
key: key,
closeCh: make(chan struct{}),
eventTrackerStartBlock: stateReceiverTrackerStartBlock,
pollInterval: common.Duration{Duration: pollInterval},
pollInterval: pollInterval,
}
}

Expand Down
6 changes: 3 additions & 3 deletions tracker/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type EventTracker struct {
subscriber eventSubscription
logger hcf.Logger
numBlockConfirmations uint64 // minimal number of child blocks required for the parent block to be considered final
pollInterval common.Duration
pollInterval time.Duration
}

func NewEventTracker(
Expand All @@ -37,7 +37,7 @@ func NewEventTracker(
numBlockConfirmations uint64,
startBlock uint64,
logger hcf.Logger,
pollInterval common.Duration,
pollInterval time.Duration,
) *EventTracker {
return &EventTracker{
dbPath: dbPath,
Expand Down Expand Up @@ -75,7 +75,7 @@ func (e *EventTracker) Start(ctx context.Context) error {
}

jsonBlockTracker := blocktracker.NewJSONBlockTracker(provider.Eth())
jsonBlockTracker.PollInterval = e.pollInterval.Duration
jsonBlockTracker.PollInterval = e.pollInterval
blockTracker := blocktracker.NewBlockTracker(
provider.Eth(),
blocktracker.WithBlockMaxBacklog(blockMaxBacklog),
Expand Down

0 comments on commit f47c9ae

Please sign in to comment.