Skip to content

Commit

Permalink
Bump to cosmos-sdk 0.47.5
Browse files Browse the repository at this point in the history
* Upgrade wasmd version to 0.43.0
* Upgrade wasmvm version to 1.5.0
* Add Dockerfile
  • Loading branch information
VegeBun-csj authored Dec 14, 2023
2 parents f58002d + 6ddfded commit 4376987
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 122 deletions.
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# syntax=docker/dockerfile:1
ARG GO_VERSION="1.20"
ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11"
# --------------------------------------------------------
# Builder
# --------------------------------------------------------
FROM golang:${GO_VERSION}-alpine as builder
ARG GIT_VERSION
ARG GIT_COMMIT
RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers
# Download go dependencies
WORKDIR /dora
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 ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \
-O /lib/libwasmvm_muslc.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1)
# Copy the remaining files
COPY . .
# Build dorad binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
GOWORK=off go build \
-mod=readonly \
-tags "netgo,ledger,muslc" \
-ldflags \
"-X github.com/cosmos/cosmos-sdk/version.Name="dora" \
-X github.com/cosmos/cosmos-sdk/version.AppName="dorad" \
-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=netgo,ledger,muslc \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o /dora/build/dorad \
/dora/cmd/dorad/main.go
# --------------------------------------------------------
# Runner
# --------------------------------------------------------
FROM ${RUNNER_IMAGE}
COPY --from=builder /dora/build/dorad /bin/dorad
ENV HOME /dora
WORKDIR $HOME
EXPOSE 26656
EXPOSE 26657
EXPOSE 1317
# Note: uncomment the line below if you need pprof in localdora
# We disable it by default in out main Dockerfile for security reasons
# EXPOSE 6060
ENTRYPOINT ["dorad"]
55 changes: 48 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
v0_3_0 "github.com/DoraFactory/doravota/app/upgrades/v0_3_0"

ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
Expand Down Expand Up @@ -123,6 +125,7 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
// cosmwasm "github.com/CosmWasm/wasmvm"

appparams "github.com/DoraFactory/doravota/app/params"
"github.com/DoraFactory/doravota/docs"
Expand Down Expand Up @@ -161,7 +164,7 @@ var (

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
// produce a list of enabled proposals to pass into wasmd app.
func GetEnabledProposals() []wasm.ProposalType {
/* func GetEnabledProposals() []wasm.ProposalType {
if EnableSpecificProposals == "" {
if ProposalsEnabled == "true" {
return wasm.EnableAllProposals
Expand All @@ -175,7 +178,7 @@ func GetEnabledProposals() []wasm.ProposalType {
}
return proposals
}

*/
func getGovProposalHandlers() []govclient.ProposalHandler {
var govProposalHandlers []govclient.ProposalHandler
// this line is used by starport scaffolding # stargate/app/govProposalHandlers
Expand Down Expand Up @@ -335,7 +338,7 @@ func New(
invCheckPeriod uint,
encodingConfig appparams.EncodingConfig,
appOpts servertypes.AppOptions,
enabledProposals []wasm.ProposalType,
// enabledProposals []wasm.ProposalType,
wasmOpts []wasm.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
Expand Down Expand Up @@ -621,6 +624,15 @@ func New(
// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := strings.Join(AllCapabilities(), ",")

// wasmer, err := cosmwasm.NewVM(filepath.Join(wasmDir, "wasm"), availableCapabilities, 32, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize)
// if err != nil {
// panic(err)
// }

// trackingWasmVm := wasmtypes.Newwa(wasmer, &wasmdTypes.NoOpContractGasProcessor{})


app.WasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
Expand All @@ -643,9 +655,9 @@ func New(
)

// The gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
/* if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}
} */

// Set legacy router for backwards compatibility with gov v1beta1
app.GovKeeper.SetLegacyRouter(govRouter)
Expand Down Expand Up @@ -678,8 +690,9 @@ func New(

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(wasmtypes.ModuleName, wasmStack)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand All @@ -704,6 +717,10 @@ func New(
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.


// NOTE: add upgrade(this must be called before `app.LoadLatestVersion()`)
app.setupUpgradeHandlers()

app.mm = module.NewManager(
genutil.NewAppModule(
app.AccountKeeper,
Expand Down Expand Up @@ -1063,3 +1080,27 @@ func (app *App) SimulationManager() *module.SimulationManager {
func (app *App) ModuleManager() *module.Manager {
return app.mm
}

func (app *App) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
v0_3_0.UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.ModuleManager().RunMigrations(ctx, app.Configurator(), fromVM)
},
)

// setup store loader
// load the upgrade info from the disk
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

if upgradeInfo.Name == v0_3_0.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storetypes.StoreUpgrades{}))
}
}
12 changes: 6 additions & 6 deletions app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func BenchmarkSimulation(b *testing.B) {
0,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
baseapp.SetChainID(config.ChainID),
)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestAppStateDeterminism(t *testing.T) {
simcli.FlagPeriodValue,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
fauxMerkleModeOpt,
baseapp.SetChainID(chainID),
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestAppImportExport(t *testing.T) {
0,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
baseapp.SetChainID(config.ChainID),
)
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestAppImportExport(t *testing.T) {
0,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
baseapp.SetChainID(config.ChainID),
)
Expand Down Expand Up @@ -416,7 +416,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
0,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
fauxMerkleModeOpt,
baseapp.SetChainID(config.ChainID),
Expand Down Expand Up @@ -485,7 +485,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
0,
app.MakeEncodingConfig(),
appOptions,
wasm.EnableAllProposals,
// wasm.EnableAllProposals,
emptyWasmOpts,
fauxMerkleModeOpt,
baseapp.SetChainID(config.ChainID),
Expand Down
3 changes: 3 additions & 0 deletions app/upgrades/v0_3_0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package v0_3_0

const UpgradeName = "0.3.0"
2 changes: 2 additions & 0 deletions app/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ func AllCapabilities() []string {
"stargate",
"cosmwasm_1_1",
"cosmwasm_1_2",
"cosmwasm_1_3",
"cosmwasm_1_4",
}
}
2 changes: 1 addition & 1 deletion cmd/dorad/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func initSDKConfig() {
const (
// Name = "Dora Vota"
// AppName = "dorad"
Version = "0.2.0"
Version = "0.3.0"
// Commit = ""
// BuildTags = ""
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/dorad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (a appCreator) newApp(
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
a.encodingConfig,
appOpts,
app.GetEnabledProposals(),
// app.GetEnabledProposals(),
wasmOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
Expand Down Expand Up @@ -353,7 +353,7 @@ func (a appCreator) appExport(
uint(1),
a.encodingConfig,
appOpts,
app.GetEnabledProposals(),
// app.GetEnabledProposals(),
emptyWasmOpts,
)

Expand Down
Loading

0 comments on commit 4376987

Please sign in to comment.