Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## 🛠️ Upgrades
- JWK Util and re-upgrade for params
   - PR: #182
-  Globalfee modifiers
   - PR: #183

##  🔨 Fixes
- drop to alpine 18 to avoid lib issues with wasmvm
   - PR: #181
- Fix Docker Scout invocation
   - PR: #184

## What's Changed
* drop to alpine 18 to avoid lib issues with wasmvm by @ash-burnt in #181
* JWK Util and re-upgrade for params by @ash-burnt in #182
* Patch/globalfee multipliers by @edjroz in #183
* Fix Docker Scout invocation by @froch in #184

**Full Changelog**: v4.0.0...v5.0.0
  • Loading branch information
2xburnt committed Dec 21, 2024
1 parent 3971007 commit d2ac3d0
Show file tree
Hide file tree
Showing 30 changed files with 386 additions and 417 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/docker-scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
name: Docker Scout

on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -38,8 +34,7 @@ jobs:
with:
images: burnt/xion
tags: |
type=semver,pattern={{version}},priority=1000
type=sha,priority=700
type=raw,value=scout,priority=1000
- name: Build Docker image
uses: docker/build-push-action@v5
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
- "XionSendPlatformFee"
- "XionAbstractAccount"
- "WebAuthNAbstractAccount"
- "XionMinimumFeeDefault"
- "XionMinimumFeeZero"

steps:
- name: Set up Go 1.21
Expand Down
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.19 AS go-builder
FROM golang:1.21-alpine3.18 AS go-builder
ARG arch=x86_64

ENV WASMVM_VERSION=v1.5.2
Expand Down Expand Up @@ -60,13 +60,12 @@ EXPOSE 26657
# prometheus
EXPOSE 26660

RUN mkdir /xion

RUN set -euxo pipefail \
&& echo http://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& apk add --no-cache \
bash \
curl>8.6.0-r0 \
openssl \
curl \
htop \
jq \
lz4 \
Expand All @@ -76,6 +75,8 @@ RUN set -euxo pipefail \
FROM xion-base AS xion-dev

COPY ./docker/entrypoint.sh /home/xiond/entrypoint.sh
WORKDIR /home/xiond/

CMD ["/home/xiond/entrypoint.sh"]

# --------------------------------------------------------
Expand All @@ -90,9 +91,9 @@ RUN set -euxo pipefail \
xiond

RUN set -eux \
&& chown -R xiond:xiond /home/xiond \
&& chown -R xiond:xiond /xion
&& chown -R xiond:xiond /home/xiond

USER xiond:xiond
WORKDIR /home/xiond/.xiond

