Skip to content

Commit

Permalink
Fail to Boot if P2P Not Enabled for OCR (#12005)
Browse files Browse the repository at this point in the history
* Fail to Boot if P2P Not Enabled for OCR

OCR and OCR2 both require P2P.V2 to be enabled with valid listen addresses. In the case that one
or both are enabled, return an error if P2P is not enabled.

* update to changelog
  • Loading branch information
EasterTheBunny authored Feb 19, 2024
1 parent da02459 commit ff6f53b
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (c *Core) ValidateConfig() (err error) {
err = multierr.Append(err, configutils.ErrInvalid{Name: "RootDir", Value: true, Msg: fmt.Sprintf("Failed to expand RootDir. Please use an explicit path: %s", verr)})
}

if (*c.OCR.Enabled || *c.OCR2.Enabled) && !*c.P2P.V2.Enabled {
err = multierr.Append(err, configutils.ErrInvalid{Name: "P2P.V2.Enabled", Value: false, Msg: "P2P required for OCR or OCR2. Please enable P2P or disable OCR/OCR2."})
}

return err
}

Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
peerWrapper = ocrcommon.NewSingletonPeerWrapper(keyStore, cfg.P2P(), cfg.OCR(), cfg.Database(), db, globalLogger)
srvcs = append(srvcs, peerWrapper)
} else {
globalLogger.Debug("P2P stack disabled")
return nil, fmt.Errorf("P2P stack required for OCR or OCR2")
}

