Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODOs finalize-block, event-history, signing,add cosmos.msg.v1.signer to protos txs #1873

Merged
merged 40 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fb4e389
add chain-id to setup to prevent assert failure in chain Init()
nullpointer0x00 Mar 15, 2024
a34dbca
start updating finalize block tests, fixing signing
nullpointer0x00 Mar 18, 2024
424c68d
add pub key
nullpointer0x00 Mar 20, 2024
a5c441c
add address to signing
nullpointer0x00 Mar 20, 2024
3944556
add address decoders, update test events
nullpointer0x00 Mar 20, 2024
ad02b41
check the tx events
nullpointer0x00 Mar 21, 2024
f7a59d2
fix a few more tests, remove debug file
nullpointer0x00 Mar 21, 2024
52b65f1
update git ignore for debug files
nullpointer0x00 Mar 21, 2024
d13f3c8
minor refactors
nullpointer0x00 Mar 21, 2024
7ba86c1
add assess custom msg fee custom signer field
nullpointer0x00 Mar 27, 2024
2b81079
add custom signers to rewards proto
nullpointer0x00 Mar 27, 2024
0c2a5af
add new sdk
nullpointer0x00 Mar 28, 2024
391bb7b
add back event history and simulate function context return
nullpointer0x00 Mar 28, 2024
1ad946d
use SimulateProv instead of Simulate
nullpointer0x00 Mar 28, 2024
353004c
gen rewards pb.go with custom signing option
nullpointer0x00 Mar 28, 2024
4f2555b
add gov legacy router
nullpointer0x00 Mar 28, 2024
eb7f00d
update with new cosmos-sdk tag
nullpointer0x00 Mar 28, 2024
2a2cd80
Update all tests to use finalize block, add latest proposal walk
nullpointer0x00 Mar 28, 2024
a3c23e4
fix marker protos and add custom signers
nullpointer0x00 Mar 28, 2024
c672b23
update bank send restriction test with finalize block
nullpointer0x00 Mar 28, 2024
260723c
add custom signers to attribute protos
nullpointer0x00 Mar 28, 2024
a2f1368
remove unneeded begin block since we use SimDeliver instead of Delive…
nullpointer0x00 Apr 1, 2024
83fb165
remove begin block from ibcratelimit test, fix route check, unmarshal…
nullpointer0x00 Apr 1, 2024
276a13a
remove begin block from marker test, fix route check, unmarshal inste…
nullpointer0x00 Apr 1, 2024
25a9206
remove begin block from name test, fix route check, unmarshal instead…
nullpointer0x00 Apr 1, 2024
27c41a5
remove begin block from trigger test, fix route check, unmarshal inst…
nullpointer0x00 Apr 1, 2024
d1c3bb9
remove begin block from reward test, fix route check, unmarshal inste…
nullpointer0x00 Apr 1, 2024
20d7b6c
remove begin block from oracle test, fix route check, unmarshal inste…
nullpointer0x00 Apr 1, 2024
3971604
update weighted operation tests
nullpointer0x00 Apr 1, 2024
12f6323
remove todos
nullpointer0x00 Apr 1, 2024
ed74ecc
proto update
nullpointer0x00 Apr 1, 2024
5e8666b
merge main-v0.50
nullpointer0x00 Apr 1, 2024
78953d6
finish up SimulateFromSeed event-history todo
nullpointer0x00 Apr 1, 2024
2084063
fix reward periods for tests
nullpointer0x00 Apr 2, 2024
8f9bdfe
fix reward vote rules for new event structure
nullpointer0x00 Apr 2, 2024
30b73e5
move sleep in test
nullpointer0x00 Apr 2, 2024
5b91a4a
fix simulate from seed
nullpointer0x00 Apr 2, 2024
953a787
fix assert
nullpointer0x00 Apr 2, 2024
50717c8
remove un need return
nullpointer0x00 Apr 2, 2024
ae9f042
merge main
nullpointer0x00 Apr 2, 2024
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
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 @@ -505,7 +505,7 @@ func New(
app.MsgFeesKeeper = msgfeeskeeper.NewKeeper(
appCodec, keys[msgfeestypes.StoreKey], app.GetSubspace(msgfeestypes.ModuleName),
authtypes.FeeCollectorName, pioconfig.GetProvenanceConfig().FeeDenom,
app.Simulate, encodingConfig.TxConfig.TxDecoder(), interfaceRegistry,
app.SimulateProv, encodingConfig.TxConfig.TxDecoder(), interfaceRegistry,
)

pioMsgFeesRouter := app.MsgServiceRouter().(*piohandlers.PioMsgServiceRouter)
Expand Down Expand Up @@ -729,6 +729,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 @@ -1100,7 +1104,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 @@ -75,15 +76,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))
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved
if withGenesis {
return app, NewDefaultGenesisState(encCdc.Marshaler)
}
Expand Down Expand Up @@ -264,7 +265,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 @@ -275,7 +276,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 @@ -504,7 +505,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 @@ -2,6 +2,7 @@ package handlers_test

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -174,15 +175,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
Loading