Skip to content

Commit

Permalink
A few build fixes (#1254)
Browse files Browse the repository at this point in the history
* (fix) Add emacs backups to .gitignore
(fix) A tiny bit more documentation
(feat) respect VCPKG_ALWAYS_INSTALL
(fix) The protobuf library now appears to want curried arguments.

* (fix) A few more fixes for transit to GCP so I can test them ..

* (feat) install-from-apt

* (fix) More fixes for transit

* (fix) Revert Pbrt patch - I think I had an old version installed in opam :-(

* (fix) Fix up README

* (fix) Yet more build fixes
  • Loading branch information
rrw-zilliqa authored Jul 2, 2024
1 parent a5a81f7 commit de22052
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 54 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ deps/schnorr/install/
# -----------------------------------------------------------------------------
vcpkg_installed/

debug/
debug/

# Emacs backups
*~
\#*
.\#*
2 changes: 2 additions & 0 deletions INSTALL.md → INSTALL.old.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
107 changes: 58 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<p align="center">
<a href="https://scilla-lang.org/"><img src="https://github.com/Zilliqa/scilla/blob/master/imgs/scilla-logo-color.jpg" width="200" height="200"></a>
</p>
# 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 <https://github.com/microsoft/vcpkg>.

```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 `<cstdio>` properly. You now need to fix this:

```
make install
sed -i '1s;^;#include <cstdint>\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 <scilla-repo>
# 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 <scilla-based-project-repo>
ln -s ~/path/to/scilla/_opam _opam
```
make uninstall
```

## Running the binary
Expand Down Expand Up @@ -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)

Loading

0 comments on commit de22052

Please sign in to comment.