I want to port the fork of evmos by zama-ai to use rollkit.
Can anyone give me some advice on the same?
Hello!
You can take a look at the source repository here GitHub - zama-ai/fhevm-go: fhevm-go is an open-source library used to easily integrate the fhEVM into an EVM-compatible blockchain. and the associated documentation here Overview | fhEVM-go
If rollkit can use go-ethereum, the integration should be pretty straight forward. Otherwise, I think it will be more complicated.
Thanks for the tip and yes it does
Quick question, i have to make a dockerfile and upload the docker image and then replace that with the geth node in rollkit right?
I don’t know rollkit, but you should build their geth client with the modification explained in the doc.
is there a way we can reuse [go-ethereum fork of zama] , but the problem is it doesnt build . Also since the fhevm-go is based on a some previous version of geth, some of the documentation doesnt work.
What are your errors during build? Is it related to geth or rollkit?
Its related to geth, when i try to integrate fhevm into EVm compatible . When i try to do make geth
╰─ make geth
go run build/ci.go install ./cmd/geth
>>> /usr/local/go/bin/go build -ldflags "--buildid=none -X github.com/ethereum/go-ethereum/internal/version.gitCommit=4c4219e405f60e63bc50f8504695bb0baaaaed80 -X github.com/ethereum/go-ethereum/internal/version.gitDate=20241015 -s" -tags urfave_cli_no_docs,ckzg -trimpath -v -o /Users/rahulguha/geth/go-ethereum/build/bin/geth ./cmd/geth
github.com/ethereum/go-ethereum/core/vm
# github.com/ethereum/go-ethereum/core/vm
core/vm/contracts.go:344:26: undefined: in
core/vm/evm.go:112:47: not enough arguments in call to evm.interpreter.evm.StateDB.AddBalance
have ("github.com/ethereum/go-ethereum/common".Address, *big.Int)
want ("github.com/ethereum/go-ethereum/common".Address, *uint256.Int, tracing.BalanceChangeReason)
core/vm/evm.go:116:9: cannot use evm.interpreter.evm.StateDB.GetBalance(addr) (value of type *uint256.Int) as *big.Int value in return statement
core/vm/evm.go:153:87: cannot use value (variable of type *big.Int) as *uint256.Int value in argument to evm.interpreter.evm.create
core/vm/evm.go:157:103: cannot use value (variable of type *big.Int) as *uint256.Int value in argument to evm.interpreter.evm.create
core/vm/interpreter.go:53:9: cannot use s.Memory (variable of type *Memory) as fhevm.Memory value in return statement: *Memory does not implement fhevm.Memory (wrong type for method GetCopy)
have GetCopy(uint64, uint64) ([]byte)
want GetCopy(int64, int64) ([]byte)
util.go:47: exit status 1
exit status 1
make: *** [geth] Error 1
But mainly the errors are in contracts.go
, evm.go
and interpreter.go
Can you simply try with our released go-ethereum integration Release v0.5.0 · zama-ai/zbc-go-ethereum · GitHub
Is there a docker version of this?
i am getting this error
n file included from ../go/pkg/mod/github.com/zama-ai/fhevm-go@v0.2.0-5/fhevm/tfhe_ciphertext.go:4:
./tfhe_wrappers.h:1:10: fatal error: 'tfhe.h' file not found
1 | #include <tfhe.h>
| ^~~~~~~~
1 error generated.
I got this error while building the go-ethereum
fork of zama also.
As explained here, you need to build it and link it within zbc-go-ethereum:
The build step includes the build of the tfhe-rs C API.
Thanks it worked. Also when i tried to run the docker image, i am getting these errors
2024-10-16 17:49:06 INFO: global keys aren't initialized automatically (FHEVM_GO_KEYS_DIR env variable not set)
2024-10-16 17:49:06 panic: TFHE_EXECUTOR_CONTRACT_ADDRESS not found
2024-10-16 17:49:06
2024-10-16 17:49:06 goroutine 1 [running]:
2024-10-16 17:49:06 github.com/zama-ai/fhevm-go/fhevm.init.5()
2024-10-16 17:49:06 github.com/zama-ai/fhevm-go@v1.0.0/fhevm/precompiles.go:21 +0x70
my dockerfile looks like this
# Build stage for fhevm-go
FROM ubuntu:20.04 AS fhevm-builder
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
make \
gcc \
g++ \
libssl-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install Go 1.21 for ARM64
RUN curl -OL https://golang.org/dl/go1.21.3.linux-arm64.tar.gz \
&& tar -C /usr/local -xzf go1.21.3.linux-arm64.tar.gz \
&& rm go1.21.3.linux-arm64.tar.gz
ENV PATH="/usr/local/go/bin:${PATH}"
# Clone and build fhevm-go
RUN git clone --recurse-submodules https://github.com/zama-ai/fhevm-go /fhevm-go
WORKDIR /fhevm-go
RUN make build
# Build stage for Geth
FROM ubuntu:20.04 AS geth-builder
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
make \
gcc \
g++ \
libssl-dev \
pkg-config \
libtool \
autoconf \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Go 1.21 for ARM64
RUN curl -OL https://golang.org/dl/go1.21.3.linux-arm64.tar.gz \
&& tar -C /usr/local -xzf go1.21.3.linux-arm64.tar.gz \
&& rm go1.21.3.linux-arm64.tar.gz
ENV PATH="/usr/local/go/bin:${PATH}"
# Copy the built fhevm-go library
COPY --from=fhevm-builder /fhevm-go /fhevm-go
WORKDIR /go-ethereum
COPY . .
# Modify go.mod to use the local fhevm-go build
RUN go mod edit -replace github.com/zama-ai/fhevm-go=../fhevm-go
# Set environment variables for linking
ENV CGO_LDFLAGS="-L/fhevm-go/tfhe-rs/target/release -ltfhe -ldl"
ENV CGO_CFLAGS="-I/fhevm-go/tfhe-rs/include"
# Build Geth
RUN make geth
# Final stage
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y ca-certificates libssl1.1 && rm -rf /var/lib/apt/lists/*
COPY --from=geth-builder /go-ethereum/build/bin/geth /usr/local/bin/
# Copy all .so files from the release directory
COPY --from=geth-builder /fhevm-go/tfhe-rs/target/release/*.so /usr/lib/
# If .so files are not present, copy .a files as a fallback
COPY --from=geth-builder /fhevm-go/tfhe-rs/target/release/*.a /usr/lib/
ENV LD_LIBRARY_PATH=/usr/lib
EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]
The error you get is related to the TFHE_EXECUTOR_CONTRACT_ADDRESS environment variable that is read by fhevm-go at startup. The way deployment is done in the fhevm
repository right now leads to address 0x596E6682c72946AF006B27C131793F2b62527A4b for TFHEExecutor. So you can set it via the following and the start again:
export TFHE_EXECUTOR_CONTRACT_ADDRESS=0x596E6682c72946AF006B27C131793F2b62527A4b
If you are deploying fhEVM contracts in a different way, you can change to the address you are using.
The TFHEExecutor contract is the only one allowed to do FHE computation and that’s why its address is special and is also used in the ACL contract.
You can look at how this address is used and deployed here: