Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*.toml
*.tpl
*.hcl
go.work
go.work.sum
contracts/wasm
Dockerfile
docOps/
Expand All @@ -29,5 +27,6 @@ wal
wasp
!tools/wasp-cli
!tools/evm/evmemulator
!tools/gendoc
wasp-cluster
waspdb
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/** linguist-vendored
# Vendored static libraries — mark as binary so git never diffs/merges them
vendor/github.com/iotaledger/grocksdb/dist/**/*.a binary
5 changes: 4 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
paths-ignore:
- "**/README.md"

env:
GOFLAGS: -mod=vendor

jobs:
build:
name: Build only
Expand Down Expand Up @@ -50,7 +53,7 @@ jobs:

- name: Test
run: |
TEST_SHORT_PKGS="$(go list ./... \
TEST_SHORT_PKGS="$(GOFLAGS=-mod=vendor go list ./... \
| grep -v '/tools/cluster' \
)" make test-short

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cluster-tests-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- cron: '0 2 * * *'
workflow_dispatch:

env:
GOFLAGS: -mod=vendor

jobs:
cluster-tests:
name: Run cluster tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
environment: release
name: Release Docker
runs-on: ubuntu-latest
env:
GOFLAGS: -mod=vendor
outputs:
version: ${{ steps.tagger.outputs.tag }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/simulator-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
paths-ignore:
- "**/README.md"

env:
GOFLAGS: -mod=vendor

jobs:
test-short:
name: Test (short, simulator)
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ wasp.log
/submsg
waspdb**/
cluster-data/
dist/
/dist/
.idea/
.vscode/
.tlacache/
vendor/
*.bat
*.bak
Cargo.lock
Expand Down Expand Up @@ -43,7 +42,7 @@ tests_output.log
*.blk
TMP*
tmp.*
sdk/
/sdk/
libiota_sdk.so
libiota_sdk.dylib
iota_sdk.dll
Expand Down
13 changes: 2 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,10 @@ WORKDIR /scratch
RUN mkdir /app
RUN mkdir /app/waspdb

# Make sure that modules only get pulled when the module file has changed
COPY go.mod go.sum ./

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Project build stage
# Copy source and vendor
COPY . .

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go build -o /app/wasp -a -ldflags=${BUILD_LD_FLAGS} .
RUN go build -mod=vendor -o /app/wasp -a -ldflags=${BUILD_LD_FLAGS} .

############################
# Image
Expand Down
9 changes: 2 additions & 7 deletions Dockerfile.noncached
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ WORKDIR /scratch
RUN mkdir /app
RUN mkdir /app/waspdb

# Make sure that modules only get pulled when the module file has changed
COPY go.mod go.sum ./

RUN go mod download

# Project build stage
# Copy source and vendor
COPY . .

RUN go build -o /app/wasp -a -ldflags=${BUILD_LD_FLAGS} .
RUN go build -mod=vendor -o /app/wasp -a -ldflags=${BUILD_LD_FLAGS} .

############################
# Image
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ DOCKER_BUILD_ARGS = # E.g. make docker-build "DOCKER_BUILD_ARGS=--tag wasp:devel
#
TEST_PKG=./...
TEST_ARG=
TEST_SHORT_PKGS ?= $(shell go list ./... | tr '\n' ' ')
TEST_SHORT_PKGS ?= $(shell GOFLAGS=-mod=vendor go list ./... | tr '\n' ' ')

BUILD_PKGS ?= ./
BUILD_CMD=go build -o . -ldflags $(BUILD_LD_FLAGS)
INSTALL_CMD=go install -ldflags $(BUILD_LD_FLAGS)

export GOFLAGS := -mod=vendor

# Docker image name and tag
DOCKER_IMAGE_NAME=wasp
DOCKER_IMAGE_TAG=develop
Expand All @@ -26,7 +28,7 @@ compile-solidity:
cd packages/evm/evmtest/wiki_how_tos && go generate

build-cli:
cd tools/wasp-cli && go mod tidy && go build -ldflags $(BUILD_LD_FLAGS) -tags rocksdb -o ../../
go build -tags rocksdb -ldflags $(BUILD_LD_FLAGS) -o . ./tools/wasp-cli/

build-full: build-cli
$(BUILD_CMD) ./...
Expand All @@ -40,7 +42,7 @@ gendoc:
./scripts/gendoc.sh

genqlient:
cd clients/iotagraphql && GOTOOLCHAIN=go1.24.6 go run github.com/Khan/genqlient@v0.8.1
cd clients/iotagraphql && GOFLAGS= GOTOOLCHAIN=go1.24.6 go run github.com/Khan/genqlient@v0.8.1

test-full: install
go test -tags runheavy -race -ldflags $(BUILD_LD_FLAGS) ./... --timeout 60m --count 1 -failfast
Expand All @@ -61,10 +63,10 @@ test-short-simulator:
| grep -v '/clients/iotagraphql/iotaclienttest')

