Skip to content

refactor(config): simplify applyEventConfig (follow-up to #6615)#6735

Open
vividctrlalt wants to merge 1 commit intotronprotocol:developfrom
vividctrlalt:refactor/apply-event-config-cleanup
Open

refactor(config): simplify applyEventConfig (follow-up to #6615)#6735
vividctrlalt wants to merge 1 commit intotronprotocol:developfrom
vividctrlalt:refactor/apply-event-config-cleanup

Conversation

@vividctrlalt
Copy link
Copy Markdown
Contributor

What

Follow-up to #6615 as committed in this thread.

The 5-condition || chain in applyEventConfig (and the 3-condition variant in the FilterQuery section) was an over-faithful migration of develop's hasPath logic — that signal is erased once values flow through ConfigBeanFactory + withFallback. With reference.conf shipping topics = [...] and contractAddress = [""] defaults, both conditions evaluate to true on every startup. PARAMETER.eventPluginConfig and PARAMETER.eventFilter were therefore built unconditionally, regardless of event.subscribe.enable.

Why it's safe

Manager.java:564 is the sole consumer of both fields, gated by isEventSubscribe() (= ec.isEnable()). Whether the fields are populated or null when enable=false makes no observable difference — the plugin never starts.

Change

  • Replace the always-true || chains with a single early-out: if (!ec.isEnable()) return;
  • Drop the now-redundant outer if {...} wrappers (the dedent is mechanical)

Tests

ArgsTest regression coverage:

  • testEventConfigDisabledSkipsEpcAndFilter — enable=false → both null
  • testEventConfigEnabledBuildsEpcAndFilter — enable=true → both built
  • testEventConfigEnabledWithInvalidFromBlockLeavesFilterNull — epc built, filter left null on parse failure

Follow-up to tronprotocol#6615. The `||` chains guarding eventPluginConfig and
eventFilter construction were always-true after the bean-binding
refactor (reference.conf ships default `topics` and `contractAddress`),
so both fields were built on every startup regardless of
`event.subscribe.enable`. Their only consumer (Manager.java:564) is
already gated by `isEventSubscribe()`, so collapsing the entry to
`if (!ec.isEnable()) return;` is equivalent.

Tests in ArgsTest cover enable=false (skip both), enable=true (build
both), and enable=true with an invalid filter block (epc built, filter
left null).
@halibobo1205 halibobo1205 requested a review from xxo1shine April 30, 2026 09:56
@halibobo1205 halibobo1205 added topic:event subscribe transaction trigger, block trigger, contract event, contract log topic:config labels Apr 30, 2026
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:config topic:event subscribe transaction trigger, block trigger, contract event, contract log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants