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

[feat] Resubmit the operator module #12

Merged
merged 47 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1b5526c
feat(dogfood): implement sdk staking interface
MaxMustermann2 Feb 8, 2024
4949df5
refactor the non-compliant code
TimmyExogenous Dec 20, 2023
20d9e3d
add more info for error log
TimmyExogenous Dec 26, 2023
f6ccc82
add operator module
TimmyExogenous Jan 19, 2024
8683574
update avs_operator_assets_state
TimmyExogenous Jan 22, 2024
abf43f1
add opt-out function
TimmyExogenous Jan 23, 2024
ed545b3
update opt-out function
TimmyExogenous Jan 24, 2024
7b198d9
update slash function
TimmyExogenous Jan 25, 2024
54dfa8a
update slash function
TimmyExogenous Jan 26, 2024
60d64b5
finish slash function
TimmyExogenous Jan 28, 2024
efe31fe
update abci.go in operator module
TimmyExogenous Jan 29, 2024
6de7a1d
finish abci.go in operator module
TimmyExogenous Jan 29, 2024
c35bca7
update abci.go in the delegation module
TimmyExogenous Jan 29, 2024
31d7b7b
solve the problems identified by code review
TimmyExogenous Jan 30, 2024
8ea56b5
fix some bugs of operator module
TimmyExogenous Jan 30, 2024
b2c9d1a
resolve the problems of code style
TimmyExogenous Jan 30, 2024
e824f47
remove the redundant code from the abci.go file in the operator module
TimmyExogenous Jan 31, 2024
57fcb7a
change file name in operator module
TimmyExogenous Jan 31, 2024
5c98ed3
test getting historical operator info
TimmyExogenous Feb 1, 2024
502b370
add ContextForHistoricalState to retrieve historical state
TimmyExogenous Feb 4, 2024
a02457b
fix the testing bug for retrieving histrical operator info
TimmyExogenous Feb 4, 2024
a149345
update for retrieving historical state
TimmyExogenous Feb 4, 2024
f3a6f00
fix test bug for delegation
TimmyExogenous Feb 6, 2024
4364b36
add unit test for operator module
TimmyExogenous Feb 7, 2024
5fbedd0
fix the problems after rebasing to dogfood
TimmyExogenous Feb 23, 2024
7168331
copy the code from operator_consent to integrate with the dogfood mod…
TimmyExogenous Feb 24, 2024
3fd0dbf
correct the dependency in x/operator/keeper/utils_test.go
TimmyExogenous Feb 27, 2024
3da8cba
delete snapshot and refine some code about operator module
TimmyExogenous Feb 27, 2024
3832849
add unit test for slash in operator module
TimmyExogenous Feb 28, 2024
7d8d25b
Test to see if the workflow for checking the PR will be activated.
TimmyExogenous Feb 28, 2024
97df83c
refine the naming about stakerId assetId and clientChainId
TimmyExogenous Feb 29, 2024
9fd1543
change LayerZeroChainId to LayerZeroChainID
TimmyExogenous Mar 6, 2024
d30c84f
change recordId to recordID
TimmyExogenous Mar 6, 2024
7987618
change stakeId to stakeID
TimmyExogenous Mar 6, 2024
bb6b18a
Merge branch 'develop' into copy-app-chain
TimmyExogenous Mar 6, 2024
9952240
fix super lint error
TimmyExogenous Mar 6, 2024
3015943
refine the code related to updating state
TimmyExogenous Mar 11, 2024
16dce4f
redefine change info struct and fix some lint problems
TimmyExogenous Mar 12, 2024
26d7b72
Merge branch 'develop' into copy-app-chain
TimmyExogenous Mar 12, 2024
fa2a36a
mv the function related to setting ExocoreLzAppAddress to assets modu…
TimmyExogenous Mar 12, 2024
032c5eb
fix the proto-lint error
TimmyExogenous Mar 13, 2024
03b5c9e
refine the unconvitional code identified by code review in the procom…
TimmyExogenous Mar 14, 2024
3c08c5e
add code comments for GetAvsSupportedAssets
TimmyExogenous Mar 15, 2024
361d0fa
Merge branch 'develop' into copy-app-chain
TimmyExogenous Mar 15, 2024
ddaf1a2
resolve the missed issues identified by code review, such as adding s…
TimmyExogenous Mar 18, 2024
e8f6c8c
fix the prtobuf lint error
TimmyExogenous Mar 18, 2024
4596ca6
remove the unnecessary code related to operator from the delegation p…
TimmyExogenous Mar 20, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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
20 changes: 16 additions & 4 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 @@ -29,6 +32,7 @@ import (
"github.com/ExocoreNetwork/exocore/x/deposit"
depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper"
depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/types"
operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/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"
Expand Down Expand Up @@ -255,9 +259,10 @@ var (
recovery.AppModuleBasic{},
revenue.AppModuleBasic{},
consensus.AppModuleBasic{},
// exoCore staking modules
// Exocore modules
restaking_assets_manage.AppModuleBasic{},
deposit.AppModuleBasic{},
operator.AppModuleBasic{},
delegation.AppModuleBasic{},
withdraw.AppModuleBasic{},
reward.AppModuleBasic{},
Expand Down Expand Up @@ -352,6 +357,7 @@ type ExocoreApp struct {
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 @@ -435,6 +440,7 @@ func NewExocoreApp(
withdrawTypes.StoreKey,
rewardTypes.StoreKey,
exoslashTypes.StoreKey,
operatorTypes.StoreKey,
)

// Add the EVM transient store key
Expand Down Expand Up @@ -616,8 +622,11 @@ 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.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAVS{}, delegationTypes.VirtualISlashKeeper{})
// 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.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.StakingAssetsManageKeeper, app.DepositKeeper, delegationTypes.VirtualISlashKeeper{}, &app.OperatorKeeper)
app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper)

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)
Expand All @@ -638,7 +647,6 @@ func NewExocoreApp(
app.RewardKeeper,
),
)

epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochskeeper.NewMultiEpochHooks(
Expand Down Expand Up @@ -791,6 +799,7 @@ func NewExocoreApp(
// exoCore app modules
restaking_assets_manage.NewAppModule(appCodec, app.StakingAssetsManageKeeper),
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 @@ -837,6 +846,7 @@ func NewExocoreApp(
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
Expand Down Expand Up @@ -879,6 +889,7 @@ func NewExocoreApp(
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
Expand Down Expand Up @@ -919,6 +930,7 @@ func NewExocoreApp(
// ExoCore modules
stakingAssetsManageTypes.ModuleName,
depositTypes.ModuleName,
operatorTypes.ModuleName,
delegationTypes.ModuleName,
withdrawTypes.ModuleName,
rewardTypes.ModuleName,
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
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ require (
github.com/cosmos/ibc-go/v7 v7.2.1-0.20230829085526-4d114bd09096
github.com/ethereum/go-ethereum v1.11.5
github.com/evmos/evmos/v14 v14.0.0-rc4
github.com/golang/protobuf v1.5.3
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.31.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
Loading