forked from omni-network/omni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_config.go
211 lines (195 loc) · 6.89 KB
/
app_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package app
import (
attestmodule "github.com/omni-network/omni/halo/attest/module"
attesttypes "github.com/omni-network/omni/halo/attest/types"
"github.com/omni-network/omni/halo/evmstaking"
portalmodule "github.com/omni-network/omni/halo/portal/module"
portaltypes "github.com/omni-network/omni/halo/portal/types"
registrymodule "github.com/omni-network/omni/halo/registry/module"
registrytypes "github.com/omni-network/omni/halo/registry/types"
valsyncmodule "github.com/omni-network/omni/halo/valsync/module"
valsynctypes "github.com/omni-network/omni/halo/valsync/types"
engevmmodule "github.com/omni-network/omni/octane/evmengine/module"
engevmtypes "github.com/omni-network/omni/octane/evmengine/types"
"github.com/ethereum/go-ethereum/params"
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// Bech32HRP is the human-readable-part of the Bech32 address format.
const (
Bech32HRP = "omni"
// TODO(corver): Maybe move these to genesis itself.
genesisVoteWindow = 64
genesisVoteExtLimit = 256
genesisTrimLag = 72_000 // Delete attestations state after +-1 day (given a period of 1.2s).
defaultPruningKeep = 72_000 // Keep 1 day's of application state by default (given period of 1.2s).
defaultPruningInterval = 300 // Prune every 5 minutes or so.
)
// init initializes the Cosmos SDK configuration.
//
//nolint:gochecknoinits // Cosmos-style
func init() {
// Set prefixes
accountPubKeyPrefix := Bech32HRP + "pub"
validatorAddressPrefix := Bech32HRP + "valoper"
validatorPubKeyPrefix := Bech32HRP + "valoperpub"
consNodeAddressPrefix := Bech32HRP + "valcons"
consNodePubKeyPrefix := Bech32HRP + "valconspub"
// Set and seal config
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(Bech32HRP, accountPubKeyPrefix)
cfg.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
cfg.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
cfg.Seal()
// Override default power reduction: 1 ether (1e18) $STAKE == 1 power.
sdk.DefaultPowerReduction = sdkmath.NewInt(params.Ether)
}
// DepConfig returns the default app depinject config.
func DepConfig() depinject.Config {
return depinject.Configs(
appConfig,
depinject.Supply(),
)
}
//nolint:gochecknoglobals // Cosmos-style
var (
genesisModuleOrder = []string{
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
genutiltypes.ModuleName,
valsynctypes.ModuleName,
engevmtypes.ModuleName,
}
beginBlockers = []string{
distrtypes.ModuleName, // Note: slashing happens after distr.BeginBlocker
slashingtypes.ModuleName,
stakingtypes.ModuleName, // Note: staking module is required if HistoricalEntries param > 0
attesttypes.ModuleName,
}
endBlockers = []string{
attesttypes.ModuleName,
valsynctypes.ModuleName, // Wraps staking module end blocker (must come after attest module)
}
// blocked account addresses.
blockAccAddrs = []string{
authtypes.FeeCollectorName,
distrtypes.ModuleName,
stakingtypes.BondedPoolName,
stakingtypes.NotBondedPoolName,
evmstaking.ModuleName,
}
moduleAccPerms = []*authmodulev1.ModuleAccountPermission{
{Account: authtypes.FeeCollectorName},
{Account: distrtypes.ModuleName},
{Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: evmstaking.ModuleName, Permissions: []string{authtypes.Burner, authtypes.Minter}},
}
// appConfig application configuration (used by depinject).
appConfig = appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Name: runtime.ModuleName,
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
AppName: Name,
BeginBlockers: beginBlockers,
// Setting endblockers in newApp since valsync replaces staking endblocker.
InitGenesis: genesisModuleOrder,
OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{
{
ModuleName: authtypes.ModuleName,
KvStoreKey: "acc",
},
},
}),
},
{
Name: authtypes.ModuleName,
Config: appconfig.WrapAny(&authmodulev1.Module{
ModuleAccountPermissions: moduleAccPerms,
Bech32Prefix: Bech32HRP,
}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txconfigv1.Config{
SkipAnteHandler: true, // Disable ante handler (since we don't have proper txs).
SkipPostHandler: true,
}),
},
{
Name: banktypes.ModuleName,
Config: appconfig.WrapAny(&bankmodulev1.Module{
BlockedModuleAccountsOverride: blockAccAddrs,
}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
},
{
Name: genutiltypes.ModuleName,
Config: appconfig.WrapAny(&genutilmodulev1.Module{}),
},
{
Name: stakingtypes.ModuleName,
Config: appconfig.WrapAny(&stakingmodulev1.Module{}),
},
{
Name: slashingtypes.ModuleName,
Config: appconfig.WrapAny(&slashingmodulev1.Module{}),
},
{
Name: engevmtypes.ModuleName,
Config: appconfig.WrapAny(&engevmmodule.Module{}),
},
{
Name: attesttypes.ModuleName,
Config: appconfig.WrapAny(&attestmodule.Module{
VoteWindow: genesisVoteWindow,
VoteExtensionLimit: genesisVoteExtLimit,
TrimLag: genesisTrimLag,
}),
},
{
Name: valsynctypes.ModuleName,
Config: appconfig.WrapAny(&valsyncmodule.Module{}),
},
{
Name: portaltypes.ModuleName,
Config: appconfig.WrapAny(&portalmodule.Module{}),
},
{
Name: registrytypes.ModuleName,
Config: appconfig.WrapAny(®istrymodule.Module{}),
},
},
})
)