test-cluster: install
go test -race -ldflags $(BUILD_LD_FLAGS) --count 1 -timeout 25m -failfast $(shell go list ./tools/cluster/tests/...)
go test -race -ldflags $(BUILD_LD_FLAGS) --count 1 -timeout 25m -failfast $(shell GOFLAGS=-mod=vendor go list ./tools/cluster/tests/...)

install-cli:
cd tools/wasp-cli && go mod tidy && go install -ldflags $(BUILD_LD_FLAGS)
go install -ldflags $(BUILD_LD_FLAGS) ./tools/wasp-cli/

install-full: install-cli
$(INSTALL_CMD) ./...
Expand All @@ -78,7 +80,7 @@ lint: lint-wasp-cli
golangci-lint run --timeout 5m

lint-wasp-cli:
cd ./tools/wasp-cli && golangci-lint run --timeout 5m
cd ./tools/wasp-cli && GOFLAGS= golangci-lint run --timeout 5m

apiclient-docker:
./clients/apiclient/generate_client.sh docker
Expand Down Expand Up @@ -112,4 +114,12 @@ deps-versions:
awk -F ":" '{ print $$1 }' | \
{ read from ; read to; awk -v s="$$from" -v e="$$to" 'NR>1*s&&NR<1*e' packages/testutil/privtangle/privtangle.go; }

.PHONY: all compile-solidity build-cli build-full build build-lint test-full test test-short install-cli install-full install lint gofumpt-list docker-build deps-versions genqlient
vendor:
[ ! -d vendor ] || chmod -R u+w vendor
GOFLAGS= go work vendor
./scripts/vendor_fix_cgo.sh

tidy:
GOFLAGS= ./scripts/go_mod_tidy.sh

.PHONY: all compile-solidity build-cli build-full build build-lint test-full test test-short install-cli install-full install lint gofumpt-list docker-build deps-versions genqlient vendor tidy
2 changes: 1 addition & 1 deletion scripts/gendoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ GIT_REF_TAG="$(git describe --tags)"

BUILD_LD_FLAGS="-X=github.com/iotaledger/wasp/v2/components/app.Version=${GIT_REF_TAG}"

go run -ldflags ${BUILD_LD_FLAGS} main.go
GOFLAGS= go run -ldflags ${BUILD_LD_FLAGS} main.go

cd ${CURRENT_DIR}
12 changes: 8 additions & 4 deletions scripts/go_mod_tidy.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/bash

go mod tidy
GOFLAGS= go mod tidy

pushd tools/gendoc
go mod tidy
GOFLAGS= go mod tidy
popd

pushd tools/wasp-cli
go mod tidy
GOFLAGS= go mod tidy
popd

pushd tools/evm/evmemulator
go mod tidy
GOFLAGS= go mod tidy
popd

# Re-vendor after tidy
go work vendor
./scripts/vendor_fix_cgo.sh
1 change: 1 addition & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CURRENT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PARENT_DIR="$( builtin cd ${CURRENT_DIR}/.. >/dev/null 2>&1 ; pwd -P )"
cd ${PARENT_DIR}
export GOFLAGS=-mod=vendor

OUTPUT_TO_FILE=false
if [[ $1 = "-f" ]]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/run_tests_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CURRENT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PARENT_DIR="$( builtin cd ${CURRENT_DIR}/.. >/dev/null 2>&1 ; pwd -P )"
cd ${PARENT_DIR}
export GOFLAGS=-mod=vendor

