Improve Import/Export Simulation Errors (#4607)

This commit is contained in:
Federico Kunze
2019-06-28 19:20:36 +01:00
committed by Alessio Treglia
parent f9dea984c2
commit 4a0fbb3d6e
9 changed files with 593 additions and 47 deletions
-3
View File
@@ -46,8 +46,6 @@ var (
GetValidatorSigningInfoAddress = types.GetValidatorSigningInfoAddress
GetValidatorMissedBlockBitArrayPrefixKey = types.GetValidatorMissedBlockBitArrayPrefixKey
GetValidatorMissedBlockBitArrayKey = types.GetValidatorMissedBlockBitArrayKey
GetValidatorSlashingPeriodPrefix = types.GetValidatorSlashingPeriodPrefix
GetValidatorSlashingPeriodKey = types.GetValidatorSlashingPeriodKey
GetAddrPubkeyRelationKey = types.GetAddrPubkeyRelationKey
NewMsgUnjail = types.NewMsgUnjail
ParamKeyTable = types.ParamKeyTable
@@ -61,7 +59,6 @@ var (
ModuleCdc = types.ModuleCdc
ValidatorSigningInfoKey = types.ValidatorSigningInfoKey
ValidatorMissedBlockBitArrayKey = types.ValidatorMissedBlockBitArrayKey
ValidatorSlashingPeriodKey = types.ValidatorSlashingPeriodKey
AddrPubkeyRelationKey = types.AddrPubkeyRelationKey
DoubleSignJailEndTime = types.DoubleSignJailEndTime
DefaultMinSignedPerWindow = types.DefaultMinSignedPerWindow
+9 -16
View File
@@ -27,12 +27,18 @@ const (
QuerySigningInfos = "signingInfos"
)
// key prefix bytes
// Keys for slashing store
// Items are stored with the following key: values
//
// - 0x01<consAddress_Bytes>: ValidatorSigningInfo
//
// - 0x02<consAddress_Bytes><period_Bytes>: bool
//
// - 0x03<accAddr_Bytes>: crypto.PubKey
var (
ValidatorSigningInfoKey = []byte{0x01} // Prefix for signing info
ValidatorMissedBlockBitArrayKey = []byte{0x02} // Prefix for missed block bit array
ValidatorSlashingPeriodKey = []byte{0x03} // Prefix for slashing period
AddrPubkeyRelationKey = []byte{0x04} // Prefix for address-pubkey relation
AddrPubkeyRelationKey = []byte{0x03} // Prefix for address-pubkey relation
)
// stored by *Consensus* address (not operator address)
@@ -61,19 +67,6 @@ func GetValidatorMissedBlockBitArrayKey(v sdk.ConsAddress, i int64) []byte {
return append(GetValidatorMissedBlockBitArrayPrefixKey(v), b...)
}
// stored by *Consensus* address (not operator address)
func GetValidatorSlashingPeriodPrefix(v sdk.ConsAddress) []byte {
return append(ValidatorSlashingPeriodKey, v.Bytes()...)
}
// stored by *Consensus* address (not operator address) followed by start height
func GetValidatorSlashingPeriodKey(v sdk.ConsAddress, startHeight int64) []byte {
b := make([]byte, 8)
// this needs to be height + ValidatorUpdateDelay because the slashing period for genesis validators starts at height -ValidatorUpdateDelay
binary.BigEndian.PutUint64(b, uint64(startHeight+sdk.ValidatorUpdateDelay))
return append(GetValidatorSlashingPeriodPrefix(v), b...)
}
// get pubkey relation key used to get the pubkey from the address
func GetAddrPubkeyRelationKey(address []byte) []byte {
return append(AddrPubkeyRelationKey, address...)