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

feat: update the slashing and evidence modules to work with ICS #15908

Merged
merged 12 commits into from
Apr 25, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 2023/04/21 13:41:27 TestKeyCodec [rapid] draw key: testutil.TestKeyCodec{KeySpecs:[]testutil.TestFieldSpec{testutil.TestFieldSpec{FieldName:"dur", Gen:(*rapid.Generator[interface {}])(0x140002218c0)}}, Codec:(*ormkv.KeyCodec)(0x14001322480)}
# 2023/04/21 13:41:27 TestKeyCodec [rapid] draw values[0]: &impl.messageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000154840)}
# 2023/04/21 13:41:27 TestKeyCodec [rapid] draw values2[0]: &impl.messageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000154840)}
# 2023/04/21 13:41:27 TestKeyCodec assertion failed: 1 (int) != -1 (int)
#
v0.4.8#6224298232862242562
0x9249249249249
0x0
0x9867f1f40f739
0xe
0x0
0x0
0x0
0x10000000000000
0x0
0x0
0x0
0x0
0x0
0x10000000000000
0x0
0x1
0x0
0x0
0x0
0x10000000000000
0x0
0x0
0x0
0x0
0x0
0x0
0x10000000000000
0x0
0x1
0x0
0x0
0x1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 2023/04/21 13:41:29 TestUniqueKeyCodec [rapid] draw keyCodec: testutil.TestKeyCodec{KeySpecs:[]testutil.TestFieldSpec{testutil.TestFieldSpec{FieldName:"u32", Gen:(*rapid.Generator[interface {}])(0x14000221320)}}, Codec:(*ormkv.KeyCodec)(0x14000531a70)}
# 2023/04/21 13:41:29 TestUniqueKeyCodec [rapid] draw primaryKeyCodec: testutil.TestKeyCodec{KeySpecs:[]testutil.TestFieldSpec{testutil.TestFieldSpec{FieldName:"i32", Gen:(*rapid.Generator[interface {}])(0x14000221500)}}, Codec:(*ormkv.KeyCodec)(0x14000531b00)}
# 2023/04/21 13:41:29 TestUniqueKeyCodec [rapid] draw a0: &testpb.ExampleTable{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0x14000222000)}, sizeCache:0, unknownFields:[]uint8(nil), U32:0x0, U64:0x0, Str:"", Bz:[]uint8(nil), Ts:(*timestamppb.Timestamp)(nil), Dur:(*durationpb.Duration)(nil), I32:1, S32:0, Sf32:0, I64:0, S64:0, Sf64:0, F32:0x0, F64:0x0, B:false, E:0, Repeated:[]uint32(nil), Map:map[string]uint32(nil), Msg:(*testpb.ExampleTable_ExampleMessage)(nil), Sum:testpb.isExampleTable_Sum(nil)}
#
v0.4.8#4211888547178155051
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x6b74f03291620
0x4
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x1
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
0x0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 2023/04/21 13:41:29 TestRandomTableData [rapid] draw i: 0
# 2023/04/21 13:41:29 TestRandomTableData [rapid] draw j: 2
# 2023/04/21 13:41:29 TestRandomTableData assertion failed: error is not nil: start must be before end for field testpb.ExampleTable.str: invalid range iteration keys
#
v0.4.8#16769933745078028119
0x0
0x0
0x0
0x0
0x0
0x1
14 changes: 1 addition & 13 deletions x/evidence/keeper/infraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ func (k Keeper) handleEquivocationEvidence(ctx sdk.Context, evidence *types.Equi
logger := k.Logger(ctx)
consAddr := evidence.GetConsensusAddress()

if _, err := k.slashingKeeper.GetPubkey(ctx, consAddr.Bytes()); err != nil {
// Ignore evidence that cannot be handled.
//
// NOTE: We used to panic with:
// `panic(fmt.Sprintf("Validator consensus-address %v not found", consAddr))`,
// but this couples the expectations of the app to both CometBFT and
// the simulator. Both are expected to provide the full range of
// allowable but none of the disallowed evidence types. Instead of
// getting this coordination right, it is easier to relax the
// constraints and ignore evidence that cannot be handled.
return
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do not panic l75, can we at least log something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we move the validator and pubkey check above this and we can short-circuit everything else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can replicate this no-op in the slashing infractions.go ?

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as duplicate.

This comment was marked as off-topic.

// calculate the age of the evidence
infractionHeight := evidence.GetHeight()
infractionTime := evidence.GetTime()
Expand Down Expand Up @@ -82,6 +69,7 @@ func (k Keeper) handleEquivocationEvidence(ctx sdk.Context, evidence *types.Equi
// allowable but none of the disallowed evidence types. Instead of
// getting this coordination right, it is easier to relax the
// constraints and ignore evidence that cannot be handled.
logger.Info(fmt.Sprintf("expected pubkey for validator %s but not found", consAddr))
return
}
}
Expand Down