-
Notifications
You must be signed in to change notification settings - Fork 279
OAPP-2067 fix(ua-devtools): skip already-pinned libraries with areBytes32Equal #1947
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
base: main
Are you sure you want to change the base?
Changes from all commits
ae85dfe
868229e
e15803f
2a707cd
36003c9
0307d6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| "@layerzerolabs/ua-devtools": patch | ||
| --- | ||
|
|
||
| Fix library wire skip checks with chain-aware address equality | ||
|
|
||
| `configureSendLibraries` / `configureReceiveLibraries` (and read-library equivalents) | ||
| previously compared addresses with `toLowerCase()` or strict `===`. Checksum or | ||
| padding mismatches caused already-pinned libraries to be re-proposed, which reverts | ||
| on-chain with `LZ_SameValue`. Comparisons now use | ||
| `areBytes32Equal(normalizePeer(…, localEid), …)` so EVM checksum/padding and Solana | ||
| base58 both compare correctly. Bare `areBytes32Equal` on raw library strings is not | ||
| enough — it throws on base58. Keeps the existing "lock defaults" behavior when the | ||
| OApp is still on the endpoint default. | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ import { | |
| configureOApp, | ||
| configureOAppDelegates, | ||
| configureCallerBpsCap, | ||
| configureReceiveLibraries, | ||
| configureSendLibraries, | ||
| IOApp, | ||
| OAppFactory, | ||
| OAppOmniGraph, | ||
|
|
@@ -416,6 +418,40 @@ describe('oapp/config', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('configureSendLibraries address equality idempotency', () => { | ||
| it('should skip when already pinned even if config uses lowercase addresses', async () => { | ||
| const ethSendLibrary = await getLibraryAddress(ethSendUln2_Opt2) | ||
| const avaxSendLibrary = await getLibraryAddress(avaxSendUln2_Opt2) | ||
| const [registerErrors] = await signAndSend([ | ||
| await ethEndpointV2Sdk.registerLibrary(ethSendLibrary), | ||
| await avaxEndpointV2Sdk.registerLibrary(avaxSendLibrary), | ||
| ]) | ||
| expect(registerErrors).toEqual([]) | ||
|
|
||
| const [setErrors] = await signAndSend([ | ||
| await ethEndpointV2Sdk.setSendLibrary(ethPoint.address, avaxPoint.eid, ethSendLibrary), | ||
| await avaxEndpointV2Sdk.setSendLibrary(avaxPoint.address, ethPoint.eid, avaxSendLibrary), | ||
| ]) | ||
| expect(setErrors).toEqual([]) | ||
|
|
||
| const graph: OAppOmniGraph = { | ||
| contracts: [{ point: ethPoint }, { point: avaxPoint }], | ||
| connections: [ | ||
| { | ||
| vector: { from: ethPoint, to: avaxPoint }, | ||
| config: { sendLibrary: ethSendLibrary.toLowerCase() }, | ||
| }, | ||
| { | ||
| vector: { from: avaxPoint, to: ethPoint }, | ||
| config: { sendLibrary: avaxSendLibrary.toLowerCase() }, | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| expect(await configureSendLibraries(graph, oappSdkFactory)).toEqual([]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('configureReceiveLibraries lock defaults', () => { | ||
| let ethReceiveLibrary: string, avaxReceiveLibrary: string, graph: OAppOmniGraph | ||
| beforeEach(async () => { | ||
|
|
@@ -576,6 +612,60 @@ describe('oapp/config', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('configureReceiveLibraries address equality idempotency', () => { | ||
| it('should skip when already pinned even if config uses lowercase addresses', async () => { | ||
| const ethReceiveLibrary = await getLibraryAddress(ethReceiveUln2_Opt2) | ||
| const avaxReceiveLibrary = await getLibraryAddress(avaxReceiveUln2_Opt2) | ||
| const [registerErrors] = await signAndSend([ | ||
| await ethEndpointV2Sdk.registerLibrary(ethReceiveLibrary), | ||
| await avaxEndpointV2Sdk.registerLibrary(avaxReceiveLibrary), | ||
| ]) | ||
| expect(registerErrors).toEqual([]) | ||
|
|
||
| const [setErrors] = await signAndSend([ | ||
| await ethEndpointV2Sdk.setReceiveLibrary( | ||
| ethPoint.address, | ||
| avaxPoint.eid, | ||
| ethReceiveLibrary, | ||
| BigInt(0) | ||
| ), | ||
| await avaxEndpointV2Sdk.setReceiveLibrary( | ||
| avaxPoint.address, | ||
| ethPoint.eid, | ||
| avaxReceiveLibrary, | ||
| BigInt(0) | ||
| ), | ||
| ]) | ||
| expect(setErrors).toEqual([]) | ||
|
|
||
| const graph: OAppOmniGraph = { | ||
| contracts: [{ point: ethPoint }, { point: avaxPoint }], | ||
| connections: [ | ||
| { | ||
| vector: { from: ethPoint, to: avaxPoint }, | ||
| config: { | ||
| receiveLibraryConfig: { | ||
| receiveLibrary: ethReceiveLibrary.toLowerCase(), | ||
| gracePeriod: BigInt(0), | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| vector: { from: avaxPoint, to: ethPoint }, | ||
| config: { | ||
| receiveLibraryConfig: { | ||
| receiveLibrary: avaxReceiveLibrary.toLowerCase(), | ||
| gracePeriod: BigInt(0), | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| expect(await configureReceiveLibraries(graph, oappSdkFactory)).toEqual([]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('configureReceiveLibraryTimeouts', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we also want to run the normalized equality checks on |
||
| let ethDefaultReceiveLibrary: string, | ||
| ethReceiveLibrary_Opt2: string, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add some simple tests for hex padding and Solana base58 format?