From 2c1b1082db870b3f87bc1063f99706019e1b2d4e Mon Sep 17 00:00:00 2001 From: "marvel.yu" Date: Fri, 30 Oct 2026 16:45:18 +0800 Subject: [PATCH] add reproduceable code for CICD --- MakefileBuild.mk | 5 ++-- MakefileEc2.mk | 66 ++++++++++++++++++++++++++++++++++++++++-------- node/Makefile | 38 +++++++++++++++++++++++----- 3 files changed, 91 insertions(+), 18 deletions(-) diff --git a/MakefileBuild.mk b/MakefileBuild.mk index 5a1acc355..04d4dbcd5 100644 --- a/MakefileBuild.mk +++ b/MakefileBuild.mk @@ -12,11 +12,12 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)" # ─── morph-node / tx-submitter (formerly MakefileEc2.mk) ───────────────────── +# build for mainnet build-bk-prod-morph-prod-mainnet-to-morph-node: if [ ! -d dist ]; then mkdir -p dist; fi - cd $(PWD)/node && make build + cd $(PWD)/node && make morphnode-repro cp node/build/bin/morphnode dist/ - cp node/build/bin/tendermint dist/ + sha256sum dist/morphnode tar -czvf morph-node.tar.gz dist aws s3 cp morph-node.tar.gz s3://morph-0582-morph-technical-department-mainnet-data/morph-setup/morph-node.tar.gz diff --git a/MakefileEc2.mk b/MakefileEc2.mk index c8c9873eb..3331fb335 100644 --- a/MakefileEc2.mk +++ b/MakefileEc2.mk @@ -1,10 +1,56 @@ -# New release system: MakefileEc2.mk only holds service start / healthcheck -# commands. Build artifacts are produced by MakefileBuild.mk. -# -# Target naming convention: -# start-${env_key}-${app_name} -# healthcheck-${env_key}-${app_name} -# -# morph-node and tx-submitter on EC2 are started by the release system's own -# launch flow, so no start targets are defined here yet. Add them below when -# needed. +TIMESTAMP := $(shell date +%s | xargs printf '0x%x') +PWD := $(shell pwd) +GORUN = env GO111MODULE=on go run +GITVERSION := v1.0.0 +LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT) +LDFLAGSSTRING +=-X main.GitDate=$(GITDATE) +LDFLAGSSTRING +=-X main.GitVersion=$(GITVERSION) +LDFLAGS := -ldflags "$(LDFLAGSSTRING)" + +# build for mainnet +build-bk-prod-morph-prod-mainnet-to-morph-node: + if [ ! -d dist ]; then mkdir -p dist; fi + cd $(PWD)/node && make morphnode-repro + cp node/build/bin/morphnode dist/ + sha256sum dist/morphnode + tar -czvf morph-node.tar.gz dist + aws s3 cp morph-node.tar.gz s3://morph-0582-morph-technical-department-mainnet-data/morph-setup/morph-node.tar.gz + +build-bk-prod-morph-prod-mainnet-to-morph-tx-submitter: + if [ ! -d dist ]; then mkdir -p dist; fi + env GO111MODULE=on CGO_LDFLAGS="-ldl" CGO_ENABLED=1 go build -v $(LDFLAGS) -o tx-submitter/tx-submitter ./tx-submitter/cmd + cp tx-submitter/tx-submitter dist/ + tar -czvf tx-submitter.tar.gz dist + aws s3 cp tx-submitter.tar.gz s3://morph-0582-morph-technical-department-mainnet-data/morph-setup/tx-submitter.tar.gz + +# build for qanet +build-bk-test-morph-test-qanet-to-morph-node-qanet: + if [ ! -d dist ]; then mkdir -p dist; fi + cd $(PWD)/node && make build + cp node/build/bin/morphnode dist/ + cp node/build/bin/tendermint dist/ + tar -czvf morph-node.tar.gz dist + aws s3 cp morph-node.tar.gz s3://morph-7637-morph-technical-department-qanet-data/morph-setup/morph-node.tar.gz + +build-bk-test-morph-test-qanet-to-morph-tx-submitter-qanet: + if [ ! -d dist ]; then mkdir -p dist; fi + env GO111MODULE=on CGO_LDFLAGS="-ldl" CGO_ENABLED=1 go build -v $(LDFLAGS) -o tx-submitter/tx-submitter ./tx-submitter/cmd + cp tx-submitter/tx-submitter dist/ + tar -czvf tx-submitter.tar.gz dist + aws s3 cp tx-submitter.tar.gz s3://morph-7637-morph-technical-department-qanet-data/morph-setup/tx-submitter.tar.gz + + # build for hoodi +build-bk-prod-morph-prod-testnet-to-morph-node-hoodi: + if [ ! -d dist ]; then mkdir -p dist; fi + cd $(PWD)/node && make build + cp node/build/bin/morphnode dist/ + cp node/build/bin/tendermint dist/ + tar -czvf morph-node.tar.gz dist + aws s3 cp morph-node.tar.gz s3://morph-0582-morph-technical-department-testnet-data/testnet/hoodi/morph-setup/morph-node.tar.gz + +build-bk-prod-morph-prod-testnet-to-morph-tx-submitter-hoodi: + if [ ! -d dist ]; then mkdir -p dist; fi + env GO111MODULE=on CGO_LDFLAGS="-ldl" CGO_ENABLED=1 go build -v $(LDFLAGS) -o tx-submitter/tx-submitter ./tx-submitter/cmd + cp tx-submitter/tx-submitter dist/ + tar -czvf tx-submitter.tar.gz dist + aws s3 cp tx-submitter.tar.gz s3://morph-0582-morph-technical-department-testnet-data/testnet/hoodi/morph-setup/tx-submitter.tar.gz \ No newline at end of file diff --git a/node/Makefile b/node/Makefile index acd835766..7aa3ed603 100644 --- a/node/Makefile +++ b/node/Makefile @@ -1,29 +1,56 @@ -GITCOMMIT := $(shell git rev-parse --short HEAD) +GITCOMMIT := $(shell git rev-parse --short=8 HEAD) GITDATE := $(shell git show -s --format='%ct') -VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") +VERSION ?= $(shell git describe --tags --always --dirty --abbrev=8 2>/dev/null || echo "dev") BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) +# Set by the morphnode-repro target below. Strips everything that varies between +# two builds of the same source tree, so the binary is byte-identical: +# - the build timestamp, which has no meaning for a reproducible artifact +# - the Go build ID, which depends on the state of the build cache +# - absolute checkout paths, via -trimpath +# - the VCS stamps, which depend on whether .git is present and whether the +# tree is dirty; Version and GitCommit already carry that information +# - the random LC_UUID that Apple's linker stamps into every Mach-O binary +# (on Linux the equivalent GNU build-id is derived from content already) +ifdef REPRO +BUILD_TIME := reproducible +BUILDFLAGS += -trimpath -buildvcs=false +LDFLAGSSTRING +=-buildid= +ifeq ($(shell uname -s),Darwin) +LDFLAGSSTRING +=-extldflags=-Wl,-no_uuid +endif +endif + LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT) LDFLAGSSTRING +=-X main.GitDate=$(GITDATE) LDFLAGSSTRING +=-X main.Version=$(VERSION) LDFLAGSSTRING +=-X main.BuildTime=$(BUILD_TIME) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" +BUILDFLAGS += $(LDFLAGS) morphnode: if [ ! -d build/bin ]; then mkdir -p build/bin; fi go mod download - env GO111MODULE=on CGO_ENABLED=1 CGO_LDFLAGS="-ldl" go build -o build/bin/morphnode -v $(LDFLAGS) ./cmd/node + env GO111MODULE=on CGO_ENABLED=1 CGO_LDFLAGS="-ldl" go build -o build/bin/morphnode -v $(BUILDFLAGS) ./cmd/node .PHONY: morphnode tendermint: if [ ! -d build/bin ]; then mkdir -p build/bin; fi go mod download - env GO111MODULE=on CGO_ENABLED=1 go build -o build/bin/tendermint -v $(LDFLAGS) ./cmd/tendermint + env GO111MODULE=on CGO_ENABLED=1 go build -o build/bin/tendermint -v $(BUILDFLAGS) ./cmd/tendermint .PHONY: tendermint build: morphnode tendermint .PHONY: build +# Same binary as `make morphnode`, but byte-identical across builds of an +# identical source tree. This still requires a fixed toolchain: morphnode is +# built with cgo, so the Go version and the C toolchain must match too. Build +# inside ops/docker/Dockerfile.l2-node to guarantee that across machines. +morphnode-repro: + $(MAKE) morphnode REPRO=1 +.PHONY: morphnode-repro + init: if [ -d build/config ]; then exit 0; fi if [ ! -d build ]; then mkdir -p build; fi @@ -94,7 +121,7 @@ testnet-clean: testnet-down install-tendermint: if [ ! -d build/bin ]; then mkdir -p build/bin; fi go mod download - env GO111MODULE=on CGO_ENABLED=1 go install -v $(LDFLAGS) ./cmd/tendermint + env GO111MODULE=on CGO_ENABLED=1 go install -v $(BUILDFLAGS) ./cmd/tendermint .PHONY: tendermint @@ -102,4 +129,3 @@ install-tendermint: -