Skip to content

Commit

Permalink
Merge branch 'main' into whitelisting-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed Jul 20, 2024
2 parents bed0a18 + 51a080f commit 50773f5
Show file tree
Hide file tree
Showing 41 changed files with 705 additions and 285 deletions.
15 changes: 14 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
v7 "github.com/classic-terra/core/v3/app/upgrades/v7"
v7_1 "github.com/classic-terra/core/v3/app/upgrades/v7_1"
v8 "github.com/classic-terra/core/v3/app/upgrades/v8"
v8_1 "github.com/classic-terra/core/v3/app/upgrades/v8_1"
v9 "github.com/classic-terra/core/v3/app/upgrades/v9"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
Expand All @@ -76,7 +77,19 @@ var (
DefaultNodeHome string

// Upgrades defines upgrades to be applied to the network
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade, v6_1.Upgrade, v7.Upgrade, v7_1.Upgrade, v8.Upgrade, v9.Upgrade}
Upgrades = []upgrades.Upgrade{
v2.Upgrade,
v3.Upgrade,
v4.Upgrade,
v5.Upgrade,
v6.Upgrade,
v6_1.Upgrade,
v7.Upgrade,
v7_1.Upgrade,
v8.Upgrade,
v8_1.Upgrade,
v9.Upgrade,
}

// Forks defines forks to be applied to the network
Forks = []upgrades.Fork{}
Expand Down
19 changes: 10 additions & 9 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
Expand Down Expand Up @@ -498,14 +499,14 @@ func initParamsKeeper(
) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable())
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable())
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable())
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable())
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable())
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable())
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
Expand All @@ -514,7 +515,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(taxexemptiontypes.ModuleName)
paramsKeeper.Subspace(treasurytypes.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())
paramsKeeper.Subspace(dyncommtypes.ModuleName)

return paramsKeeper
Expand Down
2 changes: 0 additions & 2 deletions app/legacy/pubkey_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
var replacementKeys replacementConfigs

err = json.Unmarshal(jsonReplacementBlob, &replacementKeys)

if err != nil {
log.Fatal(errors.Wrap(err, "Could not unmarshal replacement keys "))
}
Expand Down Expand Up @@ -112,7 +111,6 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
state[slashing.ModuleName] = clientCtx.Codec.MustMarshalJSON(&slashingGenesis)

genDoc.AppState, err = json.Marshal(state)

if err != nil {
log.Fatal("Could not marshal App State")
}
Expand Down
13 changes: 13 additions & 0 deletions app/upgrades/v8_1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//nolint:revive
package v8_1

import (
"github.com/classic-terra/core/v3/app/upgrades"
)

const UpgradeName = "v8_1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV81UpgradeHandler,
}
24 changes: 24 additions & 0 deletions app/upgrades/v8_1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//nolint:revive
package v8_1

