From 0c7fd316eb006c0afc13996c00ac8bde1078b32c Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 26 Jun 2020 15:58:27 +0400 Subject: [PATCH] abci/example/kvstore: decrease val power by 1 upon equivocation (#5056) in `persistent_kvstore` --- abci/example/kvstore/persistent_kvstore.go | 19 ++++++++++++------- networks/remote/integration.sh | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/abci/example/kvstore/persistent_kvstore.go b/abci/example/kvstore/persistent_kvstore.go index 0f79a067d..1ac46b836 100644 --- a/abci/example/kvstore/persistent_kvstore.go +++ b/abci/example/kvstore/persistent_kvstore.go @@ -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, - }) } } diff --git a/networks/remote/integration.sh b/networks/remote/integration.sh index 2a88035af..972ae6065 100644 --- a/networks/remote/integration.sh +++ b/networks/remote/integration.sh @@ -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