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

Fix ctx block height #444

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ func (app *BabylonApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx)

// set context height to zero
height := ctx.HeaderInfo().Height
height := ctx.BlockHeight()
headerInfo := ctx.HeaderInfo()
headerInfo.Height = 0
ctx = ctx.WithHeaderInfo(headerInfo)
ctx = ctx.WithHeaderInfo(headerInfo).WithBlockHeight(0)

// reinitialize all validators
err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (app *BabylonApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
// reset context height
headerInfo = ctx.HeaderInfo()
headerInfo.Height = height
ctx = ctx.WithHeaderInfo(headerInfo)
ctx = ctx.WithHeaderInfo(headerInfo).WithBlockHeight(height)

/* Handle staking state. */

Expand Down
2 changes: 1 addition & 1 deletion testutil/datagen/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ func HeaderToHeaderInfo(header *ibctmtypes.Header) *zctypes.HeaderInfo {
func WithCtxHeight(ctx sdk.Context, height uint64) sdk.Context {
headerInfo := ctx.HeaderInfo()
headerInfo.Height = int64(height)
ctx = ctx.WithHeaderInfo(headerInfo)
ctx = ctx.WithHeaderInfo(headerInfo).WithBlockHeader(cmtproto.Header{Height: int64(height)})
return ctx
}
4 changes: 2 additions & 2 deletions x/btcstaking/keeper/btc_height_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// IndexBTCHeight indexes the current BTC height, and saves it to KVStore
func (k Keeper) IndexBTCHeight(ctx context.Context) {
babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
btcTip := k.btclcKeeper.GetTipInfo(ctx)
if btcTip == nil {
return
Expand All @@ -31,7 +31,7 @@ func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight u
}

func (k Keeper) GetCurrentBTCHeight(ctx context.Context) (uint64, error) {
babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
return k.GetBTCHeightAtBabylonHeight(ctx, babylonHeight)
}

Expand Down
2 changes: 1 addition & 1 deletion x/btcstaking/keeper/finality_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (k Keeper) SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error
if fp.IsSlashed() {
return types.ErrFpAlreadySlashed
}
fp.SlashedBabylonHeight = uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
fp.SlashedBabylonHeight = uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
btcTip := k.btclcKeeper.GetTipInfo(ctx)
if btcTip == nil {
panic(fmt.Errorf("failed to get current BTC tip"))
Expand Down
2 changes: 1 addition & 1 deletion x/btcstaking/keeper/incentive.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (k Keeper) RecordRewardDistCache(ctx context.Context) {
}

// all good, set the reward distribution cache of the current height
k.setRewardDistCache(ctx, uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height), rdc)
k.setRewardDistCache(ctx, uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), rdc)
}

func (k Keeper) setRewardDistCache(ctx context.Context, height uint64, rdc *types.RewardDistCache) {
Expand Down
2 changes: 1 addition & 1 deletion x/btcstaking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Helper struct {

func NewHelper(t testing.TB, btclcKeeper *types.MockBTCLightClientKeeper, btccKeeper *types.MockBtcCheckpointKeeper) *Helper {
k, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper)
ctx = ctx.WithHeaderInfo(header.Info{Height: 1})
ctx = ctx.WithHeaderInfo(header.Info{Height: 1}).WithBlockHeight(1)
msgSrvr := keeper.NewMsgServerImpl(*k)

return &Helper{
Expand Down
2 changes: 1 addition & 1 deletion x/btcstaking/keeper/voting_power_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func (k Keeper) RecordVotingPowerTable(ctx context.Context) {
covenantQuorum := k.GetParams(ctx).CovenantQuorum
// tip of Babylon and Bitcoin
babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
btcTipHeight, err := k.GetCurrentBTCHeight(ctx)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion x/checkpointing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func makeBtcCkptBytes(r *rand.Rand, epoch uint64, appHash []byte, bitmap []byte,
}

func curStateUpdate(ctx sdk.Context, status types.CheckpointStatus) *types.CheckpointStateUpdate {
height, time := ctx.HeaderInfo().Height, ctx.HeaderInfo().Time
height, time := ctx.BlockHeight(), ctx.BlockTime()
return &types.CheckpointStateUpdate{
State: status,
BlockHeight: uint64(height),
Expand Down
2 changes: 1 addition & 1 deletion x/checkpointing/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (cm *RawCheckpointWithMeta) IsMoreMatureThanStatus(status CheckpointStatus)
// where the time/height are captured by the current ctx
func (cm *RawCheckpointWithMeta) RecordStateUpdate(ctx context.Context, status CheckpointStatus) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
height, time := sdkCtx.HeaderInfo().Height, sdkCtx.HeaderInfo().Time
height, time := sdkCtx.BlockHeight(), sdkCtx.BlockTime()
stateUpdate := &CheckpointStateUpdate{
State: status,
BlockHeight: uint64(height),
Expand Down
4 changes: 2 additions & 2 deletions x/epoching/keeper/apphash_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (k Keeper) GetAppHash(ctx context.Context, height uint64) ([]byte, error) {
// RecordAppHash stores the AppHash of the current header to KVStore
func (k Keeper) RecordAppHash(ctx context.Context) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
height := uint64(sdkCtx.HeaderInfo().Height)
appHash := sdkCtx.HeaderInfo().AppHash
height := uint64(sdkCtx.BlockHeight())
appHash := sdkCtx.BlockHeader().AppHash
// HACK: the app hash for the first height is set to nil
// instead of the hash of an empty byte slice as intended
// see proposed fix: https://github.com/cosmos/cosmos-sdk/pull/18524
Expand Down
3 changes: 2 additions & 1 deletion x/epoching/keeper/drop_validator_msg_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ func NewDropValidatorMsgDecorator(ek Keeper) *DropValidatorMsgDecorator {
// - MsgCancelUnbondingDelegation
func (qmd DropValidatorMsgDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
// skip if at genesis block, as genesis state contains txs that bootstrap the initial validator set
if ctx.HeaderInfo().Height == 0 {
if ctx.BlockHeight() == 0 {
return next(ctx, tx, simulate)
}
// BlockHeight()
// after genesis, if validator-related message, reject msg
for _, msg := range tx.GetMsgs() {
if qmd.IsValidatorRelatedMsg(msg) {
Expand Down
15 changes: 7 additions & 8 deletions x/epoching/keeper/epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (k Keeper) getEpochInfo(ctx context.Context, epochNumber uint64) (*types.Ep

// InitEpoch sets the zero epoch number to DB
func (k Keeper) InitEpoch(ctx context.Context) {
header := sdk.UnwrapSDKContext(ctx).HeaderInfo()
header := sdk.UnwrapSDKContext(ctx).BlockHeader()
if header.Height > 0 {
panic("InitEpoch can be invoked only at genesis")
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func (k Keeper) RecordLastHeaderAndAppHashRoot(ctx context.Context) error {
return errorsmod.Wrapf(types.ErrInvalidHeight, "RecordLastBlockHeader can only be invoked at the last block of an epoch")
}
// record last block header
header := sdk.UnwrapSDKContext(ctx).HeaderInfo()
header := sdk.UnwrapSDKContext(ctx).BlockHeader()
epoch.LastBlockTime = &header.Time
// calculate and record the Merkle root
appHashes, err := k.GetAllAppHashesForEpoch(ctx, epoch)
Expand All @@ -88,9 +88,9 @@ func (k Keeper) RecordSealerAppHashForPrevEpoch(ctx context.Context) *types.Epoc
epoch := k.GetEpoch(ctx)
if !epoch.IsFirstBlock(ctx) {
panic(fmt.Errorf("RecordSealerAppHashForPrevEpoch can only be invoked at the first header of a non-zero epoch. "+
"current epoch: %v, current height: %d", epoch, sdk.UnwrapSDKContext(ctx).HeaderInfo().Height))
"current epoch: %v, current height: %d", epoch, sdk.UnwrapSDKContext(ctx).BlockHeight()))
}
header := sdk.UnwrapSDKContext(ctx).HeaderInfo()
header := sdk.UnwrapSDKContext(ctx).BlockHeader()

// get the sealed epoch, i.e., the epoch earlier than the current epoch
sealedEpoch, err := k.GetHistoricalEpoch(ctx, epoch.EpochNumber-1)
Expand All @@ -112,12 +112,11 @@ func (k Keeper) RecordSealerBlockHashForEpoch(ctx context.Context) *types.Epoch
epoch := k.GetEpoch(ctx)
if !epoch.IsLastBlock(ctx) {
panic(fmt.Errorf("RecordSealerBlockHashForEpoch can only be invoked at the last header of a non-zero epoch. "+
"current epoch: %v, current height: %d", epoch, sdk.UnwrapSDKContext(ctx).HeaderInfo().Height))
"current epoch: %v, current height: %d", epoch, sdk.UnwrapSDKContext(ctx).BlockHeight()))
}
header := sdk.UnwrapSDKContext(ctx).HeaderInfo()

// record the sealer block hash for the sealing epoch
epoch.SealerBlockHash = header.Hash
epoch.SealerBlockHash = sdk.UnwrapSDKContext(ctx).HeaderHash()
k.setEpochInfo(ctx, epoch.EpochNumber, epoch)

return epoch
Expand All @@ -131,7 +130,7 @@ func (k Keeper) IncEpoch(ctx context.Context) types.Epoch {
incrementedEpochNumber := epochNumber + 1

epochInterval := k.GetParams(ctx).EpochInterval
newEpoch := types.NewEpoch(incrementedEpochNumber, epochInterval, uint64(sdkCtx.HeaderInfo().Height), nil)
newEpoch := types.NewEpoch(incrementedEpochNumber, epochInterval, uint64(sdkCtx.BlockHeight()), nil)
k.setEpochInfo(ctx, incrementedEpochNumber, &newEpoch)

return newEpoch
Expand Down
7 changes: 3 additions & 4 deletions x/epoching/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"cosmossdk.io/core/header"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/cosmos/cosmos-sdk/types/query"
"github.com/stretchr/testify/require"

"github.com/babylonchain/babylon/testutil/datagen"
testhelper "github.com/babylonchain/babylon/testutil/helper"
"github.com/babylonchain/babylon/x/epoching/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/stretchr/testify/require"
)

// FuzzParamsQuery fuzzes queryClient.Params
Expand Down Expand Up @@ -85,7 +84,7 @@ func FuzzCurrentEpoch(f *testing.F) {
Time: randomHeader.Time,
ChainID: randomHeader.ChainID,
}
ctx = ctx.WithHeaderInfo(headerInfo)
ctx = ctx.WithHeaderInfo(headerInfo).WithBlockHeader(*randomHeader)
keeper.IncEpoch(ctx)
}
req := types.QueryCurrentEpochRequest{}
Expand Down
2 changes: 1 addition & 1 deletion x/epoching/keeper/lifecycle_delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (k Keeper) RecordNewDelegationState(ctx context.Context, delAddr sdk.AccAdd
}
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
height, time := sdkCtx.HeaderInfo().Height, sdkCtx.HeaderInfo().Time
height, time := sdkCtx.BlockHeight(), sdkCtx.BlockTime()
DelegationStateUpdate := types.DelegationStateUpdate{
State: state,
ValAddr: valAddr.String(),
Expand Down
2 changes: 1 addition & 1 deletion x/epoching/keeper/lifecycle_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (k Keeper) RecordNewValState(ctx sdk.Context, valAddr sdk.ValAddress, state
ValLife: []*types.ValStateUpdate{},
}
}
height, time := ctx.HeaderInfo().Height, ctx.HeaderInfo().Time
height, time := ctx.BlockHeight(), ctx.BlockTime()
valStateUpdate := types.ValStateUpdate{
State: state,
BlockHeight: uint64(height),
Expand Down
4 changes: 2 additions & 2 deletions x/epoching/keeper/modified_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) []abci.Va
func (k Keeper) getAllMatureValidators(ctx sdk.Context) []sdk.ValAddress {
matureValAddrs := []sdk.ValAddress{}

blockTime := ctx.HeaderInfo().Time
blockHeight := ctx.HeaderInfo().Height
blockTime := ctx.BlockTime()
blockHeight := ctx.BlockHeight()

// unbondingValIterator will contains all validator addresses indexed under
// the ValidatorQueueKey prefix. Note, the entire index key is composed as
Expand Down
12 changes: 6 additions & 6 deletions x/epoching/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func (ms msgServer) WrappedDelegate(goCtx context.Context, msg *types.MsgWrapped
)
}

blockHeight := uint64(ctx.HeaderInfo().Height)
blockHeight := uint64(ctx.BlockHeight())
if blockHeight == 0 {
return nil, types.ErrZeroEpochMsg
}
blockTime := ctx.HeaderInfo().Time
blockTime := ctx.BlockTime()

txid := tmhash.Sum(ctx.TxBytes())
queuedMsg, err := types.NewQueuedMessage(blockHeight, blockTime, txid, msg)
Expand Down Expand Up @@ -110,11 +110,11 @@ func (ms msgServer) WrappedUndelegate(goCtx context.Context, msg *types.MsgWrapp
)
}

blockHeight := uint64(ctx.HeaderInfo().Height)
blockHeight := uint64(ctx.BlockHeight())
if blockHeight == 0 {
return nil, types.ErrZeroEpochMsg
}
blockTime := ctx.HeaderInfo().Time
blockTime := ctx.BlockTime()

txid := tmhash.Sum(ctx.TxBytes())
queuedMsg, err := types.NewQueuedMessage(blockHeight, blockTime, txid, msg)
Expand Down Expand Up @@ -172,11 +172,11 @@ func (ms msgServer) WrappedBeginRedelegate(goCtx context.Context, msg *types.Msg
return nil, err
}

blockHeight := uint64(ctx.HeaderInfo().Height)
blockHeight := uint64(ctx.BlockHeight())
if blockHeight == 0 {
return nil, types.ErrZeroEpochMsg
}
blockTime := ctx.HeaderInfo().Time
blockTime := ctx.BlockTime()

txid := tmhash.Sum(ctx.TxBytes())
queuedMsg, err := types.NewQueuedMessage(blockHeight, blockTime, txid, msg)
Expand Down
2 changes: 1 addition & 1 deletion x/epoching/keeper/staking_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (k Keeper) CheckMsgCreateValidator(ctx context.Context, msg *stakingtypes.M
// check if SetInitialCommission fails or not
commission := stakingtypes.NewCommissionWithTime(
msg.Commission.Rate, msg.Commission.MaxRate,
msg.Commission.MaxChangeRate, sdkCtx.HeaderInfo().Time,
msg.Commission.MaxChangeRate, sdkCtx.BlockTime(),
)
if _, err := validator.SetInitialCommission(commission); err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions x/epoching/types/epoching.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ func (e Epoch) GetSecondBlockHeight() uint64 {
}

func (e Epoch) IsLastBlock(ctx context.Context) bool {
return e.GetLastBlockHeight() == uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
return e.GetLastBlockHeight() == uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
}

func (e Epoch) IsLastBlockByHeight(height int64) bool {
return e.GetLastBlockHeight() == uint64(height)
}

func (e Epoch) IsFirstBlock(ctx context.Context) bool {
return e.FirstBlockHeight == uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
return e.FirstBlockHeight == uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
}

func (e Epoch) IsSecondBlock(ctx context.Context) bool {
if e.EpochNumber == 0 {
return false
}
return e.GetSecondBlockHeight() == uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height)
return e.GetSecondBlockHeight() == uint64(sdk.UnwrapSDKContext(ctx).BlockHeight())
}

func (e Epoch) IsVoteExtensionProposal(ctx context.Context) bool {
Expand All @@ -79,9 +79,9 @@ func (e Epoch) IsVoteExtensionProposal(ctx context.Context) bool {
func (e Epoch) IsFirstBlockOfNextEpoch(ctx context.Context) bool {
sdkCtx := sdk.UnwrapSDKContext(ctx)
if e.EpochNumber == 0 {
return sdkCtx.HeaderInfo().Height == 1
return sdkCtx.BlockHeight() == 1
} else {
height := uint64(sdkCtx.HeaderInfo().Height)
height := uint64(sdkCtx.BlockHeight())
return e.FirstBlockHeight+e.CurrentEpochInterval == height
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/finality/keeper/evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (k Keeper) HasEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, heig
}

func (k Keeper) GetEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) (*types.Evidence, error) {
if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < height {
if uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()) < height {
return nil, types.ErrHeightTooHigh
}
store := k.evidenceStore(ctx, fpBtcPK)
Expand Down
6 changes: 3 additions & 3 deletions x/finality/keeper/indexed_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
// IndexBlock indexes the current block, saves the corresponding indexed block
// to KVStore
func (k Keeper) IndexBlock(ctx context.Context) {
headerInfo := sdk.UnwrapSDKContext(ctx).HeaderInfo()
header := sdk.UnwrapSDKContext(ctx).BlockHeader()
ib := &types.IndexedBlock{
Height: uint64(headerInfo.Height),
AppHash: headerInfo.AppHash,
Height: uint64(header.Height),
AppHash: header.AppHash,
Finalized: false,
}
k.SetBlock(ctx, ib)
Expand Down
4 changes: 2 additions & 2 deletions x/finality/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"math/rand"
"testing"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"cosmossdk.io/core/header"
"github.com/babylonchain/babylon/testutil/datagen"
keepertest "github.com/babylonchain/babylon/testutil/keeper"
Expand Down Expand Up @@ -156,7 +156,7 @@ func FuzzAddFinalitySig(f *testing.F) {

// Case 3: successful if the finality provider has voting power and has not casted this vote yet
// index this block first
ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: blockHash})
ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: blockHash}).WithBlockHeader(cmtproto.Header{Height: int64(blockHeight), AppHash: blockHash})
fKeeper.IndexBlock(ctx)
bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1)
// add vote and it should work
Expand Down
4 changes: 2 additions & 2 deletions x/finality/keeper/tallying.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (k Keeper) TallyBlocks(ctx context.Context) {
if err != nil {
// invoking TallyBlocks when BTC staking protocol is not activated is a programming error
panic(fmt.Errorf("cannot tally a block when the BTC staking protocol hasn't been activated yet, current height: %v, activated height: %v",
sdkCtx.HeaderInfo().Height, activatedHeight))
sdkCtx.BlockHeight(), activatedHeight))
}

// start finalising blocks since max(activatedHeight, nextHeightToFinalize)
Expand All @@ -38,7 +38,7 @@ func (k Keeper) TallyBlocks(ctx context.Context) {
// - has finality providers, finalised: impossible to happen, panic
// - does not have finality providers, finalised: impossible to happen, panic
// After this for loop, the blocks since earliest activated height are either finalised or non-finalisable
for i := startHeight; i <= uint64(sdkCtx.HeaderInfo().Height); i++ {
for i := startHeight; i <= uint64(sdkCtx.BlockHeight()); i++ {
ib, err := k.GetBlock(ctx, i)
if err != nil {
panic(err) // failing to get an existing block is a programming error
Expand Down
2 changes: 1 addition & 1 deletion x/finality/keeper/votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (k Keeper) HasSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340Pu
}

func (k Keeper) GetSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340PubKey) (*bbn.SchnorrEOTSSig, error) {
if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < height {
if uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()) < height {
return nil, types.ErrHeightTooHigh
}
store := k.voteStore(ctx, height)
Expand Down
2 changes: 1 addition & 1 deletion x/incentive/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper) error {
// - send a portion of coins in the fee collector account to the incentive module account
// - accumulate BTC staking gauge at the current height
// - accumulate BTC timestamping gauge at the current epoch
if sdk.UnwrapSDKContext(ctx).HeaderInfo().Height > 0 {
if sdk.UnwrapSDKContext(ctx).BlockHeight() > 0 {
k.HandleCoinsInFeeCollector(ctx)
}
return nil
Expand Down
Loading