Skip to content

Commit

Permalink
Merge in main v0.50
Browse files Browse the repository at this point in the history
  • Loading branch information
Taztingo committed Apr 4, 2024
2 parents 4fba653 + d72b319 commit ff4a465
Show file tree
Hide file tree
Showing 45 changed files with 1,750 additions and 1,509 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vendor/
# VS Code
.history/
.vscode/
__debug_bin
__debug_bin*

# Eclipse
.project
Expand Down
8 changes: 6 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func New(
app.MsgFeesKeeper = msgfeeskeeper.NewKeeper(
appCodec, keys[msgfeestypes.StoreKey], app.GetSubspace(msgfeestypes.ModuleName),
authtypes.FeeCollectorName, pioconfig.GetProvenanceConfig().FeeDenom,
app.Simulate, app.txConfig.TxDecoder(), interfaceRegistry,
app.SimulateProv, app.txConfig.TxDecoder(), interfaceRegistry,
)

pioMsgFeesRouter := app.MsgServiceRouter().(*piohandlers.PioMsgServiceRouter)
Expand Down Expand Up @@ -752,6 +752,10 @@ func New(
appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper,
app.StakingKeeper, app.DistrKeeper, app.BaseApp.MsgServiceRouter(), govtypes.Config{MaxMetadataLen: 10000}, govAuthority,
)

// Set legacy router for backwards compatibility with gov v1beta1
govKeeper.SetLegacyRouter(govRouter)

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// app.SanctionKeeper // TODO[1760]: sanction
Expand Down Expand Up @@ -1123,7 +1127,7 @@ func New(

app.SetEndBlocker(app.EndBlocker)

app.SetAggregateEventsFunc(piohandlers.AggregateEvents) // TODO[1760]: event-history
app.SetAggregateEventsFunc(piohandlers.AggregateEvents)

// Add upgrade plans for each release. This must be done before the baseapp seals via LoadLatestVersion() down below.
InstallCustomUpgradeHandlers(app)
Expand Down
20 changes: 18 additions & 2 deletions app/params/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,34 @@
package params

import (
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec"
amino "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/gogoproto/proto"
)

// MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration.
// This function should be used only internally (in the SDK).
// App user shouldn't create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() EncodingConfig {
cdc := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
cdc := amino.NewLegacyAmino()
signingOptions := signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
},
}
interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signingOptions,
})
marshaler := codec.NewProtoCodec(interfaceRegistry)

