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

smaller app.go #1009

Merged
merged 5 commits into from
Mar 3, 2022
Merged
Changes from all commits
Commits
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
141 changes: 18 additions & 123 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -50,13 +50,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

// Authz: Authorization for accounts to perform actions on behalf of other accounts.
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"

// Bank: allows users to transfer tokens
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

// Capability: allows developers to atomically define what a module can and cannot do
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
@@ -66,29 +59,15 @@ import (

// Evidence handling for double signing, misbehaviour, etc.
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"

// Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

// Params: Parameters that are always available
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

// Slashing:
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"

// Staking: Allows the Tendermint validator set to be chosen based on bonded stake.
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

// Upgrade: Software upgrades handling and coordination.
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

// IBC Transfer: Defines the "transfer" IBC port
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"

// IBC: Inter-blockchain communication
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"

// Osmosis application prarmeters
appparams "github.com/osmosis-labs/osmosis/v7/app/params"
@@ -99,38 +78,11 @@ import (
v7 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v7"
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"

// Modules that live in the Osmosis repository and are specific to Osmosis
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"

// Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"

// Generalized Automated Market Maker
gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types"

// Incentives: Allows Osmosis and foriegn chain communities to incentivize users to provide liquidity
incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types"

// Lockup: allows tokens to be locked (made non-transferrable)
lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types"

// Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint
minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types"

// Pool incentives:
poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"

// Superfluid: Allows users to stake gamm (bonded liquidity)
superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types"

// Txfees: Allows Osmosis to charge transaction fees without harming IBC user experience
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"

// Wasm: Allows Osmosis to interact with web assembly smart contracts
"github.com/CosmWasm/wasmd/x/wasm"

// Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
)

const appName = "OsmosisApp"
@@ -226,9 +178,17 @@ func init() {

// NewOsmosis returns a reference to an initialized Osmosis.
func NewOsmosisApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmEnabledProposals []wasm.ProposalType, wasmOpts []wasm.Option,
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig appparams.EncodingConfig,
appOpts servertypes.AppOptions,
wasmEnabledProposals []wasm.ProposalType,
wasmOpts []wasm.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *OsmosisApp {

@@ -243,32 +203,9 @@ func NewOsmosisApp(

// Define what keys will be used in the cosmos-sdk key/value store.
// Cosmos-SDK modules each have a "key" that allows the application to reference what they've stored on the chain.
keys := sdk.NewKVStoreKeys(
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,
gammtypes.StoreKey,
lockuptypes.StoreKey,
claimtypes.StoreKey,
incentivestypes.StoreKey,
epochstypes.StoreKey,
poolincentivestypes.StoreKey,
authzkeeper.StoreKey,
txfeestypes.StoreKey,
superfluidtypes.StoreKey,
bech32ibctypes.StoreKey,
wasm.StoreKey,
)
// Keys are in keys.go to kep app.go as brief as possible.
keys := sdk.NewKVStoreKeys(KVStoreKeys()...)

// Define transient store keys
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)

@@ -364,8 +301,10 @@ func NewOsmosisApp(
appOpts,
wasmConfig,
keys[wasm.StoreKey],
app.AccountKeeper, app.BankKeeper,
app.TxFeesKeeper, app.GAMMKeeper,
app.AccountKeeper,
app.BankKeeper,
app.TxFeesKeeper,
app.GAMMKeeper,
ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
app.IBCKeeper.ChannelKeeper,
@@ -428,50 +367,6 @@ func (app *OsmosisApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
}

// BlockedAddrs returns all the app's module account addresses that are not
// allowed to receive external tokens.
func (app *OsmosisApp) BlockedAddrs() map[string]bool {
blockedAddrs := make(map[string]bool)
for acc := range maccPerms {
blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
}

// We block all OFAC-blocked ETH addresses from receiving tokens as well
// The list is sourced from: https://www.treasury.gov/ofac/downloads/sanctions/1.0/sdn_advanced.xml
ofacRawEthAddrs := []string{
"0x7F367cC41522cE07553e823bf3be79A889DEbe1B",
"0xd882cfc20f52f2599d84b8e8d58c7fb62cfe344b",
"0x901bb9583b24d97e995513c6778dc6888ab6870e",
"0xa7e5d5a720f06526557c513402f2e6b5fa20b008",
"0x8576acc5c05d6ce88f4e49bf65bdf0c62f91353c",
"0x1da5821544e25c636c1417ba96ade4cf6d2f9b5a",
"0x7Db418b5D567A4e0E8c59Ad71BE1FcE48f3E6107",
"0x72a5843cc08275C8171E582972Aa4fDa8C397B2A",
"0x7F19720A857F834887FC9A7bC0a0fBe7Fc7f8102",
"0x9f4cda013e354b8fc285bf4b9a60460cee7f7ea9",
"0x3cbded43efdaf0fc77b9c55f6fc9988fcc9b757d",
"0x2f389ce8bd8ff92de3402ffce4691d17fc4f6535",
"0x19aa5fe80d33a56d56c78e82ea5e50e5d80b4dff",
"0xe7aa314c77f4233c18c6cc84384a9247c0cf367b",
"0x308ed4b7b49797e1a98d3818bff6fe5385410370",
"0x2f389ce8bd8ff92de3402ffce4691d17fc4f6535",
"0x19aa5fe80d33a56d56c78e82ea5e50e5d80b4dff",
"0x67d40EE1A85bf4a4Bb7Ffae16De985e8427B6b45",
"0x6f1ca141a28907f78ebaa64fb83a9088b02a8352",
"0x6acdfba02d390b97ac2b2d42a63e85293bcc160e",
"0x48549a34ae37b12f6a30566245176994e17c6b4a",
"0x5512d943ed1f7c8a43f3435c85f7ab68b30121b0",
"0xc455f7fd3e0e12afd51fba5c106909934d8a0e4a",
"0xfec8a60023265364d066a1212fde3930f6ae8da7",
}
for _, addr := range ofacRawEthAddrs {
blockedAddrs[addr] = true
blockedAddrs[strings.ToLower(addr)] = true
}

return blockedAddrs
}

// LegacyAmino returns SimApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
51 changes: 51 additions & 0 deletions app/blocked.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package app

import (
"strings"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// BlockedAddrs returns all the app's module account addresses that are not
// allowed to receive external tokens.
func (app *OsmosisApp) BlockedAddrs() map[string]bool {
blockedAddrs := make(map[string]bool)
for acc := range maccPerms {
blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
}

// We block all OFAC-blocked ETH addresses from receiving tokens as well
// The list is sourced from: https://www.treasury.gov/ofac/downloads/sanctions/1.0/sdn_advanced.xml
ofacRawEthAddrs := []string{
"0x7F367cC41522cE07553e823bf3be79A889DEbe1B",
"0xd882cfc20f52f2599d84b8e8d58c7fb62cfe344b",
"0x901bb9583b24d97e995513c6778dc6888ab6870e",
"0xa7e5d5a720f06526557c513402f2e6b5fa20b008",
"0x8576acc5c05d6ce88f4e49bf65bdf0c62f91353c",
"0x1da5821544e25c636c1417ba96ade4cf6d2f9b5a",
"0x7Db418b5D567A4e0E8c59Ad71BE1FcE48f3E6107",
"0x72a5843cc08275C8171E582972Aa4fDa8C397B2A",
"0x7F19720A857F834887FC9A7bC0a0fBe7Fc7f8102",
"0x9f4cda013e354b8fc285bf4b9a60460cee7f7ea9",
"03cbded43efdaf0fc77b9c55f6fc9988fcc9b757d",
"0x2f389ce8bd8ff92de3402ffce4691d17fc4f6535",
"0x19aa5fe80d33a56d56c78e82ea5e50e5d80b4dff",
"0xe7aa314c77f4233c18c6cc84384a9247c0cf367b",
"0x308ed4b7b49797e1a98d3818bff6fe5385410370",
"0x2f389ce8bd8ff92de3402ffce4691d17fc4f6535",
"0x19aa5fe80d33a56d56c78e82ea5e50e5d80b4dff",
"0x67d40EE1A85bf4a4Bb7Ffae16De985e8427B6b45",
"0x6f1ca141a28907f78ebaa64fb83a9088b02a8352",
"0x6acdfba02d390b97ac2b2d42a63e85293bcc160e",
"0x48549a34ae37b12f6a30566245176994e17c6b4a",
"0x5512d943ed1f7c8a43f3435c85f7ab68b30121b0",
"0xc455f7fd3e0e12afd51fba5c106909934d8a0e4a",
"0xfec8a60023265364d066a1212fde3930f6ae8da7",
}
for _, addr := range ofacRawEthAddrs {
blockedAddrs[addr] = true
blockedAddrs[strings.ToLower(addr)] = true
}

return blockedAddrs
}
29 changes: 29 additions & 0 deletions app/keepers.go
Original file line number Diff line number Diff line change
@@ -501,3 +501,32 @@ func (app *OsmosisApp) initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino

return paramsKeeper
}

func KVStoreKeys() []string {
return []string{
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,
gammtypes.StoreKey,
lockuptypes.StoreKey,
claimtypes.StoreKey,
incentivestypes.StoreKey,
epochstypes.StoreKey,
poolincentivestypes.StoreKey,
authzkeeper.StoreKey,
txfeestypes.StoreKey,
superfluidtypes.StoreKey,
bech32ibctypes.StoreKey,
wasm.StoreKey,
}
}