Proto: replace precheck with validate_operation
Context
The %Pipelining project aims to streamline the global validation process, thus enabling broadcasting blocks (and operations) faster. In the early stage of the project, we focus on separating the business logic from operation validation and its application.
This MR introduces the Validate_operation
module, whose purpose is to perform effect-free sanity checks on operations before applying them -- or, instead of applying them e.g. with the mempool mode intended for the prevalidator.
Here, validate_operation
replaces precheck
for manager operations, that is the business logic formerly implemented by precheck_manager_contents
in apply.ml, and does nothing for non-manager operations -- their validation is kept intertwined with the application phase in apply_operation
.
The main (and breaking) semantic change introduced in this MR, is that the one-operation-per-manager-per-block restriction (1M) is now enforced in blocks, whereas before it was (optionally) executed by the Octez node during prevalidation, via the protocol plugin. This means that bakers will no longer be able to bypass this restriction.
Beyond than the changes above, we also do a heavy refactoring in apply.ml
in particular, and more generally in lib_protocol
. To make the changes easier to review, most of them are done step by step in precheck
in apply.ml
first. The goal is that when validate_operation
is eventually introduced to replace precheck
, both are quite similar and we are confident we implement the same business logic.
Other bug-fixs:
- the
run_operation
RPC now correctly checks that all operations in the batch have the same source.
Manually testing the MR
Tests for this MR have been integrated before with !5475 (merged), but they have been updated for the new interface. We have also adapted several previous integration and tezt tests with 492b0794, 03879acf, 37148b73, f13d076b, af01da66, e5b76efb. Changes can be asserted with
dune exec src/proto_alpha/lib_protocol/test/integration/gas/main.exe
dune exec src/proto_alpha/lib_protocol/test/integration/operations/main.exe
dune exec tezt/tests/main.exe -- --file manager_operations.ml
In addition, we have additional tests for validate and the 1m restriction in !5614 (merged)
dune exec src/proto_alpha/lib_protocol/test/integration/validate/main.exe -- test "^1M"
and some replay tests: via tezos-node replay
command and a tweaked apply (see: vicall@pipelining@precheck-to-validate
)
The bug-fix for run_operation
(source consistency were not checked in batch) is now checked in a tezt test that can be run with the following command :
dune exec tezt/tests/main.exe -- --file "op_validation.ml"
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
Follow ups
- #3243 (closed) Improve the internal documentation of the operation validation module
- #3162 (closed) Integrate the motivation for this changes in the online dev documentation (!5490 (merged))
- #3244 Should simulation use the prevalidator contexts?
- #3245 (closed) Update the plugin to call directly validate_operation and remove precheck_manager
- #3260 Examine the classification of the Subtraction_overflow error
- !5614 (merged) WIP test 1M on the protocol
- #3261 (closed) Improve the quality assurance