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
[CT-1202] logic to handle unauthorized maker orders when authenticato… #2412
[CT-1202] logic to handle unauthorized maker orders when authenticato… #2412
Changes from 3 commits
e43f28d
e0366ae
7249c08
b5dbf33
186588b
e200b1f
4070e80
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Ensure
writeCache()
is called to commit state changesAfter successfully placing the short-term order with
PlaceShortTermOrder
, you should callwriteCache()
to commit the changes from the cached context to the main context. Otherwise, the modifications intempCtx
won't persist, and the order placement might not have the intended effect in the test.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.
For my understanding, this PR doesn't need to touch
ProcessOperations
explicitly, because it's already taken care of by callingAnteHandler
on the orders right?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.
again, the assumption here is that the light weight validation is sufficient because all current validations are stateless
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, and
ProcessOperations
do run the anthenticators explicitly since we cannot trust the proposerThere 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.
None of the logic here is specific to x/clob - should this function be a method in CLOB or Accountplus?
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.
We need to decode maker orders for all fills (regardless of smart account) - do we think this is okay because there are not many fews?
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.
I was planning to look at frame graphs after this is merged and deployed and optimize only if needed. I feel like this might be okay since like you said, only a very small percentage of the orders get matched.
note that all crossing maker orders get decoded, not just those that generate a fill
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
Issues Found: Incomplete Implementation of
accountPlusKeeper
inNewKeeper
The
NewKeeper
function signature inprotocol/x/clob/keeper/keeper.go
has been updated to include theaccountPlusKeeper
parameter. However, the implementation does not initialize this new field within theKeeper
struct. Additionally, multiple calls toNewKeeper
across the project are missing the requiredaccountPlusKeeper
parameter.Affected Areas:
protocol/x/clob/keeper/keeper.go
:NewKeeper
implementation missing initialization ofaccountPlusKeeper
.NewKeeper
is called without theaccountPlusKeeper
parameter, including but not limited to:protocol/x/stats/keeper/keeper.go
protocol/x/subaccounts/keeper/keeper.go
protocol/testutil/keeper/assets.go
protocol/app/app.go
Please address these issues to ensure that the
accountPlusKeeper
is properly integrated and initialized throughout the codebase.🔗 Analysis chain
LGTM. Verify
NewKeeper
implementation and usage.The addition of the
accountPlusKeeper
parameter to theNewKeeper
function signature is consistent with the struct change. However, we need to ensure that the implementation properly initializes this new field.Please verify the following:
The
NewKeeper
function implementation:All calls to
NewKeeper
have been updated:Action Required: Update All
NewKeeper
Calls to IncludeaccountPlusKeeper
The
NewKeeper
function signature has been updated to include theaccountPlusKeeper
parameter. However, the implementation inprotocol/x/clob/keeper/keeper.go
does not initialize this new field. Additionally, ensure that all calls toNewKeeper
across the project are updated to include theaccountPlusKeeper
parameter to maintain consistency and prevent potential issues.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1216
Script:
Length of output: 5220
Script:
Length of output: 5248
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.
🛠️ Refactor suggestion
Refactor duplicated code for setting
TxBytes
into a helper functionThe code for creating a transaction builder, setting messages, encoding the transaction, and updating
ctx.TxBytes
is duplicated. Consider refactoring this code into a helper function to improve maintainability and reduce code duplication.You can create a helper function like this:
Then, replace the duplicated code with:
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.
🛠️ Refactor suggestion
Refactor duplicated code into a helper function
The code in lines 626-634 and 644-651 is duplicated. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this repeated code into a helper function.
Apply this diff to refactor the code:
Define the helper function outside the selected line ranges:
Also applies to: 644-651
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
Missing
MaybeValidateAuthenticators
Implementation in MemClobKeeper InterfaceThe
MaybeValidateAuthenticators
method has been added to theMemClobKeeper
interface, but it appears that many implementations do not include this method. Please ensure that all concrete types implementingMemClobKeeper
provide an implementation forMaybeValidateAuthenticators
to maintain interface compliance.🔗 Analysis chain
New method added to MemClobKeeper interface
The addition of
MaybeValidateAuthenticators
method aligns with the PR objective of handling unauthorized maker orders. However, there are a few points to consider:MemClobKeeper
will need to be updated to include this method.To ensure all implementations are updated, run the following script:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 148215