Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Aug 31, 2023
2 parents 47d83e4 + c63b170 commit ab4bc28
Show file tree
Hide file tree
Showing 63 changed files with 11,508 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
* New `GetByAddr` metadata query [#1443](https://github.com/provenance-io/provenance/issues/1443).
* Add Trigger module queries to stargate whitelist for smart contracts [#1636](https://github.com/provenance-io/provenance/issues/1636)
* Added the saffron upgrade handlers [PR 1648](https://github.com/provenance-io/provenance/pull/1648).
* Create the `x/hold` module which facilitates locking funds in an owners account [#1607](https://github.com/provenance-io/provenance/issues/1607).
Funds with a hold on them cannot be transferred until the hold is removed.
Management of holds is internal, but there are queries for looking up holds on accounts.
Holds are also reflected in the `x/bank` module's `SpendableBalances` query.

### Improvements

Expand Down
16 changes: 16 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ import (
attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper"
attributetypes "github.com/provenance-io/provenance/x/attribute/types"
attributewasm "github.com/provenance-io/provenance/x/attribute/wasm"
"github.com/provenance-io/provenance/x/hold"
holdkeeper "github.com/provenance-io/provenance/x/hold/keeper"
holdmodule "github.com/provenance-io/provenance/x/hold/module"
ibchooks "github.com/provenance-io/provenance/x/ibchooks"
ibchookskeeper "github.com/provenance-io/provenance/x/ibchooks/keeper"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
Expand Down Expand Up @@ -214,6 +217,7 @@ var (
msgfeesmodule.AppModuleBasic{},
rewardmodule.AppModuleBasic{},
triggermodule.AppModuleBasic{},
holdmodule.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -301,6 +305,7 @@ type App struct {
MetadataKeeper metadatakeeper.Keeper
AttributeKeeper attributekeeper.Keeper
NameKeeper namekeeper.Keeper
HoldKeeper holdkeeper.Keeper
WasmKeeper *wasm.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper

Expand Down Expand Up @@ -377,6 +382,7 @@ func New(
quarantine.StoreKey,
sanction.StoreKey,
triggertypes.StoreKey,
hold.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -535,6 +541,10 @@ func New(
app.AttributeKeeper, app.NameKeeper, app.TransferKeeper, markerReqAttrBypassAddrs,
)

app.HoldKeeper = holdkeeper.NewKeeper(
appCodec, keys[hold.StoreKey], app.BankKeeper,
)

pioMessageRouter := MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler {
return pioMsgFeesRouter.Handler(msg)
})
Expand Down Expand Up @@ -689,6 +699,7 @@ func New(
wasm.NewAppModule(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper),
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
holdmodule.NewAppModule(appCodec, app.HoldKeeper),

// IBC
ibc.NewAppModule(app.IBCKeeper),
Expand Down Expand Up @@ -735,6 +746,7 @@ func New(
vestingtypes.ModuleName,
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -771,6 +783,7 @@ func New(
paramstypes.ModuleName,
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -801,6 +814,7 @@ func New(
attributetypes.ModuleName,
metadatatypes.ModuleName,
msgfeestypes.ModuleName,
hold.ModuleName,

ibchost.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -838,6 +852,7 @@ func New(
vestingtypes.ModuleName,
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,

ibchookstypes.ModuleName,
icatypes.ModuleName,
Expand Down Expand Up @@ -884,6 +899,7 @@ func New(
msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry),
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper),
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
holdmodule.NewAppModule(appCodec, app.HoldKeeper),
provwasm.NewWrapper(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper),

// IBC
Expand Down
6 changes: 3 additions & 3 deletions app/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), sdksim.FlagPeriodValue, MakeEncodingConfig(), sdksim.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
_, _, simParams, simErr := simulation.SimulateFromSeed(
b,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -88,7 +88,7 @@ func BenchmarkInvariants(b *testing.B) {
app := New(logger, db, nil, true, map[int64]bool{}, b.TempDir(), sdksim.FlagPeriodValue, MakeEncodingConfig(), sdksim.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
_, lastBlockTime, simParams, simErr := simulation.SimulateFromSeed(
b,
os.Stdout,
app.BaseApp,
Expand All @@ -111,7 +111,7 @@ func BenchmarkInvariants(b *testing.B) {

PrintStats(config, db)

ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight() + 1})
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight() + 1, Time: lastBlockTime})

// 3. Benchmark each invariant separately
//
Expand Down
24 changes: 14 additions & 10 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
cmdconfig "github.com/provenance-io/provenance/cmd/provenanced/config"
"github.com/provenance-io/provenance/internal/pioconfig"
attributetypes "github.com/provenance-io/provenance/x/attribute/types"
"github.com/provenance-io/provenance/x/hold"
markertypes "github.com/provenance-io/provenance/x/marker/types"
metadatatypes "github.com/provenance-io/provenance/x/metadata/types"
msgfeetype "github.com/provenance-io/provenance/x/msgfees/types"
Expand Down Expand Up @@ -111,10 +112,10 @@ func TestFullAppSimulation(t *testing.T) {
app := New(logger, db, nil, true, map[int64]bool{}, t.TempDir(), sdksim.FlagPeriodValue, MakeEncodingConfig(), sdksim.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "provenanced", app.Name())

fmt.Printf("running provenance full app simulation")
fmt.Printf("running provenance full app simulation\n")

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
_, _, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -151,7 +152,7 @@ func TestSimple(t *testing.T) {
require.Equal(t, "provenanced", app.Name())

// run randomized simulation
_, _, simErr := simulation.SimulateFromSeed(
_, _, _, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -188,10 +189,10 @@ func TestAppImportExport(t *testing.T) {
home := t.TempDir()
app := New(logger, db, nil, true, map[int64]bool{}, home, sdksim.FlagPeriodValue, MakeEncodingConfig(), sdksim.EmptyAppOptions{}, fauxMerkleModeOpt)

fmt.Printf("running provenance test import export")
fmt.Printf("running provenance test import export\n")

// Run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
_, lastBlockTime, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -242,8 +243,8 @@ func TestAppImportExport(t *testing.T) {
}
}()

ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight(), Time: lastBlockTime})
ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight(), Time: lastBlockTime})
newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)

Expand Down Expand Up @@ -274,6 +275,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[nametypes.StoreKey], newApp.keys[nametypes.StoreKey], [][]byte{}},
{app.keys[metadatatypes.StoreKey], newApp.keys[metadatatypes.StoreKey], [][]byte{}},
{app.keys[triggertypes.StoreKey], newApp.keys[triggertypes.StoreKey], [][]byte{}},
{app.keys[hold.StoreKey], newApp.keys[hold.StoreKey], [][]byte{}},
}

for _, skp := range storeKeysPrefixes {
Expand Down Expand Up @@ -305,7 +307,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
app := New(logger, db, nil, true, map[int64]bool{}, home, sdksim.FlagPeriodValue, MakeEncodingConfig(), sdksim.EmptyAppOptions{}, fauxMerkleModeOpt)

// Run randomized simulation
stopEarly, simParams, simErr := simulation.SimulateFromSeed(
stopEarly, lastBlockTime, simParams, simErr := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
Expand Down Expand Up @@ -348,9 +350,11 @@ func TestAppSimulationAfterImport(t *testing.T) {

newApp.InitChain(abci.RequestInitChain{
AppStateBytes: exported.AppState,
Time: lastBlockTime,
})

_, _, err = simulation.SimulateFromSeed(
sdksim.FlagGenesisTimeValue = lastBlockTime.Unix()
_, _, _, err = simulation.SimulateFromSeed(
t,
os.Stdout,
newApp.BaseApp,
Expand Down Expand Up @@ -419,7 +423,7 @@ func TestAppStateDeterminism(t *testing.T) {
config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
)

_, _, err := simulation.SimulateFromSeed(
_, _, _, err := simulation.SimulateFromSeed(
t,
os.Stdout,
app.BaseApp,
Expand Down
5 changes: 3 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper"
attributetypes "github.com/provenance-io/provenance/x/attribute/types"
"github.com/provenance-io/provenance/x/hold"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types"
triggertypes "github.com/provenance-io/provenance/x/trigger/types"
Expand Down Expand Up @@ -108,7 +109,7 @@ var upgrades = map[string]appUpgrade{

return vm, nil
},
Added: []string{ibchookstypes.ModuleName},
Added: []string{hold.ModuleName, ibchookstypes.ModuleName},
},
"saffron": { // upgrade for v1.17.0
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -125,7 +126,7 @@ var upgrades = map[string]appUpgrade{

return vm, nil
},
Added: []string{ibchookstypes.ModuleName},
Added: []string{hold.ModuleName, ibchookstypes.ModuleName},
},
// TODO - Add new upgrade definitions here.
}
Expand Down
Loading

0 comments on commit ab4bc28

Please sign in to comment.