Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[SLT-234] feat(rfq): dynamic block conf wait + receipt x event quote check w/ RPC consensus #3190
[SLT-234] feat(rfq): dynamic block conf wait + receipt x event quote check w/ RPC consensus #3190
Changes from 2 commits
4a87e3d
0aa10b6
3958292
7fca370
353b63c
bfd1761
5bc3004
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 76 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L76
Check warning on line 86 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L85-L86
Check warning on line 94 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L93-L94
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.
Handle potential errors when retrieving required confirmations
In the
hasEnoughConfirmations
function, the retrieval ofrequiredConfirmations
does not handle potential errors froml.cfg.GetLimitConfirmations()
. If this function can return an error, it should be properly handled to prevent unexpected behavior.Modify the code to handle the error:
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.
Correct the tracer name to reflect the function accurately
The tracer name in
isUnderVolumeLimit
is currently set to"limiter.underVolumeLimitLimit"
, which seems redundant and may lead to confusion. It should be corrected to"limiter.isUnderVolumeLimit"
to match the function name and maintain consistency.Apply this diff to update the tracer name:
📝 Committable suggestion
Check warning on line 218 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L215-L218
Check warning on line 224 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L223-L224
Check warning on line 229 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L228-L229
Check warning on line 234 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L234
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.
Prevent potential index out-of-range panic when accessing receipt logs
Accessing
receipt.Logs[0]
without checking ifreceipt.Logs
is non-empty can result in a runtime panic if the logs slice is empty. To ensure robustness, add a check to verify thatreceipt.Logs
contains at least one entry before accessing it.Apply this diff to add the necessary check:
📝 Committable suggestion
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.
Check for empty receipt logs before accessing the first element
Accessing
receipt.Logs[0]
without verifying thatreceipt.Logs
is not empty can lead to an index out-of-range panic if the slice is empty. Before accessingreceipt.Logs[0].Data
, ensure that there is at least one log entry inreceipt.Logs
.Apply this diff to add the necessary check:
📝 Committable suggestion
Check warning on line 248 in services/rfq/relayer/limiter/limiter.go
Codecov / codecov/patch
services/rfq/relayer/limiter/limiter.go#L242-L248
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.
New checkReceipt method enhances security, but needs a safeguard
The
checkReceipt
method is a valuable addition that verifies transaction receipts and handles potential reorg scenarios. The event parsing and field matching logic provide a robust check for transaction validity.However, there's a potential issue:
Add a check before accessing log data to prevent a potential nil pointer dereference:
This change will prevent a panic if the receipt has no logs, which could happen in certain edge cases.
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: codecov/patch
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.
💡 Codebase verification
rfqFieldsMatch function is not exhaustive
The
rfqFieldsMatch
function currently verifies transaction ID, sender, origin amount, destination amount, and origin token. However, theBridgeRequested
event includes additional fields that should also be matched to ensure comprehensive validation:destChainId
)destToken
)sendChainGas
)Please update the
rfqFieldsMatch
function to include these fields to address the TODO comment and enhance the reliability of the verification process.🔗 Analysis chain
New rfqFieldsMatch function is comprehensive, but needs review
The
rfqFieldsMatch
function provides a thorough comparison of RFQ fields with event data, which is crucial for verifying the integrity of the transaction. The checks cover all essential fields: transaction ID, sender, amounts, and token.However, there's an open question:
The TODO comment suggests that the field matching might not be exhaustive. Please review if there are any additional fields that should be checked. Consider adding checks for:
If these fields are not available in the event data, update the comment to explain why the current checks are sufficient.
This will help ensure that all necessary fields are being verified and improve the robustness of the check.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 352
Script:
Length of output: 186
Script:
Length of output: 648
Script:
Length of output: 6623