CMD ["/usr/bin/xiond", "version"]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ test-integration-xion-send-platform-fee: compile_integration_tests
test-integration-xion-abstract-account: compile_integration_tests
@XION_IMAGE=$(XION_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run XionAbstractAccount

test-integration-xion-min-default: compile_integration_tests
@XION_IMAGE=$(XION_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestXionMinimumFeeDefault

test-integration-xion-min-zero: compile_integration_tests
@XION_IMAGE=$(XION_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestXionMinimumFeeZero

test-integration-min:
@XION_IMAGE=$(XION_IMAGE) cd integration_tests && go test -v -run TestXionMinimumFeeDefault -mod=readonly -tags='ledger test_ledger_mock' ./...

Expand Down
6 changes: 3 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/burnt-labs/xion/app/upgrades"
v4 "github.com/burnt-labs/xion/app/upgrades/v4"
v5 "github.com/burnt-labs/xion/app/upgrades/v5"
"github.com/burnt-labs/xion/x/mint"
mintkeeper "github.com/burnt-labs/xion/x/mint/keeper"
minttypes "github.com/burnt-labs/xion/x/mint/types"
Expand All @@ -163,7 +163,7 @@ var (
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""
Upgrades = []upgrades.Upgrade{v4.Upgrade}
Upgrades = []upgrades.Upgrade{v5.Upgrade}
)

// These constants are derived from the above variables.
Expand Down Expand Up @@ -589,7 +589,7 @@ func NewWasmApp(
app.JwkKeeper = jwkkeeper.NewKeeper(
appCodec,
keys[jwktypes.StoreKey],
app.GetSubspace(xiontypes.ModuleName))
app.GetSubspace(jwktypes.ModuleName))

app.XionKeeper = xionkeeper.NewKeeper(
appCodec,
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v5

import (
store "github.com/cosmos/cosmos-sdk/store/types"

"github.com/burnt-labs/xion/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5"
)

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

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info("Upgrade complete")
return vm, err
}
}
36 changes: 33 additions & 3 deletions integration_tests/minimum_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func TestXionMinimumFeeDefault(t *testing.T) {
}

t.Parallel()
td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}, {defaultMinGasPrices.String()}}))
td := BuildXionChain(t, "0.025uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}, {defaultMinGasPrices.String()}}))

assertion := func(t *testing.T, ctx context.Context, xion *cosmos.CosmosChain, xionUser ibc.Wallet, recipientAddress string, fundAmount int64) {
//currentHeight, _ := xion.Height(ctx)
_, err := ExecTx(t, ctx, xion.FullNodes[0],
xionUser.KeyName(),
"xion", "send", xionUser.KeyName(),
Expand All @@ -37,7 +36,7 @@ func TestXionMinimumFeeDefault(t *testing.T) {

balance, err := xion.GetBalance(ctx, xionUser.FormattedAddress(), xion.Config().Denom)
require.NoError(t, err)
require.Equal(t, fundAmount-14342, balance)
require.Equal(t, fundAmount-2415, balance)

balance, err = xion.GetBalance(ctx, recipientAddress, xion.Config().Denom)
require.NoError(t, err)
Expand All @@ -47,6 +46,37 @@ func TestXionMinimumFeeDefault(t *testing.T) {
testMinimumFee(t, &td, assertion)
}

func TestXionMinimumFeeZero(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}

t.Parallel()
td := BuildXionChain(t, "0.0uxion", ModifyInterChainGenesis(ModifyInterChainGenesisFn{ModifyGenesisShortProposals}, [][]string{{votingPeriod, maxDepositPeriod}, {defaultMinGasPrices.String()}}))

assertion := func(t *testing.T, ctx context.Context, xion *cosmos.CosmosChain, xionUser ibc.Wallet, recipientAddress string, fundAmount int64) {
toSend := int64(100)

_, err := ExecTx(t, ctx, xion.FullNodes[0],
xionUser.KeyName(),
"xion", "send", xionUser.KeyName(),
"--chain-id", xion.Config().ChainID,
recipientAddress, fmt.Sprintf("%d%s", toSend, xion.Config().Denom),
)
require.NoError(t, err)

balance, err := xion.GetBalance(ctx, xionUser.FormattedAddress(), xion.Config().Denom)
require.NoError(t, err)
require.Equal(t, fundAmount-toSend, balance)

balance, err = xion.GetBalance(ctx, recipientAddress, xion.Config().Denom)
require.NoError(t, err)
require.Equal(t, uint64(toSend), uint64(balance))
}

testMinimumFee(t, &td, assertion)
}

func testMinimumFee(t *testing.T, td *TestData, assert assertionFn) {
xion, ctx := td.xionChain, td.ctx

Expand Down
14 changes: 12 additions & 2 deletions integration_tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestXionUpgradeIBC(t *testing.T) {
users := interchaintest.GetAndFundTestUsers(t, td.ctx, "default", fundAmount, td.xionChain)
chainUser := users[0]

CosmosChainUpgradeIBCTest(t, &td, chainUser, "xion", "current", "xion", "upgrade", "v4")
CosmosChainUpgradeIBCTest(t, &td, chainUser, "xion", "local", "v5")
}

func CosmosChainUpgradeIBCTest(t *testing.T, td *TestData, chainUser ibc.Wallet, chainName, initialVersion, upgradeContainerRepo, upgradeVersion string, upgradeName string) {
func CosmosChainUpgradeIBCTest(t *testing.T, td *TestData, chainUser ibc.Wallet, upgradeContainerRepo, upgradeVersion string, upgradeName string) {
//t.Skip("ComosChainUpgradeTest should be run manually, please comment skip and follow instructions when running")
chain, ctx, client := td.xionChain, td.ctx, td.client

Expand Down Expand Up @@ -104,4 +104,14 @@ func CosmosChainUpgradeIBCTest(t *testing.T, td *TestData, chainUser ibc.Wallet,
err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), chain)
require.NoError(t, err, "chain did not produce blocks after upgrade")

// check that the upgrade set the params
paramsModResp, err := ExecQuery(t, ctx, chain.FullNodes[0],
"params", "subspace", "jwk", "TimeOffset")
require.NoError(t, err)
t.Logf("jwk params response: %v", paramsModResp)

paramsResp, err := ExecQuery(t, ctx, chain.FullNodes[0],
"jwk", "params")
require.NoError(t, err)
t.Logf("jwk params response: %v", paramsResp)
}
4 changes: 2 additions & 2 deletions integration_tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func BuildXionChain(t *testing.T, gas string, modifyGenesis func(ibc.ChainConfig
},
//GasPrices: "0.1uxion",
GasPrices: gas,
GasAdjustment: 2.0,
GasAdjustment: 1.3,
Type: "cosmos",
ChainID: "xion-1",
Bin: "xiond",
Expand Down Expand Up @@ -542,7 +542,7 @@ func TxCommandOverrideGas(t *testing.T, tn *cosmos.ChainNode, keyName, gas strin
}

func ExecTx(t *testing.T, ctx context.Context, tn *cosmos.ChainNode, keyName string, command ...string) (string, error) {
stdout, _, err := tn.Exec(ctx, TxCommandOverrideGas(t, tn, keyName, "0.1uxion", command...), nil)
stdout, _, err := tn.Exec(ctx, TxCommandOverrideGas(t, tn, keyName, tn.Chain.Config().GasPrices, command...), nil)
if err != nil {
return "", err
}
Expand Down
6 changes: 2 additions & 4 deletions proto/xion/jwk/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ option go_package = "github.com/burnt-labs/xion/x/jwk/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;

uint64 time_offset = 1; // in nanoseconds
uint64 deployment_gas = 2; // gas to deploy a new project/audience
uint64 time_offset = 1 [(gogoproto.moretags) = "yaml:\"time_offset\""]; // in nanoseconds
uint64 deployment_gas = 2 [(gogoproto.moretags) = "yaml:\"deployment_gas\""]; // gas to deploy a new project/audience
}
8 changes: 4 additions & 4 deletions proto/xion/jwk/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ service Query {

// Parameters queries the parameters of the module.
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/jwk/jwk/params";
option (google.api.http).get = "/xion/jwk/params";

}

// Queries a list of Audience items.
rpc Audience (QueryGetAudienceRequest) returns (QueryGetAudienceResponse) {
option (google.api.http).get = "/jwk/jwk/audience/{aud}";
option (google.api.http).get = "/xion/jwk/audience/{aud}";

}
rpc AudienceAll (QueryAllAudienceRequest) returns (QueryAllAudienceResponse) {
option (google.api.http).get = "/jwk/jwk/audience";
option (google.api.http).get = "/xion/jwk/audience";

}

// Queries a list of ValidateJWT items.
rpc ValidateJWT (QueryValidateJWTRequest) returns (QueryValidateJWTResponse) {
option (google.api.http).get = "/jwk/jwk/validate_jwt/{aud}/{sub}/{sigBytes}";
option (google.api.http).get = "/xion/jwk/validate_jwt/{aud}/{sub}/{sigBytes}";

}
}
Expand Down
18 changes: 5 additions & 13 deletions x/globalfee/ante/antetest/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,19 @@ func (s *IntegrationTestSuite) TestGlobalFeeSetAnteHandler() {
if !tc.networkFee {
s.Require().Equal(sdk.NewDecCoins(tc.minGasPrice...), minGas)
} else {
s.Require().Equal(sdk.NewDecCoinsFromCoins(expected...), minGas)
s.Require().Equal(expected, minGas)
}
})
}
}

func getFee(originFee sdk.DecCoins, gasLimit uint64) sdk.Coins {
func getFee(originFee sdk.DecCoins, gasLimit uint64) sdk.DecCoins {
var targetFee sdk.DecCoins = originFee
if len(originFee) == 0 {
targetFee = []sdk.DecCoin{sdk.NewDecCoinFromDec("uxion", sdk.NewDec(0))}
}
requiredFees := make(sdk.Coins, len(targetFee))
// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdk.NewDec(int64(gasLimit))
for i, gp := range targetFee {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
}

return requiredFees.Sort()
return targetFee.Sort()
}

func (s *IntegrationTestSuite) TestGetTxFeeRequired() {
Expand All @@ -253,11 +245,11 @@ func (s *IntegrationTestSuite) TestGetTxFeeRequired() {
s.Require().Equal(err.Error(), "empty staking bond denomination")

// set non-zero local min gas prices
localMinGasPrices := sdk.NewCoins(sdk.NewCoin("uxion", sdk.NewInt(1)))
localMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoin("uxion", sdk.NewInt(1)))

// setup tests with non-empty local min gas prices
feeDecorator, _ = s.SetupTestGlobalFeeStoreAndMinGasPrice(
sdk.NewDecCoinsFromCoins(localMinGasPrices...),
localMinGasPrices,
globalfeeParamsEmpty,
bondDenom,
)
Expand Down
Loading

0 comments on commit d2ac3d0

Please sign in to comment.