Incorrect version lock description after Swift 5 migration #264

Closed
opened 2025-12-29 15:27:50 +01:00 by adam · 5 comments
Owner

Originally created by @dr-mobiblocks on GitHub (Apr 2, 2019).

0e254867b6/Sources/CoreStore%2BCustomDebugStringConvertible.swift (L1017-L1022)

Proposed change:

let bytes = data.withUnsafeBytes {
	$0.bindMemory(to: HashElement.self)
		.map { "\("0x\(String($0, radix: 16, uppercase: false))")" }
}
Originally created by @dr-mobiblocks on GitHub (Apr 2, 2019). https://github.com/JohnEstropia/CoreStore/blob/0e254867b620107f38d06fc33e13838a2eec651a/Sources/CoreStore%2BCustomDebugStringConvertible.swift#L1017-L1022 Proposed change: ```swift let bytes = data.withUnsafeBytes { $0.bindMemory(to: HashElement.self) .map { "\("0x\(String($0, radix: 16, uppercase: false))")" } } ```
adam added the corestore bug label 2025-12-29 15:27:50 +01:00
adam closed this issue 2025-12-29 15:27:50 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Apr 4, 2019):

Just to clarify, is the current implementation producing a different hash from the proposed cleaner implementation?

@JohnEstropia commented on GitHub (Apr 4, 2019): Just to clarify, is the current implementation producing a different hash from the proposed cleaner implementation?
Author
Owner

@JohnEstropia commented on GitHub (Apr 4, 2019):

Just checked with the unit tests, both codes seem to produce the same hash so technically neither is "Incorrect". The new syntax is ideal though so I'll be updating this in the next version.

@JohnEstropia commented on GitHub (Apr 4, 2019): ~Just checked with the unit tests, both codes seem to produce the same hash so technically neither is "Incorrect". The new syntax is ideal though so I'll be updating this in the next version.~
Author
Owner

@dr-mobiblocks commented on GitHub (Apr 4, 2019):

Yes, it is producing a different hash 'format'.

XCode 10.2 console ouput after a schema change

Current:

...
Expected lock values: [
    "M1": [0x87, 0xaf, 0x91, 0x57],
    "M2": [0xb6, 0x5, 0x64, 0x3a],
    "M3": [0x92, 0x71, 0x22, 0x19],
    "M4": [0x60, 0xf3, 0x94, 0xd5],
    "M5": [0x61, 0x17, 0xab, 0x41],
    "M6": [0x79, 0xec, 0x74, 0x53],
    "M7": [0xd2, 0x4, 0xc5, 0x4a],
    "M8": [0xb8, 0x54, 0xf3, 0x82],
    "M9": [0xa4, 0x10, 0xf4, 0x4],
    "M10": [0x4f, 0xa1, 0x3d, 0x3],
    "M11": [0x6f, 0xed, 0x2a, 0xd1],
    "M12": [0x1, 0xd2, 0x4a, 0x7e],
    "M13": [0xea, 0xc5, 0x85, 0x99]
]
Actual lock values: [
    "M1": [0x87, 0xaf, 0x91, 0x57],
    "M2": [0x54, 0xd5, 0x2a, 0xee],
    "M3": [0x92, 0x71, 0x22, 0x19],
    "M4": [0x60, 0xf3, 0x94, 0xd5],
    "M5": [0x61, 0x17, 0xab, 0x41],
    "M6": [0x79, 0xec, 0x74, 0x53],
    "M7": [0xd2, 0x4, 0xc5, 0x4a],
    "M8": [0xb8, 0x54, 0xf3, 0x82],
    "M9": [0xa4, 0x10, 0xf4, 0x4],
    "M10": [0x4f, 0xa1, 0x3d, 0x3],
    "M11": [0x6f, 0xed, 0x2a, 0xd1],
    "M12": [0x1, 0xd2, 0x4a, 0x7e],
    "M13": [0xea, 0xc5, 0x85, 0x99]
]
...

Before migrating to Swift 5 and proposed implementation:

