-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: changes to sdk for interchain security #15917
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/slashing/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
) | ||
|
||
// HandleValidatorSignature handles a validator signature, must be called once per validator per block. | ||
|
@@ -16,9 +15,6 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre | |
|
||
// fetch the validator public key | ||
consAddr := sdk.ConsAddress(addr) | ||
if _, err := k.GetPubkey(ctx, addr); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #15908 |
||
panic(fmt.Sprintf("Validator consensus-address %s not found", consAddr)) | ||
} | ||
|
||
// don't update missed blocks when validator's jailed | ||
if k.sk.IsValidatorJailed(ctx, consAddr) { | ||
|
@@ -88,17 +84,13 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre | |
// Note that this *can* result in a negative "distributionHeight" up to -ValidatorUpdateDelay-1, | ||
// i.e. at the end of the pre-genesis block (none) = at the beginning of the genesis block. | ||
// That's fine since this is just used to filter unbonding delegations & redelegations. | ||
distributionHeight := height - sdk.ValidatorUpdateDelay - 1 | ||
|
||
coinsBurned := k.sk.SlashWithInfractionReason(ctx, consAddr, distributionHeight, power, k.SlashFractionDowntime(ctx), stakingtypes.Infraction_INFRACTION_DOWNTIME) | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeSlash, | ||
sdk.NewAttribute(types.AttributeKeyAddress, consAddr.String()), | ||
sdk.NewAttribute(types.AttributeKeyPower, fmt.Sprintf("%d", power)), | ||
sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueMissingSignature), | ||
sdk.NewAttribute(types.AttributeKeyJailed, consAddr.String()), | ||
sdk.NewAttribute(types.AttributeKeyBurnedCoins, coinsBurned.String()), | ||
), | ||
) | ||
k.sk.Jail(ctx, consAddr) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ type ValidatorSet interface { | |
StakingTokenSupply(sdk.Context) math.Int // total staking token supply | ||
|
||
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction | ||
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int | ||
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, Infraction) | ||
SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, Infraction) math.Int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, v0.45.x-ics did have a breaking change in Slash, but in v0.47 we decided not to break the API for users, hence the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vuong177 hey can you check this out, can we move the slash func for consumer keeper to SlashWithInfractionReason |
||
Jail(sdk.Context, sdk.ConsAddress) // jail a validator | ||
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added in v0.46 (so it is normal it isn't on v0.45.x and v0.45.x-ics). Could you please tell us which issues you are facing with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot, but @vuong177 can. He is the person who identified this stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the consumer app doesn't have a valset because it operate on the provider chain valset, so any time consumer app init genesis the valset check will always return an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not that familiar with ICS codebase, but this makes sense.
Have you investigated if the consumer app could recover the panic? I know this isn't ideal, but this is a UX improvement for all but consumer chains.