Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ubuntu:latest
LABEL authors="deadlium, computerKeeda, Hitisha-G, saatvik333"

ENTRYPOINT ["top", "-b"]
74 changes: 74 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.22"
ARG RUNNER_IMAGE="gcr.io/distroless/static"

# --------------------------------------------------------
# Builder
# --------------------------------------------------------

FROM golang:${GO_VERSION}-alpine3.20 as builder

ARG GIT_VERSION
ARG GIT_COMMIT
ARG BUILD_TAGS
ARG ENABLED_PROPOSALS

ENV GOTOOLCHAIN go1.22.9

RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers

# Download Go dependencies
WORKDIR /junction
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.$(uname -m).a && \
# Verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.$(uname -m).a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1)

# Copy the remaining files
COPY . .

# Build junctiond binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go build \
-mod=readonly \
-tags ${BUILD_TAGS} \
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="junction" \
-X github.com/cosmos/cosmos-sdk/version.AppName="junctiond" \
-X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \
-X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \
-X github.com/cosmos/cosmos-sdk/version.BuildTags='${BUILD_TAGS}' \
-X github.com/junction-org/junction/app.EnableSpecificProposals=${ENABLED_PROPOSALS} \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /junction/build/junctiond \
/junction/cmd/junctiond

# --------------------------------------------------------
# Runner
# --------------------------------------------------------

FROM ${RUNNER_IMAGE}

COPY --from=builder /junction/build/junctiond /bin/junctiond

ENV HOME /junction
WORKDIR $HOME

EXPOSE 26656
EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["junctiond"]
60 changes: 59 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# Makefile for building and linting Go project
DOCKER := $(shell which docker)
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
GO_VERSION=1.23
COMMIT := $(shell git log -1 --format='%H')

LEDGER_ENABLED ?= true

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

empty = $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))
# Basic project settings
BINARY_NAME=junctiond
BUILD_DIR=./build
Expand Down Expand Up @@ -44,6 +83,7 @@ default: build
build: go.sum
@echo "Building $(BINARY_NAME) binary..."
$(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME) $(SOURCE_DIR)
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME) >> $(CHECKSUM_FILE)

# Install the binary
install:
Expand Down Expand Up @@ -85,4 +125,22 @@ build-all: go.sum
GOOS=windows GOARCH=amd64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(SOURCE_DIR)
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe >> $(CHECKSUM_FILE)

.PHONY: default build install test clean lint print-system build-all
build-static-linux-amd64: go.sum $(BUILD_DIR)/
mkdir -p $(BUILD_DIR)
$(DOCKER) buildx create --name junctionbuilder || true
$(DOCKER) buildx use junctionbuilder
$(DOCKER) buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg BUILD_TAGS=$(build_tags_comma_sep),muslc \
--platform linux/amd64 \
-t junction-amd64 \
--load \
-f Dockerfile.builder .
$(DOCKER) rm -f junctionbinary || true
$(DOCKER) create -ti --name junctionbinary junction-amd64
$(DOCKER) cp junctionbinary:/bin/junctiond $(BUILD_DIR)/junctiond-linux-amd64
$(DOCKER) rm -f junctionbinary

.PHONY: default build install test clean lint print-system build-all build-static-linux-amd64
97 changes: 10 additions & 87 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package app

