Proto/plugin: fix a minor problem with run_operation RPC in tests
Context
The POST /chains/<chain>/blocks/<block>/helpers/scripts/run_operation RPC crashes when the predecessor of <block> does not belong to a protocol of the Alpha family (which contains every protocol except Genesis), and the input operation is not a manager operation. This is of course not an issue in most situations and doesn't affect Mainnet at all.
But in tezt, it is usual to test operations right on top of the level-1 alpha activation block, whose predecessor is the Genesis block. The problem never came up because there was no tezt test calling run_operation on a non-manager operation. But an upcoming refactoring (!5770 (merged)) would extend this problem to manager operations, which would break many existing tests. This could be solved by baking an additional block (to get from level 1 to level 2) in all affected tests, but it is cleaner to fix the root of the problem.
-
The first commit adds a test that showcases the problem.
-
The second commit fixes the problem by removing the call to
Alpha_context.Level.pred(inrun_operation_serviceinlib_plugin/RPC.ml) that crashes when called on level1. Instead of using theapply_modePartial_constructionwhich requires apredecessor_levelvalue, therun_operationRPC uses a newMempool_no_consensus_opmode. The RPC now explicitly fails on consensus operations (indeed, callingrun_operationon a consensus operation does not make much sense, and could already give inconsistent results). The RPC's description is updated accordingly. We also add TODOs about desirable improvements torun_operation, linking to follow-up issues #3364 and #3401 (closed).
This MR is on top of !5769 (merged) that improves the testing of run_operation.
Fixes #3363 (closed).
Manually testing the MR
Run the tezt tests on run_operation:
dune exec tezt/tests/main.exe -- run_operation
Moreover, check that the new test fails before the fix commit:
dune exec tezt/tests/main.exe -- run_operation proposals
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.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR