Browse Source

abci/example/kvstore: decrease val power by 1 upon equivocation (#5056)

in `persistent_kvstore`
pull/5062/head
Anton Kaliaev 4 years ago
committed by GitHub
parent
commit
0c7fd316eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions
  1. +12
    -7
      abci/example/kvstore/persistent_kvstore.go
  2. +2
    -2
      networks/remote/integration.sh

+ 12
- 7
abci/example/kvstore/persistent_kvstore.go View File

@ -125,16 +125,21 @@ func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock)
// reset valset changes
app.ValUpdates = make([]types.ValidatorUpdate, 0)
// Punish validators who committed equivocation.
for _, ev := range req.ByzantineValidators {
if ev.Type == tmtypes.ABCIEvidenceTypeDuplicateVote {
// decrease voting power by 1
if ev.TotalVotingPower == 0 {
continue
addr := string(ev.Validator.Address)
if pubKey, ok := app.valAddrToPubKeyMap[addr]; ok {
app.updateValidator(types.ValidatorUpdate{
PubKey: pubKey,
Power: ev.Validator.Power - 1,
})
app.logger.Info("Decreased val power by 1 because of the equivocation",
"val", addr)
} else {
app.logger.Error("Wanted to punish val, but can't find it",
"val", addr)
}
app.updateValidator(types.ValidatorUpdate{
PubKey: app.valAddrToPubKeyMap[string(ev.Validator.Address)],
Power: ev.TotalVotingPower - 1,
})
}
}


+ 2
- 2
networks/remote/integration.sh View File

@ -10,8 +10,8 @@ sudo apt-get upgrade -y
sudo apt-get install -y jq unzip python-pip software-properties-common make
# get and unpack golang
curl -O https://storage.googleapis.com/golang/go1.13.linux-amd64.tar.gz
tar -xvf go1.13.linux-amd64.tar.gz
curl -O https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
tar -xvf go1.14.4.linux-amd64.tar.gz
## move binary and add to path
mv go /usr/local


Loading…
Cancel
Save