ethereum-optimism / op-geth

GNU Lesser General Public License v3.0
254 stars 652 forks source link

fix: store and log correct OPVersion #297

Closed bitwiseguy closed 2 months ago

bitwiseguy commented 2 months ago

Description

Ensure OPVersion is set correctly during make geth and during docker build. This was broken when checking out a specific, non-HEAD commit, which creates a "detached head" scenario. Also when a commit did not have an associated tag, the OPVersion was set to 0.1.0-unstable, which has now been changed to set OPVersion to untagged.

Tests

Manually tested the following scenarios

  1. Detached head

    git checkout 6aa2348118138a4f7021208ffaf8582d73169ba1
    git tag --points-at 6aa2348118138a4f7021208ffaf8582d73169ba1
    > v1.101311.0-rc.1

    Ran make geth and got the following output (verified -ldflags were set correctly):

    go run build/ci.go install ./cmd/geth
    >>> /usr/local/go/bin/go build -ldflags "-X github.com/ethereum/go-ethereum/internal/version.gitCommit=6aa2348118138a4f7021208ffaf8582d73169ba1 -X github.com/ethereum/go-ethereum/internal/version.gitDate=20240404 -X github.com/ethereum/go-ethereum/params.gitTag=v1.101311.0-rc.1 -s" -tags urfave_cli_no_docs,ckzg -trimpath -v -o /Users/samuel/repos/op-geth/build/bin/geth ./cmd/geth

    Created a docker image and checked its printed version

    docker buildx build -f Dockerfile . -t op-geth   
    docker run op-geth -- version    

    Got the following output (verified Version was set correctly)

    Geth
    Version: 1.101311.0-rc.1
    Git Commit: 6aa2348118138a4f7021208ffaf8582d73169ba1
    Git Commit Date: 20240404
    Upstream Version: 1.13.11-stable
    Architecture: arm64
    Go Version: go1.21.9
    Operating System: linux
    GOPATH=
    GOROOT=

    Started the container and verified the logged version looked correct:

    INFO [04-11|20:20:57.483] Starting peer-to-peer node               instance=Geth/v1.101311.0-rc.1-6aa23481-20240404/linux-arm64/go1.21.9
  2. Untagged commit

    git checkout optimism // on commit db7c618bff4b1b66e9b515a029a060026ea3c0d6

    Ran make geth and got the following output (verified -ldflags were set correctly):

    go run build/ci.go install ./cmd/geth
    >>> /usr/local/go/bin/go build -ldflags "-X github.com/ethereum/go-ethereum/internal/version.gitCommit=db7c618bff4b1b66e9b515a029a060026ea3c0d6 -X github.com/ethereum/go-ethereum/internal/version.gitDate=20240409 -s" -tags urfave_cli_no_docs,ckzg -trimpath -v -o /Users/samuel/repos/op-geth/build/bin/geth ./cmd/geth

    Created a docker image and checked its printed version

    docker buildx build -f Dockerfile . -t op-geth   
    docker run op-geth -- version    

    Got the following output (verified Version was set correctly)

    Geth
    Version: untagged
    Git Commit: db7c618bff4b1b66e9b515a029a060026ea3c0d6
    Git Commit Date: 20240409
    Upstream Version: 1.13.11-stable
    Architecture: arm64
    Go Version: go1.21.9
    Operating System: linux
    GOPATH=
    GOROOT=

    Started the container and verified the logged version looked correct (couldn't get rid of "v" before "untagged" without creating another diff with geth here:

    INFO [04-11|20:24:43.806] Starting peer-to-peer node               instance=Geth/vuntagged-db7c618b-20240409/linux-arm64/go1.21.9

Additional context

I do not have access to Circle CI so right now I am unable to verify that the $CIRCLE_TAG env var is set to the appropriate value here.

Metadata