Revision daea8ababad0396971bf2c9062c5f177521b051d authored by Ilias Garnier on 21 June 2019, 12:47:37 UTC, committed by Pierre Boutillier on 21 October 2019, 12:25:27 UTC
I. Rescaling step cost
- Rescale step_cost by 2^7 to allow finer cost accounting in the
  interpeter.
- Expose new function atomic_step_cost exposing finer resolution step
  increments.

II. Provide facilities for interpreter-specific cost accounting

Introduce new functions `Gas.incr_interpreter_cost` and
`Gas.bill_interpreter_cost`.

- The context stores a new counter 'interpreter_cost' of type
  Gas_limit_repr.cost
- functions are provided to:
  - increment this counter (incr_interpreter_cost) and
  - bill for the gas corresponding to this counter and reset this
  counter. Until bill_interpreter_cost is called, the interpreter_cost
  is _not_ taken into account into the effectively consumed gas.
- Each call to incr_interpreter_cost still checks that we are under
  the operation and block gas limits.
- The interpreter uses these functions instead of the usual
  Gas.consume.

The invariant that has to be respected for this to be transparent to
the rest of the protocol is that all continuations of the `step`
function to other functions should bill and reset the interpreter_cost
beforehand. This concerns calls to interp, calls to the typechecker,
calls to read from a big map, calls to the
serialization/deserialization  mechanism, etc; in short, all calls to
other parts of the protocol should have a context in a state where
this fine-grained gas bookkeeping has been settled and reset.
1 parent c5bda6c
Raw File
update_hashes.sh
#! /bin/sh

script_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
cd "$script_dir"/..

branch=$1
has_git() {
    which git && [ -d .git ]
}

if has_git && ! [ -z "$(git status -s)" ] ; then
    echo "This script cannot be applied within a dirty git directory,"
    echo "you need 'stash' or 'commit' your changes before."
    exit 1
fi

set -e

current_hash_genesis=`jq '.hash' < src/proto_genesis/lib_protocol/src/TEZOS_PROTOCOL | tr -d '"'`
echo "Genesis's current hash: $current_hash_genesis"
genesis_tmpdir=`mktemp -d`
mkdir $genesis_tmpdir/src
cp src/proto_genesis/lib_protocol/src/*.ml src/proto_genesis/lib_protocol/src/*.mli $genesis_tmpdir/src/
grep -v '"hash"' < src/proto_genesis/lib_protocol/src/TEZOS_PROTOCOL > $genesis_tmpdir/src/TEZOS_PROTOCOL
new_hash_genesis=`./tezos-protocol-compiler -hash-only $genesis_tmpdir/tmp $genesis_tmpdir/src`
echo "Genesis's new hash: $new_hash_genesis"
if [ "$current_hash_genesis" != "$new_hash_genesis" ]
then
    find . -type f -exec sed "s/$current_hash_genesis/$new_hash_genesis/g" -i {} \;
    git commit -a -m "Update proto Genesis's hash"
else
    echo "Proto Genesis's hash hasn't changed, nothing to do"
fi

current_hash_alpha=`jq '.hash' < src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL | tr -d '"'`
echo "Alpha's current hash: $current_hash_alpha"
alpha_tmpdir=`mktemp -d`
mkdir $alpha_tmpdir/src
cp src/proto_alpha/lib_protocol/src/*.ml src/proto_alpha/lib_protocol/src/*.mli $alpha_tmpdir/src/
grep -v '"hash"' < src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL > $alpha_tmpdir/src/TEZOS_PROTOCOL
new_hash_alpha=`./tezos-protocol-compiler -hash-only $alpha_tmpdir/tmp $alpha_tmpdir/src`
echo "Alpha's new hash: $new_hash_alpha"
if [ "$current_hash_alpha" != "$new_hash_alpha" ]
then
    find src/proto_alpha src/bin_client docs -type f -exec sed "s/$current_hash_alpha/$new_hash_alpha/g" -i {} \;
    git commit -a -m "Update proto Alpha's hash"
else
    echo "Proto Alpha's hash hasn't changed, nothing to do"
fi
back to top