Skip to content

Commit

Permalink
rebase and fix the issues from code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmyExogenous committed Nov 11, 2024
1 parent 35ad190 commit 784e834
Show file tree
Hide file tree
Showing 10 changed files with 1,371 additions and 168 deletions.
7 changes: 0 additions & 7 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"bytes"
"encoding/binary"
"sort"
"strings"

Expand Down Expand Up @@ -211,9 +210,3 @@ func SortByPower(
}
return sortedOperatorAddrs, sortedPubKeys, sortedPowers
}

func EncodeHeightBytes(height uint64) []byte {
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, height)
return buf
}
6 changes: 2 additions & 4 deletions x/avs/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,8 @@ func (k Keeper) GetAVSEpochInfo(ctx sdk.Context, addr string) (*epochstypes.Epoc
return nil, err
}
avsInfo := avsInfoResp.Info
epochInfo, found := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier)
if !found {
return nil, types.ErrEpochNotFound.Wrapf("epoch info not found %s", avsInfo.EpochIdentifier)
}
// Epoch information must be present because it is checked when setting AVS information.
epochInfo, _ := k.epochsKeeper.GetEpochInfo(ctx, avsInfo.EpochIdentifier)
return &epochInfo, nil
}

Expand Down
3 changes: 1 addition & 2 deletions x/avs/keeper/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper_test
import (
"strconv"

sdkmath "cosmossdk.io/math"
types "github.com/ExocoreNetwork/exocore/x/avs/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -18,7 +17,7 @@ func (suite *AVSTestSuite) TestTaskInfo() {
TaskResponsePeriod: 10000,
TaskChallengePeriod: 5000,
ThresholdPercentage: 60,
TaskTotalPower: sdk.Dec(sdkmath.ZeroInt()),
TaskTotalPower: sdk.ZeroDec(),
}
err := suite.App.AVSManagerKeeper.SetTaskInfo(suite.Ctx, info)
suite.NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions x/dogfood/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (k Keeper) Hooks() types.DogfoodHooks {
return types.MultiDogfoodHooks{}
}

// MarkUpdateValidatorSetFlag marks the end of the epoch. It is called within the BeginBlocker to inform
// the module to apply the validator updates at the end of this block.
// MarkUpdateValidatorSetFlag marks that the validator set needs to be updated at the end of this block.
// Mostly, these updates occur in response to the epoch ending. In other cases, they are the result of slashing.
func (k Keeper) MarkUpdateValidatorSetFlag(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
key := types.ShouldUpdateValidatorSetByteKey()
Expand Down
1 change: 0 additions & 1 deletion x/operator/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
assetstype "github.com/ExocoreNetwork/exocore/x/assets/types"

keytypes "github.com/ExocoreNetwork/exocore/types/keys"
assetstype "github.com/ExocoreNetwork/exocore/x/assets/types"
avstypes "github.com/ExocoreNetwork/exocore/x/avs/types"
"github.com/ExocoreNetwork/exocore/x/operator/types"
tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
Expand Down
2 changes: 1 addition & 1 deletion x/operator/keeper/usd_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (k *Keeper) CalculateUSDValueForStaker(ctx sdk.Context, stakerID, avsAddr s
return sdkmath.LegacyDec{}, err
}
if optedUSDValues.ActiveUSDValue.IsZero() {
return sdkmath.LegacyZeroDec(), err
return sdkmath.LegacyZeroDec(), nil
}

// calculate the active voting power for staker
Expand Down
4 changes: 1 addition & 3 deletions x/operator/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/binary"
"math"

"github.com/ExocoreNetwork/exocore/utils"

"golang.org/x/xerrors"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -165,7 +163,7 @@ func KeyForVotingPowerSnapshot(avs common.Address, height int64) []byte {
return AppendMany(
avs.Bytes(),
// Append the height
utils.EncodeHeightBytes(uint64(height)),
sdk.Uint64ToBigEndian(uint64(height)),
)
}

Expand Down
Loading

0 comments on commit 784e834

Please sign in to comment.