Skip to content

Commit

Permalink
Merge pull request #12 from ExocoreNetwork/copy-app-chain
Browse files Browse the repository at this point in the history
[feat] Resubmit the operator module
  • Loading branch information
mikebraver authored Mar 21, 2024
2 parents bdb2207 + 4596ca6 commit 658364d
Show file tree
Hide file tree
Showing 184 changed files with 12,038 additions and 4,308 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
uses: cosmos/gosec@master
with:
# we let the report trigger content trigger a failure using the GitHub Security features.
args: "-no-fail -fmt sarif -out results.sarif ./..."
# exclude G705 as it is almost always a false positive, it is removed from gosec master
# but the action has not been updated to reflect the change.
args: "-exclude G705 -no-fail -fmt sarif -out results.sarif ./..."
if: "env.GIT_DIFF_FILTERED != ''"
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
Expand Down
64 changes: 38 additions & 26 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"path/filepath"
"sort"

"github.com/ExocoreNetwork/exocore/x/operator"
operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper"

exoslash "github.com/ExocoreNetwork/exocore/x/slash"

slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper"
Expand All @@ -23,15 +26,16 @@ import (
ethante "github.com/evmos/evmos/v14/app/ante/evm"
"github.com/evmos/evmos/v14/ethereum/eip712"

"github.com/ExocoreNetwork/exocore/x/assets"
assetsKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper"
assetsTypes "github.com/ExocoreNetwork/exocore/x/assets/types"
"github.com/ExocoreNetwork/exocore/x/delegation"
delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper"
delegationTypes "github.com/ExocoreNetwork/exocore/x/delegation/types"
"github.com/ExocoreNetwork/exocore/x/deposit"
depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper"
depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/types"
"github.com/ExocoreNetwork/exocore/x/restaking_assets_manage"
stakingAssetsManageKeeper "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/keeper"
stakingAssetsManageTypes "github.com/ExocoreNetwork/exocore/x/restaking_assets_manage/types"
operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types"
"github.com/ExocoreNetwork/exocore/x/reward"
rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper"
rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types"
Expand Down Expand Up @@ -255,9 +259,10 @@ var (
recovery.AppModuleBasic{},
revenue.AppModuleBasic{},
consensus.AppModuleBasic{},
// exoCore staking modules
restaking_assets_manage.AppModuleBasic{},
// Exocore modules
assets.AppModuleBasic{},
deposit.AppModuleBasic{},
operator.AppModuleBasic{},
delegation.AppModuleBasic{},
withdraw.AppModuleBasic{},
reward.AppModuleBasic{},
Expand Down Expand Up @@ -346,12 +351,13 @@ type ExocoreApp struct {
RecoveryKeeper *recoverykeeper.Keeper
RevenueKeeper revenuekeeper.Keeper

// exocore staking module keepers
StakingAssetsManageKeeper stakingAssetsManageKeeper.Keeper
DepositKeeper depositKeeper.Keeper
DelegationKeeper delegationKeeper.Keeper
WithdrawKeeper withdrawKeeper.Keeper
RewardKeeper rewardKeeper.Keeper
// exocore assets module keepers
AssetsKeeper assetsKeeper.Keeper
DepositKeeper depositKeeper.Keeper
DelegationKeeper delegationKeeper.Keeper
WithdrawKeeper withdrawKeeper.Keeper
RewardKeeper rewardKeeper.Keeper
OperatorKeeper operatorKeeper.Keeper

ExoSlashKeeper slashKeeper.Keeper
// the module manager
Expand Down Expand Up @@ -398,7 +404,6 @@ func NewExocoreApp(
app.SetPrepareProposal(handler.PrepareProposalHandler())
app.SetProcessProposal(handler.ProcessProposalHandler())
})

// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
bApp := baseapp.NewBaseApp(
Name,
Expand Down Expand Up @@ -429,12 +434,13 @@ func NewExocoreApp(
epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey,
revenuetypes.StoreKey, recoverytypes.StoreKey,
// exoCore module keys
stakingAssetsManageTypes.StoreKey,
assetsTypes.StoreKey,
delegationTypes.StoreKey,
depositTypes.StoreKey,
withdrawTypes.StoreKey,
rewardTypes.StoreKey,
exoslashTypes.StoreKey,
operatorTypes.StoreKey,
)

// Add the EVM transient store key
Expand Down Expand Up @@ -614,13 +620,16 @@ func NewExocoreApp(
)

// set exoCore staking keepers
app.StakingAssetsManageKeeper = stakingAssetsManageKeeper.NewKeeper(keys[stakingAssetsManageTypes.StoreKey], appCodec)
app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper)
app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec)
app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper)
app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.AssetsKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAvs{}, delegationTypes.VirtualSlashKeeper{})
// todo: need to replace the virtual keepers with actual keepers after they have been implemented
app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, delegationTypes.VirtualOperatorOptedInKeeper{})
app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.StakingAssetsManageKeeper, app.DepositKeeper)
app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.StakingAssetsManageKeeper)
app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.StakingAssetsManageKeeper)
app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper, delegationTypes.VirtualSlashKeeper{}, &app.OperatorKeeper)
app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper)

