Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add docker #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# syntax=docker/dockerfile:1.4

# Use rust:bookworm as the build environment
FROM rust:bookworm as build-environment

# Set non-interactive mode for apt so it doesn't ask for user input during the build
ENV DEBIAN_FRONTEND=noninteractive

# # Install required dependencies
# RUN apt-get update && apt-get install -y clang lld curl build-essential linux-generic git \
# && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh \
# && chmod +x ./rustup.sh \
# && ./rustup.sh -y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can clean up this comment


RUN apt-get update && apt-get install cmake -y

ARG TARGETARCH
WORKDIR /opt


# Add the required CFLAGS if the TARGETARCH matches
RUN [[ "$TARGETARCH" = "x86_64-unknown-linux-gnu" ]] && echo "export CFLAGS=-mno-outline-atomics" >> $HOME/.profile || true

WORKDIR /opt/cryo
COPY . .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid pulling unnecessary parts of repo I would explicitly add crates and Cargo.toml Cargo.lock are src copy


RUN . $HOME/.profile && cargo build --bin cryo --release --locked \
&& mkdir out \
&& mv target/release/cryo out/cryo \
&& strip out/cryo

# Use debian:bookworm-slim for the client
FROM debian:bookworm-slim as cryo-client

ENV DEBIAN_FRONTEND=noninteractive

# Install required dependencies
# RUN apt-get update -y && apt-get install linux-generic git -y

RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*

# Copy the compiled binary from the build environment
COPY --from=build-environment /opt/cryo/out/cryo /usr/local/bin/cryo

# Add a user for cryo
RUN useradd -ms /bin/bash cryo

ENTRYPOINT ["cryo"]
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ cryo can extract the following datasets from EVM nodes:
- `blocks`
- `transactions` (alias = `txs`)
- `logs` (alias = `events`)
- `contracts`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is unrelated, rebase?

- `traces` (alias = `call_traces`)
- `state_diffs` (alias for `storage_diffs` + `balance_diff` + `nonce_diffs` + `code_diffs`)
- `balance_diffs`
Expand Down Expand Up @@ -62,7 +61,7 @@ This method requires having rust installed. See [rustup](https://rustup.rs/) for

Make sure that `~/.cargo/bin` is on your `PATH`. One way to do this is by adding the line `export PATH="$HOME/.cargo/bin:$PATH"` to your `~/.bashrc` or `~/.profile`.

#### Installing `cryo_python` from pypi
#### Method 3: Installing `cryo_python` from pypi

(make sure rust is installed first, see [rustup](https://www.rust-lang.org/tools/install))

Expand All @@ -71,7 +70,7 @@ pip install maturin
pip install cryo_python
```

#### Installing `cryo_python` from source
#### Method 4: Installing `cryo_python` from source

```bash
pip install maturin
Expand All @@ -81,6 +80,16 @@ maturin build --release
pip install <OUTPUT_OF_MATURIN_BUILD>.whl
```

#### Method 5: Docker

In order to run `cryo` in a docker container

```shell
docker build -t <CONTAINER_NAME> .
docker run -it <CONTAINER_NAME> <CRYO_SUBCOMMAND>
```


## Data Schema

Many `cryo` cli options will affect output schemas by adding/removing columns or changing column datatypes.
Expand All @@ -96,7 +105,6 @@ Many `cryo` cli options will affect output schemas by adding/removing columns or
|Blocks|1|1|`eth_getBlockByNumber`|
|Transactions|1|multiple|`eth_getBlockByNumber`|
|Logs|multiple|multiple|`eth_getLogs`|
|Contracts|1|multiple|`trace_block`|
|Traces|1|multiple|`trace_block`|
|State Diffs|1|multiple|`trace_replayBlockTransactions`|
|Vm Traces|1|multiple|`trace_replayBlockTransactions`|
Expand All @@ -119,7 +127,6 @@ Arguments:
- blocks
- transactions (alias = txs)
- logs (alias = events)
- contracts
- traces (alias = call_traces)
- state_diffs (= balance + code + nonce + storage diffs)
- balance_diffs
Expand Down