Arm and disarm

Instrumenting in-place

Scribble supports instrumenting files in-place for interoperability with user-specific testing and deployment environments. This is specifed with the --output-mode files option. One use case for this mode is to run the user test suite on the instrumented code. For example lets assume we have these 2 files:


contract Base {


import "Base.sol";
contract Foo is Base {
/// #if_succeeds {:msg "P1"} y == x + 1;
function inc(uint x) public pure returns (uint y) {
return x+1;

We can instrument them in-place using the following command:

scribble Foo.sol --output-mode files

This would generate 2 new files - Foo.instrumented.sol and __scribble_ReentrancyUtils.sol.Foo.instrumented.sol is the instrumented counterparts ofFoo.sol, and __scribble_ReentrancyUtils.sol contains a helper contract. Now a user can manually swap Foo.instrumented.sol with Foo.sol, re-build their contracts and run tests on the instrumented contracts, and later swap the originals back. However these steps are tedious, which is why scribble automates them with the --arm and --disarm options. We can add the --arm option when instrumenting like so:

scribble Foo.sol --output-mode files --arm
Foo.sol -> Foo.sol.instrumented
Copying Foo.sol to Foo.sol.original
Copying Foo.sol.instrumented to Foo.sol

As noted in the output, scribble performed 3 steps:

  1. Emit the instrumented version of Foo.sol - Foo.instrumented.sol

  2. Make a copy of the original Foo.sol as Foo.original.sol

  3. Replace Foo.sol with Foo.instrumented.sol

At this point if you rebuild the contracts you would get the instrumented version of the code. To revert back to the original un-instrumented code its sufficient to run the same command with --disarm instead of --arm:

scribble Foo.sol --output-mode files --disarm
Moving Foo.sol.original to Foo.sol
Removing Foo.sol.instrumented

Note that the --disarm command still tries to compile the files. If due to some bug, the instrumented code doesn't compile, you may need to revert the changes by hand, by swapping back the .original.sol versions of the files.

At the moment --disarm doesn't remove the helper __scribble_ReentrancyUtils.sol file.