app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.AssetsKeeper, app.DepositKeeper)
app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.AssetsKeeper)
app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.AssetsKeeper)
// We call this after setting the hooks to ensure that the hooks are set on the keeper
evmKeeper.WithPrecompiles(
evmkeeper.AvailablePrecompiles(
Expand All @@ -632,13 +641,12 @@ func NewExocoreApp(
app.IBCKeeper.ChannelKeeper,
app.DepositKeeper,
app.DelegationKeeper,
app.StakingAssetsManageKeeper,
app.AssetsKeeper,
app.WithdrawKeeper,
app.ExoSlashKeeper,
app.RewardKeeper,
),
)

epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochskeeper.NewMultiEpochHooks(
Expand Down Expand Up @@ -789,8 +797,9 @@ func NewExocoreApp(
revenue.NewAppModule(app.RevenueKeeper, app.AccountKeeper,
app.GetSubspace(revenuetypes.ModuleName)),
// exoCore app modules
restaking_assets_manage.NewAppModule(appCodec, app.StakingAssetsManageKeeper),
assets.NewAppModule(appCodec, app.AssetsKeeper),
deposit.NewAppModule(appCodec, app.DepositKeeper),
operator.NewAppModule(appCodec, app.OperatorKeeper),
delegation.NewAppModule(appCodec, app.DelegationKeeper),
withdraw.NewAppModule(appCodec, app.WithdrawKeeper),
reward.NewAppModule(appCodec, app.RewardKeeper),
Expand Down Expand Up @@ -835,8 +844,9 @@ func NewExocoreApp(
revenuetypes.ModuleName,
consensusparamtypes.ModuleName,
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
assetsTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
Expand Down Expand Up @@ -877,8 +887,9 @@ func NewExocoreApp(
revenuetypes.ModuleName,
consensusparamtypes.ModuleName,
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
assetsTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
Expand Down Expand Up @@ -917,8 +928,9 @@ func NewExocoreApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
assetsTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
Expand Down Expand Up @@ -1257,7 +1269,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck
return paramsKeeper
}

Expand Down
14 changes: 10 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"time"

pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"

"cosmossdk.io/simapp"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
Expand Down Expand Up @@ -38,7 +40,7 @@ func init() {
}

// DefaultTestingAppInit defines the IBC application used for testing
var DefaultTestingAppInit func(chainID string, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) = SetupTestingApp
var DefaultTestingAppInit func(chainID string, pruneOpts *pruningtypes.PruningOptions, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) = SetupTestingApp

// DefaultConsensusParams defines the default Tendermint consensus params used in
// Evmos testing.
Expand Down Expand Up @@ -95,7 +97,6 @@ func Setup(
} else {
logger = log.NewNopLogger()
}

app := NewExocoreApp(
logger,
db, nil, true, map[int64]bool{},
Expand Down Expand Up @@ -202,21 +203,26 @@ func GenesisStateWithValSet(app *ExocoreApp, genesisState simapp.GenesisState,
// SetupTestingApp initializes the IBC-go testing application
// need to keep this design to comply with the ibctesting SetupTestingApp func
// and be able to set the chainID for the tests properly
func SetupTestingApp(chainID string, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) {
func SetupTestingApp(chainID string, pruneOpts *pruningtypes.PruningOptions, isPrintLog bool) func() (ibctesting.TestingApp, map[string]json.RawMessage) {
return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
db := dbm.NewMemDB()
cfg := encoding.MakeConfig(ModuleBasics)
logger := log.NewNopLogger()
if isPrintLog {
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
}
baseAppOptions := make([]func(*baseapp.BaseApp), 0)
baseAppOptions = append(baseAppOptions, baseapp.SetChainID(chainID))
if pruneOpts != nil {
baseAppOptions = append(baseAppOptions, baseapp.SetPruning(*pruneOpts))
}
app := NewExocoreApp(
logger,
db, nil, true,
map[int64]bool{},
DefaultNodeHome, 5, cfg,
simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome),
baseapp.SetChainID(chainID),
baseAppOptions...,
)
return app, NewDefaultGenesisState(app.appCodec)
}
Expand Down
32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ require (
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.31.1
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
go.opencensus.io v0.24.0
golang.org/x/crypto v0.12.0
golang.org/x/crypto v0.21.0
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e
google.golang.org/grpc v1.57.1
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.3.0
)

Expand All @@ -49,7 +52,7 @@ require (
github.com/rs/cors v1.9.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/zondax/hid v0.9.1 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/net v0.22.0 // indirect
)

require (
Expand Down Expand Up @@ -105,7 +108,7 @@ require (
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/go-stack/stack v1.8.1 // indirect
Expand All @@ -116,11 +119,11 @@ require (
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
Expand All @@ -144,7 +147,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.7.16 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down Expand Up @@ -191,20 +194,17 @@ require (
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/tools v0.10.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230815205213-6bfd019c3878 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
pgregory.net/rapid v0.5.5 // indirect
Expand Down
Loading

0 comments on commit 658364d

Please sign in to comment.