From 2ff5b98f7a365cab1e43d7e196f6442831c2312e Mon Sep 17 00:00:00 2001 From: Igor Crevar Date: Thu, 12 Oct 2023 10:40:26 +0200 Subject: [PATCH] remove flag --- command/genesis/params.go | 10 ---- command/helper/helper.go | 2 - command/server/config/config.go | 26 ++++------ command/server/init.go | 4 -- command/server/params.go | 9 ++-- command/server/server.go | 7 --- e2e-polybft/e2e/bridge_test.go | 72 --------------------------- e2e-polybft/framework/test-cluster.go | 15 +----- e2e-polybft/framework/test-server.go | 28 ++++------- server/config.go | 5 +- 10 files changed, 27 insertions(+), 151 deletions(-) diff --git a/command/genesis/params.go b/command/genesis/params.go index 1e202827fa..379c3eae17 100644 --- a/command/genesis/params.go +++ b/command/genesis/params.go @@ -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. diff --git a/command/helper/helper.go b/command/helper/helper.go index b934dbd2d4..e4be18ce8f 100644 --- a/command/helper/helper.go +++ b/command/helper/helper.go @@ -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"` } diff --git a/command/server/config/config.go b/command/server/config/config.go index 072184c0eb..93b372bbf3 100644 --- a/command/server/config/config.go +++ b/command/server/config/config.go @@ -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"` @@ -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 @@ -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, } } diff --git a/command/server/init.go b/command/server/init.go index 996a664477..216c4e28c1 100644 --- a/command/server/init.go +++ b/command/server/init.go @@ -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() } diff --git a/command/server/params.go b/command/server/params.go index 43f39f76f5..da48b929e9 100644 --- a/command/server/params.go +++ b/command/server/params.go @@ -43,8 +43,6 @@ const ( concurrentRequestsDebugFlag = "concurrent-requests-debug" webSocketReadLimitFlag = "websocket-read-limit" - relayerTrackerPollIntervalFlag = "relayer-poll-interval" - metricsIntervalFlag = "metrics-interval" ) @@ -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, } } diff --git a/command/server/server.go b/command/server/server.go index aa64d2b248..f9c4ab4c6c 100644 --- a/command/server/server.go +++ b/command/server/server.go @@ -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( - ¶ms.rawConfig.RelayerTrackerPollInterval, - relayerTrackerPollIntervalFlag, - defaultConfig.RelayerTrackerPollInterval, - "interval (number of seconds) at which relayer's tracker polls for latest block at childchain", - ) - cmd.Flags().DurationVar( ¶ms.rawConfig.MetricsInterval, metricsIntervalFlag, diff --git a/e2e-polybft/e2e/bridge_test.go b/e2e-polybft/e2e/bridge_test.go index b80dee4e70..a5e70035e5 100644 --- a/e2e-polybft/e2e/bridge_test.go +++ b/e2e-polybft/e2e/bridge_test.go @@ -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) -} diff --git a/e2e-polybft/framework/test-cluster.go b/e2e-polybft/framework/test-cluster.go index cce2586b18..77b583e573 100644 --- a/e2e-polybft/framework/test-cluster.go +++ b/e2e-polybft/framework/test-cluster.go @@ -131,8 +131,7 @@ type TestClusterConfig struct { IsPropertyTest bool TestRewardToken string - RootTrackerPollInterval time.Duration - RelayerTrackerPollInterval time.Duration + RootTrackerPollInterval time.Duration ProxyContractsAdmin string @@ -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 @@ -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) } @@ -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 diff --git a/e2e-polybft/framework/test-server.go b/e2e-polybft/framework/test-server.go index ff4950938e..471759151e 100644 --- a/e2e-polybft/framework/test-server.go +++ b/e2e-polybft/framework/test-server.go @@ -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) @@ -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 diff --git a/server/config.go b/server/config.go index ff725973b0..63240f6ddf 100644 --- a/server/config.go +++ b/server/config.go @@ -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