import (
"context"
wasmkeeper "github.com/airchains-network/junction/x/wasm/keeper"
"io"
"os"
"path/filepath"

upgradetypes "cosmossdk.io/x/upgrade/types"
trackgatemoduletypes "github.com/airchains-network/junction/x/trackgate/types"
sdk "github.com/cosmos/cosmos-sdk/types"

_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
"cosmossdk.io/depinject"
"cosmossdk.io/log"
Expand Down Expand Up @@ -141,16 +136,18 @@ type App struct {
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasmkeeper.Keeper

// Scoped IBC
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedIBCTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

JunctionKeeper junctionmodulekeeper.Keeper
TrackgateKeeper trackgatemodulekeeper.Keeper
WasmKeeper wasmkeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// simulation manager
Expand Down Expand Up @@ -221,6 +218,7 @@ func New(
// Passing the getter, the app IBC Keeper will always be accessible.
// This needs to be removed after IBC supports App Wiring.
app.GetIBCKeeper,
app.GetWasmKeeper,
app.GetCapabilityScopedKeeper,
// Supply the logger
logger,
Expand Down Expand Up @@ -331,89 +329,14 @@ func New(

app.App = appBuilder.Build(db, traceStore, baseAppOptions...)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == "jip-2" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{trackgatemoduletypes.StoreKey},
}
//upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
//if err != nil {
// panic(err)
//}

app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
app.UpgradeKeeper.SetUpgradeHandler(
"jip-2",
func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
//storeUpgrades := storetypes.StoreUpgrades{
// Added: []string{trackgateTypes.StoreKey},
//}
//
//app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(plan.Height, &storeUpgrades))

// Skip the capability module migration to avoid setting the index again
// You can use the module manager to skip migrations for the capability module by adjusting the version map

// Check if the capability index is already set before attempting to initialize it
latestIndex := app.CapabilityKeeper.GetLatestIndex(sdkCtx)
if latestIndex == 0 {
// The index is not set, so we can safely initialize it
err := app.CapabilityKeeper.InitializeIndex(sdkCtx, 1) // Initialize with index 1 or a value > 0
if err != nil {
return nil, err
}
} else {
logger.Info("Capability index already initialized, skipping re-initialization")
}
//configurator := app.Configurator()
//versionMap, err := app.ModuleManager.RunMigrations(sdkCtx, configurator, fromVM)
//if err != nil {
// return nil, err
//}
//// Convert the VersionMap to a string for logging
//versionMapString := fmt.Sprintf("%v", versionMap)
//logger.Info(versionMapString)
//
//// Ensure the capability module is not migrated again
//if version, exists := versionMap["capability"]; exists && version >= 1 {
// logger.Info("Skipping capability module migration")
//}
versionMap := module.VersionMap{
"trackgate": 1,
}

//authority := authtypes.NewModuleAddress(govtypes.ModuleName)
//
//// Create the Trackgate Keeper
//app.TrackgateKeeper = trackgatemodulekeeper.NewKeeper(
// app.AppCodec(),
// runtime.NewKVStoreService(app.GetKey(trackgatemoduletypes.StoreKey)),
// logger,
// authority.String(),
// app.BankKeeper,
//)

//Create the Trackgate AppModule
//trackgateModule := trackgate.NewAppModule(
// app.AppCodec(),
// app.TrackgateKeeper,
// app.AccountKeeper,
// app.BankKeeper,
//)
//
//// Register the Trackgate module using app.RegisterModules
//err = app.RegisterModules(trackgateModule)
if err != nil {
return nil, err
}

return versionMap, nil
}, // Upgrade handler function
)
}
app.RegisterUpgradeHandlers()
// Register legacy modules
app.registerIBCModules()
app.registerWasmAndIBCModules(appOpts, wasmOpts)

// register streaming services
if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions app/app_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
wasmtypes "github.com/airchains-network/junction/x/wasm/types"
"time"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
Expand Down Expand Up @@ -96,6 +97,8 @@ var (
group.ModuleName,
consensustypes.ModuleName,
circuittypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
// chain modules
junctionmoduletypes.ModuleName,
trackgatemoduletypes.ModuleName,
Expand All @@ -122,6 +125,8 @@ var (
ibctransfertypes.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
//wasm module
wasmtypes.ModuleName,
// chain modules
junctionmoduletypes.ModuleName,
trackgatemoduletypes.ModuleName,
Expand All @@ -142,6 +147,8 @@ var (
capabilitytypes.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
//wasm module
wasmtypes.ModuleName,
// chain modules
junctionmoduletypes.ModuleName,
trackgatemoduletypes.ModuleName,
Expand All @@ -165,6 +172,8 @@ var (
{Account: ibctransfertypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
// wasm module permissions
{Account: wasmtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: trackgatemoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down
Loading