import (
"github.com/classic-terra/core/v3/app/keepers"
"github.com/classic-terra/core/v3/app/upgrades"
treasurytypes "github.com/classic-terra/core/v3/x/treasury/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV81UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set default oracle split
keepers.TreasuryKeeper.SetOracleSplitRate(ctx, treasurytypes.DefaultOracleSplit)
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
125 changes: 125 additions & 0 deletions contrib/updates/Dockerfile.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base

###############################################################################
# Builder
###############################################################################

FROM base as builder-stage-1

ARG source
ARG GIT_COMMIT
ARG GIT_VERSION
ARG BUILDPLATFORM
ARG GOOS=linux \
GOARCH=amd64

ENV GOOS=$GOOS \
GOARCH=$GOARCH

# NOTE: add libusb-dev to run with LEDGER_ENABLED=true
RUN set -eux &&\
apk update &&\
apk add --no-cache \
ca-certificates \
linux-headers \
build-base \
cmake \
git

# install mimalloc for musl
WORKDIR ${GOPATH}/src/mimalloc
RUN set -eux &&\
git clone --depth 1 --branch v2.1.2 \
https://github.com/microsoft/mimalloc . &&\
mkdir -p build &&\
cd build &&\
cmake .. &&\
make -j$(nproc) &&\
make install

# download dependencies to cache as layer
WORKDIR ${GOPATH}/src/app
COPY ${source}go.mod ${source}go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download -x

# Cosmwasm - Download correct libwasmvm version and verify checksum
RUN set -eux &&\
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \
wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \
if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \
WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \
elif [ ${BUILDPLATFORM} = "linux/arm64" ]; then \
WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.aarch64.a"; \
else \
echo "Unsupported Build Platfrom ${BUILDPLATFORM}"; \
exit 1; \
fi; \
wget ${WASMVM_URL} -O /lib/libwasmvm_muslc.a; \
CHECKSUM=`sha256sum /lib/libwasmvm_muslc.a | cut -d" " -f1`; \
grep ${CHECKSUM} /tmp/checksums.txt; \
rm /tmp/checksums.txt

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

FROM builder-stage-1 as builder-stage-2

ARG source
ARG GOOS=linux \
GOARCH=amd64

ENV GOOS=$GOOS \
GOARCH=$GOARCH

# Copy the remaining files
COPY ${source} .

# Build app binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go install \
-mod=readonly \
-tags "netgo,muslc" \
-ldflags " \
-w -s -linkmode=external -extldflags \
'-L/go/src/mimalloc/build -lmimalloc -Wl,-z,muldefs -static' \
-X github.com/cosmos/cosmos-sdk/version.Name='terra' \
-X github.com/cosmos/cosmos-sdk/version.AppName='terrad' \
-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,muslc' \
" \
-trimpath \
./...

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

FROM alpine as terra-core

RUN apk update && apk add wget lz4 aria2 curl jq gawk coreutils "zlib>1.2.12-r2" libssl3

COPY --from=builder-stage-2 /go/bin/terrad /usr/local/bin/terrad

RUN addgroup -g 1000 terra && \
adduser -u 1000 -G terra -D -h /app terra

# rest server
EXPOSE 1317
# grpc server
EXPOSE 9090
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657

WORKDIR /app

CMD ["terrad", "version"]
2 changes: 1 addition & 1 deletion contrib/updates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ networks:
driver: default
config:
-
subnet: 192.168.10.0/16
subnet: 192.168.10.0/24
4 changes: 2 additions & 2 deletions contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# These fields should be fetched automatically in the future
# Need to do more upgrade to see upgrade patterns
OLD_VERSION=v2.4.2
OLD_VERSION=v3.0.3
# this command will retrieve the folder with the largest number in format v<number>
SOFTWARE_UPGRADE_NAME=$(ls -d -- ./app/upgrades/v* | sort -Vr | head -n 1 | xargs basename)
BUILDDIR=$1
Expand All @@ -30,7 +30,7 @@ fi
## check if $BUILDDIR/old/terrad exists
if [ ! -f "$BUILDDIR/old/terrad" ]; then
mkdir -p $BUILDDIR/old
docker build --platform linux/amd64 --no-cache --build-arg source=./_build/core-${OLD_VERSION:1}/ --tag classic-terra/terraclassic.terrad-binary.old .
docker build --platform linux/amd64 --no-cache --build-arg source=./_build/core-${OLD_VERSION:1}/ --tag classic-terra/terraclassic.terrad-binary.old -f contrib/updates/Dockerfile.old .
docker create --platform linux/amd64 --name old-temp classic-terra/terraclassic.terrad-binary.old:latest
docker cp old-temp:/usr/local/bin/terrad $BUILDDIR/old/
docker rm old-temp
Expand Down
Empty file modified contrib/updates/upgrade-test.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion custom/auth/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
// MinInitialDepositDecorator prevents submitting governance proposal low initial deposit
NewMinInitialDepositDecorator(options.GovKeeper, options.TreasuryKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
NewFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TaxExemptionKeeper, options.TreasuryKeeper),
NewFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TaxExemptionKeeper, options.TreasuryKeeper, options.DistributionKeeper),
dyncommante.NewDyncommDecorator(options.Cdc, options.DyncommKeeper, options.StakingKeeper),

// Do not add any other decorators below this point unless explicitly explain.
Expand Down
6 changes: 5 additions & 1 deletion custom/auth/ante/expected_keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
Expand All @@ -10,11 +11,12 @@ import (
type TreasuryKeeper interface {
RecordEpochTaxProceeds(ctx sdk.Context, delta sdk.Coins)
GetTaxRate(ctx sdk.Context) (taxRate sdk.Dec)
GetTaxCap(ctx sdk.Context, denom string) (taxCap sdk.Int)
GetTaxCap(ctx sdk.Context, denom string) (taxCap math.Int)
GetBurnSplitRate(ctx sdk.Context) sdk.Dec
// HasBurnTaxExemptionAddress(ctx sdk.Context, addresses ...string) bool
// HasBurnTaxExemptionContract(ctx sdk.Context, address string) bool
GetMinInitialDepositRatio(ctx sdk.Context) sdk.Dec
GetOracleSplitRate(ctx sdk.Context) sdk.Dec
}

// OracleKeeper for feeder validation
Expand All @@ -33,6 +35,8 @@ type BankKeeper interface {
type DistrKeeper interface {
FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
GetFeePool(ctx sdk.Context) distributiontypes.FeePool
GetCommunityTax(ctx sdk.Context) math.LegacyDec
SetFeePool(ctx sdk.Context, feePool distributiontypes.FeePool)
}

type GovKeeper interface {
Expand Down
4 changes: 3 additions & 1 deletion custom/auth/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ type FeeDecorator struct {
feegrantKeeper ante.FeegrantKeeper
treasuryKeeper TreasuryKeeper
taxexemptionKeeper taxexemptionkeeper.Keeper
distrKeeper DistrKeeper
}

func NewFeeDecorator(ak ante.AccountKeeper, bk BankKeeper, fk ante.FeegrantKeeper, te taxexemptionkeeper.Keeper, tk TreasuryKeeper) FeeDecorator {
func NewFeeDecorator(ak ante.AccountKeeper, bk BankKeeper, fk ante.FeegrantKeeper, te taxexemptionkeeper.Keeper, tk TreasuryKeeper, dk DistrKeeper) FeeDecorator {
return FeeDecorator{
accountKeeper: ak,
bankKeeper: bk,
feegrantKeeper: fk,
taxexemptionKeeper: te,
treasuryKeeper: tk,
distrKeeper: dk,
}
}

Expand Down
Loading

0 comments on commit 50773f5

Please sign in to comment.