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

fix: market bitvise colision #3257

Merged
merged 1 commit into from
Jan 20, 2025
Merged

Conversation

dudantas
Copy link
Member

Description

This PR fixes an issue in the market system where the offer.counter value experienced collisions due to the use of a bitwise AND operation with a 16-bit mask (& 0xFFFF). When the id value exceeded multiples of 65,536 (e.g., 65,536, 131,072), the result would reset to 0, causing incorrect behavior. The fix introduces a transformation using the XOR operator (^ 0xABCDEF) before applying the mask to distribute the values more uniformly and avoid collisions.

Behaviour

Actual

When the id value in the market system reaches a multiple of 65,536, the offer.counter resets to 0 due to the bitwise AND mask (& 0xFFFF). This causes collisions and incorrect behavior in market offers.

Expected

The offer.counter should maintain unique values for different id inputs, even when they are multiples of 65,536. No collisions should occur.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

The following tests were performed to verify the fix:

  • Test A: Inserted market offers with id values close to and exceeding multiples of 65,536. Verified that offer.counter values were unique and no collisions occurred.
  • Test B: Ran regression tests to ensure that other parts of the market system were unaffected by the change.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@majestyotbr majestyotbr merged commit e362848 into main Jan 20, 2025
33 checks passed
@majestyotbr majestyotbr deleted the dudantas/fix-market-bitvise-colision branch January 20, 2025 18:11
vllworldbuilding pushed a commit to vllworldbuilding/canary that referenced this pull request Jan 30, 2025
This fixes an issue in the market system where the `offer.counter` value experienced collisions due to the use of a bitwise AND operation with a 16-bit mask (`& 0xFFFF`). 
When the `id` value exceeded multiples of 65,536 (e.g., 65,536, 131,072), the result would reset to `0`, causing incorrect behavior.
The fix introduces a transformation using the XOR operator (`^0xABCDEF`) before applying the mask to distribute the values more uniformly and avoid collisions.
lucas-caminha pushed a commit to lucas-caminha/canary that referenced this pull request Feb 10, 2025
This fixes an issue in the market system where the `offer.counter` value experienced collisions due to the use of a bitwise AND operation with a 16-bit mask (`& 0xFFFF`). 
When the `id` value exceeded multiples of 65,536 (e.g., 65,536, 131,072), the result would reset to `0`, causing incorrect behavior.
The fix introduces a transformation using the XOR operator (`^0xABCDEF`) before applying the mask to distribute the values more uniformly and avoid collisions.
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.

2 participants