-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathabci.go
37 lines (31 loc) · 1.1 KB
/
abci.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package keeper
import (
"context"
"fmt"
"cosmossdk.io/core/comet"
"cosmossdk.io/x/evidence/types"
"github.com/cosmos/cosmos-sdk/telemetry"
)
// BeginBlocker iterates through and handles any newly discovered evidence of
// misbehavior submitted by CometBFT. Currently, only equivocation is handled.
func (k Keeper) BeginBlocker(ctx context.Context, cometService comet.Service) error {
start := telemetry.Now()
defer telemetry.ModuleMeasureSince(types.ModuleName, start, telemetry.MetricKeyBeginBlocker)
bi := cometService.CometInfo(ctx)
evidences := bi.Evidence
for _, evidence := range evidences {
switch evidence.Type {
// It's still ongoing discussion how should we treat and slash attacks with
// premeditation. So for now we agree to treat them in the same way.
case comet.LightClientAttack, comet.DuplicateVote:
evidence := types.FromABCIEvidence(evidence, k.consensusAddressCodec)
err := k.handleEquivocationEvidence(ctx, evidence)
if err != nil {
return err
}
default:
k.Logger.Error(fmt.Sprintf("ignored unknown evidence type: %x", evidence.Type))
}
}
return nil
}