diff --git a/.drone.star b/.drone.star new file mode 100644 index 000000000..8b8e81bdc --- /dev/null +++ b/.drone.star @@ -0,0 +1,6 @@ +load("scripts/drone/pipelines/test_and_build.star", "pipeline_test_and_build") + +def main(ctx): + return [ + pipeline_test_and_build(ctx) + ] diff --git a/.drone.star.yml b/.drone.star.yml new file mode 100644 index 000000000..5bed2d261 --- /dev/null +++ b/.drone.star.yml @@ -0,0 +1,55 @@ +--- +kind: pipeline +name: test_and_build +services: +- image: docker:dind + name: dind + privileged: true + volumes: + - name: dockersock + path: /var/run +steps: +- commands: + - git fetch --tags + image: alpine/git + name: fetch +- commands: + - sleep 10 + - ls -l /var/run/docker.sock + - test -S /var/run/docker.sock && echo 'Docker socket found' || echo 'Docker socket + missing' + image: alpine + name: debug_dind + volumes: + - name: dockersock + path: /var/run +- commands: + - ./scripts/go-test.sh + environment: + GOPROXY: http://goproxy + image: publicawesome/golang:1.23.5-devtooling + name: test +- commands: + - apk add --no-cache ca-certificates build-base git + - wget https://github.com/CosmWasm/wasmvm/releases/download/v2.1.4/libwasmvm_muslc.x86_64.a + -O /lib/libwasmvm_muslc.x86_64.a + - echo 'a4a3d09b36fabb65b119d5ba23442c23694401fcbee4451fe6b7e22e325a4bac /lib/libwasmvm_muslc.x86_64.a' + | sha256sum -c + - LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build + - echo 'Ensuring binary is statically linked ...' && (file $PWD/bin/starsd | grep + 'statically linked') + environment: + GOPROXY: http://goproxy + image: golang:1.23.5-alpine3.20 + name: build +- commands: + - docker build -t publicawesome/stargaze:latest . + image: docker:24 + name: build_docker + volumes: + - name: dockersock + path: /var/run +type: docker +volumes: +- name: dockersock + temp: {} diff --git a/.drone.yml b/.drone.yml index 2b595b60d..ef66eeb0b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,7 +33,7 @@ steps: branch: no-cache - name: test - image: publicawesome/golang:1.22.7-devtooling + image: publicawesome/golang:1.23.5-devtooling volumes: - name: cache path: /go @@ -42,7 +42,7 @@ steps: environment: GOPROXY: http://goproxy - name: build - image: golang:1.22.7-alpine3.19 + image: golang:1.23.5-alpine3.20 volumes: - name: cache path: /go @@ -77,12 +77,12 @@ steps: password: from_secret: docker_password tags: - - 15.0.0-alpha.5 + - 15.0.0-alpha.6 when: event: - push branch: - - jhernandezb/fix-cron + - jhernandezb/ci-starlark - main - name: docker_release image: plugins/docker @@ -99,7 +99,7 @@ steps: - tag - name: release - image: golang:1.22.7 + image: golang:1.23.5 environment: GITHUB_TOKEN: from_secret: github_token @@ -194,7 +194,7 @@ steps: environment: GOPROXY: http://goproxy - name: stargaze - image: publicawesome/golang:1.22.7-devtooling + image: publicawesome/golang:1.23.5-devtooling volumes: - name: cache path: /go @@ -282,7 +282,7 @@ steps: when: branch: no-cache - name: build-wrapper - image: publicawesome/golang:1.22.7-devtooling + image: publicawesome/golang:1.23.5-devtooling volumes: - name: cache path: /go @@ -353,7 +353,7 @@ steps: - ./scripts/ci/upgrade/proposal.sh - name: stargaze-upgraded pull: always - image: publicawesome/stargaze:15.0.0-alpha.5 + image: publicawesome/stargaze:15.0.0-alpha.6 commands: - ./scripts/ci/upgrade/run-upgrade.sh environment: @@ -372,7 +372,7 @@ steps: - http://icad:26657 - name: check-params pull: always - image: publicawesome/stargaze:15.0.0-alpha.5 + image: publicawesome/stargaze:15.0.0-alpha.6 commands: - starsd q mint params --node http://stargaze-upgraded:26657 - starsd q alloc params --node http://stargaze-upgraded:26657 @@ -411,7 +411,7 @@ steps: trigger: branch: - main - - jhernandezb/fix-cron + - jhernandezb/ci-starlark event: - pull_request - push @@ -424,6 +424,6 @@ volumes: --- kind: signature -hmac: 7f6a696633927ee7fcac8511be795df0f17c229369d245c4c7cb4ca83c09ac96 +hmac: b4fff1025b0382cb7da82819a4193894007fe959061dbfe709ab9e142b4933da ... diff --git a/Dockerfile b/Dockerfile index a01ec166b..d053d9018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # docker build . -t publicawesome/stargaze:latest # docker run --rm -it publicawesome/stargaze:latest /bin/sh -FROM golang:1.22.7-alpine3.19 AS go-builder +FROM golang:1.23.5-alpine3.20 AS go-builder RUN set -eux; apk add --no-cache ca-certificates build-base git; @@ -26,7 +26,7 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build # -------------------------------------------------------- -FROM alpine:3.19 +FROM alpine:3.20 COPY --from=go-builder /code/bin/starsd /usr/bin/starsd RUN apk add -U --no-cache ca-certificates diff --git a/Makefile b/Makefile index 724f808e5..2614fc6c5 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ endif check_go_version: @echo "Go version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION)" -ifneq ($(GO_MINOR_VERSION),22) - @echo "ERROR: Go version 1.22 is required for this version of Stargaze" +ifneq ($(GO_MINOR_VERSION),23) + @echo "ERROR: Go version 1.23 is required for this version of Stargaze" exit 1 endif @@ -188,3 +188,7 @@ proto-format: proto-lint: @$(protoImage) buf lint --error-format=json + + +drone-generate: + drone starlark --format --target .drone.star.yml diff --git a/cmd/starsd/cmd/root.go b/cmd/starsd/cmd/root.go index 750502c20..696aee9b2 100644 --- a/cmd/starsd/cmd/root.go +++ b/cmd/starsd/cmd/root.go @@ -135,6 +135,8 @@ func NewRootCmd() *cobra.Command { panic(err) } + rootCmd.PersistentPreRunE = chainPreRuns(rootCmd.PersistentPreRunE, SetPreferredSettings, LogPreferredSettings) + return rootCmd } @@ -181,6 +183,7 @@ func initRootCmd( func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) wasm.AddModuleInitFlags(startCmd) + startCmd.Flags().Bool(flagSkipPreferredSettings, false, "Skip preferred settings") startCmd.PreRunE = chainPreRuns(CheckLibwasmVersion, startCmd.PreRunE) } diff --git a/cmd/starsd/cmd/settings.go b/cmd/starsd/cmd/settings.go new file mode 100644 index 000000000..ad79a950b --- /dev/null +++ b/cmd/starsd/cmd/settings.go @@ -0,0 +1,92 @@ +package cmd + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/server" + "github.com/spf13/cobra" +) + +const flagSkipPreferredSettings = "skip-preferred-settings" + +type PreferredSetting struct { + ViperKey string + Value string + Set func(serverCtx *server.Context, key, value string) error +} + +var preferredSettings = []PreferredSetting{ + { + ViperKey: "consensus.timeout_commit", + Value: "3s", + Set: func(serverCtx *server.Context, key, value string) error { + serverCtx.Viper.Set(key, value) + serverCtx.Config.Consensus.TimeoutCommit = 3 * time.Second + return nil + }, + }, + { + ViperKey: "consensus.timeout_propose", + Value: "2s", + Set: func(serverCtx *server.Context, key, value string) error { + serverCtx.Viper.Set(key, value) + serverCtx.Config.Consensus.TimeoutPropose = 2 * time.Second + return nil + }, + }, + { + ViperKey: "wasm.memory_cache_size", + Value: "1024", + Set: func(serverCtx *server.Context, key, value string) error { + serverCtx.Viper.Set(key, value) + return nil + }, + }, +} + +func SetPreferredSettings(cmd *cobra.Command, _ []string) error { + if cmd.Name() != "start" { + return nil + } + + skip, err := cmd.Flags().GetBool(flagSkipPreferredSettings) + if err != nil { + return err + } + if skip { + return nil + } + + serverCtx := server.GetServerContextFromCmd(cmd) + + for _, setting := range preferredSettings { + err := setting.Set(serverCtx, setting.ViperKey, setting.Value) + if err != nil { + return err + } + } + + return server.SetCmdServerContext(cmd, serverCtx) +} + +func LogPreferredSettings(cmd *cobra.Command, _ []string) error { + if cmd.Name() != "start" { + return nil + } + serverCtx := server.GetServerContextFromCmd(cmd) + + skip, err := cmd.Flags().GetBool(flagSkipPreferredSettings) + if err != nil { + return err + } + + if !skip { + serverCtx.Logger.Info("using preferred settings use --skip-preferred-settings to disable") + } + + serverCtx.Logger.Info("using timeout_commit", "value", serverCtx.Config.Consensus.TimeoutCommit.String()) + serverCtx.Logger.Info("using timeout_propose", "value", serverCtx.Config.Consensus.TimeoutPropose.String()) + serverCtx.Logger.Info("using wasm.memory_cache_size", "value", serverCtx.Viper.Get("wasm.memory_cache_size")) + + return nil +} diff --git a/docker/Dockerfile.go-devtools b/docker/Dockerfile.go-devtools index 7ab01c880..4e869ae95 100644 --- a/docker/Dockerfile.go-devtools +++ b/docker/Dockerfile.go-devtools @@ -1,5 +1,5 @@ -# docker build . -t publicawesome/golang:1.22.7-devtooling -f docker/Dockerfile.go-devtools -FROM golang:1.22.7 +# docker build . -t publicawesome/golang:1.23.5-devtooling -f docker/Dockerfile.go-devtools +FROM golang:1.23.5 RUN apt-get update && \ apt-get install -y cmake && \ apt-get -y clean && \ diff --git a/e2e/go.sum b/e2e/go.sum index 163e8c1e2..7c14200ae 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -244,7 +244,7 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEV github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Shopify/toxiproxy v2.2.1+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/StirlingMarketingGroup/go-namecase v1.0.0 h1:2CzaNtCzc4iNHirR+5ru9OzGg8rQp860gqLBFqRI02Y= diff --git a/go.mod b/go.mod index 4fc7ef66d..5d25cf6f5 100644 --- a/go.mod +++ b/go.mod @@ -226,7 +226,7 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // TODO: update afer official release - github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 => github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20241211032059-0cbb0ab1dd93 + github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 => github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250129183033-079b03c57592 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 // TODO: remove after https://github.com/spf13/viper/issues/1706 gets fixed github.com/spf13/viper => github.com/spf13/viper v1.17.0 diff --git a/go.sum b/go.sum index c5cdc66b1..810292d52 100644 --- a/go.sum +++ b/go.sum @@ -950,8 +950,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20241211032059-0cbb0ab1dd93 h1:lP4IhTGA5ofKrtxbmOonyYlwpFnpoMlaNVBdm6rJIAs= -github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20241211032059-0cbb0ab1dd93/go.mod h1:goY+Rwme+gTLS1jMIfVZ8t7+g6sfU3KFSaT/anjTi3o= +github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250129183033-079b03c57592 h1:9d3J5hp6Byh46DucY2v+Gokcwjx/oO5bigXmjyk3MFQ= +github.com/public-awesome/ibc-apps/modules/ibc-hooks/v8 v8.0.0-20250129183033-079b03c57592/go.mod h1:Ey2qRry7072+p/PWIk9ceL2HfJmW30XgI+7Zxd8r30M= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= diff --git a/scripts/drone/pipelines/test_and_build.star b/scripts/drone/pipelines/test_and_build.star new file mode 100644 index 000000000..53ac68d6b --- /dev/null +++ b/scripts/drone/pipelines/test_and_build.star @@ -0,0 +1,121 @@ + +go_dev_image = "publicawesome/golang:1.23.5-devtooling" +go_image = "golang:1.23.5-alpine3.20" +wasmvm_version = "v2.1.4" +wasmvm_x86_84_hash = "a4a3d09b36fabb65b119d5ba23442c23694401fcbee4451fe6b7e22e325a4bac" +docker_image = "docker:24" +docker_dind_image = "docker:dind" + +def pipeline_test_and_build(ctx): + return { + "kind": "pipeline", + "type": "docker", + "name": "test_and_build", + "steps": [ + step_fetch(ctx), + step_debug_dind(ctx), + step_test(ctx), + step_build(ctx), + step_build_docker(ctx), + + ], + "volumes": [ + create_volume_dockersock(ctx) + ], + "services": [ + service_dind(ctx) + ] + } + +# Fetch the latest tags from the repository +def step_fetch(ctx): + return { + "name": "fetch", + "image": "alpine/git", + "commands": [ + "git fetch --tags" + ] + } + +def step_test(ctx): + return { + "name": "test", + "image": go_dev_image, + "commands": [ + "./scripts/go-test.sh" + ], + "environment": { + "GOPROXY": "http://goproxy" + } + } + +def step_build(ctx): + return { + "name": "build", + "image": go_image, + "commands": [ + "apk add --no-cache ca-certificates build-base git", + "wget https://github.com/CosmWasm/wasmvm/releases/download/{}/libwasmvm_muslc.x86_64.a -O /lib/libwasmvm_muslc.x86_64.a".format(wasmvm_version), + "echo '{} /lib/libwasmvm_muslc.x86_64.a' | sha256sum -c".format(wasmvm_x86_84_hash), + "LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build", + "echo 'Ensuring binary is statically linked ...' && (file $PWD/bin/starsd | grep 'statically linked')" + ], + "environment": { + "GOPROXY": "http://goproxy" + } + } + + +def step_build_docker(ctx): + return { + "name": "build_docker", + "image": docker_image, + "commands": [ + "docker build -t publicawesome/stargaze:latest ." + ], + "volumes": [ + mount_volume(ctx, "dockersock", "/var/run") + ] + } + +def step_debug_dind(ctx): + return { + "name": "debug_dind", + "image": "alpine", + "commands": [ + "sleep 10", + "ls -l /var/run/docker.sock", + "test -S /var/run/docker.sock && echo 'Docker socket found' || echo 'Docker socket missing'" + ], + "volumes": [ + mount_volume(ctx, "dockersock", "/var/run") + ] + } + +def service_dind(ctx): + return { + "name": "dind", + "image": docker_dind_image, + "privileged": True, + "volumes": [ + mount_volume(ctx, "dockersock", "/var/run") + ] + } + +def mount_volume(ctx, name, path): + return { + "name": name, + "path": path + } + +def create_volume_dockersock(ctx): + return { + "name": "dockersock", + "temp": dict() + } + +def volume_docker_export(ctx): + return { + "name": "docker_export", + "path": "/containers/export" + }