Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
likesToEatFish committed Jul 22, 2024
1 parent 50ba5e3 commit 09db0b6
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 241 deletions.
1 change: 1 addition & 0 deletions proto/osmosis/types/v1beta1/wire.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ message SlashInfo {
message ScheduleInfo {
string validator = 1;
string actor = 2;
string denom = 3;
}

// ConsumerPacketData contains a consumer packet data and a type tag
Expand Down
6 changes: 6 additions & 0 deletions x/meshsecurity/keeper/valset_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (k Keeper) ScheduleBonded(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand All @@ -34,6 +35,7 @@ func (k Keeper) ScheduleUnbonded(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand Down Expand Up @@ -74,6 +76,7 @@ func (k Keeper) ScheduleJailed(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand All @@ -87,6 +90,7 @@ func (k Keeper) ScheduleTombstoned(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand All @@ -100,6 +104,7 @@ func (k Keeper) ScheduleUnjailed(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand All @@ -113,6 +118,7 @@ func (k Keeper) ScheduleModified(ctx sdk.Context, addr sdk.ValAddress) error {
Data: &cptypes.ConsumerPacketData_SchedulePacketData{
SchedulePacketData: &cptypes.ScheduleInfo{
Validator: addr.String(),
Denom: k.Staking.BondDenom(ctx),
},
},
}
Expand Down
80 changes: 80 additions & 0 deletions x/meshsecurityprovider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ func (k Keeper) OnRecvBondedPacket(
packet channeltypes.Packet,
data *cptypes.ScheduleInfo,
) (cptypes.PacketAckResult, error) {
intermediary, found := k.GetIntermediary(ctx, data.Denom)
if !found {
ModuleLogger(ctx).Error("External Staker not found for validor",
data.Validator,
)
panic(fmt.Errorf("external Staker not found for validor %s", data.Validator))
}

if intermediary.Status != types.Bonded {
intermediary.Status = types.Bonded
}
k.SetIntermediary(ctx, intermediary)
return cptypes.SlashPacketHandledResult, nil
}

Expand All @@ -110,7 +121,18 @@ func (k Keeper) OnRecvUnbondedPacket(
packet channeltypes.Packet,
data *cptypes.ScheduleInfo,
) (cptypes.PacketAckResult, error) {
intermediary, found := k.GetIntermediary(ctx, data.Denom)
if !found {
ModuleLogger(ctx).Error("External Staker not found for validor",
data.Validator,
)
panic(fmt.Errorf("external Staker not found for validor %s", data.Validator))
}

if intermediary.Status != types.Unbonded {
intermediary.Status = types.Unbonded
}
k.SetIntermediary(ctx, intermediary)
return cptypes.SlashPacketHandledResult, nil
}

Expand All @@ -119,6 +141,31 @@ func (k Keeper) OnRecvJailedPacket(
packet channeltypes.Packet,
data *cptypes.ScheduleInfo,
) (cptypes.PacketAckResult, error) {
intermediary, found := k.GetIntermediary(ctx, data.Denom)
if !found {
ModuleLogger(ctx).Error("External Staker not found for validor",
data.Validator,
)
panic(fmt.Errorf("external Staker not found for validor %s", data.Validator))
}

if intermediary.IsUnboned() {
ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator)
return cptypes.SlashPacketHandledResult, nil
}

if intermediary.IsTombstoned() {
ModuleLogger(ctx).Info(
"slash packet dropped because validator %s is already tombstoned", data.Validator,
)
return cptypes.SlashPacketHandledResult, nil
}
if intermediary.IsJailed() {
ModuleLogger(ctx).Info("validator %s jailed", data.Validator)
return cptypes.SlashPacketHandledResult, nil
}
intermediary.Jailed = true
k.SetIntermediary(ctx, intermediary)

return cptypes.SlashPacketHandledResult, nil
}
Expand All @@ -128,6 +175,20 @@ func (k Keeper) OnRecvTombstonedPacket(
packet channeltypes.Packet,
data *cptypes.ScheduleInfo,
) (cptypes.PacketAckResult, error) {
intermediary, found := k.GetIntermediary(ctx, data.Denom)
if !found {
ModuleLogger(ctx).Error("External Staker not found for validor",
data.Validator,
)
panic(fmt.Errorf("external Staker not found for validor %s", data.Validator))
}

if intermediary.IsUnboned() {
ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator)
return cptypes.SlashPacketHandledResult, nil
}
intermediary.Tombstoned = true
k.SetIntermediary(ctx, intermediary)

return cptypes.SlashPacketHandledResult, nil
}
Expand All @@ -136,6 +197,25 @@ func (k Keeper) OnRecvUnjailedPacket(
packet channeltypes.Packet,
data *cptypes.ScheduleInfo,
) (cptypes.PacketAckResult, error) {
intermediary, found := k.GetIntermediary(ctx, data.Denom)
if !found {
ModuleLogger(ctx).Error("External Staker not found for validor",
data.Validator,
)
panic(fmt.Errorf("external Staker not found for validor %s", data.Validator))
}

if intermediary.IsUnboned() {
ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator)
return cptypes.SlashPacketHandledResult, nil
}
if !intermediary.Jailed {
ModuleLogger(ctx).Error("validator %s is not jailed", data.Validator)
return cptypes.SlashPacketHandledResult, nil
}

intermediary.Jailed = false
k.SetIntermediary(ctx, intermediary)

return cptypes.SlashPacketHandledResult, nil
}
Expand Down
95 changes: 48 additions & 47 deletions x/meshsecurityprovider/types/delegate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 09db0b6

Please sign in to comment.