Repository navigation
feat(API): refactor merge http servlets #6976
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
Merged
kuny0707
merged 20 commits into
tronprotocol:release_v4.8.3
from
Little-Peony:refactor_merge_http_servlets
Oct 13, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
46bab31
refactor(http): derive http endpoint registry from @HttpApi annotations
Little-Peony ff01362
fix(http): adapt sanitized error responses to the servlet registry
Little-Peony 0c21d25
test(http): diff the derived registry against the pre-refactor routes
Little-Peony fa4b77e
docs(http): drop the removed audit matrix from HttpApi javadoc
Little-Peony f78a695
fix(http): rate-limit per port and select PBFT cursor after admission
Little-Peony cb7f914
test(http): reject an endpoint declared on an abstract class
Little-Peony 0d7e8c9
test(http): check a failed mount leaves the http port unbound
Little-Peony c1cc0a4
docs(http): note an excluded servlet can still be mounted directly
Little-Peony 741fa23
fix(http): fall back to the class-name limiter and keep servlet tests
Little-Peony 3e8896e
Merge branch 'release_v4.8.3' into refactor_merge_http_servlets
Little-Peony 6ff7333
fix merge
Little-Peony 483d44c
fix merge
Little-Peony 876afa3
test(http): move JSON format tests to servlets package
Little-Peony 46b5be8
Merge branch 'release_v4.8.3' into refactor_merge_http_servlets
Little-Peony 23501bf
Merge branch 'release_v4.8.3' into refactor_merge_http_servlets
Little-Peony 3d9dee6
docs(config): document OnPBFTServlet naming for rate limiter
Little-Peony a14f28d
fix comments
Little-Peony 41179b7
Merge branch 'release_v4.8.3' into refactor_merge_http_servlets
SeriousCoding789 7b9e91e
test(http): update imports of the moved servlet utilities
Little-Peony c1d32ee
Merge branch 'release_v4.8.3' into refactor_merge_http_servlets
Little-Peony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
framework/src/main/java/org/tron/core/services/filter/SolidityCursorFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.tron.core.services.filter; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
| import org.tron.core.db.Manager; | ||
| import org.tron.core.db2.core.Chainbase; | ||
|
|
||
| @Component | ||
| public class SolidityCursorFilter extends WalletCursorFilter { | ||
|
|
||
| @Autowired | ||
| public SolidityCursorFilter(Manager dbManager) { | ||
| super(dbManager, Chainbase.Cursor.SOLIDITY); | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
framework/src/main/java/org/tron/core/services/filter/WalletCursorFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.tron.core.services.filter; | ||
|
|
||
| import java.io.IOException; | ||
| import javax.servlet.Filter; | ||
| import javax.servlet.FilterChain; | ||
| import javax.servlet.FilterConfig; | ||
| import javax.servlet.ServletException; | ||
| import javax.servlet.ServletRequest; | ||
| import javax.servlet.ServletResponse; | ||
| import org.tron.core.db.Manager; | ||
| import org.tron.core.db2.core.Chainbase; | ||
|
|
||
| /** | ||
| * Selects which state view the http servlets on this port read from. | ||
| * | ||
| * <p>The read cursor is a per-thread setting ({@code ThreadLocal} in {@code Chainbase}): it only | ||
| * decides from which snapshot the current thread starts its reads, and has no effect on any | ||
| * other thread. This filter sets the cursor before the servlet runs, so the same stateless | ||
| * servlet beans can serve {@code /wallet} (HEAD) and {@code /walletsolidity} (SOLIDITY) without | ||
| * per-port subclasses. The SOLIDITY view is resolved from the live head on every read, so it can | ||
| * be selected before rate limiting; the PBFT view is an offset from the head and is selected by | ||
| * {@code RateLimiterServlet} once the request is admitted. | ||
| * | ||
| * <p>The cursor is always reset to HEAD in a finally block: jetty pools its worker threads, and | ||
| * a leftover cursor would leak into the next request served by the same thread. Only read-only | ||
| * endpoints may be mounted behind this filter — write paths must run with the HEAD cursor. | ||
| */ | ||
| public abstract class WalletCursorFilter implements Filter { | ||
|
|
||
| private final Manager dbManager; | ||
| private final Chainbase.Cursor cursor; | ||
|
|
||
| protected WalletCursorFilter(Manager dbManager, Chainbase.Cursor cursor) { | ||
| this.dbManager = dbManager; | ||
| this.cursor = cursor; | ||
| } | ||
|
|
||
| @Override | ||
| public void init(FilterConfig filterConfig) throws ServletException { | ||
| // do nothing | ||
| } | ||
|
|
||
| @Override | ||
| public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, | ||
| FilterChain filterChain) throws IOException, ServletException { | ||
| try { | ||
| dbManager.setCursor(cursor); | ||
| filterChain.doFilter(servletRequest, servletResponse); | ||
| } finally { | ||
| dbManager.resetCursor(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void destroy() { | ||
| // do nothing | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.