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

Adjust ban times for DL dat files #17021

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion chia/data_layer/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,8 @@ async def received_correct_file(self, tree_id: bytes32, server_info: ServerInfo)
await self.update_server_info(tree_id, new_server_info)

async def server_misses_file(self, tree_id: bytes32, server_info: ServerInfo, timestamp: int) -> None:
BAN_TIME_BY_MISSING_COUNT = [5 * 60] * 3 + [15 * 60] * 3 + [60 * 60] * 2 + [240 * 60]
# Max banned time is 1 hour.
BAN_TIME_BY_MISSING_COUNT = [5 * 60] * 3 + [15 * 60] * 3 + [30 * 60] * 2 + [60 * 60]
index = min(server_info.num_consecutive_failures, len(BAN_TIME_BY_MISSING_COUNT) - 1)
new_server_info = replace(
server_info,
Expand Down
6 changes: 5 additions & 1 deletion chia/data_layer/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ async def insert_from_delta_file(
except Exception:
target_filename = client_foldername.joinpath(filename)
os.remove(target_filename)
await data_store.received_incorrect_file(tree_id, server_info, timestamp)
# await data_store.received_incorrect_file(tree_id, server_info, timestamp)
# incorrect file bans for 7 days which in practical usage
# is too long given this file might be incorrect for various reasons
# therefore, use the misses file logic instead
await data_store.server_misses_file(tree_id, server_info, timestamp)
await data_store.rollback_to_generation(tree_id, existing_generation - 1)
raise

Expand Down
2 changes: 1 addition & 1 deletion tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ async def test_server_selection(data_store: DataStore, tree_id: bytes32) -> None
assert servers_info[0].url == "http://127.0.0.1/8000"
await data_store.received_correct_file(tree_id=tree_id, server_info=servers_info[0])

ban_times = [5 * 60] * 3 + [15 * 60] * 3 + [60 * 60] * 2 + [240 * 60] * 10
ban_times = [5 * 60] * 3 + [15 * 60] * 3 + [30 * 60] * 2 + [60 * 60] * 10
for ban_time in ban_times:
servers_info = await data_store.get_available_servers_for_store(tree_id=tree_id, timestamp=current_timestamp)
assert len(servers_info) == 1
Expand Down
Loading