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

extracted configuration value for vm-queries delay #5071

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 2 additions & 0 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@
TrieOperationsDeadlineMilliseconds = 10000
# GetAddressesBulkMaxSize represents the maximum number of addresses to be fetched in a bulk per API request. 0 means unlimited
GetAddressesBulkMaxSize = 100
# VmQueryDelayAfterStartInSec represents the number of seconds to wait when starting node before accepting vm query requests
VmQueryDelayAfterStartInSec = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 5 sec even for testnets too low for a value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used this for testing, forgot to change back. done

# EndpointsThrottlers represents a map for maximum simultaneous go routines for an endpoint
EndpointsThrottlers = [{ Endpoint = "/transaction/:hash", MaxNumGoRoutines = 10 },
{ Endpoint = "/transaction/send", MaxNumGoRoutines = 2 },
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ type WebServerAntifloodConfig struct {
SameSourceResetIntervalInSec uint32
TrieOperationsDeadlineMilliseconds uint32
GetAddressesBulkMaxSize uint32
VmQueryDelayAfterStartInSec uint32
EndpointsThrottlers []EndpointsThrottlersConfig
}

Expand Down
10 changes: 7 additions & 3 deletions node/nodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ import (

const (
// TODO: remove this after better handling VM versions switching
// delayBeforeScQueriesStart represents the delay before the sc query processor should start to allow external queries
delayBeforeScQueriesStart = 2 * time.Minute
// defaultDelayBeforeScQueriesStartInSec represents the default delay before the sc query processor should start to allow external queries
defaultDelayBeforeScQueriesStartInSec = 120

maxTimeToClose = 10 * time.Second
// SoftRestartMessage is the custom message used when the node does a soft restart operation
Expand Down Expand Up @@ -516,9 +516,13 @@ func (nr *nodeRunner) executeOneComponentCreationCycle(

log.Info("application is now running")

delayInSecBeforeAllowingVmQueries := configs.GeneralConfig.WebServerAntiflood.VmQueryDelayAfterStartInSec
if delayInSecBeforeAllowingVmQueries == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a warn here to specify that we override the config value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

delayInSecBeforeAllowingVmQueries = defaultDelayBeforeScQueriesStartInSec
}
// TODO: remove this and treat better the VM versions switching
go func(statusHandler core.AppStatusHandler) {
time.Sleep(delayBeforeScQueriesStart)
time.Sleep(time.Duration(delayInSecBeforeAllowingVmQueries) * time.Second)
close(allowExternalVMQueriesChan)
statusHandler.SetStringValue(common.MetricAreVMQueriesReady, strconv.FormatBool(true))
}(managedStatusCoreComponents.AppStatusHandler())
Expand Down