forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix updateValidatorDistInfoFromPool (cosmos#3046)
Fixes regression introduced by cosmos#2984. Continuiation of cosmos#3033 , which didn't fix the simulation issues. (candidate) Complete solution for cosmos#3019, 9002 halt bug. From cosmos#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.
- Loading branch information
Showing
7 changed files
with
91 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters