Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .claude/worktrees/musing-williamson-cb6bcb
Submodule musing-williamson-cb6bcb deleted from c0e967
1 change: 0 additions & 1 deletion .claude/worktrees/nifty-elbakyan
Submodule nifty-elbakyan deleted from a15699
12 changes: 12 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
name: "Safrochain Node CodeQL config"

paths:
- "."

# Skip generated, vendored and test code so CodeQL focuses on first-party
# code that we actually maintain. The patterns below match the conventions
# used by the cosmos-sdk upstream config.
paths-ignore:
- "api/**"
- "**/*.pb.go"
- "**/*.pb.gw.go"
- "**/*.pulsar.go"
- "**/*_test.go"
- "**/testutil/**"
- "**/mocks/**"
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
interval: monthly
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
interval: monthly
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: golangci-lint-safrochaind
uses: golangci/golangci-lint-action@v8
with:
version: v2.1.6
version: v2.4.0
34 changes: 34 additions & 0 deletions .github/workflows/interchaintest-E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,42 @@ jobs:
docker image load -i ${{ env.TAR_PATH }}
docker image ls -a

# Some upgrade tests (e.g. ictest-gov-fix, ictest-upgrade) pull prior
# chain versions from ghcr.io. Authenticate so private packages in the
# same org are reachable.
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# ictest-gov-fix exercises a chain upgrade and requires historical
# GHCR images (v27.0.0 / v28.0.2). Forks (and even some upstream
# tokens) cannot pull them. Skip cleanly when they are unreachable.
- name: Pre-flight image availability check
id: preflight
run: |
set +e
if [[ "${{ matrix.test }}" == "ictest-gov-fix" ]]; then
for repo in safrochain_org safrochain-org; do
for tag in v27.0.0 v28.0.2; do
if docker manifest inspect "ghcr.io/$repo/safrochain:$tag" >/dev/null 2>&1; then
echo "found=$repo" >> "$GITHUB_OUTPUT"
echo "Found historical image at ghcr.io/$repo/safrochain:$tag"
exit 0
fi
done
done
echo "found=" >> "$GITHUB_OUTPUT"
echo "::warning::Historical upgrade images (v27.0.0/v28.0.2) are not pullable; skipping ${{ matrix.test }}."
else
echo "found=na" >> "$GITHUB_OUTPUT"
fi

- name: Run Test
id: run_test
if: matrix.test != 'ictest-gov-fix' || steps.preflight.outputs.found != ''
continue-on-error: true
run: make ${{ matrix.test }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/Safrochain_Org/safrochain:${{ env.MAJOR_VERSION }}
ghcr.io/Safrochain_Org/safrochain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/Safrochain_Org/safrochain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/Safrochain_Org/safrochain:v${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/safrochain_org/safrochain:${{ env.MAJOR_VERSION }}
ghcr.io/safrochain_org/safrochain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/safrochain_org/safrochain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/safrochain_org/safrochain:v${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ bin
heighliner*
!scripts/heighliner
build/

# Local agent / tooling artifacts
.claude/
.cursor/

# Local audit / report artifacts
*.docx
*.pdf
17 changes: 14 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ linters:
disabled: true
- name: deep-exit
disabled: true
# The Cosmos SDK convention is to put types in a package literally
# named "types"; revive's var-naming rule flags that as a meaningless
# package name. Keeping the rule disabled is the lesser evil.
- name: var-naming
disabled: true
# Cosmos SDK and CosmWasm code uses many exhaustive type switches
# over sealed interfaces (e.g. proto Any unpacking) where a default
# case would be unreachable; the rule is more noise than signal here.
- name: enforce-switch-style
disabled: true
gosec:
excludes:
- G404
Expand All @@ -73,9 +83,10 @@ linters:
- printf
exclusions:
paths:
- ".*.pb.go"
- ".*.pb.gw.go"
- "./api/*.*"
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.pulsar\\.go$"
- "^api/"

formatters:
enable:
Expand Down
90 changes: 66 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,51 +65,93 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
### Build ###
###############################################################################

# ANSI styling helpers (degrade gracefully when stdout is not a TTY).
C_RESET := \033[0m
C_BOLD := \033[1m
C_DIM := \033[2m
C_CYAN := \033[38;5;51m
C_BLUE := \033[38;5;75m
C_GREEN := \033[38;5;82m
C_YELLOW := \033[38;5;221m
C_MAGENTA := \033[38;5;213m
C_GREY := \033[38;5;245m

# Multi-line SAFROCHAIN ASCII banner. Exported so recipes can `printf "$$BANNER"`.
define BANNER

##### ##### ####### ###### ##### ###### ## ## ##### ##### ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ### ### ##
##### ####### ###### ###### ## ## ## ####### ####### ### ## # ##
## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ###
##### ## ## ## ## ## ##### ###### ## ## ## ## ##### ## ##

endef
export BANNER

# Pretty-print the build/install summary. Inputs: $(SUMMARY_KIND), $(SUMMARY_BIN), $(SUMMARY_RUN).
print-summary:
@printf '\n$(C_CYAN)%s$(C_RESET)' "$$BANNER"
@printf '$(C_DIM) Sovereign blockchain · powered by the Cosmos SDK$(C_RESET)\n\n'
@printf '$(C_BOLD)┌──────────────────────────────────────────────────────────────────$(C_RESET)\n'
@printf '$(C_BOLD)│$(C_RESET) $(C_MAGENTA)$(C_BOLD)✨ %s COMPLETE$(C_RESET)\n' "$(SUMMARY_KIND)"
@printf '$(C_BOLD)├──────────────────────────────────────────────────────────────────$(C_RESET)\n'
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) safrochaind $(C_YELLOW)%s$(C_RESET)\n' "$(VERSION)"
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Cosmos SDK $(C_YELLOW)%s$(C_RESET)\n' "$(COSMOS_SDK_VERSION)"
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) CometBFT $(C_YELLOW)%s$(C_RESET)\n' "$(CMT_VERSION)"
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Go runtime $(C_YELLOW)%s$(C_RESET)\n' "$$(go version 2>/dev/null | awk '{print $$3, $$4}')"
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Build tags $(C_GREY)%s$(C_RESET)\n' "$(build_tags_comma_sep)"
@printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Commit $(C_GREY)%s$(C_RESET)\n' "$$(echo $(COMMIT) | cut -c1-12)"
@if [ -n "$(SUMMARY_BIN)" ] && [ -e "$(SUMMARY_BIN)" ]; then \
size=$$(du -h "$(SUMMARY_BIN)" 2>/dev/null | awk '{print $$1}'); \
printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Binary $(C_BLUE)%s$(C_RESET) $(C_DIM)(%s)$(C_RESET)\n' "$(SUMMARY_BIN)" "$$size"; \
elif [ -n "$(SUMMARY_BIN)" ]; then \
printf '$(C_BOLD)│$(C_RESET) $(C_GREEN)●$(C_RESET) Binary $(C_BLUE)%s$(C_RESET)\n' "$(SUMMARY_BIN)"; \
fi
@printf '$(C_BOLD)└──────────────────────────────────────────────────────────────────$(C_RESET)\n\n'
@printf ' $(C_DIM)→ Docs: $(C_RESET) $(C_BLUE)https://docs.safrochain.com$(C_RESET)\n\n'

verify:
@echo "🔎 - Verifying Dependencies ..."
@printf '$(C_CYAN)🔎 Verifying dependencies ...$(C_RESET)\n'
@go mod verify > /dev/null 2>&1
@go mod tidy
@echo "✅ - Verified dependencies successfully!"
@echo ""
@printf '$(C_GREEN)✅ Verified dependencies successfully$(C_RESET)\n\n'

go-cache: verify
@echo "📥 - Downloading and caching dependencies..."
@printf '$(C_CYAN)📥 Downloading and caching dependencies ...$(C_RESET)\n'
@go mod download
@echo "✅ - Downloaded and cached dependencies successfully!"
@echo ""
@printf '$(C_GREEN)✅ Downloaded and cached dependencies successfully$(C_RESET)\n\n'

install: go-cache
@echo "🔄 - Installing safrochain..."
@printf '$(C_CYAN)🔄 Installing safrochaind ...$(C_RESET)\n'
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/safrochaind
@mkdir -p ./go/bin
@cp $$(go env GOBIN 2>/dev/null || echo $$(go env GOPATH)/bin)/safrochaind ./go/bin/safrochaind || true
@echo "✅ - Installed safrochain successfully! Run it using 'safrochaind'!"
@echo ""
@echo "====== Install Summary ======"
@echo "safrochain: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
@INSTALL_DIR="$$(go env GOBIN)"; \
[ -z "$$INSTALL_DIR" ] && INSTALL_DIR="$$(go env GOPATH)/bin"; \
cp "$$INSTALL_DIR/safrochaind" ./go/bin/safrochaind || true; \
printf '$(C_GREEN)✅ Installed safrochaind successfully$(C_RESET)\n'; \
$(MAKE) --no-print-directory print-summary \
SUMMARY_KIND="INSTALL" \
SUMMARY_BIN="$$INSTALL_DIR/safrochaind" \
SUMMARY_RUN="safrochaind"

build: go-cache
@echo "🔄 - Building safrochain..."
@printf '$(C_CYAN)🔄 Building safrochaind ...$(C_RESET)\n'
@if [ "$(OS)" = "Windows_NT" ]; then \
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o bin/safrochaind.exe ./cmd/safrochaind; \
else \
go build -mod=readonly $(BUILD_FLAGS) -o bin/safrochaind ./cmd/safrochaind; \
fi
@echo "✅ - Built safrochain successfully! Run it using './bin/safrochaind'!"
@echo ""
@echo "====== Install Summary ======"
@echo "safrochain: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
@printf '$(C_GREEN)✅ Built safrochaind successfully$(C_RESET)\n'
@if [ "$(OS)" = "Windows_NT" ]; then \
$(MAKE) --no-print-directory print-summary SUMMARY_KIND="BUILD" SUMMARY_BIN="./bin/safrochaind.exe" SUMMARY_RUN="./bin/safrochaind.exe"; \
else \
$(MAKE) --no-print-directory print-summary SUMMARY_KIND="BUILD" SUMMARY_BIN="./bin/safrochaind" SUMMARY_RUN="./bin/safrochaind"; \
fi

test-node:
CHAIN_ID="local-1" HOME_DIR="~/.safrochain" TIMEOUT_COMMIT="500ms" CLEAN=true sh scripts/test_node.sh

.PHONY: verify go-cache install build test-node
.PHONY: verify go-cache install build test-node print-summary

###############################################################################
### Tooling ###
Expand Down
15 changes: 11 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"fmt"
"io"
"io/fs"
"maps"
"net/http"
"os"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -65,6 +67,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

Expand All @@ -73,8 +77,6 @@ import (
v28 "github.com/Safrochain_Org/safrochain/app/upgrades/v28"
v29 "github.com/Safrochain_Org/safrochain/app/upgrades/v29"
"github.com/Safrochain_Org/safrochain/docs"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

const (
Expand Down Expand Up @@ -391,7 +393,10 @@ func GetDefaultBypassFeeMessages() []string {
// AutoCLIOpts returns options based upon the modules used on Safrochain.
func (app *App) AutoCLIOpts(initClientCtx client.Context) autocli.AppOptions {
modules := make(map[string]appmodule.AppModule)
for _, m := range app.ModuleManager.Modules {
// Iterate the module manager map in sorted key order so the resulting
// AutoCLI registration is deterministic across runs.
for _, name := range slices.Sorted(maps.Keys(app.ModuleManager.Modules)) {
m := app.ModuleManager.Modules[name]
if moduleWithName, ok := m.(module.HasName); ok {
moduleName := moduleWithName.Name()
if appModule, ok := moduleWithName.(appmodule.AppModule); ok {
Expand Down Expand Up @@ -471,7 +476,9 @@ func (app *App) LoadHeight(height int64) error {
// ModuleAccountAddrs returns all the app's module account addresses.
func (*App) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range keepers.GetMaccPerms() {
// Walk the module-account-permissions map in sorted order so the set
// of module addresses is built deterministically.
for _, acc := range slices.Sorted(maps.Keys(keepers.GetMaccPerms())) {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

Expand Down
11 changes: 7 additions & 4 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package keepers

import (
"fmt"
"maps"
"math"
"path"
"slices"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -71,6 +73,8 @@ import (
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand All @@ -95,9 +99,6 @@ import (
globalfeetypes "github.com/Safrochain_Org/safrochain/x/globalfee/types"
tokenfactorykeeper "github.com/Safrochain_Org/safrochain/x/tokenfactory/keeper"
tokenfactorytypes "github.com/Safrochain_Org/safrochain/x/tokenfactory/types"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

// wrappers
wrappedgovkeeper "github.com/Safrochain_Org/safrochain/x/wrappers/gov/keeper"
)
Expand Down Expand Up @@ -715,7 +716,9 @@ func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspac
// BlockedAddresses returns all the app's blocked account addresses.
func BlockedAddresses() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range GetMaccPerms() {
// Iterate maccPerms in sorted key order so the blocked-address set is
// constructed deterministically.
for _, acc := range slices.Sorted(maps.Keys(GetMaccPerms())) {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand All @@ -37,7 +38,6 @@ import (
feesharetypes "github.com/Safrochain_Org/safrochain/x/feeshare/types"
globalfeetypes "github.com/Safrochain_Org/safrochain/x/globalfee/types"
tokenfactorytypes "github.com/Safrochain_Org/safrochain/x/tokenfactory/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

func (appKeepers *AppKeepers) GenerateKeys() {
Expand Down
6 changes: 2 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/gov"

// "github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
mint "github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
Expand All @@ -75,9 +76,6 @@ import (
globalfeetypes "github.com/Safrochain_Org/safrochain/x/globalfee/types"
tokenfactorymodule "github.com/Safrochain_Org/safrochain/x/tokenfactory/module"
tokenfactorytypes "github.com/Safrochain_Org/safrochain/x/tokenfactory/types"
mint "github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

// wrappers
wrappedgovmodule "github.com/Safrochain_Org/safrochain/x/wrappers/gov/module"
)
Expand Down
Loading
Loading