diff --git a/.github/generate_change_log.sh b/.github/generate_change_log.sh index 9caf6f202..b50893ddf 100755 --- a/.github/generate_change_log.sh +++ b/.github/generate_change_log.sh @@ -24,26 +24,20 @@ TESTNET_ZIP_SUM="$(checksum ./testnet.zip)" LINUX_BIN_SUM="$(checksum ./linux/geth)" MAC_BIN_SUM="$(checksum ./macos/geth)" WINDOWS_BIN_SUM="$(checksum ./windows/geth.exe)" -ARM5_BIN_SUM="$(checksum ./arm5/geth-linux-arm-5)" -ARM6_BIN_SUM="$(checksum ./arm6/geth-linux-arm-6)" -ARM7_BIN_SUM="$(checksum ./arm7/geth-linux-arm-7)" ARM64_BIN_SUM="$(checksum ./arm64/geth-linux-arm64)" OUTPUT=$(cat <<-END ## Changelog\n ${CHANGE_LOG}\n ## Assets\n -| Assets | Sha256 Checksum |\n -| :-----------: |------------|\n -| mainnet.zip | ${MAINNET_ZIP_SUM} |\n -| testnet.zip | ${TESTNET_ZIP_SUM} |\n -| geth_linux | ${LINUX_BIN_SUM} |\n -| geth_mac | ${MAC_BIN_SUM} |\n -| geth_windows | ${WINDOWS_BIN_SUM} |\n -| geth_linux_arm-5 | ${ARM5_BIN_SUM} |\n -| geth_linux_arm-6 | ${ARM6_BIN_SUM} |\n -| geth_linux_arm-7 | ${ARM7_BIN_SUM} |\n +| Assets | Sha256 Checksum | +| :-----------: |------------| +| mainnet.zip | ${MAINNET_ZIP_SUM} | +| testnet.zip | ${TESTNET_ZIP_SUM} | +| geth_linux | ${LINUX_BIN_SUM} | +| geth_mac | ${MAC_BIN_SUM} | +| geth_windows | ${WINDOWS_BIN_SUM} | | geth_linux_arm64 | ${ARM64_BIN_SUM} |\n END ) -echo -e ${OUTPUT} \ No newline at end of file +echo -e "${OUTPUT}" \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ebe646dfe..87bfb710d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -50,7 +50,7 @@ jobs: uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.50 + version: v1.52.2 working-directory: ./ skip-pkg-cache: true skip-cache: true diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index df63b64ca..e9979b069 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -44,8 +44,17 @@ jobs: # ============================== - name: Build Binary for ${{matrix.os}} - env: - CGO_ENABLED: "0" + if: matrix.os == 'ubuntu-latest' + run: | + go mod download + wget https://musl.cc/x86_64-linux-musl-cross.tgz + tar -xvf ./x86_64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth + + - name: Build Binary for ${{matrix.os}} + if: matrix.os != 'ubuntu-latest' run: | go mod download make geth @@ -58,7 +67,12 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | go mod download - make geth-linux-arm + wget https://musl.cc/aarch64-linux-musl-cross.tgz + tar -xvf ./aarch64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth-linux-arm64 -a ./cmd/geth + # ============================== # Upload artifacts # ============================== @@ -84,27 +98,6 @@ jobs: name: windows path: ./build/bin/geth.exe - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm5 - path: ./build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm6 - path: ./build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm7 - path: ./build/bin/geth-linux-arm-7 - - name: Upload ARM-64 Build uses: actions/upload-artifact@v3 if: matrix.os == 'ubuntu-latest' @@ -145,24 +138,6 @@ jobs: name: windows path: ./windows - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm7 - path: ./arm7 - - name: Download Artifacts uses: actions/download-artifact@v3 with: @@ -204,7 +179,4 @@ jobs: ./linux/geth_linux ./macos/geth_macos ./windows/geth_windows.exe - ./arm5/geth-linux-arm-5 - ./arm6/geth-linux-arm-6 - ./arm7/geth-linux-arm-7 ./arm64/geth-linux-arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fd5ecf23..e771923e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,8 +44,17 @@ jobs: # ============================== - name: Build Binary for ${{matrix.os}} - env: - CGO_ENABLED: "0" + if: matrix.os == 'ubuntu-latest' + run: | + go mod download + wget https://musl.cc/x86_64-linux-musl-cross.tgz + tar -xvf ./x86_64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth + + - name: Build Binary for ${{matrix.os}} + if: matrix.os != 'ubuntu-latest' run: | go mod download make geth @@ -58,7 +67,12 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | go mod download - make geth-linux-arm + wget https://musl.cc/aarch64-linux-musl-cross.tgz + tar -xvf ./aarch64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth-linux-arm64 -a ./cmd/geth + # ============================== # Upload artifacts # ============================== @@ -84,27 +98,6 @@ jobs: name: windows path: ./build/bin/geth.exe - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm5 - path: ./build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm6 - path: ./build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm7 - path: ./build/bin/geth-linux-arm-7 - - name: Upload ARM-64 Build uses: actions/upload-artifact@v3 if: matrix.os == 'ubuntu-latest' @@ -145,24 +138,6 @@ jobs: name: windows path: ./windows - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm7 - path: ./arm7 - - name: Download Artifacts uses: actions/download-artifact@v3 with: @@ -211,7 +186,4 @@ jobs: ./linux/geth_linux ./macos/geth_macos ./windows/geth_windows.exe - ./arm5/geth-linux-arm-5 - ./arm6/geth-linux-arm-6 - ./arm7/geth-linux-arm-7 ./arm64/geth-linux-arm64 diff --git a/Dockerfile b/Dockerfile index ecbc855cd..316cc2896 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,8 @@ COPY go.sum /go-ethereum/ RUN cd /go-ethereum && go mod download ADD . /go-ethereum + +# For blst ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth @@ -28,10 +30,9 @@ ENV BSC_HOME=/bsc ENV HOME=${BSC_HOME} ENV DATA_DIR=/data -ARG VERSION_GCC=11.2.1_git20220219-r2 ENV PACKAGES ca-certificates jq \ bash bind-tools tini \ - grep curl sed gcc==${VERSION_GCC} + grep curl sed gcc RUN apk add --no-cache $PACKAGES \ && rm -rf /var/cache/apk/* \ diff --git a/Dockerfile.alltools b/Dockerfile.alltools index 3205b412e..c3cfed913 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -13,6 +13,9 @@ COPY go.sum /go-ethereum/ RUN cd /go-ethereum && go mod download ADD . /go-ethereum +# For blst +ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" +ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" RUN cd /go-ethereum && go run build/ci.go install # Pull all binaries into a second stage deploy alpine container diff --git a/Makefile b/Makefile index c18cdddea..adda257e7 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ .PHONY: geth android ios evm all test truffle-test clean .PHONY: docker -.PHONY: geth-linux-arm geth-linux-arm64 geth-linux-arm5 geth-linux-arm6 geth-linux-arm7 GOBIN = ./build/bin GO ?= latest @@ -17,23 +16,6 @@ geth: @echo "Done building." @echo "Run \"$(GOBIN)/geth\" to launch geth." -ldflags = -X main.gitCommit=$(GIT_COMMIT) \ - -X main.gitDate=$(GIT_COMMIT_DATE) - -geth-linux-arm: geth-linux-arm5 geth-linux-arm6 geth-linux-arm7 geth-linux-arm64 - -geth-linux-arm5: - env GO111MODULE=on GOARCH=arm GOARM=5 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-5 ./cmd/geth - -geth-linux-arm6: - env GO111MODULE=on GOARCH=arm GOARM=6 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-6 ./cmd/geth - -geth-linux-arm7: - env GO111MODULE=on GOARCH=arm GOARM=7 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-7 ./cmd/geth - -geth-linux-arm64: - env GO111MODULE=on GOARCH=arm64 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm64 ./cmd/geth - all: $(GORUN) build/ci.go install diff --git a/README.md b/README.md index 9b6c28f24..0b62ea7af 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Many of the below are the same as or similar to go-ethereum. For prerequisites and detailed build instructions please read the [Installation Instructions](https://geth.ethereum.org/docs/getting-started/installing-geth). -Building `geth` requires both a Go (version 1.18 or later) and a C compiler. You can install +Building `geth` requires both a Go (version 1.19 or later) and a C compiler. You can install them using your favourite package manager. Once the dependencies are installed, run ```shell @@ -74,6 +74,16 @@ or, to build the full suite of utilities: make all ``` +If you get such error when running the node with self built binary: +```shell +Caught SIGILL in blst_cgo_init, consult /bindinds/go/README.md. +``` +please try to add the following environment variables and build again: +```shell +export CGO_CFLAGS="-O -D__BLST_PORTABLE__" +export CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" +``` + ## Executables The bsc project comes with several wrappers/executables found in the `cmd` diff --git a/build/checksums.txt b/build/checksums.txt index 1d2f1cba1..f781ba6b7 100644 --- a/build/checksums.txt +++ b/build/checksums.txt @@ -14,44 +14,52 @@ e4032e7c52ebc48bad5c58ba8de0759b6091d9b1e59581a8a521c8c9d88dbe93 go1.19.5.linux- 764871cbca841a99a24e239b63c68a4aaff4104658e3165e9ca450cac1fcbea3 go1.19.5.linux-s390x.tar.gz 85a75555e82d8aa6f486d8d29491c593389682acce9f0c270090d5938eee30ef go1.19.5.windows-arm64.zip -06456f980c7dfddfa6a30bf37a839843ee6564a2f9c4c9a8c1319dcdfeae0748 golangci-lint-1.50.1-linux-mips64le.tar.gz -0f615fb8c364f6e4a213f2ed2ff7aa1fc2b208addf29511e89c03534067bbf57 golangci-lint-1.50.1-darwin-amd64.tar.gz -10200bdf2a22d63a3b7f51d3b28e8b919b638b449b6d7867b26af008e33190b6 golangci-lint-1.50.1-linux-ppc64le.deb -131a339395aedd1e32672d9b6243abfeef91adff493bd4fb8d3edcd38e7d7498 golangci-lint-1.50.1-linux-arm64.rpm -162667015519495c2ae35955ff7804d2170ee94a24497cbe0ddf163d5ce10dd4 golangci-lint-1.50.1-linux-ppc64le.tar.gz -193fcf9b72345a8a0d27c330d8433eb6c9bce249bb2e1edea7143d4dbc1acaf4 golangci-lint-1.50.1-linux-mips64le.rpm -1dfeff81f222ec776bee2b8ddf36d727b0300b71e672e80096b2897be296f825 golangci-lint-1.50.1-windows-armv6.zip -26daf55ff7ab4d858058d666ed08ba7c1757d3eb47b24c071955d2bd30fc368a golangci-lint-1.50.1-linux-mips64.deb -3c6ff7318c574cf6096014fd527b36430721cc7a484819a7569478e20a478e1c golangci-lint-1.50.1-freebsd-amd64.tar.gz -3ca9753d7804b34f9165427fbe339dbea69bd80be8a10e3f02c6037393b2e1c4 golangci-lint-1.50.1-darwin-arm64.tar.gz -3ea0a6d5946340f6831646e2c67a317dd9b35bdc4e09b2df953a86f09ba05d74 golangci-lint-1.50.1-linux-arm64.tar.gz -4ba1dc9dbdf05b7bdc6f0e04bdfe6f63aa70576f51817be1b2540bbce017b69a golangci-lint-1.50.1-linux-amd64.tar.gz -4ed8e23077e2466350a100b988cde79750d9ef03498aa4f05d72dbd2e4b28233 golangci-lint-1.50.1-linux-s390x.rpm -50d05c2932a8ea567882fe0586f6b5c1bbfb2a2e944dafaa8f649606ad92105f golangci-lint-1.50.1-linux-ppc64le.rpm -5af2ab7c6d389dde240f7f0d661742cfce615b4b8f8f879c7c36b398f7000db1 golangci-lint-1.50.1-linux-s390x.deb -656ea0215985dfd02ed14018cee868f518d34e2274b14ec675b01aea0d305e28 golangci-lint-1.50.1-freebsd-386.tar.gz -6c371d9a37cad2d3719c45d113a07c9619e52406ca2381d247c217a41c6f5d57 golangci-lint-1.50.1-linux-armv7.deb -6d11fb6ed91ba3aecbf2ea8e1a95dce16cf0449d54aa77c607ac4e75cc43213a golangci-lint-1.50.1-windows-386.zip -73ad2af342e00e59f0a5fbd71cfb17c5dc0f765d2cf4391d5a69c79a7a8b24af golangci-lint-1.50.1-linux-mips64.rpm -757d4f17177c6eff01974e2c8e3122b85d542d1a375c416d2a870ef785ad188b golangci-lint-1.50.1-linux-arm64.deb -7fd52d1da270fa8448c975d2500b6ef2d19db143b6cfc205de16612d6f4effa9 golangci-lint-1.50.1-windows-arm64.zip -81f3136bc111bfe51da293fafcee7642dbf998e2d25bf83d24a2ff18f8d1fc14 golangci-lint-1.50.1-linux-armv7.tar.gz -8965c4327e742444bd4359bd952d42ebc645eba929d3826dd12adb8a14cc6248 golangci-lint-1.50.1-linux-386.tar.gz -8c2da214884db02fb7f3d929672c515ae3b9d10defad4dd661c4ab365a316d68 golangci-lint-1.50.1-windows-amd64.zip -96ae5ef97fec1487bcfd298e9341855ed6bf2f7d6a0bd9dfa758d2c1e4da96ec golangci-lint-1.50.1-linux-mips64.tar.gz -96ce5d9e7ae8134342e8c671ca357d92096b76673b61caf5524bfd6d772ee714 golangci-lint-1.50.1-linux-riscv64.deb -980832f12fbdd0a8e636666839b168c2bbf0ca573ff50b042d3977f65c4987d7 golangci-lint-1.50.1-linux-armv6.tar.gz -999126cbd30f08b41b9eb3cef0bb72686eace82d9cb388e8e24a910ff7a8be51 golangci-lint-1.50.1-linux-386.rpm -a2f2da85622630ff2d0aecac1acc1b3b62c4853594e49fc5a266d6ddbe1a692e golangci-lint-1.50.1-freebsd-armv7.tar.gz -a8af864c92743243ae986f20afdcc58b2cb15b0063e2821c519dcc3c8efc669d golangci-lint-1.50.1-linux-386.deb -aaa3e42de0a57c7c1f64991e3c6d0f9a97aa06455a1cde5a55c59a7fa76e2045 golangci-lint-1.50.1-linux-riscv64.tar.gz -bcdcd7a8068aa91bba432a20909babc911269504325aeff15171f29ecc72b9f0 golangci-lint-1.50.1-linux-mips64le.deb -c1d3abf0d873c7e1f123bf468f940b152526aa5af72aa5f1f5acc1733012293c golangci-lint-1.50.1-linux-armv7.rpm -c2955d6b10ce005ee20b4ad03e5cd805076971a5335a215a757d1ab72db499f9 golangci-lint-1.50.1-linux-amd64.deb -c79ec2884ff743dd965bace09f4f22d5412ccfc3fbd4aec719c8edc48fb455a0 golangci-lint-1.50.1-linux-s390x.tar.gz -c946f6ecb87ddc4f32a98baad0aa9b59f3066b04b2dc822d085c184f85764c7b golangci-lint-1.50.1-windows-armv7.zip -c9c4856e01166e835888c82af02c3952a3b55b75d5c02b674501c03f5ea1e107 golangci-lint-1.50.1-linux-amd64.rpm -dfe91654cbc5c12245c608b0fad44772ce90938c483ff945a0059442f5f3722f golangci-lint-1.50.1-freebsd-armv6.tar.gz -e140169da4ec3d1132277f2109d7202638a6032326bdeada547ffcd9d8cbedbc golangci-lint-1.50.1-linux-armv6.rpm -ecbbc8c35787aea093ef5c639972612a2300bbdc75b21466f4674f8c0d2e38ed golangci-lint-1.50.1-linux-armv6.deb -f42db20276811d7e6002d237985e658a0d1bca36586642bc071e9df9454fb4fc golangci-lint-1.50.1-linux-riscv64.rpm +000d4d58f1e25323aaf0da20b337d059d401c8c1fb31cef92ce50ef35c05e877 golangci-lint-1.52.2-linux-ppc64le.deb +0970b2e3ecc20003a0fc78b078623ab27c61f0f809a44288e2cc438bfbbf5616 golangci-lint-1.52.2-linux-s390x.deb +0bfe9b51f68a33cc4e43139151d8032b57b15e61a19f5a7554b687a3fa166ab8 golangci-lint-1.52.2-netbsd-armv7.tar.gz +0e4e24085d364f4e03752c060d5f37b5ead52acd62f07392f4c9022515e0ecd8 golangci-lint-1.52.2-linux-armv7.rpm +0f19ad6c037d45867f4978287a7a6d78bc761daf8e6cb3a5e6af86d5714b0258 golangci-lint-1.52.2-linux-armv6.tar.gz +1506b19f3f0410f6d85d1e339a47fcc84646d552516c0f429dc8cd7f34b4069a golangci-lint-1.52.2-windows-armv6.zip +1cc68baa226e186c15c5514a6e93b1cc8d47ff06aaf1a395b8266434cb01df29 golangci-lint-1.52.2-linux-386.rpm +1d23661087ae686563e40d3b1e33f309dd3b4ba7d1c7e571ca7723f77a52a9e4 golangci-lint-1.52.2-linux-s390x.rpm +227673a18d21b428f1768bb8ee46e38c36a0f002960bc6211ef6137b85d03f52 golangci-lint-1.52.2-freebsd-armv7.tar.gz +24f0272e5741c05c59e7162b7ff0258cfa6beb0d9265bd87c386fe80ac25135d golangci-lint-1.52.2-linux-mips64.deb +3abc8ad30b336ccbe3c5e3c65fa146f5b12d8e81e644345fa8d51cdbaa8cb570 golangci-lint-1.52.2-netbsd-amd64.tar.gz +40a2645b4c7bd94c16618eb0f12b32cd54c17e5620f761cf477b256d3622f299 golangci-lint-1.52.2-windows-386.zip +40b40002e07db81628d94108265525052c58fc9ce358bef26a36d27f0aea3d87 golangci-lint-1.52.2-windows-amd64.zip +41e936b62ba4fc66c02daf6fa9cf74213bc2220745c7a796acbe197c05ed26bb golangci-lint-1.52.2-netbsd-armv6.tar.gz +4bcbb4cf34bf3c8ae1ca880d12516a999499189326621599f8362ededd6e4229 golangci-lint-1.52.2-linux-riscv64.tar.gz +4edb83f1433f7c57f06f79a7fc30bf3f920c1f86c334e481661ac6627d80293f golangci-lint-1.52.2-linux-arm64.deb +50d662e86d094dbad6634d086eca4f670ffa8ea7142508d8da357a2d750ac21a golangci-lint-1.52.2-linux-armv7.tar.gz +6891597bedbcd7e530d08ed198bab7eeb9b23f3f8161dc6e87505b783cb11593 golangci-lint-1.52.2-windows-arm64.zip +6d79f4f3448b70e83952e746fcb9e251c6ba94ec2790a912806cc1704ade4d64 golangci-lint-1.52.2-linux-mips64.rpm +6de51ae05d39002421caf6049e0dd0014a2f10961471c5547c905d33d8e6adf1 golangci-lint-1.52.2-linux-armv6.deb +715dc0f0cf3538c3b2c75f084dde8dcdc3485b3494f42a6d0d9c0dc61e62b5a8 golangci-lint-1.52.2-linux-s390x.tar.gz +7c559332a97ee49b80427aba5a7122e17cac18c57e700f48e6db5ffcbbb61b2b golangci-lint-1.52.2-linux-arm64.rpm +81201bb5f19897fefb4380af2e187a0133dc5efda22254698c063cc36a601f43 golangci-lint-1.52.2-linux-386.deb +89e523d45883903cfc472ab65621073f850abd4ffbb7720bbdd7ba66ee490bc8 golangci-lint-1.52.2-darwin-arm64.tar.gz +8d60d63eee38f8de679e57b1a781de32987152f004f852f20cd47baa4c582209 golangci-lint-1.52.2-linux-mips64le.rpm +9e22df0516cbd847910f353d92245e58eab2b6edacc669646bfa06eb032a65a3 golangci-lint-1.52.2-linux-riscv64.deb +a1a74747a196d4ccd2394ea8a461508eb2edf1eb5a88010611debf572991961d golangci-lint-1.52.2-linux-loong64.tar.gz +a7f076d0fb50e0f5bc24d0f3b2567f2cfe864441e6ad20323189b7fde7cc065d golangci-lint-1.52.2-freebsd-386.tar.gz +abc100851a59cbcea2a7e9ff5ad2974a43270135520aeac9a302ca6c712a41e1 golangci-lint-1.52.2-linux-loong64.rpm +adf11a1f7f43b5a431c19cccea260e6205e2e2b42a2d2d450e31c287fec199f2 golangci-lint-1.52.2-linux-amd64.rpm +b2249e43e1624486398f41700dbe4094a4222bf50b2b1b3a740323adb9a1b66f golangci-lint-1.52.2-linux-386.tar.gz +b8e81bf979dc8bf226cb592eb78c1792f1018c3dea1bbeb11517efc4cc3301bb golangci-lint-1.52.2-windows-armv7.zip +bb9a6a0aabe39fb3d581cc200c639ce6598821a53b4d16ec59366c65f4cc2960 golangci-lint-1.52.2-source.tar.gz +c152280b2e61c202614c1c476cf4458922cda0d2781e4492be2c22d45655cae0 golangci-lint-1.52.2-freebsd-armv6.tar.gz +c8bf25c0bca142638ce4bfc921bf23d23038818d57658d69aa4a9947d514d48f golangci-lint-1.52.2-linux-ppc64le.rpm +c9cf72d12058a131746edd409ed94ccd578fbd178899d1ed41ceae3ce5f54501 golangci-lint-1.52.2-linux-amd64.tar.gz +d03f2b331b5139eddea5db2b49066d10a90094747b08d72d7b2d61cf91c79a27 golangci-lint-1.52.2-linux-mips64le.tar.gz +d609c1d49591d714148e1f8c8b5ae9f9565c601aeabc44a5a53ba44b0eb99f36 golangci-lint-1.52.2-linux-riscv64.rpm +d679adad29603ed7549372b64077cccad784e404deffe5c1e9495a06659cff33 golangci-lint-1.52.2-linux-mips64.tar.gz +d91e8cb60920cf0e46958ed917fcdd059738c00d162189c2e878424ffc8ada75 golangci-lint-1.52.2-linux-ppc64le.tar.gz +d9b5820b491e317fb1360775441d68bd3dc2f303439da5b6d536df23977e28c9 golangci-lint-1.52.2-freebsd-amd64.tar.gz +ddeae781cf07c016898efd80eaed6853a91bfaf1f22c08fbbf5cf08a573b98c4 golangci-lint-1.52.2-linux-loong64.deb +dfc5e755cfa95381f61f736780ff736a5b6c9cbccc88140348986c166d484f85 golangci-lint-1.52.2-linux-amd64.deb +e57f2599de73c4da1d36d5255b9baec63f448b3d7fb726ebd3cd64dabbd3ee4a golangci-lint-1.52.2-darwin-amd64.tar.gz +ebfb5b643ba73ef6007236b90f863ae49fc34fd366682c971b7d1308ab28f642 golangci-lint-1.52.2-netbsd-386.tar.gz +f46b60a90fab5916a7de899ad9a3a4b3d77278c2e1737d070719d3ea27919557 golangci-lint-1.52.2-linux-armv7.deb +f6e39d0ac4691c2b9f49d6d5819594f48bb03e18692fd6d100e7114077f710e6 golangci-lint-1.52.2-linux-armv6.rpm +fa5da589075143628a49a0c123ccd76a8717bb6308fb3bdb6bf1df59435d921b golangci-lint-1.52.2-linux-mips64le.deb +fc09a97f8888809fab83a316f7da70c8ed74d4863b7eed7d872cec41911a55e8 golangci-lint-1.52.2-linux-arm64.tar.gz diff --git a/build/ci.go b/build/ci.go index d036b7d6e..8ab3c0b96 100644 --- a/build/ci.go +++ b/build/ci.go @@ -24,19 +24,18 @@ Usage: go run build/ci.go Available commands are: - install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables - test [ -coverage ] [ packages... ] -- runs the tests - lint -- runs certain pre-selected linters - archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts - importkeys -- imports signing keys from env - debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package - nsis -- creates a Windows NSIS installer - aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive - xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework - purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore + install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables + test [ -coverage ] [ packages... ] -- runs the tests + lint -- runs certain pre-selected linters + archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts + importkeys -- imports signing keys from env + debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package + nsis -- creates a Windows NSIS installer + aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive + xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework + purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore For all commands, -n prevents execution of external programs (dry run mode). - */ package main @@ -198,9 +197,10 @@ func main() { func doInstall(cmdline []string) { var ( - dlgo = flag.Bool("dlgo", false, "Download Go and build with it") - arch = flag.String("arch", "", "Architecture to cross build for") - cc = flag.String("cc", "", "C compiler to cross build with") + dlgo = flag.Bool("dlgo", false, "Download Go and build with it") + arch = flag.String("arch", "", "Architecture to cross build for") + cc = flag.String("cc", "", "C compiler to cross build with") + output = flag.String("o", "", "Output directory for build artifacts") ) flag.CommandLine.Parse(cmdline) @@ -213,7 +213,8 @@ func doInstall(cmdline []string) { // Configure the build. env := build.Env() - gobuild := tc.Go("build", buildFlags(env)...) + buildArgs := buildFlags(env) + gobuild := tc.Go("build", buildArgs...) // arm64 CI builders are memory-constrained and can't handle concurrent builds, // better disable it. This check isn't the best, it should probably @@ -239,7 +240,11 @@ func doInstall(cmdline []string) { for _, pkg := range packages { args := make([]string, len(gobuild.Args)) copy(args, gobuild.Args) - args = append(args, "-o", executablePath(path.Base(pkg))) + outputPath := executablePath(path.Base(pkg)) + if output != nil && *output != "" { + outputPath = *output + } + args = append(args, "-o", outputPath) args = append(args, pkg) build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env}) } @@ -338,7 +343,7 @@ func doLint(cmdline []string) { // downloadLinter downloads and unpacks golangci-lint. func downloadLinter(cachedir string) string { - const version = "1.50.1" + const version = "1.52.2" csdb := build.MustLoadChecksums("build/checksums.txt") arch := runtime.GOARCH diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index 9fc0a0fcf..a1eaf83a3 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -39,6 +39,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -74,7 +75,9 @@ var ( diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures // 100 native token - maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether)) + maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether)) + verifyVoteAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/verifyVoteAttestationFailed", nil) + updateAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/updateAttestationFailed", nil) systemContracts = map[common.Address]bool{ common.HexToAddress(systemcontracts.ValidatorContract): true, @@ -596,6 +599,7 @@ func (p *Parlia) verifyCascadingFields(chain consensus.ChainHeaderReader, header // Verify vote attestation for fast finality. if err := p.verifyVoteAttestation(chain, header, parents); err != nil { + verifyVoteAttestationFailedGauge.Inc(1) if chain.Config().IsPlato(header.Number) { return err } @@ -689,15 +693,7 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash headers[i], headers[len(headers)-1-i] = headers[len(headers)-1-i], headers[i] } - verifiedAttestations := make(map[common.Hash]struct{}, len(headers)) - for index, header := range headers { - // vote attestation should be checked here to decide whether to update attestation of snapshot between [Luban,Plato) - // because err of verifyVoteAttestation is ignored when importing blocks and headers before Plato. - if p.chainConfig.IsLuban(header.Number) && !p.chainConfig.IsPlato(header.Number) && p.verifyVoteAttestation(chain, header, headers[:index]) == nil { - verifiedAttestations[header.Hash()] = struct{}{} - } - } - snap, err := snap.apply(headers, chain, parents, p.chainConfig, verifiedAttestations) + snap, err := snap.apply(headers, chain, parents, p.chainConfig) if err != nil { return nil, err } diff --git a/consensus/parlia/snapshot.go b/consensus/parlia/snapshot.go index ccc81d7f6..e7a9dea46 100644 --- a/consensus/parlia/snapshot.go +++ b/consensus/parlia/snapshot.go @@ -21,15 +21,18 @@ import ( "encoding/hex" "encoding/json" "errors" + "fmt" "sort" + lru "github.com/hashicorp/golang-lru" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - lru "github.com/hashicorp/golang-lru" ) // Snapshot is the state of the validatorSet at a given point. @@ -174,12 +177,27 @@ func (s *Snapshot) isMajorityFork(forkHash string) bool { } func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.ChainConfig, parliaConfig *params.ParliaConfig) { + if !chainConfig.IsLuban(header.Number) { + return + } + // The attestation should have been checked in verify header, update directly attestation, _ := getVoteAttestationFromHeader(header, chainConfig, parliaConfig) if attestation == nil { return } + // Headers with bad attestation are accepted before Plato upgrade, + // but Attestation of snapshot is only updated when the target block is direct parent of the header + targetNumber := attestation.Data.TargetNumber + targetHash := attestation.Data.TargetHash + if targetHash != header.ParentHash || targetNumber+1 != header.Number.Uint64() { + log.Warn("updateAttestation failed", "error", fmt.Errorf("invalid attestation, target mismatch, expected block: %d, hash: %s; real block: %d, hash: %s", + header.Number.Uint64()-1, header.ParentHash, targetNumber, targetHash)) + updateAttestationFailedGauge.Inc(1) + return + } + // Update attestation s.Attestation = &types.VoteData{ SourceNumber: attestation.Data.SourceNumber, @@ -189,7 +207,7 @@ func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.C } } -func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderReader, parents []*types.Header, chainConfig *params.ChainConfig, verifiedAttestations map[common.Hash]struct{}) (*Snapshot, error) { +func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderReader, parents []*types.Header, chainConfig *params.ChainConfig) (*Snapshot, error) { // Allow passing in no headers for cleaner code if len(headers) == 0 { return s, nil @@ -280,10 +298,7 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea } } - _, voteAssestationNoErr := verifiedAttestations[header.Hash()] - if chainConfig.IsPlato(header.Number) || (chainConfig.IsLuban(header.Number) && voteAssestationNoErr) { - snap.updateAttestation(header, chainConfig, s.config) - } + snap.updateAttestation(header, chainConfig, s.config) snap.RecentForkHashes[number] = hex.EncodeToString(header.Extra[extraVanity-nextForkHashSize : extraVanity]) } diff --git a/core/vote/vote_journal.go b/core/vote/vote_journal.go index 3fede2407..c11c754e3 100644 --- a/core/vote/vote_journal.go +++ b/core/vote/vote_journal.go @@ -12,7 +12,8 @@ import ( ) const ( - maxSizeOfRecentEntry = 512 + maxSizeOfRecentEntry = 512 + maliciousVoteSlashScope = 256 ) type VoteJournal struct { diff --git a/core/vote/vote_manager.go b/core/vote/vote_manager.go index c35245694..fe99418e9 100644 --- a/core/vote/vote_manager.go +++ b/core/vote/vote_manager.go @@ -180,7 +180,11 @@ func (voteManager *VoteManager) UnderRules(header *types.Header) (bool, uint64, } //Rule 2: A validator must not vote within the span of its other votes. - for blockNumber := sourceNumber + 1; blockNumber < targetNumber; blockNumber++ { + blockNumber := sourceNumber + 1 + if blockNumber+maliciousVoteSlashScope < targetNumber { + blockNumber = targetNumber - maliciousVoteSlashScope + } + for ; blockNumber < targetNumber; blockNumber++ { if voteDataBuffer.Contains(blockNumber) { voteData, ok := voteDataBuffer.Get(blockNumber) if !ok { @@ -188,7 +192,8 @@ func (voteManager *VoteManager) UnderRules(header *types.Header) (bool, uint64, continue } if voteData.(*types.VoteData).SourceNumber > sourceNumber { - log.Debug("error: cur vote is within the span of other votes") + log.Debug(fmt.Sprintf("error: cur vote %d-->%d is within the span of other votes %d-->%d", + sourceNumber, targetNumber, voteData.(*types.VoteData).SourceNumber, voteData.(*types.VoteData).TargetNumber)) return false, 0, common.Hash{} } } diff --git a/core/vote/vote_pool.go b/core/vote/vote_pool.go index 0e12855b6..664f12f76 100644 --- a/core/vote/vote_pool.go +++ b/core/vote/vote_pool.go @@ -257,6 +257,7 @@ func (pool *VotePool) transfer(blockHash common.Hash) { for _, vote := range voteBox.voteMessages { // Verify if the vote comes from valid validators based on voteAddress (BLSPublicKey). if pool.engine.VerifyVote(pool.chain, vote) != nil { + pool.receivedVotes.Remove(vote.Hash()) continue }