Skip to content

Commit

Permalink
Merge pull request #28 from terpnetwork/hard-nett/v0.4.0
Browse files Browse the repository at this point in the history
Hard nett/v0.4.0
  • Loading branch information
discoverdefiteam authored Feb 19, 2023
2 parents 2b8926a + cc8513a commit 8ef7c32
Show file tree
Hide file tree
Showing 82 changed files with 12,400 additions and 995 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/proto-buf-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: bufbuild/buf-setup-action@v1.9.0
- uses: bufbuild/buf-setup-action@v1.13.1

# lint checks
- uses: bufbuild/buf-lint-action@v1
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Upgrade to WasmVM v1.2.0
- Upgrade to cosmos-proto v1.0.0-beta.1
- Upgrade to spf13/cobra v1.6.1
- Upgrade to Tendermint v0.34.24
- Upgrade to go-metrics v0.4.1
- Upgrade to ics23 v0.9.0
- Upgrade to btcutil v1.0.5
- Upgrade to ledger-go v0.9.3
- Upgrade to go-humanize v1.0.1-0.20200219035652-afde56e7acac
- x/terp module for supplychainid & supplychain db core concepts
- Provide full x/upgrade features

## [v0.2.0](https://github.com/terpnetwork/terp-core/tree/v0.2.0) (2022-12-12)

Expand Down
9 changes: 8 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ License: Apache2.0
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2016 All in Bits, Inc


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -201,3 +201,10 @@ License: Apache2.0
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This project uses code from the following Apache-licensed projects:

- wasmd: https://github.com/CosmWasm/wasmd
- bcna: https://github.com/BitCannaGlobal/bcna

The Apache License, Version 2.0 applies to these components of the codebase.
52 changes: 49 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,26 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

store "github.com/cosmos/cosmos-sdk/store/types"
wasmappparams "github.com/terpnetwork/terp-core/app/params"
"github.com/terpnetwork/terp-core/x/wasm"
wasmclient "github.com/terpnetwork/terp-core/x/wasm/client"
wasmkeeper "github.com/terpnetwork/terp-core/x/wasm/keeper"

//BCNA Module

terpmodule "github.com/terpnetwork/terp-core/x/terp"
terpmodulekeeper "github.com/terpnetwork/terp-core/x/terp/keeper"
terpmoduletypes "github.com/terpnetwork/terp-core/x/terp/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

const appName = "TerpApp"
const (
appName = "TerpApp"
v040UpgradeName = "v040"
)

