Skip to content

refactor(framework): decouple Manager from TronJsonRpcImpl - #6990

Merged
kuny0707 merged 8 commits into
tronprotocol:release_v4.8.3from
0xbigapple:refactor/decouple-jsonrpc-filter
Oct 9, 2026
Merged

kuny0707 merged 8 commits into
tronprotocol:release_v4.8.3from
0xbigapple:refactor/decouple-jsonrpc-filter

Conversation

@0xbigapple

@0xbigapple 0xbigapple commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?
close #6963
Removes the Manager → TronJsonRpcImpl reverse dependency left by #6732, where core-layer Manager holds the json-rpc filter consumer through a @Lazy injection.

  • Adds a standalone FilterCapsuleQueue bean; Manager.postBlockFilter/postLogsFilter produce into it, so Manager no longer references anything under org.tron.core.services.jsonrpc (repo-wide framework/src/main is now @Lazy-free).
  • Moves the consumer loop into TronJsonRpcImpl: started by @PostConstruct when isJsonRpcFilterEnabled(), single daemon thread, stopped by close(). The consumer now runs on a daemon thread (the old Manager loop was non-daemon).
  • TronJsonRpcImpl constructor becomes (NodeInfoService, Wallet, Manager); setManager() is removed and the direct-construction test sites are migrated.
  • close() is rewritten: an AtomicBoolean guard makes it idempotent and serves as a visibility-safe stop flag, the loop exits on interrupt, and the consumer is awaited before logsFilterPool shuts down so an in-flight capsule completes on graceful shutdown. If the closing thread is interrupted, close() still waits up to 2 seconds, uninterruptibly, for the consumer before shutting down the pool.
  • ApplicationImpl.shutdown() now closes the consumer after producers stop and before dbManager.close(); the later Spring-destruction close() is a no-op.
  • The instanceof dispatch logs a warning for unknown FilterTriggerCapsule subtypes instead of silently dropping them.

Runtime behavior of the filter API is unchanged: same unbounded queue, same discard-on-shutdown semantics, one consumer shared by the FullNode/solidity/PBFT json-rpc services.

Why are these changes required?

Follow-up agreed in the #6732 review (see discussion). FullNode sets allowCircularReferences(false); @Lazy, like ObjectProvider or a runtime getBean(), only makes Spring tolerate the cycle. The reverse core → API edge stays, obscuring the component graph, and later json-rpc cleanups keep copying the pattern. This PR removes the edge instead.

This PR has been tested by:

  • Unit Tests
  • Manual Testing
    • private chain: block production with registered filters; eth_getFilterChanges delivers; SIGTERM log order confirms consumer → logs-filter-pool → dbManager → context close, single shutdown episode, no errors
    • Nile and mainnet lite nodes: 5 restart cycles each with 100 filters created and polled per cycle (~2,500 queries/cycle, zero rpc errors); on mainnet the log path delivered 20k+ real contract log entries through the new queue; filters correctly report filter not found after restart; no RejectedExecutionException, no bean-cycle errors, shutdown order identical in every cycle

Follow up

Extra details

Comment thread framework/src/test/java/org/tron/core/jsonrpc/FilterPipelineLifecycleTest.java Outdated

@bladehan1 bladehan1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@kuny0707
kuny0707 merged commit 6f7b83a into tronprotocol:release_v4.8.3 Oct 9, 2026
10 checks passed
Little-Peony added a commit to Little-Peony/java-tron that referenced this pull request Oct 9, 2026
* release_v4.8.3:
  refactor(framework): decouple Manager from TronJsonRpcImpl (tronprotocol#6990)
  refactor(api): replace response copy wrappers with Jetty content count (tronprotocol#6982)
  update a new version. version name:GreatVoyage-v4.8.2.2-1-gf3e81404fe,version code:18830 (tronprotocol#7008)
  feat: improve node stability and execution efficiency (tronprotocol#7007)
  chore(p2p): internalize libp2p v2.2.9 as a local `p2p` module (tronprotocol#6992)
  refactor(vm): remove unreachable trace compression path (tronprotocol#6997)
  fix(test): isolate cross-test state leaks and stabilize flaky suites (tronprotocol#6974)
  refactor(config): improve startup errors and remove inactive assertions (tronprotocol#6960)
  ci: optimize pull request checks (tronprotocol#6938)
  fix(config): remove inactive RocksDB options (tronprotocol#6944)

# Conflicts:
#	framework/src/main/java/org/tron/core/services/http/servlets/CreateShieldedTransactionWithoutSpendAuthSigServlet.java
Little-Peony added a commit to Little-Peony/java-tron that referenced this pull request Oct 12, 2026
* release_v4.8.3:
  feat(framework): remove --keystore-factory support from FullNode (tronprotocol#6978)
  refactor(proto): remove unused proto discover definition (tronprotocol#7014)
  fix(config): close resource streams (tronprotocol#7002)
  refactor(crypto): remove unused SM2 and SM3 (tronprotocol#6999)
  feat(plugins): backfill section bloom (tronprotocol#6973)
  refactor(api): remove dead WalletExtension gRPC service and config (tronprotocol#6975)
  refactor(framework): decouple Manager from TronJsonRpcImpl (tronprotocol#6990)
  refactor(api): replace response copy wrappers with Jetty content count (tronprotocol#6982)
  update a new version. version name:GreatVoyage-v4.8.2.2-1-gf3e81404fe,version code:18830 (tronprotocol#7008)
  feat: improve node stability and execution efficiency (tronprotocol#7007)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature] decouple json-rpc filter processing from Manager

5 participants