Fix updateValidatorDistInfoFromPool (#3046)
Fixes regression introduced by #2984. Continuiation of #3033 , which didn't fix the simulation issues. (candidate) Complete solution for #3019, 9002 halt bug. From #2984, it isn't sufficient to take the fee pool rewards of a validator. Since we don't track delegator accums (as we do with validator accums), and because onValidatorModified >updateValidatorDistInfoFromPool is also being called upon delegation updates (or at least I believe this is the reason), it is necessary to also withdraw self delegation. TODO: I don't think self-delegation should be required to be modified here... consider using a delegation hook to do the self-delegation withdraw part instead, e.g. splitting the updateValidatorDistInfoFromPool function into two. It might not result in cleaner code, however. Think hard.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/bech32"
|
||||
)
|
||||
|
||||
var bech32Prefixes = []string{"cosmos", "cosmospub", "cosmosvaloper", "cosmosvaloperpub", "cosmosvalcons", "cosmosvalconspub"}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Must specify an input string")
|
||||
}
|
||||
arg := os.Args[1]
|
||||
runFromBech32(arg)
|
||||
runFromHex(arg)
|
||||
}
|
||||
|
||||
// Print info from bech32.
|
||||
func runFromBech32(bech32str string) {
|
||||
hrp, bz, err := bech32.DecodeAndConvert(bech32str)
|
||||
if err != nil {
|
||||
fmt.Println("Not a valid bech32 string")
|
||||
return
|
||||
}
|
||||
fmt.Println("Bech32 parse:")
|
||||
fmt.Printf("Human readible part: %v\nBytes (hex): %X\n",
|
||||
hrp,
|
||||
bz,
|
||||
)
|
||||
}
|
||||
|
||||
func runFromHex(hexaddr string) {
|
||||
bz, err := hex.DecodeString(hexaddr)
|
||||
if err != nil {
|
||||
fmt.Println("Not a valid hex string")
|
||||
return
|
||||
}
|
||||
fmt.Println("Hex parse:")
|
||||
fmt.Println("Bech32 formats:")
|
||||
for _, prefix := range bech32Prefixes {
|
||||
bech32Addr, err := bech32.ConvertAndEncode(prefix, bz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(" - " + bech32Addr)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user