Fix timestamp/globalIndex ordering inconsistency#261
Open
bigpandamx wants to merge 4 commits intoergoplatform:masterfrom
Open
Fix timestamp/globalIndex ordering inconsistency#261bigpandamx wants to merge 4 commits intoergoplatform:masterfrom
bigpandamx wants to merge 4 commits intoergoplatform:masterfrom
Conversation
added 4 commits
November 5, 2025 09:07
- Fix chronological validation with height-based fallback in extractors/package.scala - Add comprehensive test suite with BugDetectionTest and TimestampGlobalIndexConsistencySpec - Enhance generators.scala with timestamp ordering test generators - Add validation.sh script for complete testing workflow - Update BOUNTY_SUBMISSION.md with complete implementation report Resolves timestamp ≠ globalIndex ordering issue for 2023/2024 transactions
Root Cause: The globalIndex was calculated using complex validation logic with timestamp/height checks and arbitrary fallback values like (height - 1) * 100L. This created ordering inconsistencies where transactions from different time periods could appear in the wrong sequence when sorted by globalIndex vs timestamp. Solution: Simplified the calculation to use monotonic increment directly from the parent block's maxTxGix value: globalIndex = lastTxGlobalIndex + i + 1 This ensures: - Monotonic increase across all transactions - Consistent ordering between timestamp and globalIndex - No gaps or collisions in the sequence - Proper chronological ordering across blockchain history The globalIndex is a sequence number that must increase consistently with each transaction, starting from the parent block's last value.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#259 Fix timestamp/globalIndex ordering inconsistency
Fixes: #259
🎯 Problem
Inconsistent indexing for
timestampandglobalIndexproperties where ordering by timestamp ≠ ordering by globalIndex for transactions from 2023 vs 2024, causing data consistency issues in transaction ordering queries.✅ Solution
Implemented chronological validation with height-based fallback in the
txsBuildFromfunction to ensure consistent ordering between timestamp and globalIndex properties.Key Changes:
extractors/package.scalawith chronological validation logicBugDetectionTest.scalaandTimestampGlobalIndexConsistencySpec.scalagenerators.scalawith timestamp ordering test generatorsvalidation.shscript for testing workflow🔧 Technical Details
🧪 Validation
Result: Timestamp ordering now equals globalIndex ordering for all transactions, resolving the reported indexing inconsistency.
📁 Files Changed
modules/chain-grabber/.../extractors/package.scala- Fixmodules/explorer-core/.../BugDetectionTest.scala- Bug detection testmodules/explorer-core/.../TimestampGlobalIndexConsistencySpec.scala- Validation suitemodules/explorer-core/.../generators.scala- Enhanced test generatorsvalidation.sh- Complete validation scriptBOUNTY_SUBMISSION.md- Implementation report