[go: up one dir, main page]

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 (in run_operation_service in lib_plugin/RPC.ml) that crashes when called on level 1. Instead of using the apply_mode Partial_construction which requires a predecessor_level value, the run_operation RPC uses a new Mempool_no_consensus_op mode. The RPC now explicitly fails on consensus operations (indeed, calling run_operation on 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 to run_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.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
Edited by Diane Gallois-Wong

Merge request reports

Loading