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

R4R: Distr-PR-5 Implement Distribution #2236

Merged
merged 121 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
b2eab0d
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Aug 31, 2018
469334d
Merge branch 'rigel/piggy-bank-fee-spec' into rigel/fee-distribution
rigelrozanski Sep 3, 2018
d7794b4
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 3, 2018
9a2aee8
working
rigelrozanski Sep 4, 2018
48aa9a6
working, moved WIP distribution spec to attic
rigelrozanski Sep 4, 2018
4ddf6ca
undo spec move for PR clarity
rigelrozanski Sep 4, 2018
43ab066
move WIP-lamborghini-distribution
rigelrozanski Sep 4, 2018
38c6090
Merge branch 'rigel/move-spec' into rigel/fee-distribution
rigelrozanski Sep 5, 2018
53253aa
working
rigelrozanski Sep 5, 2018
aebd36f
...
rigelrozanski Sep 5, 2018
8ab25fa
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 5, 2018
e2b5b9b
...
rigelrozanski Sep 5, 2018
b409099
update spec
rigelrozanski Sep 5, 2018
cbb5a50
work on allocate fees
rigelrozanski Sep 5, 2018
e498d43
dec coins, refactoring distr
rigelrozanski Sep 10, 2018
7d864fe
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 10, 2018
922eb5e
...
rigelrozanski Sep 11, 2018
a153088
...
rigelrozanski Sep 11, 2018
46db96b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 13, 2018
dae32a3
...
rigelrozanski Sep 13, 2018
d60f620
working
rigelrozanski Sep 14, 2018
2eff69a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 17, 2018
431fdb8
hook, genesis, and withdraw address
rigelrozanski Sep 18, 2018
24e43b9
hookwork
rigelrozanski Sep 18, 2018
bb9e647
add in basic commission stuff
rigelrozanski Sep 18, 2018
a18b895
handler, tags, msgs, codec
rigelrozanski Sep 19, 2018
e3cf4f6
cli transactions
rigelrozanski Sep 19, 2018
73c5fdf
more cli related
rigelrozanski Sep 19, 2018
de4071f
aliases, errors
rigelrozanski Sep 19, 2018
97f7dbc
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 19, 2018
7688299
alias work, working on compiling
rigelrozanski Sep 19, 2018
df9c8db
working through compile errors
rigelrozanski Sep 19, 2018
d9396ed
working compile errors
rigelrozanski Sep 19, 2018
7002438
compile debugging
rigelrozanski Sep 20, 2018
18fdccf
...
rigelrozanski Sep 20, 2018
5dabd1b
the errors never want to seem to end...
rigelrozanski Sep 20, 2018
5790f33
...
rigelrozanski Sep 20, 2018
251a81f
yay it compiles
rigelrozanski Sep 20, 2018
d360304
breakout use of GetValidatorByConsAddr
rigelrozanski Sep 20, 2018
0d9105c
...
rigelrozanski Sep 21, 2018
0867ce8
...
rigelrozanski Sep 21, 2018
4e4749d
pulling in stuff from fee-distr PR
rigelrozanski Sep 21, 2018
ab61695
PENDING
rigelrozanski Sep 21, 2018
0f903bd
finished pulling in, compiles
rigelrozanski Sep 21, 2018
9e2b8e4
revert some gov changes
rigelrozanski Sep 21, 2018
1243507
no more compile errors in tests
rigelrozanski Sep 21, 2018
787a2f9
fix using cons address, also remove old commented distr code
rigelrozanski Sep 21, 2018
72e3025
doc update
rigelrozanski Sep 21, 2018
b212470
revert some accidental stuff
rigelrozanski Sep 21, 2018
a2b2ef9
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski Sep 22, 2018
14792f2
val comments
rigelrozanski Sep 22, 2018
d428317
import decimal from fee-distr PR
rigelrozanski Sep 22, 2018
79cfee9
pending
rigelrozanski Sep 22, 2018
6012a25
...
rigelrozanski Sep 22, 2018
6f35822
import hook from fee-distr
rigelrozanski Sep 22, 2018
1b485bb
pending
rigelrozanski Sep 22, 2018
df0d582
add staking hooks to staking spec
rigelrozanski Sep 22, 2018
9dfeeb0
address bez comments
rigelrozanski Sep 24, 2018
afe179e
remove GetValidatorByConsPubKey
rigelrozanski Sep 25, 2018
16594f7
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski Sep 25, 2018
dad4253
merge fix
rigelrozanski Sep 25, 2018
ff8d748
Merge branch 'rigel/stake-cons-addr' into rigel/truncate-decimal
rigelrozanski Sep 25, 2018
f5116b9
Merge branch 'rigel/truncate-decimal' into rigel/new-hooks
rigelrozanski Sep 25, 2018
ca2fc77
update commission hook for new commission work
rigelrozanski Sep 25, 2018
5be5ea3
comment update
rigelrozanski Sep 25, 2018
380d3e1
pull a bunch from develop
rigelrozanski Sep 25, 2018
47e899b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 25, 2018
d3146bf
...
rigelrozanski Sep 25, 2018
910af20
Merge commit '5be5ea3' into rigel/new-hooks
rigelrozanski Sep 25, 2018
9e9756a
Merge remote-tracking branch 'origin/develop' into rigel/new-hooks
rigelrozanski Sep 25, 2018
4929b02
mini-fix
rigelrozanski Sep 25, 2018
3846894
Merge branch 'rigel/new-hooks' into rigel/fee-distribution
rigelrozanski Sep 26, 2018
0436f50
...
rigelrozanski Sep 27, 2018
436d2a0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 28, 2018
956566d
proser
rigelrozanski Sep 28, 2018
60a3541
major debugs
rigelrozanski Sep 28, 2018
7ab02ae
lcd tests to include proposer
rigelrozanski Sep 28, 2018
733b616
disable endblock for lcd
rigelrozanski Sep 28, 2018
e223ead
types msg tests
rigelrozanski Sep 28, 2018
064f8b0
dec coin tests
rigelrozanski Sep 28, 2018
16f5d69
types fee pool test
rigelrozanski Sep 28, 2018
dcf0dda
...
rigelrozanski Sep 29, 2018
1e74da1
validator_info tests
rigelrozanski Oct 4, 2018
4d4de3a
delegator_dist_info tests
rigelrozanski Oct 4, 2018
3a9102e
fix
rigelrozanski Oct 4, 2018
eb01cb4
checkout distr types PR updates
rigelrozanski Oct 4, 2018
45f0dd0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 4, 2018
20a51e5
fix compile errors
rigelrozanski Oct 4, 2018
17dc812
fix distribution endblocker issues
rigelrozanski Oct 5, 2018
81d0f5f
add wanted final test case functions
rigelrozanski Oct 5, 2018
83c2781
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 5, 2018
e304b9c
debugging simulation
rigelrozanski Oct 6, 2018
142f42e
...
rigelrozanski Oct 9, 2018
6005325
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 9, 2018
46fe52b
create test initialization for distr
rigelrozanski Oct 9, 2018
c973032
...
rigelrozanski Oct 9, 2018
6d4975e
R4R: Fix simulation proposer (#2460)
cwgoes Oct 9, 2018
fc9bafb
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 10, 2018
151a81e
staking changes test_cover fixes
rigelrozanski Oct 10, 2018
ace19d9
Merge branch 'rigel/fee-distribution' of https://github.com/cosmos/co…
rigelrozanski Oct 10, 2018
52316d9
fix initialization of the test
rigelrozanski Oct 10, 2018
22de856
fix distr initialization
rigelrozanski Oct 10, 2018
3b5e57b
ctx with proposer, working through allocation test
rigelrozanski Oct 10, 2018
900a5f4
keeper_test
rigelrozanski Oct 11, 2018
f4f39ae
allocation tests
rigelrozanski Oct 11, 2018
8e378e2
got basic delegation tests working
rigelrozanski Oct 11, 2018
8cb6d10
TestWithdrawDelegationRewardWithCommission
rigelrozanski Oct 11, 2018
f3c0496
TestWithdrawDelegationRewardsAll
rigelrozanski Oct 12, 2018
a60b91b
bugfix form TestWithdrawDelegationRewardTwoDelegatorsUneven
rigelrozanski Oct 12, 2018
94731a5
some validator dist tests
rigelrozanski Oct 12, 2018
7b1f4a8
finished off validator tests
rigelrozanski Oct 12, 2018
dba20d1
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 12, 2018
06fa518
address @cwgoes comments, add in precommit calculation
rigelrozanski Oct 12, 2018
2ece2ff
address @cwgoes comments
rigelrozanski Oct 15, 2018
5de0c9a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 15, 2018
2f4a01b
address @ValarDragon comments, param store update
rigelrozanski Oct 15, 2018
43e4396
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 15, 2018
076053d
proposer reward params to global param
rigelrozanski Oct 15, 2018
eaecde2
test_utils >:(
rigelrozanski Oct 15, 2018
03b9260
oh
rigelrozanski Oct 15, 2018
32e0f14
rework to correctly use previous vote info
rigelrozanski Oct 16, 2018
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
Prev Previous commit
Next Next commit
breakout use of GetValidatorByConsAddr
  • Loading branch information
rigelrozanski committed Sep 20, 2018
commit d36030424ee5fb2d58f37cf43f422b4d8467c440
7 changes: 4 additions & 3 deletions types/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Validator interface {
GetStatus() BondStatus // status of the validator
GetOperator() ValAddress // operator address to receive/return validators coins
GetPubKey() crypto.PubKey // validation pubkey
GetConsAddr() ConsAddress // validation consensus address
GetPower() Dec // validation power
GetTokens() Dec // validation tokens
GetCommission() Dec // validator commission rate
Expand Down Expand Up @@ -73,9 +74,9 @@ type ValidatorSet interface {
TotalPower(Context) Dec // total power of the validator set

// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
Slash(Context, crypto.PubKey, int64, int64, Dec)
Jail(Context, crypto.PubKey) // jail a validator
Unjail(Context, crypto.PubKey) // unjail a validator
Slash(Context, ConsAddress, int64, int64, Dec)
Jail(Context, ConsAddress) // jail a validator
Unjail(Context, ConsAddress) // unjail a validator

// Delegation allows for getting a particular delegation for a given validator
// and delegator outside the scope of the staking module.
Expand Down
2 changes: 1 addition & 1 deletion x/gov/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) (resTags sdk.Tags) {
for _, valAddr := range nonVotingVals {
val := keeper.ds.GetValidatorSet().Validator(ctx, valAddr)
keeper.ds.GetValidatorSet().Slash(ctx,
val.GetPubKey(),
val.GetConsAddr(),
ctx.BlockHeight(),
val.GetPower().RoundInt64(),
keeper.GetTallyingProcedure(ctx).GovernancePenalty)
Expand Down
8 changes: 4 additions & 4 deletions x/slashing/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) sdk.Result {
return ErrValidatorNotJailed(k.codespace).Result()
}

addr := sdk.ConsAddress(validator.GetPubKey().Address())
consAddr := sdk.ConsAddress(validator.GetPubKey().Address())

info, found := k.getValidatorSigningInfo(ctx, addr)
info, found := k.getValidatorSigningInfo(ctx, consAddr)
if !found {
return ErrNoValidatorForAddress(k.codespace).Result()
}
Expand All @@ -49,9 +49,9 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) sdk.Result {
// update the starting height so the validator can't be immediately jailed
// again
info.StartHeight = ctx.BlockHeight()
k.setValidatorSigningInfo(ctx, addr, info)
k.setValidatorSigningInfo(ctx, consAddr, info)

k.validatorSet.Unjail(ctx, validator.GetPubKey())
k.validatorSet.Unjail(ctx, consAddr)

tags := sdk.NewTags("action", []byte("unjail"), "validator", []byte(msg.ValidatorAddr.String()))

Expand Down
36 changes: 18 additions & 18 deletions x/slashing/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio
logger := ctx.Logger().With("module", "x/slashing")
time := ctx.BlockHeader().Time
age := time.Sub(timestamp)
address := sdk.ConsAddress(addr)
consAddr := sdk.ConsAddress(addr)
pubkey, err := k.getPubkey(ctx, addr)
if err != nil {
panic(fmt.Sprintf("Validator address %v not found", addr))
panic(fmt.Sprintf("Validator consensus-address %v not found", consAddr))
}

// Double sign too old
Expand All @@ -59,37 +59,37 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio
// Cap the amount slashed to the penalty for the worst infraction
// within the slashing period when this infraction was committed
fraction := k.SlashFractionDoubleSign(ctx)
revisedFraction := k.capBySlashingPeriod(ctx, address, fraction, infractionHeight)
revisedFraction := k.capBySlashingPeriod(ctx, consAddr, fraction, infractionHeight)
logger.Info(fmt.Sprintf("Fraction slashed capped by slashing period from %v to %v", fraction, revisedFraction))

// Slash validator
k.validatorSet.Slash(ctx, pubkey, infractionHeight, power, revisedFraction)
k.validatorSet.Slash(ctx, consAddr, infractionHeight, power, revisedFraction)

// Jail validator
k.validatorSet.Jail(ctx, pubkey)
k.validatorSet.Jail(ctx, consAddr)

// Set validator jail duration
signInfo, found := k.getValidatorSigningInfo(ctx, address)
signInfo, found := k.getValidatorSigningInfo(ctx, consAddr)
if !found {
panic(fmt.Sprintf("Expected signing info for validator %s but not found", address))
panic(fmt.Sprintf("Expected signing info for validator %s but not found", consAddr))
}
signInfo.JailedUntil = time.Add(k.DoubleSignUnbondDuration(ctx))
k.setValidatorSigningInfo(ctx, address, signInfo)
k.setValidatorSigningInfo(ctx, consAddr, signInfo)
}

// handle a validator signature, must be called once per validator per block
// nolint gocyclo
func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, power int64, signed bool) {
logger := ctx.Logger().With("module", "x/slashing")
height := ctx.BlockHeight()
address := sdk.ConsAddress(addr)
consAddr := sdk.ConsAddress(addr)
pubkey, err := k.getPubkey(ctx, addr)
if err != nil {
panic(fmt.Sprintf("Validator address %v not found", addr))
panic(fmt.Sprintf("Validator consensus-address %v not found", consAddr))
}
// Local index, so counts blocks validator *should* have signed
// Will use the 0-value default signing info if not present, except for start height
signInfo, found := k.getValidatorSigningInfo(ctx, address)
signInfo, found := k.getValidatorSigningInfo(ctx, consAddr)
if !found {
// If this validator has never been seen before, construct a new SigningInfo with the correct start height
signInfo = NewValidatorSigningInfo(height, 0, time.Unix(0, 0), 0)
Expand All @@ -100,16 +100,16 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
// Update signed block bit array & counter
// This counter just tracks the sum of the bit array
// That way we avoid needing to read/write the whole array each time
previous := k.getValidatorSigningBitArray(ctx, address, index)
previous := k.getValidatorSigningBitArray(ctx, consAddr, index)
if previous == signed {
// Array value at this index has not changed, no need to update counter
} else if previous && !signed {
// Array value has changed from signed to unsigned, decrement counter
k.setValidatorSigningBitArray(ctx, address, index, false)
k.setValidatorSigningBitArray(ctx, consAddr, index, false)
signInfo.SignedBlocksCounter--
} else if !previous && signed {
// Array value has changed from unsigned to signed, increment counter
k.setValidatorSigningBitArray(ctx, address, index, true)
k.setValidatorSigningBitArray(ctx, consAddr, index, true)
signInfo.SignedBlocksCounter++
}

Expand All @@ -118,13 +118,13 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
}
minHeight := signInfo.StartHeight + k.SignedBlocksWindow(ctx)
if height > minHeight && signInfo.SignedBlocksCounter < k.MinSignedPerWindow(ctx) {
validator := k.validatorSet.ValidatorByConsAddr(ctx, address)
validator := k.validatorSet.ValidatorByConsAddr(ctx, consAddr)
if validator != nil && !validator.GetJailed() {
// Downtime confirmed: slash and jail the validator
logger.Info(fmt.Sprintf("Validator %s past min height of %d and below signed blocks threshold of %d",
pubkey.Address(), minHeight, k.MinSignedPerWindow(ctx)))
k.validatorSet.Slash(ctx, pubkey, height, power, k.SlashFractionDowntime(ctx))
k.validatorSet.Jail(ctx, pubkey)
k.validatorSet.Slash(ctx, consAddr, height, power, k.SlashFractionDowntime(ctx))
k.validatorSet.Jail(ctx, consAddr)
signInfo.JailedUntil = ctx.BlockHeader().Time.Add(k.DowntimeUnbondDuration(ctx))
} else {
// Validator was (a) not found or (b) already jailed, don't slash
Expand All @@ -134,7 +134,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
}

// Set the updated signing info
k.setValidatorSigningInfo(ctx, address, signInfo)
k.setValidatorSigningInfo(ctx, consAddr, signInfo)
}

// AddValidators adds the validators to the keepers validator addr to pubkey mapping.
Expand Down
2 changes: 1 addition & 1 deletion x/stake/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
if found {
return ErrValidatorOwnerExists(k.Codespace()).Result()
}
_, found = k.GetValidatorByConsAddr(ctx, sdk.ConsAddress(msg.PubKey.Address()))
_, found = k.GetValidatorByConsPubKey(ctx, msg.PubKey)
if found {
return ErrValidatorPubKeyExists(k.Codespace()).Result()
}
Expand Down
10 changes: 10 additions & 0 deletions x/stake/keeper/sdk_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto"
)

// Implements ValidatorSet
Expand Down Expand Up @@ -66,6 +67,15 @@ func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) sdk.V
return val
}

// get the sdk.validator for a particular pubkey
func (k Keeper) ValidatorByConsPubKey(ctx sdk.Context, consPubKey crypto.PubKey) sdk.Validator {
val, found := k.GetValidatorByConsPubKey(ctx, consPubKey)
if !found {
return nil
}
return val
}

// total power from the bond
func (k Keeper) TotalPower(ctx sdk.Context) sdk.Dec {
pool := k.GetPool(ctx)
Expand Down
33 changes: 12 additions & 21 deletions x/stake/keeper/slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/cosmos/cosmos-sdk/x/stake/types"
"github.com/tendermint/tendermint/crypto"
)

// Slash a validator for an infraction committed at a known height
Expand All @@ -24,7 +23,7 @@ import (
// not at a height in the future
//
// nolint: gocyclo
func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, power int64, slashFactor sdk.Dec) {
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) {
logger := ctx.Logger().With("module", "x/stake")

if slashFactor.LT(sdk.ZeroDec()) {
Expand All @@ -36,15 +35,15 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in
// ref https://github.com/cosmos/cosmos-sdk/issues/1348
// ref https://github.com/cosmos/cosmos-sdk/issues/1471

validator, found := k.GetValidatorByConsAddr(ctx, sdk.ConsAddress(pubkey.Address()))
validator, found := k.GetValidatorByConsAddr(ctx, consAddr)
if !found {
// If not found, the validator must have been overslashed and removed - so we don't need to do anything
// NOTE: Correctness dependent on invariant that unbonding delegations / redelegations must also have been completely
// slashed in this case - which we don't explicitly check, but should be true.
// Log the slash attempt for future reference (maybe we should tag it too)
logger.Error(fmt.Sprintf(
"WARNING: Ignored attempt to slash a nonexistent validator with address %s, we recommend you investigate immediately",
pubkey.Address()))
consAddr))
return
}

Expand Down Expand Up @@ -125,36 +124,28 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in
}

// jail a validator
func (k Keeper) Jail(ctx sdk.Context, pubkey crypto.PubKey) {
k.setJailed(ctx, pubkey, true)
validatorAddr, err := sdk.ValAddressFromHex(pubkey.Address().String())
if err != nil {
panic(err.Error())
}
func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) {
k.setJailed(ctx, consAddr, true)
logger := ctx.Logger().With("module", "x/stake")
logger.Info(fmt.Sprintf("validator %s jailed", validatorAddr))
logger.Info(fmt.Sprintf("validator %s jailed", consAddr))
// TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803
return
}

// unjail a validator
func (k Keeper) Unjail(ctx sdk.Context, pubkey crypto.PubKey) {
k.setJailed(ctx, pubkey, false)
validatorAddr, err := sdk.ValAddressFromHex(pubkey.Address().String())
if err != nil {
panic(err.Error())
}
func (k Keeper) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) {
k.setJailed(ctx, consAddr, false)
logger := ctx.Logger().With("module", "x/stake")
logger.Info(fmt.Sprintf("validator %s unjailed", validatorAddr))
logger.Info(fmt.Sprintf("validator %s unjailed", consAddr))
// TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803
return
}

// set the jailed flag on a validator
func (k Keeper) setJailed(ctx sdk.Context, pubkey crypto.PubKey, isJailed bool) {
validator, found := k.GetValidatorByConsAddr(ctx, sdk.ConsAddress(pubkey.Address()))
func (k Keeper) setJailed(ctx sdk.Context, consAddr sdk.ConsAddress, isJailed bool) {
validator, found := k.GetValidatorByConsAddr(ctx, sdk.ConsAddress(consAddr))
if !found {
panic(fmt.Errorf("validator with pubkey %s not found, cannot set jailed to %v", pubkey, isJailed))
panic(fmt.Errorf("validator with consensus-Address %s not found, cannot set jailed to %v", consAddr, isJailed))
}
validator.Jailed = isJailed
k.UpdateValidator(ctx, validator) // update validator, possibly unbonding or bonding it
Expand Down
Loading