return EncodingConfig{
Expand Down
6 changes: 1 addition & 5 deletions app/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"
"testing"
"time"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

Expand Down Expand Up @@ -41,7 +40,6 @@ func BenchmarkFullAppSimulation(b *testing.B) {
app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), simcli.FlagPeriodValue, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
// TODO[1760]: event-history: Add _ return arg back in.
_, simParams, simErr := simulation.SimulateFromSeed(
b,
os.Stdout,
Expand Down Expand Up @@ -91,9 +89,7 @@ func BenchmarkInvariants(b *testing.B) {
app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), simcli.FlagPeriodValue, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
// TODO[1760]: event-history: Add lastBlockTime return arg back in.
lastBlockTime := time.Unix(0, 0)
_, simParams, simErr := simulation.SimulateFromSeed(
_, lastBlockTime, simParams, simErr := simulation.SimulateFromSeedProv(
b,
os.Stdout,
app.BaseApp,
Expand Down
12 changes: 2 additions & 10 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func TestFullAppSimulation(t *testing.T) {
fmt.Printf("running provenance full app simulation\n")

// run randomized simulation
// TODO[1760]: event-history: Add _ return arg back in.
_, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
Expand Down Expand Up @@ -182,7 +181,6 @@ func TestSimple(t *testing.T) {
require.Equal(t, "provenanced", app.Name())

// run randomized simulation
// TODO[1760]: event-history: Add _ return arg back in.
_, _, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
Expand Down Expand Up @@ -223,9 +221,7 @@ func TestAppImportExport(t *testing.T) {
fmt.Printf("running provenance test import export\n")

// Run randomized simulation
// TODO[1760]: event-history: Add lastBlockTime return arg back in.
lastBlockTime := time.Unix(0, 0)
_, simParams, simErr := simulation.SimulateFromSeed(
_, lastBlockTime, simParams, simErr := simulation.SimulateFromSeedProv(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -340,9 +336,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
app := New(logger, db, nil, true, map[int64]bool{}, home, simcli.FlagPeriodValue, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}, fauxMerkleModeOpt)

// Run randomized simulation
// TODO[1760]: event-history: Add lastBlockTime return arg back in.
lastBlockTime := time.Unix(0, 0)
stopEarly, simParams, simErr := simulation.SimulateFromSeed(
stopEarly, lastBlockTime, simParams, simErr := simulation.SimulateFromSeedProv(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -390,7 +384,6 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, err, "InitChain")

simcli.FlagGenesisTimeValue = lastBlockTime.Unix()
// TODO[1760]: event-history: Add _ return arg back in.
_, _, err = simulation.SimulateFromSeed(
t,
os.Stdout,
Expand Down Expand Up @@ -460,7 +453,6 @@ func TestAppStateDeterminism(t *testing.T) {
config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
)

// TODO[1760]: event-history: Add _ return arg back in.
_, _, err := simulation.SimulateFromSeed(
t,
os.Stdout,
Expand Down
11 changes: 6 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
sdkmath "cosmossdk.io/math"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
Expand Down Expand Up @@ -76,15 +77,15 @@ type SetupOptions struct {
ChainID string
}

func setup(t *testing.T, withGenesis bool, invCheckPeriod uint) (*App, GenesisState) {
func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string) (*App, GenesisState) {
db := dbm.NewMemDB()
encCdc := MakeEncodingConfig()
// set default config if not set by the flow
if len(pioconfig.GetProvenanceConfig().FeeDenom) == 0 {
pioconfig.SetProvenanceConfig("", 0)
}

app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{})
app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID))
if withGenesis {
return app, NewDefaultGenesisState(encCdc.Marshaler)
}
Expand Down Expand Up @@ -274,7 +275,7 @@ func genesisStateWithValSet(t *testing.T,

// SetupQuerier initializes a new App without genesis and without calling InitChain.
func SetupQuerier(t *testing.T) *App {
app, _ := setup(t, false, 0)
app, _ := setup(t, false, 0, "")
return app
}

Expand All @@ -285,7 +286,7 @@ func SetupQuerier(t *testing.T) *App {
func SetupWithGenesisValSet(t *testing.T, chainID string, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *App {
t.Helper()

app, genesisState := setup(t, true, 5)
app, genesisState := setup(t, true, 5, chainID)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down Expand Up @@ -534,7 +535,7 @@ func SetupWithGenesisRewardsProgram(t *testing.T, nextRewardProgramID uint64, ge
}
}

app, genesisState := setup(t, true, 0)
app, genesisState := setup(t, true, 0, "")
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)
genesisState = genesisStateWithRewards(t, app, genesisState, nextRewardProgramID, genesisRewards)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.4
github.com/cosmos/cosmos-sdk v0.50.4
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.0.0
Expand Down Expand Up @@ -219,7 +219,7 @@ replace (
// TODO[1760]: wasm: Put this CosmWasm/wasmd replace back with an updated version (or delete it).
// github.com/CosmWasm/wasmd => github.com/provenance-io/wasmd v0.30.0-pio-5
// TODO[1760]: sdk: Put this replace back with an updated version of the sdk from our fork.
github.com/cosmos/cosmos-sdk => github.com/provenance-io/cosmos-sdk v0.50.5-pio-1
github.com/cosmos/cosmos-sdk => github.com/provenance-io/cosmos-sdk v0.50.5-pio-2

// TODO[1760]: Update once async-icq creates tag with our changes https://github.com/cosmos/ibc-apps/pull/168
github.com/cosmos/ibc-apps/modules/async-icq/v8 => github.com/provenance-io/ibc-apps/modules/async-icq/v8 v8.0.0-prov-1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4x
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI=
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g=
github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y=
github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE=
github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
github.com/cosmos/iavl v1.0.1 h1:D+mYbcRO2wptYzOM1Hxl9cpmmHU1ZEt9T2Wv5nZTeUw=
github.com/cosmos/iavl v1.0.1/go.mod h1:8xIUkgVvwvVrBu81scdPty+/Dx9GqwHnAvXz4cwF7RY=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
Expand Down Expand Up @@ -916,8 +916,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/provenance-io/cosmos-sdk v0.50.5-pio-1 h1:GvyZAstTVB9//RugyoUqTRez19qbEWrb2dKNIKbKz3U=
github.com/provenance-io/cosmos-sdk v0.50.5-pio-1/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/provenance-io/cosmos-sdk v0.50.5-pio-2 h1:qK+ZN2jBBFEOZZOpefAMBrU5mWj+znU87Gvxbsl8feA=
github.com/provenance-io/cosmos-sdk v0.50.5-pio-2/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/provenance-io/ibc-apps/modules/async-icq/v8 v8.0.0-prov-1 h1:p+7pxHB0ukO2aow+M6uW9gHgeQl7YJyYGyMSKHZ5My8=
github.com/provenance-io/ibc-apps/modules/async-icq/v8 v8.0.0-prov-1/go.mod h1:tObW9uxibh5Z22CtOaHVeTDotCSMyc/2B4MrYdaViBo=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
Expand Down
24 changes: 14 additions & 10 deletions internal/handlers/bank_send_restriction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handlers_test
import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -177,15 +178,18 @@ func ConstructAndSendTx(tt *testing.T, app piosimapp.App, ctx sdk.Context, acct
encCfg := moduletestutil.MakeTestEncodingConfig()
fees := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(NewTestGasLimit())))
acct = app.AccountKeeper.GetAccount(ctx, acct.GetAddress()).(*authtypes.BaseAccount)
txBytes, err := SignTxAndGetBytes(NewTestGasLimit(), fees, encCfg, priv.PubKey(), priv, *acct, ctx.ChainID(), msg)
txBytes, err := SignTxAndGetBytes(ctx, NewTestGasLimit(), fees, encCfg, priv.PubKey(), priv, *acct, ctx.ChainID(), msg)
require.NoError(tt, err, "SignTxAndGetBytes")
// TODO[1760]: finalize-block: Uncomment the rest of this func.
_ = txBytes
/*
res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})
require.Equal(tt, expectedCode, res.Code, "res=%+v", res)
if len(expectedError) > 0 {
require.Contains(tt, res.Log, expectedError, "DeliverTx result.Log")
}
*/
res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: ctx.BlockHeight() + 1,
Time: time.Now().UTC(),
Txs: [][]byte{txBytes},
},
)
require.NoError(tt, err, "FinalizeBlock expected no error")
require.Len(tt, res.TxResults, 1, "TxResults expected len not met")
require.Equal(tt, int(expectedCode), int(res.TxResults[0].Code), "res=%+v", res)
if len(expectedError) > 0 {
require.Contains(tt, res.TxResults[0].Log, expectedError, "DeliverTx result.Log")
}
}
Loading

0 comments on commit ff4a465

Please sign in to comment.