xsaga / gotham-iot-testbed

14 stars 4 forks source link

cannot convert x (type []byte) to type *[32]byte #2

Closed JY132 closed 2 weeks ago

JY132 commented 3 months ago

I have this error when building the Docker images using make:

=> ERROR [ 5/23] RUN mkdir go && go get github.com/go-sql-driver/mysql && go get github.com/mattn/go-shellwords 4.5s


[ 5/23] RUN mkdir go && go get github.com/go-sql-driver/mysql && go get github.com/mattn/go-shellwords:
4.481 # filippo.io/edwards25519 4.481 go/src/filippo.io/edwards25519/scalar.go:166:53: cannot convert x (type []byte) to type *[32]byte

Dockerfile.builder:22

21 |
22 | >>> RUN mkdir go &&\ 23 | >>> go get github.com/go-sql-driver/mysql &&\ 24 | >>> go get github.com/mattn/go-shellwords 25 |

ERROR: failed to solve: process "/bin/sh -c mkdir go && go get github.com/go-sql-driver/mysql && go get github.com/mattn/go-shellwords" did not complete successfully: exit code: 2 make: *** [Makefile:72: buildstatus/Mirai_builder] Error 1

I running this code on: Operating System: Ubuntu 22.04.4 LTS
Kernel: Linux 6.5.0-35-generic Architecture: x86-64 Hardware Vendor: Dell Inc. Hardware Model: PowerEdge R630 Python 3.10.12 GNU Make 4.3 Built for x86_64-pc-linux-gnu GNU Wget 1.21.2 built on linux-gnu. Docker version 26.1.3, build b72abbb gns3server 2.2.47

Do you guys have any clue that how to solve this?

xsaga commented 3 months ago

Thanks for reporting the issue, I can also reproduce this error.

This happens when building the Mirai/Dockerfile.builder dockerfile (after the Makefile transforms the Mirai/Dockerfile.builder.template into Mirai/Dockerfile.builder).

It seems to be related to the following issue https://github.com/FiloSottile/edwards25519/issues/38, where the solution is: "You need to update to a recent version of Go."

I've made a fast check and it seems that with a recent version of Go I can compile the code. Inside the docker container:

apt install software-properties-common
add-apt-repository ppa:longsleep/golang-backports
apt update
apt upgrade

Then,

GOPATH=/opt/Mirai-Source-Code/mirai/
go mod init mirai
go get github.com/go-sql-driver/mysql
go get github.com/mattn/go-shellwords

After this it seems to compile correctly, but I'm still not very familiar with Go, so I need to check if there is a better way to do this.

JY132 commented 3 months ago

Thanks for the reply. I have figured out what caused the problem.

The error is caused by these 2 repo: github.com/go-sql-driver/mysql and github.com/FiloSottile/edwards25519.

The mysql package require Go 1.20 or higher. I modified the Mirai docker template like this and solve the error:

FROM ubuntu:focal AS builder

RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \ git \ build-essential \ golang-1.20 \ electric-fence \ && rm -rf /var/lib/apt/lists/*

ENV PATH=$PATH:/usr/lib/go-1.20/bin ENV GOPATH=/opt/go

WORKDIR /opt

RUN git clone https://github.com/jgamblin/Mirai-Source-Code.git

RUN go mod init mirai RUN go mod tidy

RUN go get github.com/go-sql-driver/mysql RUN go get github.com/mattn/go-shellwords

xsaga commented 3 months ago

Thanks for your input! I've just commited a fix to the Mirai docker template based on your comment (with some slight changes). Here is the diff: https://github.com/xsaga/gotham-iot-testbed/commit/17799cb107cf9afdc70f6d8143eb6b2661361c6d

Now the container seems to build correctly.

I've identified other issues related to building other Dockerfile containers (not related to this one) caused by drifts in external code since the last time I tested the testbed. I'm on it.

xsaga commented 3 months ago

Fixed (https://github.com/xsaga/gotham-iot-testbed/commit/8881f43a385cec56014caa50898a88c66e6b191b), make builds all containers correctly now.