Skip to content

feat(plugin): fill section bloom using exist db#80

Open
317787106 wants to merge 1 commit into
feature/release_v4.8.2_selffrom
feature/backfill_sectionbloom
Open

feat(plugin): fill section bloom using exist db#80
317787106 wants to merge 1 commit into
feature/release_v4.8.2_selffrom
feature/backfill_sectionbloom

Conversation

@317787106

@317787106 317787106 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

DB backfill-bloom provides the ability to backfill SectionBloom data for historical blocks to enable eth_getLogs address/topics filtering. This is useful when isJsonRpcFilterEnabled was disabled during block processing and later enabled, causing historical blocks to lack SectionBloom data.

Why are these changes required?

Refer to tronprotocol#6390

This PR has been tested by:

  • Unit Tests
  • Manual Testing

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 02d97c7d-db86-4ac4-82c8-0b83eb9154cd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/backfill_sectionbloom

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/build.gradle">

<violation number="1" location="plugins/build.gradle:73">
P1: Missing `project(':chainbase').jar` in `binaryRelease`'s explicit `dependsOn` list. The comment states all project dependency jars must be declared explicitly to avoid Gradle warnings and ensure correct build ordering for fat jar assembly.</violation>
</file>

<file name="plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java">

<violation number="1" location="plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java:113">
P3: `latest block = 0` is treated as an error, causing valid genesis-only backfill runs to fail.</violation>

<violation number="2" location="plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java:140">
P2: Section-level exceptions are logged but not counted, so the command may return success after failed section processing.</violation>

<violation number="3" location="plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java:192">
P2: Default latest-block detection ignores checkpoint state, which can make backfill end too early.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/build.gradle
implementation 'io.github.tronprotocol:leveldb:1.18.2'
}
implementation project(":protocol")
implementation project(":chainbase")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Missing project(':chainbase').jar in binaryRelease's explicit dependsOn list. The comment states all project dependency jars must be declared explicitly to avoid Gradle warnings and ensure correct build ordering for fat jar assembly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/build.gradle, line 73:

<comment>Missing `project(':chainbase').jar` in `binaryRelease`'s explicit `dependsOn` list. The comment states all project dependency jars must be declared explicitly to avoid Gradle warnings and ensure correct build ordering for fat jar assembly.</comment>

<file context>
@@ -70,6 +70,7 @@ dependencies {
         implementation 'io.github.tronprotocol:leveldb:1.18.2'
     }
     implementation project(":protocol")
+    implementation project(":chainbase")
 }
 
</file context>


private Long getLatestBlockNumber() {
try {
DBInterface propertiesDb = DbTool.getDB(databaseDirectory, "properties");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Default latest-block detection ignores checkpoint state, which can make backfill end too early.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java, line 192:

<comment>Default latest-block detection ignores checkpoint state, which can make backfill end too early.</comment>

<file context>
@@ -0,0 +1,463 @@
+
+  private Long getLatestBlockNumber() {
+    try {
+      DBInterface propertiesDb = DbTool.getDB(databaseDirectory, "properties");
+      byte[] latestBlockKey = "latest_block_header_number".getBytes();
+      byte[] latestBlockBytes = propertiesDb.get(latestBlockKey);
</file context>

Comment on lines +140 to +143
} catch (Exception e) {
logger.error("Backfill failed", e);
spec.commandLine().getErr().println("Backfill failed: " + e.getMessage());
return 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Section-level exceptions are logged but not counted, so the command may return success after failed section processing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java, line 140:

<comment>Section-level exceptions are logged but not counted, so the command may return success after failed section processing.</comment>

<file context>
@@ -0,0 +1,463 @@
+
+      return result;
+
+    } catch (Exception e) {
+      logger.error("Backfill failed", e);
+      spec.commandLine().getErr().println("Backfill failed: " + e.getMessage());
</file context>
Suggested change
} catch (Exception e) {
logger.error("Backfill failed", e);
spec.commandLine().getErr().println("Backfill failed: " + e.getMessage());
return 1;
} catch (Exception e) {
errorCount.incrementAndGet();
spec.commandLine().getErr().printf("Error processing section %d to %d, %s%n",
finalSectionStart, finalSectionEnd, e.getMessage());
}

// Determine end block if not specified
if (endBlock == null) {
endBlock = getLatestBlockNumber();
if (endBlock == null || endBlock == 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: latest block = 0 is treated as an error, causing valid genesis-only backfill runs to fail.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/src/main/java/common/org/tron/plugins/DbBackfillBloom.java, line 113:

<comment>`latest block = 0` is treated as an error, causing valid genesis-only backfill runs to fail.</comment>

<file context>
@@ -0,0 +1,463 @@
+      // Determine end block if not specified
+      if (endBlock == null) {
+        endBlock = getLatestBlockNumber();
+        if (endBlock == null || endBlock == 0) {
+          spec.commandLine().getErr().println("Failed to determine latest block number");
+          return 1;
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant