refactor!: deprecate blocktime on context (#17738)
This commit is contained in:
@@ -152,7 +152,7 @@ func (k Keeper) HandleValidatorSignature(ctx context.Context, addr cryptotypes.A
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
signInfo.JailedUntil = sdkCtx.BlockHeader().Time.Add(downtimeJailDur)
|
||||
signInfo.JailedUntil = sdkCtx.HeaderInfo().Time.Add(downtimeJailDur)
|
||||
|
||||
// We need to reset the counter & bitmap so that the validator won't be
|
||||
// immediately slashed for downtime upon re-bonding.
|
||||
|
||||
@@ -3,13 +3,13 @@ package keeper_test
|
||||
import (
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
cmttime "github.com/cometbft/cometbft/types/time"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
st "cosmossdk.io/api/cosmos/staking/v1beta1"
|
||||
"cosmossdk.io/core/header"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s *KeeperTestSuite) SetupTest() {
|
||||
s.key = key
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
testCtx := sdktestutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
ctx := testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()})
|
||||
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now().Round(0).UTC()})
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig()
|
||||
|
||||
// gomock initializations
|
||||
|
||||
@@ -267,7 +267,7 @@ func (s *KeeperTestSuite) TestUnjail() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
info := slashingtypes.NewValidatorSigningInfo(sdk.ConsAddress(addr), int64(4), int64(3),
|
||||
s.ctx.BlockTime().AddDate(0, 0, 1), false, int64(10))
|
||||
s.ctx.HeaderInfo().Time.AddDate(0, 0, 1), false, int64(10))
|
||||
|
||||
s.Require().NoError(s.slashingKeeper.ValidatorSigningInfo.Set(s.ctx, sdk.ConsAddress(addr), info))
|
||||
s.stakingKeeper.EXPECT().Validator(s.ctx, valAddr).Return(val, nil)
|
||||
@@ -303,7 +303,7 @@ func (s *KeeperTestSuite) TestUnjail() {
|
||||
del := types.NewDelegation(addr.String(), valAddr.String(), sdkmath.LegacyNewDec(100))
|
||||
|
||||
s.stakingKeeper.EXPECT().Delegation(s.ctx, addr, valAddr).Return(del, nil)
|
||||
s.stakingKeeper.EXPECT().Unjail(s.ctx, sdk.ConsAddress(addr)).Return(nil)
|
||||
s.stakingKeeper.EXPECT().Unjail(s.ctx, sdk.ConsAddress(addr)).Return(nil).AnyTimes()
|
||||
|
||||
return &slashingtypes.MsgUnjail{
|
||||
ValidatorAddr: sdk.ValAddress(addr).String(),
|
||||
|
||||
@@ -64,7 +64,7 @@ func (k Keeper) Unjail(ctx context.Context, validatorAddr sdk.ValAddress) error
|
||||
|
||||
// cannot be unjailed until out of jail
|
||||
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||
if sdkCtx.BlockHeader().Time.Before(info.JailedUntil) {
|
||||
if sdkCtx.HeaderInfo().Time.Before(info.JailedUntil) {
|
||||
return types.ErrValidatorJailed
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user