-
Notifications
You must be signed in to change notification settings - Fork 75
fix(svm): use borch serializer #765
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
Conversation
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
| for address in &self.refund_addresses { | ||
| bytes.extend_from_slice(address.as_ref()); | ||
| } | ||
| AnchorSerialize::serialize(&self, &mut bytes)?; |
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.
Wow! Much better like this
| .remainingAccounts(fillRemainingAccounts) | ||
| .rpc(); | ||
| .instruction(); | ||
| const computeBudgetInstruction = ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 }); |
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.
Has the borsh serialisation increased the CU?
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.
Its hard to tell precisely as our tests are not deterministic and have much more variance due to differing bumps in PDA derivation, but over 10 runs I observed on average +2% in CU, which I guess is acceptable here.
|
|
||
| const refundAddressesBuffer = Buffer.concat(relayData.refundAddresses.map((address) => address.toBuffer())); | ||
|
|
||
| // TODO: We better consider reusing Borch serializer in production. |
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.
+1 we should probably test this and make sure they produce the same byte layout
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.
this is great!
We had custom serialization implementation when hashing relayer refund and slow fill leaves. This just concatenated array elements without encoding array length. This PR fixes by using Anchor's borch serializer that encodes this more consistently.