Skip to content

Commit

Permalink
Merge pull request #133 from mojtaba-eshghie/feat_issue_131
Browse files Browse the repository at this point in the history
Feat: adding working Dockerfile and docker-compose.yml files #131
  • Loading branch information
mojtaba-eshghie authored Jun 22, 2024
2 parents aa224ea + 8f2687a commit e1b44a8
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 7 deletions.
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Use a base image with the required GLIBC version
FROM ubuntu:20.04

# Install dependencies including git and python
RUN apt-get update && apt-get install -y \
curl \
build-essential \
wget \
ca-certificates \
libssl-dev \
git \
python3 \
python3-distutils \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Foundry and Anvil
RUN curl -L https://foundry.paradigm.xyz | bash \
&& ~/.foundry/bin/foundryup

# Set up environment variables for Foundry
ENV PATH="/root/.foundry/bin:${PATH}"

# Create and change to the app directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install Node.js dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# The command to keep the container running and allow for command execution
CMD ["bash"]
89 changes: 88 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,92 @@

Smart contracts embody complex business processes that can be difficult to analyze statically. Therefore, we present HighGuard, a runtime monitoring tool that leverages business process specifications written in DCR graphs to provide runtime verification of smart contract execution. We demonstrate how HighGuard can detect and flag deviations from specified behaviors in smart contracts deployed in the Ethereum network without code instrumentation and any additional gas costs.

## Installation

### Manual Installation

To manually install and run HighGuard, follow these steps:

1. **Clone the repository:**

```sh
git clone https://github.com/mojtaba-eshghie/HighGuard.git
cd highguard
```

2. **Install Node.js and npm:**

Ensure you have Node.js version 16.20.2 and npm version 8.19.4 installed. You can download and install Node.js from [Node.js official website](https://nodejs.org/).

Verify the installation:

```sh
node --version
npm --version
```

3. **Install project dependencies:**

```sh
npm install
```

4. **Install Foundry and Anvil:**

Follow the instructions to install Foundry from the [Foundry Book](https://book.getfoundry.sh/getting-started/installation).

```sh
curl -L https://foundry.paradigm.xyz | bash
source ~/.bashrc
foundryup
```

5. **Run the CLI commands:**

You can now run the CLI commands as needed:

```sh
pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-governance.yml
pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-escrow.yml
pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-multistageauction.yml
pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-prizedistribution.yml
pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-productorder.yml
```

### Docker Installation

To build and run the project using Docker, follow these steps:

1. **Clone the repository:**

```sh
git clone https://github.com/mojtaba-eshghie/HighGuard.git
cd highguard
```

2. **Build the Docker image:**

```sh
docker build -t HighGuard-cli-docker .
```

3. **Run the Docker container with specific commands:**

Replace the command as needed:

```sh
docker run --rm -v $(pwd):/usr/src/app HighGuard-cli-docker bash -c "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-governance.yml"
```

Example commands:

```sh
docker run --rm -v $(pwd):/usr/src/app HighGuard-cli-docker bash -c "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-escrow.yml"
docker run --rm -v $(pwd):/usr/src/app HighGuard-cli-docker bash -c "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-multistageauction.yml"
docker run --rm -v $(pwd):/usr/src/app HighGuard-cli-docker bash -c "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-prizedistribution.yml"
docker run --rm -v $(pwd):/usr/src/app HighGuard-cli-docker bash -c "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-productorder.yml"
```

## Features

### Main Features
Expand All @@ -17,6 +103,7 @@ Smart contracts embody complex business processes that can be difficult to analy

- Batteries included
- Distributed logging
<!--
## Installation
Expand All @@ -31,7 +118,7 @@ Run the `npm install` in the main repository directory and the following directo
`server/monitor`
`client`
`client` -->

## Usage

Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.8'

services:
node-cli:
build: .
volumes:
- .:/usr/src/app
working_dir: /usr/src/app
entrypoint: ["bash", "-c"]
command: "pkill anvil; node CI/run.js -t synthesized -e separate -v -c micro-configs/config-synthesized-governance.yml"
11 changes: 5 additions & 6 deletions results/Governance-1.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T16:41:24.970Z | false | 2015421 |
| vote | 2024-06-22T16:41:35.069Z | true | 2015421 |
| vote | 2024-06-22T16:41:35.542Z | false | 2015421 |
| vote | 2024-06-22T16:41:36.034Z | false | 2015421 |
| vote | 2024-06-22T16:41:36.558Z | false | 2015421 |
| executeProposal | 2024-06-22T16:41:47.065Z | false | 2015421 |
| createProposal | 2024-06-22T17:21:33.213Z | false | 2015422 |
| vote | 2024-06-22T17:21:43.126Z | true | 2015422 |
| vote | 2024-06-22T17:21:55.905Z | false | 2015422 |
| vote | 2024-06-22T17:21:57.370Z | false | 2015422 |
| vote | 2024-06-22T17:21:57.888Z | false | 2015422 |
5 changes: 5 additions & 0 deletions results/Governance-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:21:36.877Z | false | 2015423 |
| vote | 2024-06-22T17:21:47.084Z | true | 2015423 |
| vote | 2024-06-22T17:21:47.570Z | false | 2015423 |
4 changes: 4 additions & 0 deletions results/Governance-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:21:38.574Z | false | 2015424 |
| executeProposal | 2024-06-22T17:21:54.535Z | true | 2015424 |
5 changes: 5 additions & 0 deletions results/Governance-4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:21:53.262Z | false | 2015425 |
| createProposal | 2024-06-22T17:22:03.573Z | true | 2015425 |
| createProposal | 2024-06-22T17:22:16.006Z | true | 2015425 |
4 changes: 4 additions & 0 deletions results/Governance-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:21:55.923Z | false | 2015426 |
| vote | 2024-06-22T17:22:12.413Z | true | 2015426 |
4 changes: 4 additions & 0 deletions results/Governance-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:22:10.585Z | false | 2015427 |
| vote | 2024-06-22T17:22:12.298Z | true | 2015427 |
3 changes: 3 additions & 0 deletions results/Governance-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:22:14.704Z | false | 2015428 |
3 changes: 3 additions & 0 deletions results/Governance-8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Activity ID | Time | Violation | Simulation |
| --- | --- | --- | --- |
| createProposal | 2024-06-22T17:22:17.503Z | false | 2015429 |

0 comments on commit e1b44a8

Please sign in to comment.