if cfg.OCR().Enabled() {
Expand Down
3 changes: 2 additions & 1 deletion core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,8 @@ func TestConfig_Validate(t *testing.T) {
toml string
exp string
}{
{name: "invalid", toml: invalidTOML, exp: `invalid configuration: 6 errors:
{name: "invalid", toml: invalidTOML, exp: `invalid configuration: 7 errors:
- P2P.V2.Enabled: invalid value (false): P2P required for OCR or OCR2. Please enable P2P or disable OCR/OCR2.
- Database.Lock.LeaseRefreshInterval: invalid value (6s): must be less than or equal to half of LeaseDuration (10s)
- WebServer: 8 errors:
- LDAP.BaseDN: invalid value (<nil>): LDAP BaseDN can not be empty
Expand Down
7 changes: 7 additions & 0 deletions core/services/chainlink/testdata/config-invalid.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,10 @@ Name = 'primary'
URL = 'http://second.stark.node'

[[Starknet]]

[OCR2]
Enabled = true

[P2P]
[P2P.V2]
Enabled = false
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Gas bumping logic to the `SuggestedPriceEstimator`. The bumping mechanism for this estimator refetches the price from the RPC and adds a buffer on top using the greater of `BumpPercent` and `BumpMin`.

### Fixed

- `P2P.V2` is required in configuration when either `OCR` or `OCR2` are enabled. The node will fail to boot if `P2P.V2` is not enabled.

## 2.9.0 - UNRELEASED

### Added
Expand Down
276 changes: 276 additions & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
! exec chainlink node -c config.toml -s secrets.toml validate
cmp stderr err.txt
cmp stdout out.txt

-- config.toml --
Log.Level = 'debug'

[OCR2]
Enabled = true

[P2P.V2]
Enabled = false

-- secrets.toml --
[Database]
URL = 'postgresql://user:pass1234567890abcd@localhost:5432/dbname?sslmode=disable'

[Password]
Keystore = 'keystore_pass'

-- out.txt --
# Secrets:
[Database]
URL = 'xxxxx'
AllowSimplePasswords = false

[Password]
Keystore = 'xxxxx'

# Input Configuration:
[Log]
Level = 'debug'

[OCR2]
Enabled = true

[P2P]
[P2P.V2]
Enabled = false

# Effective Configuration, with defaults applied:
InsecureFastScrypt = false
RootDir = '~/.chainlink'
ShutdownGracePeriod = '5s'

[Feature]
FeedsManager = true
LogPoller = false
UICSAKeys = false

[Database]
DefaultIdleInTxSessionTimeout = '1h0m0s'
DefaultLockTimeout = '15s'
DefaultQueryTimeout = '10s'
LogQueries = false
MaxIdleConns = 10
MaxOpenConns = 20
MigrateOnStartup = true

[Database.Backup]
Dir = ''
Frequency = '1h0m0s'
Mode = 'none'
OnVersionUpgrade = true

[Database.Listener]
MaxReconnectDuration = '10m0s'
MinReconnectInterval = '1m0s'
FallbackPollInterval = '30s'

[Database.Lock]
Enabled = true
LeaseDuration = '10s'
LeaseRefreshInterval = '1s'

[TelemetryIngress]
UniConn = true
Logging = false
BufferSize = 100
MaxBatchSize = 50
SendInterval = '500ms'
SendTimeout = '10s'
UseBatchSend = true

[AuditLogger]
Enabled = false
ForwardToUrl = ''
JsonWrapperKey = ''
Headers = []

[Log]
Level = 'debug'
JSONConsole = false
UnixTS = false

[Log.File]
Dir = ''
MaxSize = '5.12gb'
MaxAgeDays = 0
MaxBackups = 1

[WebServer]
AuthenticationMethod = 'local'
AllowOrigins = 'http://localhost:3000,http://localhost:6688'
BridgeResponseURL = ''
BridgeCacheTTL = '0s'
HTTPWriteTimeout = '10s'
HTTPPort = 6688
SecureCookies = true
SessionTimeout = '15m0s'
SessionReaperExpiration = '240h0m0s'
HTTPMaxSize = '32.77kb'
StartTimeout = '15s'
ListenIP = '0.0.0.0'

[WebServer.LDAP]
ServerTLS = true
SessionTimeout = '15m0s'
QueryTimeout = '2m0s'
BaseUserAttr = 'uid'
BaseDN = ''
UsersDN = 'ou=users'
GroupsDN = 'ou=groups'
ActiveAttribute = ''
ActiveAttributeAllowedValue = ''
AdminUserGroupCN = 'NodeAdmins'
EditUserGroupCN = 'NodeEditors'
RunUserGroupCN = 'NodeRunners'
ReadUserGroupCN = 'NodeReadOnly'
UserApiTokenEnabled = false
UserAPITokenDuration = '240h0m0s'
UpstreamSyncInterval = '0s'
UpstreamSyncRateLimit = '2m0s'

[WebServer.MFA]
RPID = ''
RPOrigin = ''

[WebServer.RateLimit]
Authenticated = 1000
AuthenticatedPeriod = '1m0s'
Unauthenticated = 5
UnauthenticatedPeriod = '20s'

[WebServer.TLS]
CertPath = ''
ForceRedirect = false
Host = ''
HTTPSPort = 6689
KeyPath = ''
ListenIP = '0.0.0.0'

[JobPipeline]
ExternalInitiatorsEnabled = false
MaxRunDuration = '10m0s'
MaxSuccessfulRuns = 10000
ReaperInterval = '1h0m0s'
ReaperThreshold = '24h0m0s'
ResultWriteQueueDepth = 100

[JobPipeline.HTTPRequest]
DefaultTimeout = '15s'
MaxSize = '32.77kb'

[FluxMonitor]
DefaultTransactionQueueDepth = 1
SimulateTransactions = false

[OCR2]
Enabled = true
ContractConfirmations = 3
BlockchainTimeout = '20s'
ContractPollInterval = '1m0s'
ContractSubscribeInterval = '2m0s'
ContractTransmitterTransmitTimeout = '10s'
DatabaseTimeout = '10s'
KeyBundleID = '0000000000000000000000000000000000000000000000000000000000000000'
CaptureEATelemetry = false
CaptureAutomationCustomTelemetry = true
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false

[OCR]
Enabled = false
ObservationTimeout = '5s'
BlockchainTimeout = '20s'
ContractPollInterval = '1m0s'
ContractSubscribeInterval = '2m0s'
DefaultTransactionQueueDepth = 1
KeyBundleID = '0000000000000000000000000000000000000000000000000000000000000000'
SimulateTransactions = false
TransmitterAddress = ''
CaptureEATelemetry = false
TraceLogging = false

[P2P]
IncomingMessageBufferSize = 10
OutgoingMessageBufferSize = 10
PeerID = ''
TraceLogging = false

[P2P.V2]
Enabled = false
AnnounceAddresses = []
DefaultBootstrappers = []
DeltaDial = '15s'
DeltaReconcile = '1m0s'
ListenAddresses = []

[Keeper]
DefaultTransactionQueueDepth = 1
GasPriceBufferPercent = 20
GasTipCapBufferPercent = 20
BaseFeeBufferPercent = 20
MaxGracePeriod = 100
TurnLookBack = 1000

[Keeper.Registry]
CheckGasOverhead = 200000
PerformGasOverhead = 300000
MaxPerformDataSize = 5000
SyncInterval = '30m0s'
SyncUpkeepQueueSize = 10

[AutoPprof]
Enabled = false
ProfileRoot = ''
PollInterval = '10s'
GatherDuration = '10s'
GatherTraceDuration = '5s'
MaxProfileSize = '100.00mb'
CPUProfileRate = 1
MemProfileRate = 1
BlockProfileRate = 1
MutexProfileFraction = 1
MemThreshold = '4.00gb'
GoroutineThreshold = 5000

[Pyroscope]
ServerAddress = ''
Environment = 'mainnet'

[Sentry]
Debug = false
DSN = ''
Environment = ''
Release = ''

[Insecure]
DevWebServer = false
OCRDevelopmentMode = false
InfiniteDepthQueries = false
DisableRateLimiting = false

[Tracing]
Enabled = false
CollectorTarget = ''
NodeID = ''
SamplingRatio = 0.0
Mode = 'tls'
TLSCertPath = ''

[Mercury]
[Mercury.Cache]
LatestReportTTL = '1s'
MaxStaleAge = '1h0m0s'
LatestReportDeadline = '5s'

[Mercury.TLS]
CertFile = ''

Invalid configuration: invalid configuration: P2P.V2.Enabled: invalid value (false): P2P required for OCR or OCR2. Please enable P2P or disable OCR/OCR2.

-- err.txt --
invalid configuration

0 comments on commit ff6f53b

Please sign in to comment.