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

Commit

Permalink
remove flag
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcrevar committed Oct 12, 2023
1 parent 0ed734d commit 2ff5b98
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 151 deletions.
10 changes: 0 additions & 10 deletions command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,6 @@ func (p *genesisParams) validatePremineInfo() error {
return errReserveAccMustBePremined
}

// validateBlockTrackerPollInterval validates block tracker block interval
// which can not be 0
func (p *genesisParams) validateBlockTrackerPollInterval() error {
if p.blockTrackerPollInterval == 0 {
return helper.ErrBlockTrackerPollInterval
}

return nil
}

// validateBurnContract validates burn contract. If native token is mintable,
// burn contract flag must not be set. If native token is non mintable only one burn contract
// can be set and the specified address will be used to predeploy default EIP1559 burn contract.
Expand Down
2 changes: 0 additions & 2 deletions command/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ 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
26 changes: 10 additions & 16 deletions command/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ 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"`
RelayerTrackerPollInterval time.Duration `json:"relayer_tracker_poll_interval" yaml:"relayer_tracker_poll_interval"`
Relayer bool `json:"relayer" yaml:"relayer"`
NumBlockConfirmations uint64 `json:"num_block_confirmations" yaml:"num_block_confirmations"`

ConcurrentRequestsDebug uint64 `json:"concurrent_requests_debug" yaml:"concurrent_requests_debug"`
WebSocketReadLimit uint64 `json:"web_socket_read_limit" yaml:"web_socket_read_limit"`
Expand Down Expand Up @@ -94,10 +93,6 @@ const (
// the connection sends a close message to the peer and returns ErrReadLimit to the application.
DefaultWebSocketReadLimit uint64 = 8192

// DefaultRelayerTrackerPollInterval specifies time interval after which relayer node's event tracker
// polls child chain to get the latest block
DefaultRelayerTrackerPollInterval time.Duration = time.Second

// DefaultMetricsInterval specifies the time interval after which Prometheus metrics will be generated.
// A value of 0 means the metrics are disabled.
DefaultMetricsInterval time.Duration = time.Second * 8
Expand Down Expand Up @@ -132,15 +127,14 @@ func DefaultConfig() *Config {
Headers: &Headers{
AccessControlAllowOrigins: []string{"*"},
},
LogFilePath: "",
JSONRPCBatchRequestLimit: DefaultJSONRPCBatchRequestLimit,
JSONRPCBlockRangeLimit: DefaultJSONRPCBlockRangeLimit,
Relayer: false,
NumBlockConfirmations: DefaultNumBlockConfirmations,
ConcurrentRequestsDebug: DefaultConcurrentRequestsDebug,
WebSocketReadLimit: DefaultWebSocketReadLimit,
RelayerTrackerPollInterval: DefaultRelayerTrackerPollInterval,
MetricsInterval: DefaultMetricsInterval,
LogFilePath: "",
JSONRPCBatchRequestLimit: DefaultJSONRPCBatchRequestLimit,
JSONRPCBlockRangeLimit: DefaultJSONRPCBlockRangeLimit,
Relayer: false,
NumBlockConfirmations: DefaultNumBlockConfirmations,
ConcurrentRequestsDebug: DefaultConcurrentRequestsDebug,
WebSocketReadLimit: DefaultWebSocketReadLimit,
MetricsInterval: DefaultMetricsInterval,
}
}

Expand Down
4 changes: 0 additions & 4 deletions command/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ 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
9 changes: 3 additions & 6 deletions command/server/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const (
concurrentRequestsDebugFlag = "concurrent-requests-debug"
webSocketReadLimitFlag = "websocket-read-limit"

relayerTrackerPollIntervalFlag = "relayer-poll-interval"

metricsIntervalFlag = "metrics-interval"
)

Expand Down Expand Up @@ -187,9 +185,8 @@ func (p *serverParams) generateConfig() *server.Config {
JSONLogFormat: p.rawConfig.JSONLogFormat,
LogFilePath: p.logFileLocation,

Relayer: p.relayer,
NumBlockConfirmations: p.rawConfig.NumBlockConfirmations,
RelayerTrackerPollInterval: p.rawConfig.RelayerTrackerPollInterval,
MetricsInterval: p.rawConfig.MetricsInterval,
Relayer: p.relayer,
NumBlockConfirmations: p.rawConfig.NumBlockConfirmations,
MetricsInterval: p.rawConfig.MetricsInterval,
}
}
7 changes: 0 additions & 7 deletions command/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,6 @@ func setFlags(cmd *cobra.Command) {
"maximum size in bytes for a message read from the peer by websocket",
)

cmd.Flags().DurationVar(
&params.rawConfig.RelayerTrackerPollInterval,
relayerTrackerPollIntervalFlag,
defaultConfig.RelayerTrackerPollInterval,
"interval (number of seconds) at which relayer's tracker polls for latest block at childchain",
)

cmd.Flags().DurationVar(
&params.rawConfig.MetricsInterval,
metricsIntervalFlag,
Expand Down
72 changes: 0 additions & 72 deletions e2e-polybft/e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,75 +1531,3 @@ func TestE2E_Bridge_Transfers_AccessLists(t *testing.T) {
}
})
}

func TestE2E_Bridge_Transfers_WithBlockTrackerPollInterval(t *testing.T) {
var (
numBlockConfirmations = uint64(2)
epochSize = 30
sprintSize = uint64(5)
rootPollInterval = 5 * time.Second
relayerPollInterval = 5 * time.Second
numberOfAttempts = uint64(4)
stateSyncedLogsCount = 1
)

cluster := framework.NewTestCluster(t, 5,
framework.WithEpochSize(epochSize),
framework.WithNumBlockConfirmations(numBlockConfirmations),
framework.WithRootTrackerPollInterval(rootPollInterval),
framework.WithRelayerTrackerPollInterval(relayerPollInterval),
)
defer cluster.Stop()

cluster.WaitForReady(t)

polybftCfg, err := polybft.LoadPolyBFTConfig(path.Join(cluster.Config.TmpDir, chainConfigFileName))
require.NoError(t, err)

validatorSrv := cluster.Servers[0]
senderAccount, err := sidechain.GetAccountFromDir(validatorSrv.DataDir())
require.NoError(t, err)

childEthEndpoint := validatorSrv.JSONRPC().Eth()

// bridge some tokens for first validator to child chain
tokensToDeposit := ethgo.Ether(10)

require.NoError(t, cluster.Bridge.Deposit(
common.ERC20,
polybftCfg.Bridge.RootNativeERC20Addr,
polybftCfg.Bridge.RootERC20PredicateAddr,
rootHelper.TestAccountPrivKey,
senderAccount.Address().String(),
tokensToDeposit.String(),
"",
cluster.Bridge.JSONRPCAddr(),
rootHelper.TestAccountPrivKey,
false),
)

// wait for a couple of sprints
finalBlockNum := 5 * sprintSize

// the transaction is processed and there should be a success event
var stateSyncedResult contractsapi.StateSyncResultEvent

for i := uint64(0); i < numberOfAttempts; i++ {
logs, err := getFilteredLogs(stateSyncedResult.Sig(), 0, finalBlockNum+i*sprintSize, childEthEndpoint)
require.NoError(t, err)

if len(logs) == stateSyncedLogsCount || i == numberOfAttempts-1 {
// assert that all deposits are executed successfully
checkStateSyncResultLogs(t, logs, stateSyncedLogsCount)

break
}

require.NoError(t, cluster.WaitForBlock(finalBlockNum+(i+1)*sprintSize, 2*time.Minute))
}

// check validator balance got increased by deposited amount
balance, err := childEthEndpoint.GetBalance(ethgo.Address(senderAccount.Address()), ethgo.Latest)
require.NoError(t, err)
require.Equal(t, tokensToDeposit, balance)
}
15 changes: 1 addition & 14 deletions e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ type TestClusterConfig struct {
IsPropertyTest bool
TestRewardToken string

RootTrackerPollInterval time.Duration
RelayerTrackerPollInterval time.Duration
RootTrackerPollInterval time.Duration

ProxyContractsAdmin string

Expand Down Expand Up @@ -393,12 +392,6 @@ func WithRootTrackerPollInterval(pollInterval time.Duration) ClusterOption {
}
}

func WithRelayerTrackerPollInterval(pollInterval time.Duration) ClusterOption {
return func(h *TestClusterConfig) {
h.RelayerTrackerPollInterval = pollInterval
}
}

func WithProxyContractsAdmin(address string) ClusterOption {
return func(h *TestClusterConfig) {
h.ProxyContractsAdmin = address
Expand Down Expand Up @@ -506,11 +499,6 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T
cluster.Config.BlockTime.String())
}

if cluster.Config.RelayerTrackerPollInterval != 0 {
args = append(args, "--block-tracker-poll-interval",
cluster.Config.RelayerTrackerPollInterval.String())
}

if cluster.Config.TestRewardToken != "" {
args = append(args, "--reward-token-code", cluster.Config.TestRewardToken)
}
Expand Down Expand Up @@ -695,7 +683,6 @@ func (c *TestCluster) InitTestServer(t *testing.T,
config.Relayer = nodeType.IsSet(Relayer)
config.NumBlockConfirmations = c.Config.NumBlockConfirmations
config.BridgeJSONRPC = bridgeJSONRPC
config.RelayerTrackerPollInterval = c.Config.RelayerTrackerPollInterval
})

// watch the server for stop signals. It is important to fix the specific
Expand Down
28 changes: 11 additions & 17 deletions e2e-polybft/framework/test-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ import (
)

type TestServerConfig struct {
Name string
JSONRPCPort int64
GRPCPort int64
P2PPort int64
Validator bool
DataDir string
Chain string
LogLevel string
Relayer bool
NumBlockConfirmations uint64
BridgeJSONRPC string
RelayerTrackerPollInterval time.Duration
Name string
JSONRPCPort int64
GRPCPort int64
P2PPort int64
Validator bool
DataDir string
Chain string
LogLevel string
Relayer bool
NumBlockConfirmations uint64
BridgeJSONRPC string
}

type TestServerConfigCallback func(*TestServerConfig)
Expand Down Expand Up @@ -175,11 +174,6 @@ func (t *TestServer) Start() {

if config.Relayer {
args = append(args, "--relayer")

if config.RelayerTrackerPollInterval != 0 {
// only relayer node should have this setup if
args = append(args, "--relayer-poll-interval", config.RelayerTrackerPollInterval.String())
}
}

// Start the server
Expand Down
5 changes: 2 additions & 3 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ type Config struct {

Relayer bool

NumBlockConfirmations uint64
RelayerTrackerPollInterval time.Duration
MetricsInterval time.Duration
NumBlockConfirmations uint64
MetricsInterval time.Duration
}

// Telemetry holds the config details for metric services
Expand Down

0 comments on commit 2ff5b98

Please sign in to comment.