OUTPUT_TO_FILE=false
if [[ $1 = "-f" ]]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/run_tests_short.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CURRENT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PARENT_DIR="$( builtin cd ${CURRENT_DIR}/.. >/dev/null 2>&1 ; pwd -P )"
cd ${PARENT_DIR}
export GOFLAGS=-mod=vendor

OUTPUT_TO_FILE=false
if [[ $1 = "-f" ]]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/run_tests_specifc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CURRENT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PARENT_DIR="$( builtin cd ${CURRENT_DIR}/.. >/dev/null 2>&1 ; pwd -P )"
cd ${PARENT_DIR}
export GOFLAGS=-mod=vendor

OUTPUT_TO_FILE=false
if [[ $1 = "-f" ]]; then
Expand Down
44 changes: 44 additions & 0 deletions scripts/vendor_fix_cgo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# Post-vendor fix: copy CGO subdirectories that `go work vendor` omits.
# Go's vendor spec only copies Go package directories, skipping C/C++ source
# trees in subdirectories. Some dependencies bundle headers and static libraries
# in subdirectories referenced via CGO CFLAGS/LDFLAGS with ${SRCDIR}.
#
# This script copies those missing subdirectories from the module cache into vendor/.

set -euo pipefail

GOMODCACHE=$(go env GOMODCACHE)
VENDOR_DIR="${1:-vendor}"

# grocksdb: bundles rocksdb headers + static libs in dist/<os_arch>/
GROCKSDB_MOD="github.com/iotaledger/grocksdb"
GROCKSDB_VER=$(grep -m1 "^# ${GROCKSDB_MOD} " "${VENDOR_DIR}/modules.txt" | awk '{print $3}')
if [ -n "${GROCKSDB_VER}" ]; then
SRC="${GOMODCACHE}/${GROCKSDB_MOD}@${GROCKSDB_VER}/dist"
DST="${VENDOR_DIR}/${GROCKSDB_MOD}/dist"
if [ -d "${SRC}" ]; then
echo "vendor fix: copying ${GROCKSDB_MOD} dist/ (rocksdb headers + static libs)"
rm -rf "${DST}"
cp -r "${SRC}" "${DST}"
chmod -R u+w "${DST}"
fi
fi

# zondax/hid: bundles libusb + hidapi C sources in subdirectories
HID_MOD="github.com/zondax/hid"
HID_VER=$(grep -m1 "^# ${HID_MOD} " "${VENDOR_DIR}/modules.txt" | awk '{print $3}')
if [ -n "${HID_VER}" ]; then
for SUBDIR in libusb hidapi; do
SRC="${GOMODCACHE}/${HID_MOD}@${HID_VER}/${SUBDIR}"
DST="${VENDOR_DIR}/${HID_MOD}/${SUBDIR}"
if [ -d "${SRC}" ]; then
echo "vendor fix: copying ${HID_MOD} ${SUBDIR}/"
rm -rf "${DST}"
cp -r "${SRC}" "${DST}"
chmod -R u+w "${DST}"
fi
done
fi

echo "vendor fix: done"
2 changes: 1 addition & 1 deletion tools/api-gen/apigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ BUILD_LD_FLAGS="-X=github.com/iotaledger/wasp/v2/components/app.Version=$GIT_REF
# go run -ldflags="$BUILD_LD_FLAGS" ./main.go "$@"

# During development the version is unset, therefore 0 to not commit a new api client each time.
go run $SCRIPTPATH/main.go "$@"
GOFLAGS= go run $SCRIPTPATH/main.go "$@"
13 changes: 2 additions & 11 deletions tools/wasp-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@ WORKDIR /scratch
# Prepare the folder where we are putting all the files
RUN mkdir /app

# Make sure that modules only get pulled when the module file has changed
COPY go.mod go.sum ./

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Project build stage
# Copy source and vendor
COPY . .

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
cd ./tools/wasp-cli && go build -o /app/wasp-cli -a -ldflags=${BUILD_LD_FLAGS} .
RUN go build -mod=vendor -o /app/wasp-cli -a -ldflags=${BUILD_LD_FLAGS} ./tools/wasp-cli/

############################
# Image
Expand Down
Loading
Loading