// We pull these out so we can set them with LDFLAGS in the Makefile
var (
Expand All @@ -129,7 +139,7 @@ var (

// If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals.
// If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals.
ProposalsEnabled = "false"
ProposalsEnabled = "true"
// If set to non-empty string it must be comma-separated list of values that are all a subset
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
Expand Down Expand Up @@ -208,6 +218,7 @@ var (
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
wasm.AppModuleBasic{},
terpmodule.AppModuleBasic{},
ica.AppModuleBasic{},
intertx.AppModuleBasic{},
ibcfee.AppModuleBasic{},
Expand Down Expand Up @@ -269,6 +280,7 @@ type TerpApp struct {
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
WasmKeeper wasm.Keeper
TerpKeeper terpmodulekeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -314,7 +326,7 @@ func NewTerpApp(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, terpmoduletypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, intertxtypes.StoreKey, ibcfeetypes.StoreKey,
)
Expand Down Expand Up @@ -511,6 +523,14 @@ func NewTerpApp(
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}

app.TerpKeeper = *terpmodulekeeper.NewKeeper(
appCodec,
keys[terpmoduletypes.StoreKey],
keys[terpmoduletypes.MemStoreKey],
app.getSubspace(terpmoduletypes.ModuleName),
)
terpModule := terpmodule.NewAppModule(appCodec, app.TerpKeeper, app.AccountKeeper, app.BankKeeper)

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1"
Expand Down Expand Up @@ -620,6 +640,7 @@ func NewTerpApp(
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
intertx.NewAppModule(appCodec, app.InterTxKeeper),
terpModule,
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
)

Expand Down Expand Up @@ -651,6 +672,7 @@ func NewTerpApp(
ibcfeetypes.ModuleName,
intertxtypes.ModuleName,
wasm.ModuleName,
terpmoduletypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand All @@ -677,6 +699,7 @@ func NewTerpApp(
ibcfeetypes.ModuleName,
intertxtypes.ModuleName,
wasm.ModuleName,
terpmoduletypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -711,6 +734,7 @@ func NewTerpApp(
intertxtypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
terpmoduletypes.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
Expand All @@ -724,6 +748,7 @@ func NewTerpApp(

// create the simulation manager and define the order of the modules for deterministic simulations
//
app.RegisterUpgradeHandlers(app.configurator)
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
app.sm = module.NewSimulationManager(
Expand All @@ -742,6 +767,7 @@ func NewTerpApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
ibc.NewAppModule(app.IBCKeeper),
transfer.NewAppModule(app.TransferKeeper),
terpModule,
)

app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -785,6 +811,17 @@ func NewTerpApp(
}
}

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == v040UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedWasmKeeper = scopedWasmKeeper
Expand Down Expand Up @@ -948,9 +985,18 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(terpmoduletypes.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(wasm.ModuleName)

return paramsKeeper
}

// RegisterUpgradeHandlers returns upgrade handlers
func (app *TerpApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(v040UpgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

return app.mm.RunMigrations(ctx, cfg, vm)
})
}
2 changes: 1 addition & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (app *TerpApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
counter := int16(0)

for ; iter.Valid(); iter.Next() {
addr := sdk.ValAddress(iter.Key()[1:])
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
if !found {
panic("expected validator, not found")
Expand Down
26 changes: 26 additions & 0 deletions app/params/bech32.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package params

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

// AccountAddressPrefix defines the Paloma network's Bech32 address prefix.
const AccountAddressPrefix = "terp"

// Account specific Bech32 prefixes.
var (
AccountPubKeyPrefix = AccountAddressPrefix + "pub"
ValidatorAddressPrefix = AccountAddressPrefix + "valoper"
ValidatorPubKeyPrefix = AccountAddressPrefix + "valoperpub"
ConsNodeAddressPrefix = AccountAddressPrefix + "valcons"
ConsNodePubKeyPrefix = AccountAddressPrefix + "valconspub"
)

// SetAddressConfig sets Paloma's address configuration.
func SetAddressConfig() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix)
config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix)
config.Seal()
}
37 changes: 37 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* package upgrades
import (
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/terpnetwork/terp-core/app/keepers"
)
// BaseAppParamManager defines an interrace that BaseApp is expected to fullfil
// that allows upgrade handlers to modify BaseApp parameters.
type BaseAppParamManager interface {
GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams
StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusParams)
}
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
// must have written, in order for the state migration to go smoothly.
// An upgrade must implement this struct, and then set it in the app.go.
// The app.go will then define the handler.
type Upgrade struct {
// Upgrade version name, for the upgrade handler, e.g. `v7`
UpgradeName string
// CreateUpgradeHandler defines the function that creates an upgrade handler
CreateUpgradeHandler func(
*module.Manager,
module.Configurator,
*keepers.AppKeepers,
) upgradetypes.UpgradeHandler
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed.
StoreUpgrades store.StoreUpgrades
}
*/
18 changes: 18 additions & 0 deletions app/upgrades/v040/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*package v1
import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/terpnetwork/terp-core/app/upgrades"
)
// UpgradeName defines the on-chain upgrade name for the Terp Network v1 upgrade.
const UpgradeName = "v1" // maybe ?
var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV1UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{TBD.StoreKey, TBD.StoreKey},
},
}
*/
22 changes: 22 additions & 0 deletions app/upgrades/v040/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*package v1
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/terpnetwork/terp-core/app/keepers"
)
// CreateV10UpgradeHandler makes an upgrade handler for v10 of Juno
func CreateV1UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// mint module consensus version bumped
return mm.RunMigrations(ctx, cfg, vm)
}
}
*/
2 changes: 1 addition & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package docs
import "embed"

//go:embed static
var Docs embed.FS
var Docs embed.FS
Loading

0 comments on commit 8ef7c32

Please sign in to comment.