...
Expected lock values: [
    "M1": [0xee463a5d5791af87, 0xe3430ddaa316aadf, 0xbdef12ecf2e0010f, 0xfca3a4e26a4318f7],
    "M2": [0xd630f6413a6405b6, 0x375aba7148c2c3db, 0xfc997c3cde6eb792, 0x7179a958b8256107],
    "M3": [0xaa825c2519227192, 0xe6299648b2afbdb2, 0xadd8742695e60fea, 0xd4db9de027d11275],
    "M4": [0xfa257e39d594f360, 0xbf6c917505500af8, 0x9aac48829812bffd, 0x8e379a58e9c4fdb4],
    "M5": [0x791af64241ab1761, 0x5b5833bcde5c1f0, 0x9c68270c68fcc9dd, 0xf96840a1b20d1c13],
    "M6": [0xd50961cd5374ec79, 0xe4236bc670aaa5b5, 0xa9e29511ee7213b3, 0x39b72a29b0c81f21],
    "M7": [0xc2960af44ac504d2, 0x9067116de9fd4b72, 0x5ff80dd6979a34e3, 0xd4dea6995771512e],
    "M8": [0xba4d84a482f354b8, 0x7a667a30ecce1122, 0xf26e34e04cd06005, 0x984c8c8b58a34b80],
    "M9": [0xaed402cf04f410a4, 0xf3302367e9715e93, 0x33005aa0188bfaaf, 0xe964ad304c745d6e],
    "M10": [0x7a5f2458033da14f, 0xaed3ba7f20266b3a, 0x39b191019be7aa08, 0xda239183b6dbc61f],
    "M11": [0xd559cf1dd12aed6f, 0x5a4252907c48e0ad, 0x5156aa7e5e3f38fc, 0x272c0f48f3c97034],
    "M12": [0xdd9840b7e4ad201, 0x886a0c0166d85420, 0x5273b660cc58da41, 0xaebb6156188e9627],
    "M13": [0x6383f5119985c5ea, 0x54cf78ceccd79166, 0xacf3985d58c3896f, 0x64fb9841f53a5ace]
]
Actual lock values: [
    "M1": [0xee463a5d5791af87, 0xe3430ddaa316aadf, 0xbdef12ecf2e0010f, 0xfca3a4e26a4318f7],
    "M2": [0x3261ebf6ee2ad554, 0xec9e9b4c322d130e, 0x88108bed1326d318, 0x5c34a513ddb1b54b],
    "M3": [0xaa825c2519227192, 0xe6299648b2afbdb2, 0xadd8742695e60fea, 0xd4db9de027d11275],
    "M4": [0xfa257e39d594f360, 0xbf6c917505500af8, 0x9aac48829812bffd, 0x8e379a58e9c4fdb4],
    "M5": [0x791af64241ab1761, 0x5b5833bcde5c1f0, 0x9c68270c68fcc9dd, 0xf96840a1b20d1c13],
    "M6": [0xd50961cd5374ec79, 0xe4236bc670aaa5b5, 0xa9e29511ee7213b3, 0x39b72a29b0c81f21],
    "M7": [0xc2960af44ac504d2, 0x9067116de9fd4b72, 0x5ff80dd6979a34e3, 0xd4dea6995771512e],
    "M8": [0xba4d84a482f354b8, 0x7a667a30ecce1122, 0xf26e34e04cd06005, 0x984c8c8b58a34b80],
    "M9": [0xaed402cf04f410a4, 0xf3302367e9715e93, 0x33005aa0188bfaaf, 0xe964ad304c745d6e],
    "M10": [0x7a5f2458033da14f, 0xaed3ba7f20266b3a, 0x39b191019be7aa08, 0xda239183b6dbc61f],
    "M11": [0xd559cf1dd12aed6f, 0x5a4252907c48e0ad, 0x5156aa7e5e3f38fc, 0x272c0f48f3c97034],
    "M12": [0xdd9840b7e4ad201, 0x886a0c0166d85420, 0x5273b660cc58da41, 0xaebb6156188e9627],
    "M13": [0x6383f5119985c5ea, 0x54cf78ceccd79166, 0xacf3985d58c3896f, 0x64fb9841f53a5ace]
]
...
@dr-mobiblocks commented on GitHub (Apr 4, 2019): Yes, it is producing a different hash 'format'. XCode 10.2 console ouput after a schema change Current: ``` ... Expected lock values: [ "M1": [0x87, 0xaf, 0x91, 0x57], "M2": [0xb6, 0x5, 0x64, 0x3a], "M3": [0x92, 0x71, 0x22, 0x19], "M4": [0x60, 0xf3, 0x94, 0xd5], "M5": [0x61, 0x17, 0xab, 0x41], "M6": [0x79, 0xec, 0x74, 0x53], "M7": [0xd2, 0x4, 0xc5, 0x4a], "M8": [0xb8, 0x54, 0xf3, 0x82], "M9": [0xa4, 0x10, 0xf4, 0x4], "M10": [0x4f, 0xa1, 0x3d, 0x3], "M11": [0x6f, 0xed, 0x2a, 0xd1], "M12": [0x1, 0xd2, 0x4a, 0x7e], "M13": [0xea, 0xc5, 0x85, 0x99] ] Actual lock values: [ "M1": [0x87, 0xaf, 0x91, 0x57], "M2": [0x54, 0xd5, 0x2a, 0xee], "M3": [0x92, 0x71, 0x22, 0x19], "M4": [0x60, 0xf3, 0x94, 0xd5], "M5": [0x61, 0x17, 0xab, 0x41], "M6": [0x79, 0xec, 0x74, 0x53], "M7": [0xd2, 0x4, 0xc5, 0x4a], "M8": [0xb8, 0x54, 0xf3, 0x82], "M9": [0xa4, 0x10, 0xf4, 0x4], "M10": [0x4f, 0xa1, 0x3d, 0x3], "M11": [0x6f, 0xed, 0x2a, 0xd1], "M12": [0x1, 0xd2, 0x4a, 0x7e], "M13": [0xea, 0xc5, 0x85, 0x99] ] ... ``` Before migrating to Swift 5 and proposed implementation: ``` ... Expected lock values: [ "M1": [0xee463a5d5791af87, 0xe3430ddaa316aadf, 0xbdef12ecf2e0010f, 0xfca3a4e26a4318f7], "M2": [0xd630f6413a6405b6, 0x375aba7148c2c3db, 0xfc997c3cde6eb792, 0x7179a958b8256107], "M3": [0xaa825c2519227192, 0xe6299648b2afbdb2, 0xadd8742695e60fea, 0xd4db9de027d11275], "M4": [0xfa257e39d594f360, 0xbf6c917505500af8, 0x9aac48829812bffd, 0x8e379a58e9c4fdb4], "M5": [0x791af64241ab1761, 0x5b5833bcde5c1f0, 0x9c68270c68fcc9dd, 0xf96840a1b20d1c13], "M6": [0xd50961cd5374ec79, 0xe4236bc670aaa5b5, 0xa9e29511ee7213b3, 0x39b72a29b0c81f21], "M7": [0xc2960af44ac504d2, 0x9067116de9fd4b72, 0x5ff80dd6979a34e3, 0xd4dea6995771512e], "M8": [0xba4d84a482f354b8, 0x7a667a30ecce1122, 0xf26e34e04cd06005, 0x984c8c8b58a34b80], "M9": [0xaed402cf04f410a4, 0xf3302367e9715e93, 0x33005aa0188bfaaf, 0xe964ad304c745d6e], "M10": [0x7a5f2458033da14f, 0xaed3ba7f20266b3a, 0x39b191019be7aa08, 0xda239183b6dbc61f], "M11": [0xd559cf1dd12aed6f, 0x5a4252907c48e0ad, 0x5156aa7e5e3f38fc, 0x272c0f48f3c97034], "M12": [0xdd9840b7e4ad201, 0x886a0c0166d85420, 0x5273b660cc58da41, 0xaebb6156188e9627], "M13": [0x6383f5119985c5ea, 0x54cf78ceccd79166, 0xacf3985d58c3896f, 0x64fb9841f53a5ace] ] Actual lock values: [ "M1": [0xee463a5d5791af87, 0xe3430ddaa316aadf, 0xbdef12ecf2e0010f, 0xfca3a4e26a4318f7], "M2": [0x3261ebf6ee2ad554, 0xec9e9b4c322d130e, 0x88108bed1326d318, 0x5c34a513ddb1b54b], "M3": [0xaa825c2519227192, 0xe6299648b2afbdb2, 0xadd8742695e60fea, 0xd4db9de027d11275], "M4": [0xfa257e39d594f360, 0xbf6c917505500af8, 0x9aac48829812bffd, 0x8e379a58e9c4fdb4], "M5": [0x791af64241ab1761, 0x5b5833bcde5c1f0, 0x9c68270c68fcc9dd, 0xf96840a1b20d1c13], "M6": [0xd50961cd5374ec79, 0xe4236bc670aaa5b5, 0xa9e29511ee7213b3, 0x39b72a29b0c81f21], "M7": [0xc2960af44ac504d2, 0x9067116de9fd4b72, 0x5ff80dd6979a34e3, 0xd4dea6995771512e], "M8": [0xba4d84a482f354b8, 0x7a667a30ecce1122, 0xf26e34e04cd06005, 0x984c8c8b58a34b80], "M9": [0xaed402cf04f410a4, 0xf3302367e9715e93, 0x33005aa0188bfaaf, 0xe964ad304c745d6e], "M10": [0x7a5f2458033da14f, 0xaed3ba7f20266b3a, 0x39b191019be7aa08, 0xda239183b6dbc61f], "M11": [0xd559cf1dd12aed6f, 0x5a4252907c48e0ad, 0x5156aa7e5e3f38fc, 0x272c0f48f3c97034], "M12": [0xdd9840b7e4ad201, 0x886a0c0166d85420, 0x5273b660cc58da41, 0xaebb6156188e9627], "M13": [0x6383f5119985c5ea, 0x54cf78ceccd79166, 0xacf3985d58c3896f, 0x64fb9841f53a5ace] ] ... ```
Author
Owner

@JohnEstropia commented on GitHub (Apr 5, 2019):

I see, this is during printing. Thanks! I'll also add this in the unit tests as nothing checks it right now.

@JohnEstropia commented on GitHub (Apr 5, 2019): I see, this is during printing. Thanks! I'll also add this in the unit tests as nothing checks it right now.
Author
Owner

@JohnEstropia commented on GitHub (Apr 5, 2019):

Fixed in CoreStore 6.3.1

@JohnEstropia commented on GitHub (Apr 5, 2019): Fixed in CoreStore 6.3.1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#264