Shell & plugins: bound the mempool by op count and total byte size
Context
Fixes #5196 (closed)
The main semantic change in this MR consists in new bounding constraints on the valid operations kept in the mempool:
- Before, we ensured that the number of valid manager operations was at most
max_prechecked_manager_operations = 5000
, with no constraints on the other kinds of operations. - Now, we ensure that the number of valid operations of any kind is at most
max_operations = 10_000
, and also the sum of the sizes in bytes of all valid operations is at mostmax_total_bytes = 10_000_000
.
The values of max_operations
and max_total_bytes
can be retrieved with GET /chains/<chain>/mempool/filter
and configured with POST /chains/<chain>/mempool/filter
(just as we could do with max_prechecked_manager_operations
before).
This MR also introduces significant engineering changes, in that the bounding of the mempool is now handled inside of lib_shell
(in new file prevalidator_bounding.ml
) instead of in the plugin. As a result, significant parts of the mempool plugin have been removed; notably, the plugin no longer maintains an internal state of valid operations.
Follow-up issue: #5541 (closed)
MR that depends on this one: !8573 (merged)
Depends on: !7702 (merged) !8501 (merged)
Manually testing the MR
Green CI, in particular the new/updated tests:
dune exec tezt/tests/main.exe -- mempool bounding
dune exec tezt/tests/main.exe -- mempool filter
dune exec tezt/tests/main.exe -- mempool rpc regression
dune exec src/lib_shell/test/main.exe -- -f test_prevalidation.ml
You may also, in sandbox, use POST /chains/<chain>/mempool/filter
to change max_operations
and max_total_bytes
to low values, then try and inject too many / too large operations.
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rst
for the protocol and the environment,CHANGES.rst
at the root of the repository for everything else). -
Select suitable reviewers using the Reviewers
field below. -
Select as Assignee
the next person who should take action on that MR