Skip to content

Commit

Permalink
preferred settings support (#1171)
Browse files Browse the repository at this point in the history
* bump version

* update shasum

* bump wasmvm

* test inintial file

* add test step

* add to pipeline

* add build step

* add build step

* split pipelinne

* convert to yml to support imports

* bump to go 1.23

* bump go alpine

* fix build script

* add docker dind service

* build docker

* update docker version

* debug docker

* test

* test direct path

* sleep

* test

* Test

* mount volumes

* fix go version

* build docker and update go and alpine versions

* enable preferred settings

* run on start only

* update golang version

* fix libwasm hash

* fix lint issues

* bump ibc-hooks
  • Loading branch information
jhernandezb authored Jan 30, 2025
1 parent cd1d96d commit 669f780
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
@@ -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)
]
55 changes: 55 additions & 0 deletions .drone.star.yml
Original file line number Diff line number Diff line change
@@ -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: {}
22 changes: 11 additions & 11 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -411,7 +411,7 @@ steps:
trigger:
branch:
- main
- jhernandezb/fix-cron
- jhernandezb/ci-starlark
event:
- pull_request
- push
Expand All @@ -424,6 +424,6 @@ volumes:

---
kind: signature
hmac: 7f6a696633927ee7fcac8511be795df0f17c229369d245c4c7cb4ca83c09ac96
hmac: b4fff1025b0382cb7da82819a4193894007fe959061dbfe709ab9e142b4933da

...
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -188,3 +188,7 @@ proto-format:

proto-lint:
@$(protoImage) buf lint --error-format=json


drone-generate:
drone starlark --format --target .drone.star.yml
3 changes: 3 additions & 0 deletions cmd/starsd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func NewRootCmd() *cobra.Command {
panic(err)
}

rootCmd.PersistentPreRunE = chainPreRuns(rootCmd.PersistentPreRunE, SetPreferredSettings, LogPreferredSettings)

return rootCmd
}

Expand Down Expand Up @@ -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)
}

Expand Down
92 changes: 92 additions & 0 deletions cmd/starsd/cmd/settings.go
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions docker/Dockerfile.go-devtools
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Loading

0 comments on commit 669f780

Please sign in to comment.