This is the code to check how many orders can be filled in a single transaction
This code reflected: MystenLabs/deepbookv3#175 MystenLabs/deepbookv3#176
- run the sui-test-validator
sui-test-validator- run the stress test script
cd test-scripts
npm install
ts-node scripts/test.ts
ts-node scripts/fix.tsif an error occurs, please execute the commands again.
- result of
test.ts
#orders_in_tree 500
try filling 300 orders within single tx
{ status: 'success' }
{
computationCost: '1873000000',
storageCost: '101444800',
storageRebate: '417303612',
nonRefundableStorageFee: '4215188'
}
#orders_in_tree 1000
try filling 300 orders within single tx
{ status: 'success' }
{
computationCost: '4424000000',
storageCost: '160466400',
storageRebate: '530569908',
nonRefundableStorageFee: '5359292'
}
#orders_in_tree 1500
try filling 300 orders within single tx
{ status: 'failure', error: 'InsufficientGas in command 1' }
{
computationCost: '5000000000',
storageCost: '5183200',
storageRebate: '5131368',
nonRefundableStorageFee: '51832'
}
This shows the possibility of a DOS as vec_set::remove.
- result of
fix.ts
start place limit order
0
..
98
99
end place limit order
try filling 100 orders within single tx
{ status: 'success' }
{
computationCost: '248000000',
storageCost: '1577015200',
storageRebate: '1668379284',
nonRefundableStorageFee: '16852316'
}
This demonstrates MystenLabs/deepbookv3#220 and MystenLabs/deepbookv3#204 can protect against DOS attacks.