diff --git a/.gitignore b/.gitignore
index 5d1052ec0..8b5cb17ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -89,4 +89,9 @@ deps/schnorr/install/
# -----------------------------------------------------------------------------
vcpkg_installed/
-debug/
\ No newline at end of file
+debug/
+
+# Emacs backups
+*~
+\#*
+.\#*
diff --git a/INSTALL.md b/INSTALL.old.md
similarity index 98%
rename from INSTALL.md
rename to INSTALL.old.md
index 64737d4e5..a96742e54 100644
--- a/INSTALL.md
+++ b/INSTALL.old.md
@@ -1,5 +1,7 @@
# Building and Developing Scilla
+_These are old instructions - check out the (rather scatty) build instructions in README.md for how to build Scilla for ZQ2_
+
The recommended installation process is comprised of two separate steps:
- installation of system-wide packages using your OS native package manager and
- installation of OCaml packages using the [opam](https://opam.ocaml.org) package manager.
diff --git a/Makefile b/Makefile
index fb867a46a..00a9703ca 100644
--- a/Makefile
+++ b/Makefile
@@ -28,10 +28,22 @@ define patch_rpath
find _build/default/$(1) -type f -name '*.exe' -exec chmod u+w \{} \; -exec $(RPATH_CMD) "$(VCPKG_BASE)/lib" \{} \; -exec chmod u+w \{} \;
endef
-.PHONY: default release utop dev clean docker zilliqa-docker
+.PHONY: default release utop dev clean docker zilliqa-docker install-from-apt
default: release
+APT_REQUIREMENTS= autoconf bison build-essential ca-certificates ccache cmake cron curl dnsutils gawk \
+ git lcov libcurl4-openssl-dev libev-dev libgmp-dev libpcre3-dev libssl-dev libtool \
+ libxml2-utils ninja-build nload ocaml ocl-icd-opencl-dev opam openssh-client patchelf pkg-config \
+ rsync rsyslog tar unzip vim wget zip zlib1g-dev ocaml-dune
+
+install-from-apt:
+ sudo apt-get update -y
+ sudo apt-get install -y software-properties-common
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends $(APT_REQUIREMENTS)
+
+
# Build one library and one standalone executable that implements
# multiple subcommands and uses the library.
# The library can be loaded in utop for interactive testing.
diff --git a/README.md b/README.md
index fd52fcfe2..07201108e 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +1,100 @@
-# Scilla: A Smart Contract Intermediate Level Language
-
-[![Build Status](https://travis-ci.com/Zilliqa/scilla.svg?token=7qzjATfZuxTQvRjMHPVQ&branch=master)](https://travis-ci.com/Zilliqa/scilla)
-[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/Zilliqa/scilla/blob/master/LICENSE)
-[![Discord chat](https://img.shields.io/discord/370992535725932544.svg)](https://discord.gg/mWp9HdR)
-[![Coverage Status](https://coveralls.io/repos/github/Zilliqa/scilla/badge.svg?branch=master)](https://coveralls.io/github/Zilliqa/scilla?branch=master)
-
-
-
-
+# Scilla: A smart contract intermediate level language
## Introduction
-Scilla short for Smart Contract Intermediate-Level LAnguage is an intermediate-level smart contract language being developed for Zilliqa. Scilla has been designed as a principled language with smart contract safety in mind.
-
-Scilla imposes a structure on smart contracts that will make applications less vulnerable to attacks by eliminating certain known vulnerabilities directly at the language-level. Furthermore, the principled structure of Scilla will make applications inherently more secure and amenable to formal verification.
-Zilliqa - the underlying blockchain platform on which Scilla contracts are run, has been designed to be scalable. It employs the idea of sharding to validate transactions in parallel. Zilliqa has an intrinsic token named Zilling, ZIL for short that are required to run smart contracts on Zilliqa.
+Scilla is a smart contract language used by the Zilliqa blockchain.
-### Language Reference
-
-A comprehensive documentation on Scilla, its features and constructs can be found [here](https://scilla.readthedocs.io/en/latest/)
+A language reference can be found [here](https://scilla.readthedocs.io/en/latest/)
## Building Scilla
-If you don't want to setup and build Scilla from source, skip this section to follow the opam installation instructions.
+Here are some instructions for building Scilla natively. A dockerfile
+is provided in `docker/`, as is a
+`Dockerfile.test-modern-ubuntu-build` which we use to test these
+instructions.
### 1. Cloning source code
-We suggest users to use the latest release of Scilla available [here](https://github.com/Zilliqa/scilla/releases).
-
-If you'd like to hack on Scilla, clone it with all of its submodules:
```shell
git clone --jobs 4 --recurse-submodules https://github.com/Zilliqa/scilla/
```
### 2. Build prerequisites
-Platform specific instructions for setting up your system for building Scilla can be
-found in [INSTALL.md](./INSTALL.md).
+There are packages you'll need - run:
+
+```shell
+make install-from-apt
+```
+
+To install them, or see the list in the `Makefile`.
### 3. Compiling
-To build the project from the root folder:
+You'll need to install `vcpkg` and set `VCPKG_ROOT` to the root of your `vcpkg` installation, following the instructions at .
+
+```sh
+export VCPKG_ROOT=/my/directory/vcpkg
+export SCILLA_REPO_ROOT=/where/you/checked/out/scilla
```
+
+Now install the opam dependencies:
+
+```sh
+make opamdep
+eval $(opam env)
+```
+
+Now install packages and try to build the first time:
+
+```sh
make
```
-### Installation
+If `vcpkg` installation fails, you'll need to set:
-Scilla can be installed into your opam switch as
+```sh
+export VCPKG_ALWAYS_INSTALL=true
+```
+
+and run `make` again.
+
+The first build will fail, because `Snark.h` doesn't include `` properly. You now need to fix this:
```
-make install
+sed -i '1s;^;#include \n;' vcpkg_installed/x64-linux-dynamic/include/Snark/Snark.h
```
-and can similarly be uninstalled as
+And you may well need to:
```
-make uninstall
+make
+touch scilla/_build/default/vcpkg-ocaml/vcpkg-secp256k1/src/c_flags.exp
+make opamdep
```
-## Installing Scilla with opam
-Scilla can be installed using OCaml's package manager `opam`.
-
-### Installing Scilla from GitHub
+A few times to persuade `secp256k1` to build.
-To install the development version of Scilla package make sure you are using
-the correct opam switch and execute the following
+Now build again:
-```shell
-opam pin add scilla git+https://github.com/Zilliqa/scilla#master --yes
+```
+make
```
-### Installing Scilla from your local repo
+and this time the build should succeed!
-```shell
-cd
-# It is important to pick the right git branch because opam pins the package to the current branch
-git checkout master
-opam install ./scilla.opam
+### Installation
+
+Scilla can be installed into your opam switch as
+
+```
+make install
```
-If you are using a local opam switch (see [here](https://github.com/Zilliqa/scilla/blob/master/INSTALL.md#installing-opam-packages))
-in your local Scilla repo (`~/path/to/scilla`), then most likely you will want to reuse the same local switch for your Scilla-based project.
-To do that create a symlink `_opam` as follows:
+and can similarly be uninstalled as
-```shell
-cd
-ln -s ~/path/to/scilla/_opam _opam
+```
+make uninstall
```
## Running the binary
@@ -209,3 +217,4 @@ Visual Studio Code support for Scilla is available. [Github Source](https://gith
You can install it through:https://marketplace.visualstudio.com/items?itemName=as1ndu.scilla
Credits: [as1ndu](https://github.com/as1ndu)
+
diff --git a/README.old.md b/README.old.md
new file mode 100644
index 000000000..f57a9721b
--- /dev/null
+++ b/README.old.md
@@ -0,0 +1,240 @@
+# Scilla: A Smart Contract Intermediate Level Language
+
+[![Build Status](https://travis-ci.com/Zilliqa/scilla.svg?token=7qzjATfZuxTQvRjMHPVQ&branch=master)](https://travis-ci.com/Zilliqa/scilla)
+[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/Zilliqa/scilla/blob/master/LICENSE)
+[![Discord chat](https://img.shields.io/discord/370992535725932544.svg)](https://discord.gg/mWp9HdR)
+[![Coverage Status](https://coveralls.io/repos/github/Zilliqa/scilla/badge.svg?branch=master)](https://coveralls.io/github/Zilliqa/scilla?branch=master)
+
+
+
+
+
+## Introduction
+Scilla short for Smart Contract Intermediate-Level LAnguage is an intermediate-level smart contract language being developed for Zilliqa. Scilla has been designed as a principled language with smart contract safety in mind.
+
+Scilla imposes a structure on smart contracts that will make applications less vulnerable to attacks by eliminating certain known vulnerabilities directly at the language-level. Furthermore, the principled structure of Scilla will make applications inherently more secure and amenable to formal verification.
+
+Zilliqa - the underlying blockchain platform on which Scilla contracts are run, has been designed to be scalable. It employs the idea of sharding to validate transactions in parallel. Zilliqa has an intrinsic token named Zilling, ZIL for short that are required to run smart contracts on Zilliqa.
+
+### Language Reference
+
+A comprehensive documentation on Scilla, its features and constructs can be found [here](https://scilla.readthedocs.io/en/latest/)
+
+## Building Scilla
+
+If you don't want to setup and build Scilla from source, skip this section to follow the opam installation instructions.
+
+### 1. Cloning source code
+
+We suggest users to use the latest release of Scilla available [here](https://github.com/Zilliqa/scilla/releases).
+
+If you'd like to hack on Scilla, clone it with all of its submodules:
+```shell
+git clone --jobs 4 --recurse-submodules https://github.com/Zilliqa/scilla/
+```
+
+### 2. Build prerequisites
+
+Platform specific instructions for setting up your system for building Scilla can be
+found in [INSTALL.md](./INSTALL.md).
+
+### 3. Compiling
+
+You'll need to install `vcpkg` and set `VCPKG_ROOT` to the root of your `vcpkg` installation, following the instructions at .
+
+```sh
+export VCPKG_ROOT=/my/directory/vcpkg
+export SCILLA_REPO_ROOT=/where/you/checked/out/scilla
+apt install libgmp-dev patchelf
+```
+
+If `vcpkg` installation fails, you'll need to set:
+
+```sh
+export VCPKG_ALWAYS_INSTALL=true
+```
+
+To force vcpkg to try again. You'll also need to do:
+
+```
+make opamdep
+```
+
+To make opam dependencies. You may well need to:
+
+```
+touch scilla/_build/default/vcpkg-ocaml/vcpkg-secp256k1/src/c_flags.exp
+```
+
+And retry to persuade `secp256k1` to rebuild.
+
+Now, to build the project from the root folder:
+
+```
+make
+```
+
+### Installation
+
+Scilla can be installed into your opam switch as
+
+```
+make install
+```
+
+and can similarly be uninstalled as
+
+```
+make uninstall
+```
+
+## Installing Scilla with opam
+Scilla can be installed using OCaml's package manager `opam`.
+
+### Installing Scilla from GitHub
+
+To install the development version of Scilla package make sure you are using
+the correct opam switch and execute the following
+
+```shell
+opam pin add scilla git+https://github.com/Zilliqa/scilla#master --yes
+```
+
+### Installing Scilla from your local repo
+
+```shell
+cd
+# It is important to pick the right git branch because opam pins the package to the current branch
+git checkout master
+opam install ./scilla.opam
+```
+
+If you are using a local opam switch (see [here](https://github.com/Zilliqa/scilla/blob/master/INSTALL.md#installing-opam-packages))
+in your local Scilla repo (`~/path/to/scilla`), then most likely you will want to reuse the same local switch for your Scilla-based project.
+To do that create a symlink `_opam` as follows:
+
+```shell
+cd
+ln -s ~/path/to/scilla/_opam _opam
+```
+
+## Running the binary
+
+Once the project is built you can try the following things:
+
+#### Evaluating a standalone closed expression:
+
+From the project root, execute
+
+```
+eval-runner -gaslimit 10000 -libdir src/stdlib tests/eval/good/let.scilexp
+```
+
+Instead of `let.scilla` you might want to try any different file in
+`tests/eval`. The second argument, which is a path to the Scilla
+standard library can alternatively be specified in the environment
+variable `SCILLA_STDLIB_PATH`. This must be an absolute path (or a
+list of paths separated with `:` (or `;` on Windows).
+
+#### Type-checking a contract
+
+From the project root, execute
+
+```
+scilla-checker -gaslimit 10000 -libdir src/stdlib tests/contracts/auction.scilla
+```
+
+Instead of `auction.scilla` you might want to try any different file in
+`tests/contracts` with a complete implementation of a contract, or your
+own contract code. The second argument, which is a path to the Scilla
+standard library can alternatively be specified in the environment
+variable `SCILLA_STDLIB_PATH`. As above, this must be an absolute
+path(s).
+
+If the checker only returns the contract structure in JSON format, it
+means that the contract has no type errors. Otherwise, a type error
+trace is provided.
+
+The checker can be run with the following optional flags:
+
+- `-cf` to enable the cashflow checker and print its results.
+
+
+#### Executing a simple transition
+
+From the project root, execute
+
+```
+scilla-runner -init tests/runner/crowdfunding/init.json -istate tests/runner/crowdfunding/state_4.json -iblockchain tests/runner/crowdfunding/blockchain_4.json -imessage tests/runner/crowdfunding/message_4.json -o tests/runner/crowdfunding/output_4.json -i tests/contracts/crowdfunding.scilla -libdir src/stdlib -gaslimit 8000
+```
+ or
+```
+scilla-runner -init tests/runner/zil-game/init.json -istate tests/runner/zil-game/state_5.json -iblockchain tests/runner/zil-game/blockchain_5.json -imessage tests/runner/zil-game/message_5.json -o tests/runner/zil-game/output_5.json -i tests/contracts/zil-game.scilla -libdir src/stdlib -gaslimit 8000
+```
+
+If you'd like to see the output produced by the aforementioned commands,
+check the file specified by `-o path/to/file.json` argument.
+
+Alternatively, use the `easyrun.sh` script as below:
+
+```
+./easyrun.sh crowdfunding 1
+```
+
+where `n` is a number `0-5` for the number of "steps" to execute the
+protocol (the messages and blockchain states are provided for only so
+many steps in the simulation).
+
+#### Using Scilla as a service
+A `scilla-server` is provided that provides the functionality of `scilla-runner`
+and `scilla-checker` as a JSON-RPC server. The `scilla-server` process accepts
+contract execution requests and executes the contract, providing a JSON output
+within the server process itself.
+
+More details on the protocol can be found [here](https://github.com/Zilliqa/scilla/wiki/scilla-server-API).
+
+For local testing and experiments, a `scilla-client` is also provided on development
+builds (`make dev`). This can interact with `scilla-server`, achieving the same effect
+as `scilla-runner` and `scilla-client`.
+
+Start `scilla-server` without any arguments. Examples for checking a contract
+and running a transition via `scilla-server` are provided below. They are to be
+run on a separate shell (while `scilla-server` continues to run).
+
+```shell
+scilla-client run -argv " -init tests/runner/crowdfunding/init.json -istate tests/runner/crowdfunding/state_4.json -iblockchain tests/runner/crowdfunding/blockchain_4.json -imessage tests/runner/crowdfunding/message_4.json -o tests/runner/crowdfunding/output_4.json -i tests/contracts/crowdfunding.scilla -libdir src/stdlib -gaslimit 8000"
+
+scilla-client check -argv " -libdir src/stdlib -gaslimit 8000 tests/contracts/helloWorld.scilla"
+```
+
+
+### Where to find binaries
+
+* The runnables are put into the folder
+
+```
+$PROJECT_DIR/bin
+```
+
+## Developer Tools
+
+### Emacs mode
+
+An emacs major mode for editing Scilla contracts is [provided](./misc/emacs-mode/scilla-mode.el).
+Add the following line to your `.emacs` file to load this mode for files ending with `.scilla` and `.scillib`.
+For enabling flycheck mode for Scilla (see [INSTALL.md](./INSTALL.md)). When `scilla-checker` is available,
+type reporting is also supported. The key binding `C-c C-t` will print the type of the variable on which
+the cursor currently is.
+
+```
+;; For enabling flycheck mode for Scilla.
+(setq scilla-root "/path/to/scilla/root")
+;; Scilla mode
+(load-file "/path/to/scilla-mode.el")
+```
+### VSCode Plugin
+
+Visual Studio Code support for Scilla is available. [Github Source](https://github.com/as1ndu/vscode-scilla)
+You can install it through:https://marketplace.visualstudio.com/items?itemName=as1ndu.scilla
+
+Credits: [as1ndu](https://github.com/as1ndu)
diff --git a/docker/Dockerfile.test-modern-ubuntu-build b/docker/Dockerfile.test-modern-ubuntu-build
new file mode 100644
index 000000000..3f021592b
--- /dev/null
+++ b/docker/Dockerfile.test-modern-ubuntu-build
@@ -0,0 +1,81 @@
+FROM ubuntu:24.04 AS base
+
+RUN apt-get update -y \
+ && apt-get install -y software-properties-common \
+ && apt-get update && apt-get install -y --no-install-recommends \
+ autoconf \
+ bison \
+ build-essential \
+ ca-certificates \
+ ccache \
+ cmake \
+ cron \
+ curl \
+ dnsutils \
+ gawk \
+ git \
+ lcov \
+ libcurl4-openssl-dev \
+ libev-dev \
+ libgmp-dev \
+ libpcre3-dev \
+ libssl-dev \
+ libtool \
+ libxml2-utils \
+ ninja-build \
+ nload \
+ ocaml \
+ ocl-icd-opencl-dev \
+ opam \
+ openssh-client \
+ patchelf \
+ pkg-config \
+ rsync \
+ rsyslog \
+ tar \
+ unzip \
+ vim \
+ wget \
+ zip \
+ zlib1g-dev \
+ && apt-get autoremove -y
+
+FROM base AS builder
+
+ARG VCPKG_COMMIT_OR_TAG=2022.09.27
+ARG VCPKG_ROOT=/vcpkg
+
+RUN git clone https://github.com/microsoft/vcpkg ${VCPKG_ROOT} \
+ && git -C ${VCPKG_ROOT} checkout ${VCPKG_COMMIT_OR_TAG} \
+ && ${VCPKG_ROOT}/bootstrap-vcpkg.sh
+
+ARG SOURCE_DIR="/scilla"
+ENV SCILLA_REPO_ROOT="/scilla"
+
+WORKDIR ${SOURCE_DIR}
+
+ENV OCAML_VERSION 4.12.0
+
+COPY vcpkg-registry/ vcpkg-registry
+COPY vcpkg-configuration.json .
+COPY vcpkg.json .
+COPY vcpkg-ocaml/ vcpkg-ocaml
+COPY src/ src
+COPY scripts/ scripts
+COPY dune* ./
+COPY Makefile .
+COPY scilla.opam .
+COPY shell.nix .
+COPY .ocamlformat .
+COPY tests/ tests
+
+# Make sure vcpkg installs brings in the dependencies
+RUN --mount=type=cache,target=/root/.cache/vcpkg/ ${VCPKG_ROOT}/vcpkg install --triplet=x64-linux-dynamic
+
+ENV PKG_CONFIG_PATH="${SOURCE_DIR}/vcpkg_installed/x64-linux-dynamic/lib/pkgconfig"
+ENV SCILLA_REPO_ROOT="${SOURCE_DIR}"
+
+RUN make opamdep-ci \
+ && echo '. ~/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true ' >> ~/.bashrc \
+ && eval $(opam env) \
+ && make
diff --git a/scripts/vcpkg.sh b/scripts/vcpkg.sh
index 037b268d6..38d03f200 100755
--- a/scripts/vcpkg.sh
+++ b/scripts/vcpkg.sh
@@ -33,12 +33,15 @@ then
fi
# If already installed, exit early.
+if [[ -z "${VCPKG_ALWAYS_INSTALL}" ]]
+then
if [[ -d vcpkg_installed ]]
then
echo "Found vcpkg_installed, not installing again"
exit 0
fi
-
+fi
+
echo "Installing vcpkg"
if ! "$VCPKG_ROOT"/vcpkg install --triplet "$(scripts/vcpkg_triplet.sh)"
then
diff --git a/src/eval/Ipcmessage_pb.ml b/src/eval/Ipcmessage_pb.ml
index 13a0a6afb..af9b4fa2d 100644
--- a/src/eval/Ipcmessage_pb.ml
+++ b/src/eval/Ipcmessage_pb.ml
@@ -114,14 +114,14 @@ let rec encode_proto_scilla_val_map (v : Ipcmessage_types.proto_scilla_val_map)
Pbrt.Encoder.nested (encode_proto_scilla_val x) encoder
in
List.iter v.Ipcmessage_types.m ~f:(fun (k, v) ->
- Pbrt.Encoder.key (1, Pbrt.Bytes) encoder;
+ Pbrt.Encoder.key (1,Pbrt.Bytes) encoder;
let map_entry = ((k, Pbrt.Bytes), (v, Pbrt.Bytes)) in
Pbrt.Encoder.map_entry ~encode_key ~encode_value map_entry encoder)
and encode_proto_scilla_val (v : Ipcmessage_types.proto_scilla_val) encoder =
match v with
| Ipcmessage_types.Bval x ->
- Pbrt.Encoder.key (1, Pbrt.Bytes) encoder;
+ Pbrt.Encoder.key (1,Pbrt.Bytes) encoder;
Pbrt.Encoder.bytes x encoder
| Ipcmessage_types.Mval x ->
Pbrt.Encoder.key (2, Pbrt.Bytes) encoder;