refactor(config,protocol,ci): optimize config binding#6762
Conversation
| package protocol; | ||
|
|
||
| import "core/Tron.proto"; | ||
| import "google/api/annotations.proto"; |
There was a problem hiding this comment.
[MUST] Deleting the import google/api/annotations.proto is out of scope for this PR. The change is unrelated to config bean binding — it touches a gRPC service definition, not any of the Config beans or ConfigBeanFactory wiring. Please split it into a separate PR (e.g.
chore(proto): remove unused google.api.annotations import) So it can be reviewed and reverted independently.
There was a problem hiding this comment.
This is a little change, only including code clear up. Modified the PR title and description to align with the changes.
| if (section.hasPath("allowPBFT")) { | ||
| ConfigValue v = section.getValue("allowPBFT"); | ||
| section = section.withValue("allowPbft", v); // rename allowPBFT -> allowPbft | ||
| } |
There was a problem hiding this comment.
[NIT] normalizeNonStandardKeys cleanliness: withoutPath + hasPath guard
Two small cleanups apply to both CommitteeConfig.normalizeNonStandardKeys (this file, allowPBFT/pBFTExpireNum) and the sibling NodeConfig.normalizeNonStandardKeys (isOpenFullTcpDisconnect / discovery.external.ip):
-
section.withValue(newKey, ...)adds the new key but does not remove the legacy one. After normalize, both keys coexist in the Config tree. This is harmless forConfigBeanFactory(only the canonical name binds), but any downstream diagnostic that walks the raw Config (debug dumps, future read paths) will see two competing entries with no documented winner. Chaining.withoutPath(oldPath)after the rename keeps the post-normalize tree canonical. -
NodeConfig.normalizeNonStandardKeyscallssection.getIsNull("discovery.external.ip"), which throwsConfigException.Missingif the path itself is absent (it only returns true when the path exists with a null value). The current code relies on thereference.confdefault atexternal.ip = ""always populating this path. If a user explicitly writesnode.discovery = nullornode.discovery.external = nullto disable a sub-tree, normalize blows up with a stack trace pointing into its internals rather than at the offending config path. AhasPathguard or an explicit javadoc precondition (sectionmust be merged with reference.conf fallback) makes the implicit contract traceable.
Neither is a correctness bug given current reference.conf content; treat as nits.
| # to extend constant calls, switch to this option (--debug also extends | ||
| # block-processing, which is unsafe; see issue #6266). | ||
| # block-processing, which is unsafe; see issue #6266). Default: 0. | ||
| # constantCallTimeoutMs = 100 |
There was a problem hiding this comment.
[NIT] Document the new semantics of constantCallTimeoutMs = 0 in the sample config
This PR makes constantCallTimeoutMs = 0 a valid configuration meaning "share the block-processing deadline" — previously the same value was rejected. The sample config still shows the commented hint # constantCallTimeoutMs = 100 without explaining the special semantics of zero. Operators who previously set this to a positive value as a workaround for the old rejection won't know what 0 now implies after the upgrade.
Suggestion: add an inline comment in config.conf clarifying that 0 means "use the block-processing deadline", so the meaning of the default is discoverable from the sample alone.
What does this PR do?
Cleans up config bean binding across
CommitteeConfig,NodeConfig,EventConfig,StorageConfig, andVmConfig, removes the deadOverlayclass, drops the unusedgoogle/api/annotations.protoimport, and deletes the stalecodecov.yml.CommitteeConfig —
allowPBFT/pBFTExpireNumuse non-standard casing that JavaBean Introspector cannot derive correctly. Previously these were excluded fromConfigBeanFactoryand read field-by-field manually. Now anormalizeNonStandardKeys()helper remaps them to standard camelCase (allowPbft/pbftExpireNum) before binding, soConfigBeanFactoryhandles them automatically. The manual getter overrides (getAllowPBFT,getPBFTExpireNum) are replaced by standard Lombok-generated getters.NodeConfig — Three improvements:
isOpenFullTcpDisconnect: theis-prefix in the config key conflicts with JavaBean boolean-getter naming. The field is renamed toopenFullTcpDisconnect(Lombok auto-generates theisOpenFullTcpDisconnect()getter) andnormalizeNonStandardKeys()remaps the legacy config key before binding.discovery.external.ip: previously a standaloneexternalIPfield onNodeConfigread manually after binding. Now it is modelled asDiscoveryConfig.ExternalConfig.ipand auto-bound byConfigBeanFactory.normalizeNonStandardKeys()normalises both HOCONnulland the string sentinel"null"to""before binding.nativeQueue/topicsin EventConfig: removed redundant@Getter(NONE)+ hand-written getters;@Setter(NONE)is kept soConfigBeanFactoryskips the keys that require special handling, which are still read explicitly infromConfig().EventConfig — Replaced a 30-line field-by-field manual binding loop for
nativeQueueandtopicswithConfigBeanFactory.create()calls. ATOPIC_DEFAULTSfallback config fills optionalTopicConfigfields (solidified,ethCompatible,redundancy) so each topic item can be bound uniformly.StorageConfig — Removed
@Getter(NONE)+ hand-written getters forrawStorageConfig,defaultDbOption,defaultMDbOption, anddefaultLDbOption; standard Lombok getters now apply.@Setter(NONE)is retained on all four to preventConfigBeanFactoryfrom requiring their keys.VmConfig —
constantCallTimeoutMscarried@Setter(AccessLevel.NONE)to blockConfigBeanFactoryfrom touching it; the value was bound manually inpostProcess()viavmSection.hasPath()+vmSection.getLong(), and zero was treated as a misconfiguration. This workaround is removed:constantCallTimeoutMs = 0is added toreference.confso the key is always present andConfigBeanFactorybinds it automatically.@Setter(AccessLevel.NONE)is dropped; the field becomes a plain Lombok-managed field.hasPath/getLongbinding is replaced by a simple range check inpostProcess(): negative values and values that overflow microsecond conversion are rejected; zero is accepted as the valid default meaning "share the block-processing deadline".CONSTANT_CALL_TIMEOUT_MS_KEYandMAX_CONSTANT_CALL_TIMEOUT_MSconstants are removed.google/api/annotations.proto— Removed the unusedimport "google/api/annotations.proto"fromapi.proto. No RPC method in the file carries anoption (google.api.http)annotation, so the import was dead weight that pulled in an unnecessary dependency.codecov.yml— Deleted the stale Codecov configuration file. Codecov integration is no longer active; coverage is handled by JaCoCo +madrapps/jacoco-reportinpr-build.yml. The file had already been marked deprecated in a comment but was never removed.Overlay — Deleted the unused
Overlayclass and its sole test. The correspondingoverlayfield is removed fromCommonParameter.Why are these changes required?
The previous code used
@Getter(lombok.AccessLevel.NONE)+@Setter(lombok.AccessLevel.NONE)+ hand-written getter/setter pairs as a workaround for config keys thatConfigBeanFactorycould not bind automatically (reserved words, non-standard casing, optional keys). This pattern is verbose, error-prone, and scatters binding logic across fields andfromConfig()bodies. ThenormalizeNonStandardKeys()pattern and@Setter(NONE)-only approach eliminate the boilerplate while preserving the same runtime behaviour.This PR has been tested by:
Follow up
Extra details