-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[CLOB-1055] - final settlement e2e tests #926
Conversation
WalkthroughThe recent updates involve adding a new parameter Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (13)
- protocol/testing/e2e/gov/add_new_market_test.go (1 hunks)
- protocol/testing/e2e/gov/bridge_test.go (3 hunks)
- protocol/testing/e2e/gov/feetiers_test.go (1 hunks)
- protocol/testing/e2e/gov/perpetuals_test.go (3 hunks)
- protocol/testing/e2e/gov/prices_test.go (1 hunks)
- protocol/testing/e2e/gov/rewards_test.go (1 hunks)
- protocol/testing/e2e/gov/sending_test.go (2 hunks)
- protocol/testing/e2e/gov/stats_test.go (2 hunks)
- protocol/testing/e2e/gov/vest_test.go (4 hunks)
- protocol/testing/e2e/gov/wind_down_market_test.go (1 hunks)
- protocol/testutil/app/gov.go (3 hunks)
- protocol/testutil/constants/stateful_orders.go (1 hunks)
- protocol/testutil/constants/subaccounts.go (1 hunks)
Files skipped from review due to trivial changes (2)
- protocol/testing/e2e/gov/add_new_market_test.go
- protocol/testing/e2e/gov/stats_test.go
Additional comments: 22
protocol/testutil/app/gov.go (3)
38-38: The addition of the
submitProposalTxHeight
parameter to theSubmitAndTallyProposal
function is consistent with the PR objectives to enhance the testing framework. Ensure that all calls to this function have been updated to include the new argument.75-75: The use of
submitProposalTxHeight
withinAdvanceToBlock
function call is correct and replaces the previously hard-coded value, improving the flexibility of the test.93-93: The use of
submitProposalTxHeight
in theAdvanceToBlock
function call when the proposal submission is expected to succeed is correct and ensures that the test advances to the correct block height.protocol/testing/e2e/gov/rewards_test.go (1)
- 123-123: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call inTestUpdateRewardsModuleParams
aligns with the PR objectives to enhance the testing framework.protocol/testing/e2e/gov/feetiers_test.go (1)
- 132-132: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call inTestUpdateFeeTiersModuleParams
is consistent with the PR's aim to improve the test suite.protocol/testing/e2e/gov/sending_test.go (2)
6-7: The change in import order, moving
github.com/dydxprotocol/v4-chain/protocol/lib
below thetesting
import, follows the Go convention of grouping standard library imports separately from third-party packages.109-109: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call inTestSendFromModuleToAccount
is in line with the PR's objectives to enhance the testing framework.protocol/testing/e2e/gov/prices_test.go (1)
- 184-184: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call inTestUpdateMarketParam
is consistent with the PR's aim to improve the test suite.protocol/testing/e2e/gov/bridge_test.go (3)
111-117: The addition of
testapp.TestSubmitProposalTxHeight
as an argument totestapp.SubmitAndTallyProposal
inTestUpdateEventParams
is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all tests.214-220: The addition of
testapp.TestSubmitProposalTxHeight
as an argument totestapp.SubmitAndTallyProposal
inTestUpdateProposeParams
is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all tests.280-286: The addition of
testapp.TestSubmitProposalTxHeight
as an argument totestapp.SubmitAndTallyProposal
inTestUpdateSafetyParams
is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all tests.protocol/testing/e2e/gov/wind_down_market_test.go (1)
- 26-287: The
TestWindDownMarketProposal
function has been added to test the wind-down process of a market. It includes various scenarios to ensure the protocol behaves as expected when a market is being closed. This aligns with the PR objectives to introduce comprehensive e2e tests for the market wind-down process. Ensure that the test cases cover all possible scenarios and that the assertions are correctly validating the expected outcomes.protocol/testutil/constants/subaccounts.go (1)
- 321-336: The addition of
Dave_Num0_1BTC_Long_50001USD
follows the established pattern of subaccount definitions and appears correctly structured with appropriate fields forId
,AssetPositions
, andPerpetualPositions
.protocol/testing/e2e/gov/vest_test.go (4)
177-177: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all test cases.313-313: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all test cases.390-390: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all test cases.495-495: The addition of
testapp.TestSubmitProposalTxHeight
as an argument to theSubmitAndTallyProposal
function call is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly documented and that its usage is correctly implemented across all test cases.protocol/testing/e2e/gov/perpetuals_test.go (3)
- 132-138: The addition of
testapp.TestSubmitProposalTxHeight
as an argument totestapp.SubmitAndTallyProposal
is consistent with the PR objectives to enhance the testing framework. Ensure that the new argument is properly handled within theSubmitAndTallyProposal
function and that all tests still pass with the new argument in place.Verification successful
The attempt to verify the update to the
SubmitAndTallyProposal
function usingast-grep
did not produce any output, which means we cannot confirm through this method whether the function has been updated to handle the new argumenttestapp.TestSubmitProposalTxHeight
.Additionally, the attempt to run the tests using
go test -v
failed because thego
command was not found in the execution environment. Moreover, there was an error with therg
command usage due to an incorrect--exec
flag.To proceed, we need to correct the script to verify the update to the
SubmitAndTallyProposal
function and find a different way to confirm that the tests pass with the new argument since we cannot rungo test
directly.Let's generate a new script to check the definition of the
SubmitAndTallyProposal
function to see if it has been updated to include the new argument. We will also userg
correctly to search for the function definition.
The
ast-grep
command did not provide specific output, which means it did not find a direct match for theSubmitAndTallyProposal
function with the exact pattern provided. However, therg
command did find a reference to theSubmitAndTallyProposal
function in the fileprotocol/testutil/app/gov.go
.Given this information, we can infer that the
SubmitAndTallyProposal
function exists, but we still need to verify if it has been updated to include the new argumenttestapp.TestSubmitProposalTxHeight
. To do this, we should look at the actual definition of the function ingov.go
.Let's generate a new script to view the contents of the
gov.go
file where theSubmitAndTallyProposal
function is defined to confirm the function signature.
The output from the script shows the signature of the
SubmitAndTallyProposal
function in thegov.go
file. It confirms that the function has been updated to include a new parametersubmitProposalTxHeight uint32
, which matches thetestapp.TestSubmitProposalTxHeight
argument mentioned in the PR objectives and review comment.Based on this information, we can conclude that the
SubmitAndTallyProposal
function has been correctly updated to handle the new argument as intended by the PR. However, we do not have confirmation that the tests pass since thego test
command could not be executed in the environment.The review comment is consistent with the changes made in the codebase, and the function signature has been verified to include the new argument.
* 318-324: The addition of `testapp.TestSubmitProposalTxHeight` in the `TestUpdatePerpetualsParams` function call is consistent with the changes in the previous hunk. It's important to verify that the new argument is correctly used and that the function's behavior remains correct.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the function `SubmitAndTallyProposal` is updated to handle the new argument. ast-grep --lang go --pattern $'SubmitAndTallyProposal($_, $_, $_, testapp.TestSubmitProposalTxHeight, $_, $_, $_)' # Run tests to ensure they pass with the new argument. rg --type go 'func TestUpdatePerpetualsModuleParams' --exec cat {} | go test -vLength of output: 678
Script:
#!/bin/bash # Search for the definition of the `SubmitAndTallyProposal` function to verify if it includes the new argument. ast-grep --lang go --pattern $'func SubmitAndTallyProposal($_, $_, $_, $_, $_, $_, $_) { $$$ }' # Use rg to search for the function definition without the incorrect --exec flag. rg --type go 'func SubmitAndTallyProposal'Length of output: 199
Script:
#!/bin/bash # Display the contents of the file where `SubmitAndTallyProposal` is defined to check the function signature. rg --type go -A 10 'func SubmitAndTallyProposal' protocol/testutil/app/gov.goLength of output: 367
Verification successful
I will now generate a new script to verify the correct usage of the
testapp.TestSubmitProposalTxHeight
argument in theSubmitAndTallyProposal
function and to check if theTestUpdatePerpetualsParams
test function exists and has been updated accordingly.
The
ast-grep
command did not return any results for theSubmitAndTallyProposal
function, which could indicate that the function does not exist with the provided pattern or that the pattern did not match due to differences in the function's signature or body.However, the
rg
command confirmed the existence of theTestUpdatePerpetualsParams
function in theperpetuals_test.go
file.Given the information, I will now generate a new script to extract the full signature of the
SubmitAndTallyProposal
function to verify if it has been updated to include the new argumenttestapp.TestSubmitProposalTxHeight
.
The output from the script indicates that the
SubmitAndTallyProposal
function exists, but it does not provide the full signature. To verify the new argumenttestapp.TestSubmitProposalTxHeight
, I need to see the complete function signature.I will generate a new script to retrieve the full function signature of
SubmitAndTallyProposal
.
The full signature of the
SubmitAndTallyProposal
function has been retrieved, and it includes thesubmitProposalTxHeight uint32
parameter, which corresponds to the new argumenttestapp.TestSubmitProposalTxHeight
mentioned in the PR objectives and review comment.Based on the provided information, the addition of
testapp.TestSubmitProposalTxHeight
as a new argument in theSubmitAndTallyProposal
function call is verified, and the function's signature has been updated to reflect this change.* 469-475: Again, the addition of `testapp.TestSubmitProposalTxHeight` in the `TestSetLiquidityTier` function call is consistent with the changes in the previous hunks. Confirm that the new argument is correctly used and that the function's behavior remains correct.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the function `SubmitAndTallyProposal` is updated to handle the new argument. ast-grep --lang go --pattern $'SubmitAndTallyProposal($_, $_, $_, testapp.TestSubmitProposalTxHeight, $_, $_, $_)' # Run tests to ensure they pass with the new argument. rg --type go 'func TestUpdatePerpetualsParams' --exec cat {} | go test -vLength of output: 672
Script:
#!/bin/bash # Verify that the function `SubmitAndTallyProposal` is updated to handle the new argument. ast-grep --lang go --pattern $'func SubmitAndTallyProposal($$$) { $$$ }' # Check if the `TestUpdatePerpetualsParams` test function exists and has been updated. rg --type go 'func TestUpdatePerpetualsParams'Length of output: 214
Script:
#!/bin/bash # Extract the full signature of the `SubmitAndTallyProposal` function to verify the new argument. rg --type go 'func SubmitAndTallyProposal' -- 'protocol/testutil/app/gov.go'Length of output: 105
Script:
#!/bin/bash # Retrieve the full function signature of `SubmitAndTallyProposal`. rg --type go -A 10 'func SubmitAndTallyProposal' -- 'protocol/testutil/app/gov.go'Length of output: 370
protocol/testutil/constants/stateful_orders.go (2)
21-31: The new constant
LongTermOrder_Alice_Num0_Id0_Clob0_Buy5_Price5_GTBT5
is added correctly with appropriate field values. Ensure that the new constant is used in the test cases and that its addition is consistent with the testing strategy.31-31: Verify that the
GoodTilBlockTime
value of5
in theGoodTilOneof
field of the new constant aligns with the intended block time for the test scenarios where this constant will be used.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- protocol/testing/e2e/gov/add_new_market_test.go (1 hunks)
- protocol/testing/e2e/gov/sending_test.go (2 hunks)
- protocol/testutil/app/gov.go (4 hunks)
Files skipped from review as they are similar to previous changes (3)
- protocol/testing/e2e/gov/add_new_market_test.go
- protocol/testing/e2e/gov/sending_test.go
- protocol/testutil/app/gov.go
statefulOrders []clobtypes.MsgPlaceOrder | ||
|
||
expectedSubaccounts []satypes.Subaccount | ||
}{ |
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.
can we add a few more test cases
- trading is disabled (new messages rejected)
- trading is disabled during PCS replay (not sure if there is a good way to test this with e2e framework)
- liquidation is disabled
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 think some of these tests are things that I can break out into a different e2e test which doesn't need to include the passing of the gov proposal in the test suite. The purpose of this test suite in particular was to verify things that happen as side effects of the proposal passing (open orders cancelled, open positions closed). Will break these out
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- protocol/testing/e2e/gov/wind_down_market_test.go (1 hunks)
- protocol/testutil/constants/orders.go (2 hunks)
Additional comments: 3
protocol/testutil/constants/orders.go (3)
980-987: The newly added IOC (Immediate-Or-Cancel) orders for Alice follow the established naming convention and structure. The use of
clobtypes.Order_TIME_IN_FORCE_IOC
is consistent with the order type.1102-1109: The FOK (Fill-Or-Kill) order for Carl is consistent with the naming convention and uses the correct
TimeInForce
value. However, ensure that theGoodTilBlock
value of 20 aligns with the intended test scenarios, as this value determines the block height until which the order remains valid.Verification successful
The search within
wind_down_market_test.go
shows that theOrder_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK
constant is indeed used in a test case. The context provided around the usage of this constant in the test file includes several other orders with differentGoodTilBlock
values, suggesting that this particular order is part of a set of orders being tested for the wind-down market scenario.Given this information, it can be inferred that the
GoodTilBlock
value of 20 for Carl's FOK order is intentional and is used within the context of the end-to-end governance test scenarios, specifically in the wind-down market test. There is no indication from the output that this value is incorrect or inconsistent with the intended test scenarios.* 977-990: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [980-1109]Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the GoodTilBlock value of 20 is intended for the FOK order scenarios. # This script assumes that there is a test scenario or documentation that specifies the intended GoodTilBlock values. # Replace 'path_to_test_scenarios' with the actual path to the test scenario files or documentation. rg "Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK" path_to_test_scenariosLength of output: 145
Script:
#!/bin/bash # Search for references to the 'Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK' constant in the test files or documentation. rg "Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK"Length of output: 300
Script:
#!/bin/bash # Examine the usage of 'Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK' in 'wind_down_market_test.go' to understand the context of 'GoodTilBlock' value of 20. rg "Order_Carl_Num0_Id0_Clob0_Buy1BTC_Price50000_GTB20_FOK" -C 10 protocol/testing/e2e/gov/wind_down_market_test.goLength of output: 740
Ensure that the addition of new orders for Alice, Bob, Carl, and Dave, including various order types like IOC, FOK, and Reduce-Only, are reflected in the corresponding test cases. These constants should be utilized in tests that verify the correct behavior of the trading platform under different order conditions.
clobtypes.SubticksPerTick(clobPair.GetSubticksPerTick()), | ||
satypes.BaseQuantums(clobPair.GetStepBaseQuantums()), | ||
), | ||
), | ||
}, | ||
} | ||
for i, order := range tc.preexistingStatefulOrders { | ||
events = append( | ||
events, | ||
&indexer_manager.IndexerTendermintEvent{ | ||
Subtype: indexerevents.SubtypeStatefulOrder, | ||
OrderingWithinBlock: &indexer_manager.IndexerTendermintEvent_TransactionIndex{}, | ||
EventIndex: uint32(i + 1), | ||
Version: indexerevents.StatefulOrderEventVersion, | ||
DataBytes: indexer_manager.GetBytes( | ||
indexerevents.NewStatefulOrderRemovalEvent( | ||
order.Order.OrderId, | ||
indexershared.OrderRemovalReason_ORDER_REMOVAL_REASON_FINAL_SETTLEMENT, | ||
), | ||
), | ||
}, | ||
) | ||
} | ||
expectedOnChainMessageAfterGovProposal := indexer_manager.CreateIndexerBlockEventMessage( | ||
&indexer_manager.IndexerTendermintBlock{ | ||
Height: uint32(ctx.BlockHeight()), | ||
Time: ctx.BlockTime(), | ||
Events: events, | ||
TxHashes: []string{ | ||
string(lib.GetTxHash( | ||
[]byte{}, | ||
)), | ||
}, | ||
}, | ||
) | ||
onchainMessages := msgSender.GetOnchainMessages() | ||
require.Equal( | ||
t, | ||
expectedOnChainMessageAfterGovProposal, | ||
onchainMessages[len(onchainMessages)-1], | ||
) | ||
|
||
// Verify clob pair is transitioned to final settlement | ||
updatedClobPair, exists := tApp.App.ClobKeeper.GetClobPair(ctx, clobtypes.ClobPairId(clobPairId)) | ||
require.True(t, exists) | ||
require.Equal(t, clobtypes.ClobPair_STATUS_FINAL_SETTLEMENT, updatedClobPair.Status) | ||
|
||
// Verify that open stateful orders are removed from state | ||
for _, order := range tc.preexistingStatefulOrders { | ||
_, exists := tApp.App.ClobKeeper.GetLongTermOrderPlacement(ctx, order.Order.OrderId) | ||
require.False(t, exists) | ||
} | ||
|
||
// Set liquidation daemon info, to simulate liquidations daemon updating SubaccountOpenPositionInfo | ||
_, err := tApp.App.Server.LiquidateSubaccounts( | ||
ctx, | ||
&api.LiquidateSubaccountsRequest{ | ||
SubaccountOpenPositionInfo: []clobtypes.SubaccountOpenPositionInfo{ | ||
{ | ||
PerpetualId: 0, | ||
SubaccountsWithShortPosition: []satypes.SubaccountId{ | ||
constants.Carl_Num0, | ||
}, | ||
SubaccountsWithLongPosition: []satypes.SubaccountId{ | ||
constants.Dave_Num0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
) | ||
require.NoError(t, err) | ||
|
||
// Advance block again to trigger final settlement deleveraging in PrepareCheckState | ||
ctx = tApp.AdvanceToBlock(uint32(ctx.BlockHeight())+1, testapp.AdvanceToBlockOptions{}) | ||
|
||
// Verify that final settlement deleveraging occurs | ||
for _, expectedSubaccount := range tc.expectedSubaccounts { | ||
subaccount := tApp.App.SubaccountsKeeper.GetSubaccount(ctx, *expectedSubaccount.Id) | ||
require.Equal(t, expectedSubaccount, subaccount) | ||
} | ||
|
||
// Attempt to place new orders, should fail validation | ||
for _, order := range tc.orders { | ||
for _, checkTx := range testapp.MustMakeCheckTxsWithClobMsg( | ||
ctx, | ||
tApp.App, | ||
order, | ||
) { | ||
resp := tApp.CheckTx(checkTx) | ||
require.Contains(t, resp.Log, "trading is disabled for clob pair") | ||
require.False( | ||
t, | ||
resp.IsOK(), | ||
"Expected CheckTx to fail. Response: %+v", | ||
resp, | ||
) | ||
} | ||
} | ||
}) | ||
} |
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.
The test suite TestWindDownMarketProposal
is well-structured and covers a variety of scenarios to ensure the robustness of the market wind-down process. It checks for the correct handling of open orders and positions, the blocking of new orders, and the emission of correct events. The use of constants for test data and the modular approach to setting up the test environment are commendable for maintainability and readability.
However, there are a few areas that could be improved or need clarification:
-
Test Case Descriptions (Lines 34-125): The test cases are described in a string format which is good for readability, but it might be beneficial to include more detailed comments explaining the rationale behind each test case, especially for complex scenarios.
-
Genesis State Setup (Lines 135-175): The setup for the genesis state is comprehensive, but it's important to ensure that any changes to the genesis parameters are reflected across all tests that might be affected by these parameters.
-
Event Verification (Lines 226-278): The verification of events emitted by the indexer is crucial. It would be good to ensure that the event types and data are thoroughly checked against expected values to prevent any regressions or incorrect event emissions.
-
Error Handling (Lines 292-308): The error handling after setting the liquidation daemon info is correct. It's important to ensure that all possible error paths are tested, including any network or data-related issues that could occur in a live environment.
-
Final Settlement Deleveraging (Lines 310-317): The test for final settlement deleveraging is critical. It would be beneficial to add more assertions to verify the state of the system after deleveraging, such as checking the balances and positions of all relevant subaccounts.
-
New Order Placement (Lines 319-335): The test for blocking new orders is good. However, it would be helpful to include tests for edge cases, such as orders that are placed right at the transition to the final settlement status.
Overall, the test suite is comprehensive and seems to align with the PR objectives. It would be beneficial to ensure that all edge cases and error paths are considered and tested to guarantee the robustness of the market wind-down process.
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- protocol/testutil/constants/orders.go (2 hunks)
- protocol/testutil/constants/subaccounts.go (1 hunks)
Additional comments: 4
protocol/testutil/constants/subaccounts.go (1)
- 345-360: The addition of
Dave_Num0_1BTC_Long_50001USD
is consistent with the existing pattern of subaccount definitions in the file. The structure and data types used align with the other subaccount entries.protocol/testutil/constants/orders.go (3)
- 991-1004: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [994-1123]
The addition of new order constants with various parameters, including
TimeInForce
settings likeIOC
(Immediate or Cancel) andFOK
(Fill or Kill), seems to be consistent and correctly implemented. However, ensure that the addition of these constants aligns with the intended test scenarios and that they are utilized in the test suite effectively.
- 991-1004: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [994-1123]
The naming convention for the order constants is clear and consistent, which is good for maintainability and readability of the test suite.
- 991-1004: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [994-1123]
The use of
math.MaxUint64
forSubticks
in some orders is appropriate for representing a maximum value. However, ensure that the system's logic that processes these orders can handle such large values without overflow issues.Verification successful
Based on the analysis of the
orders.go
file, the system includes checks and logic to handleSubticks
values, including the use ofmath.MaxUint64
. The code is designed to prevent overflow issues by validatingSubticks
against theClobPair
'sSubticksPerTick
and handling large values as special cases. This suggests that the system is likely equipped to handlemath.MaxUint64
without causing overflow issues.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the system logic can handle math.MaxUint64 without overflow. # This script is a placeholder and should be replaced with actual verification steps. echo "Check system logic for handling of math.MaxUint64 in Subticks."Length of output: 134
Script:
#!/bin/bash # Search for occurrences of math.MaxUint64 in the codebase. rg "math.MaxUint64"Length of output: 14392
Script:
#!/bin/bash # Identify where Subticks are processed in the codebase and examine the logic for handling large values. rg "Subticks" --files-with-matchesLength of output: 5939
Script:
#!/bin/bash # Examine the logic in the keeper directory that processes Subticks. rg "Subticks" protocol/x/clob/keeper/ --files-with-matchesLength of output: 1311
Script:
#!/bin/bash # Examine the 'orders.go' file to understand how Subticks are processed. rg "Subticks" protocol/x/clob/keeper/orders.goLength of output: 1977
} | ||
|
||
// IOC orders. | ||
Order_Alice_Num0_Id1_Clob0_Buy5_Price15_GTB20_IOC = clobtypes.Order{ | ||
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 0}, | ||
Side: clobtypes.Order_SIDE_BUY, | ||
Quantums: 5, | ||
Subticks: 15, | ||
GoodTilOneof: &clobtypes.Order_GoodTilBlock{GoodTilBlock: 20}, | ||
TimeInForce: clobtypes.Order_TIME_IN_FORCE_IOC, | ||
} | ||
Order_Alice_Num0_Id1_Clob1_Buy5_Price15_GTB20_IOC = clobtypes.Order{ | ||
OrderId: clobtypes.OrderId{SubaccountId: Alice_Num0, ClientId: 1, ClobPairId: 1}, | ||
Side: clobtypes.Order_SIDE_BUY, |
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.
Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [994-1123]
Consider splitting the order constants into separate files if the file size becomes too large, to improve modularity and manageability of the test constants.
This PR contains an e2e test suite for generating, passing, and executing a governance proposal which winds down a market. The test suite also verifies that open stateful orders in the market are closed, positions are closed via deleveraging / final settlement deleveraging, and that the proper indexer events are emitted