Open liamsi opened 5 years ago
TODO:
As discussed with @marbar3778 the changes here pose a problem when bechifying the consensus pubkey in the SDK: https://github.com/cosmos/cosmos-sdk/blob/f1adb7afd974ee50ac9ac83a315cde932f47d7ef/x/staking/types/validator.go#L181-L182 creates a too large string (92 bytes) which can not be decoded later via: https://github.com/cosmos/cosmos-sdk/blob/f1adb7afd974ee50ac9ac83a315cde932f47d7ef/x/staking/types/validator.go#L203-L208
This increase is due to the overhead introduced here (prefix and value are encoded as fields now). The simplest way to understand and reproduce this is via running TestRandBech32PubkeyConsistency
in the sdk. The simulation will also fail (the simulation is where Marko noticed the problem).
There seems to be another bug in the changes here. Add this test (in types/address_test.go in the sdk for instance):
func TestValAddrMustMarshal(t *testing.T) {
var pub ed25519.PubKeyEd25519
tSlice := make([]types.ValAddress, 20)
for i := 0; i < 20; i++ {
rand.Read(pub[:])
acc := types.ValAddress(pub.Address())
tSlice[i] = acc
}
bz := codec.Cdc.MustMarshalBinaryLengthPrefixed(tSlice)
timeslice := []types.ValAddress{}
codec.Cdc.MustUnmarshalBinaryLengthPrefixed(bz, ×lice)
}
The latter might be somewhat related to: https://github.com/tendermint/go-amino/issues/272
In UnbondAllMatureValidatorQueue
the timeslice := []sdk.ValAddress{}
is implicitly of type
[][]byte
(ValAddress is just bytes). But this should (and previously did) work just fine. Also, repeated bytes
are allowed in protobuf.
This linter is INTENSE!
ignore these linters will fix it in a coming pr
ref: https://github.com/tendermint/go-amino/issues/267
@alexanderbez @jackzampolin this could do with more testing but I'd appreciate a first peek.