fix bech32 prefix in evidence (#8461)
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com> Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
d97e7907f1
commit
d6e4a2e9bc
@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (x/evidence) [#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) Fix bech32 prefix in evidence validator address conversion
|
||||
* (x/slashing) [\#8427](https://github.com/cosmos/cosmos-sdk/pull/8427) Fix query signing infos command
|
||||
* (simapp) [\#8418](https://github.com/cosmos/cosmos-sdk/pull/8418) Add balance coin to supply when adding a new genesis account
|
||||
* (x/bank) [\#8417](https://github.com/cosmos/cosmos-sdk/pull/8417) Validate balances and coin denom metadata on genesis
|
||||
|
||||
@ -88,7 +88,8 @@ func (e Equivocation) GetTotalPower() int64 { return 0 }
|
||||
// FromABCIEvidence converts a Tendermint concrete Evidence type to
|
||||
// SDK Evidence using Equivocation as the concrete type.
|
||||
func FromABCIEvidence(e abci.Evidence) exported.Evidence {
|
||||
consAddr, err := sdk.Bech32ifyAddressBytes(sdk.Bech32PrefixConsAddr, e.Validator.Address)
|
||||
bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix()
|
||||
consAddr, err := sdk.Bech32ifyAddressBytes(bech32PrefixConsAddr, e.Validator.Address)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
@ -57,3 +58,22 @@ func TestEquivocationValidateBasic(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvidenceAddressConversion(t *testing.T) {
|
||||
sdk.GetConfig().SetBech32PrefixForConsensusNode("testcnclcons", "testcnclconspub")
|
||||
tmEvidence := abci.Evidence{
|
||||
Type: abci.EvidenceType_DUPLICATE_VOTE,
|
||||
Validator: abci.Validator{
|
||||
Address: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
Power: 100,
|
||||
},
|
||||
Height: 1,
|
||||
Time: time.Now(),
|
||||
TotalVotingPower: 100,
|
||||
}
|
||||
evidence := types.FromABCIEvidence(tmEvidence).(*types.Equivocation)
|
||||
consAddr := evidence.GetConsensusAddress()
|
||||
// Check the address is the same after conversion
|
||||
require.Equal(t, tmEvidence.Validator.Address, consAddr.Bytes())
|
||||
sdk.GetConfig().SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user