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:add active field for validator #278

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ func NewExocoreApp(
&app.DelegationKeeper, // intentionally a pointer, since not yet initialized.
&app.OracleKeeper,
&app.AVSManagerKeeper,
&app.StakingKeeper,
delegationTypes.VirtualSlashKeeper{},
)
// the fee distribution keeper is used to allocate reward to exocore validators on epoch-basis,
Expand Down
2 changes: 2 additions & 0 deletions proto/exocore/operator/v1/validator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ message Validator {
];
// delegator_tokens is the list of asset infos
repeated DelegatorInfo delegator_tokens = 11 [(gogoproto.nullable) = false];
// active defines whether the validator exists in the Tendermint validator set
bool active = 12;
}

// DelegatorInfo records the total opted-in USD value for the specified operator
Expand Down
8 changes: 8 additions & 0 deletions x/dogfood/keeper/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ func (k Keeper) GetExocoreValidator(
return
}

// IsExocoreValidator gets a validator based on the pub key derived (consensus) address.
func (k Keeper) IsExocoreValidator(
ctx sdk.Context, addr sdk.ConsAddress,
) bool {
store := ctx.KVStore(k.storeKey)
return store.Has(types.ExocoreValidatorKey(addr.Bytes()))
}

// DeleteExocoreValidator deletes a validator based on the pub key derived address.
func (k Keeper) DeleteExocoreValidator(ctx sdk.Context, addr sdk.ConsAddress) {
store := ctx.KVStore(k.storeKey)
Expand Down
8 changes: 3 additions & 5 deletions x/operator/keeper/consensus_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import (
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types"
delegationkeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper"
oracletype "github.com/ExocoreNetwork/exocore/x/oracle/types"

assetstypes "github.com/ExocoreNetwork/exocore/x/assets/types"

"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/store/prefix"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/cometbft/cometbft/libs/log"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

Expand Down Expand Up @@ -610,6 +607,7 @@ func (k Keeper) GetValidatorByConsAddrForChainID(
ctx.Logger().Error(" new validator error", "err", err)
return types.Validator{}, false
}
val.Active = k.stakingKeeper.IsExocoreValidator(ctx, wrappedKey.ToConsAddr())
val.OperatorEarningsAddr = ops.EarningsAddr
val.OperatorApproveAddr = ops.ApproveAddr
val.OperatorMetaInfo = ops.OperatorMetaInfo
Expand Down
8 changes: 5 additions & 3 deletions x/operator/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type Keeper struct {
delegationKeeper operatortypes.DelegationKeeper
oracleKeeper operatortypes.OracleKeeper
avsKeeper operatortypes.AVSKeeper

hooks operatortypes.OperatorHooks // set separately via call to SetHooks
slashKeeper operatortypes.SlashKeeper // for jailing and unjailing check TODO(mm)
stakingKeeper operatortypes.StakingKeeper
hooks operatortypes.OperatorHooks // set separately via call to SetHooks
slashKeeper operatortypes.SlashKeeper // for jailing and unjailing check TODO(mm)
}

func NewKeeper(
Expand All @@ -32,6 +32,7 @@ func NewKeeper(
delegationKeeper operatortypes.DelegationKeeper,
oracleKeeper operatortypes.OracleKeeper,
avsKeeper operatortypes.AVSKeeper,
stakingKeeper operatortypes.StakingKeeper,
slashKeeper operatortypes.SlashKeeper,
) Keeper {
return Keeper{
Expand All @@ -41,6 +42,7 @@ func NewKeeper(
delegationKeeper: delegationKeeper,
oracleKeeper: oracleKeeper,
avsKeeper: avsKeeper,
stakingKeeper: stakingKeeper,
slashKeeper: slashKeeper,
}
}
Expand Down
3 changes: 3 additions & 0 deletions x/operator/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@ type OperatorHooks interface {
ctx sdk.Context, addr sdk.AccAddress, affectedAVSList []string,
)
}
type StakingKeeper interface {
IsExocoreValidator(ctx sdk.Context, addr sdk.ConsAddress) bool
}
135 changes: 85 additions & 50 deletions x/operator/types/validator.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading