Skip to content
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

SHARD-1147: Improve Blacklisting Consistency and Optimize Check Intervals #95

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

S0naliThakur
Copy link
Member

@S0naliThakur S0naliThakur commented Dec 6, 2024

Linear: https://linear.app/shm/issue/SHARD-1147

Summary:

  1. Reduced the blacklisting check interval from 12 hours to 5 mins.
  2. Fixed inconsistencies in updating blacklist.json to ensure changes are persistent and accurately reflected across the application.
  3. Updated the logic for asynchronous calls that modify the blacklist to ensure both in-memory and file-based data (blacklist.json) remain synchronized.

Copy link

@devendra-shardeum devendra-shardeum left a comment

Choose a reason for hiding this comment

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

changes looks good..

…sync unbans, ensure consistency, and enhance error handling.
@S0naliThakur S0naliThakur changed the title SHARD-1147: reduce ip ban time to 5 mins SHARD-1147: Improve Blacklisting Consistency and Optimize Check Intervals Dec 9, 2024
src/utils.ts Outdated
Comment on lines 696 to 702
if (verifyData.length !== this.bannedIps.length) {
if (verbose) console.log('Warning: Inconsistency detected between bannedIps and blacklist.json')
// Ensure bannedIps matches the file
this.bannedIps = verifyData.map((ip: string) => ({
ip,
timestamp: Date.now(),
}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this block needed? if this is to handle race condition, then this verification doesn't solve the issue. because verifyData.length !== this.bannedIps.length can be true but content of both arrays can be different.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the check to keep the blacklist.json data consistent with the in-memory blacklist IP map. I've now updated it so that if there's any inconsistency, it prioritizes the in-memory map.

@aniketdivekar aniketdivekar merged commit 9a8e270 into dev Dec 9, 2024
7 checks passed
@aniketdivekar aniketdivekar deleted the blacklisting-update branch December 9, 2024 14:05
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.

4 participants