From 1200d0d8ed4eeb07fffb10ee7a8833637e18a9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Husiaty=C5=84ski?= Date: Mon, 16 Dec 2019 11:44:33 +0100 Subject: [PATCH] no explicit username token registration owner (#1079) This change is a reverse of modification introduced in 0.23.0 release. Do not allow to explicitely specify a new token owner. Rely on the `AnySigner` result. The above was an improvement. We deprecate `x/username` pacakge and do not want to introduce more work, even if those are fixing issues. resolve #1066 --- CHANGELOG.md | 5 + cmd/bnscli/clitests/register_username.test | 1 - .../clitests/register_username.test.gold | 3 +- cmd/bnscli/cmd_username.go | 2 - cmd/bnsd/x/username/codec.pb.go | 117 +++++------------- cmd/bnsd/x/username/codec.proto | 2 - cmd/bnsd/x/username/handlers.go | 12 +- cmd/bnsd/x/username/msg.go | 7 -- docs/proto/index.html | 7 -- spec/gogo/cmd/bnsd/x/username/codec.proto | 2 - spec/proto/cmd/bnsd/x/username/codec.proto | 2 - 11 files changed, 41 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1db4ea..f2d0af44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ Breaking changes - `orm.WithIndex` supports multiple indexer types, - `orm.NewIndex` function was removed, +Breaking changes + +- `x/username`: rollback of registration change introduced in 0.23.0. When + registering a token, do not allow to explicitly specify the new token owner. + ## 0.23.0 diff --git a/cmd/bnscli/clitests/register_username.test b/cmd/bnscli/clitests/register_username.test index 07b2a74d..56f536c2 100644 --- a/cmd/bnscli/clitests/register_username.test +++ b/cmd/bnscli/clitests/register_username.test @@ -5,7 +5,6 @@ set -e bnscli register-username \ -name alice \ -bc fairycoin \ - -owner 92066456B2BE7F1934624087D98C203A87F7752C \ -addr 46722031342e204a756e2031303a35363a3337204345535420323031390a \ | bnscli view diff --git a/cmd/bnscli/clitests/register_username.test.gold b/cmd/bnscli/clitests/register_username.test.gold index 1c851341..84d47cc4 100644 --- a/cmd/bnscli/clitests/register_username.test.gold +++ b/cmd/bnscli/clitests/register_username.test.gold @@ -10,8 +10,7 @@ "blockchain_id": "fairycoin", "address": "46722031342e204a756e2031303a35363a3337204345535420323031390a" } - ], - "owner": "92066456B2BE7F1934624087D98C203A87F7752C" + ] } } } diff --git a/cmd/bnscli/cmd_username.go b/cmd/bnscli/cmd_username.go index 583f61a6..45f9c08c 100644 --- a/cmd/bnscli/cmd_username.go +++ b/cmd/bnscli/cmd_username.go @@ -24,7 +24,6 @@ Create a transaction for registering a username. } var ( nameFl = fl.String("name", "", "Name part of the username. For example 'alice'") - ownerFl = flAddress(fl, "owner", "", "An address that the newly registered token will belong to. Transaction does not have to be signed by this address.") namespaceFl = fl.String("ns", "iov", "Namespace (domain) part of the username. For example 'iov'") blockchainFl = fl.String("bc", "", "Blockchain network ID.") addressFl = fl.String("addr", "", "String representation of the blochain address on this network.") @@ -47,7 +46,6 @@ Create a transaction for registering a username. Metadata: &weave.Metadata{Schema: 1}, Username: *nameFl + "*" + *namespaceFl, Targets: targets, - Owner: *ownerFl, } if err := msg.Validate(); err != nil { return fmt.Errorf("given data produce an invalid message: %s", err) diff --git a/cmd/bnsd/x/username/codec.pb.go b/cmd/bnsd/x/username/codec.pb.go index ffd6ea5f..fc4b32de 100644 --- a/cmd/bnsd/x/username/codec.pb.go +++ b/cmd/bnsd/x/username/codec.pb.go @@ -170,8 +170,6 @@ type RegisterTokenMsg struct { Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // Targets is a blockchain address list that this token should point to. Targets []BlockchainAddress `protobuf:"bytes,3,rep,name=targets,proto3" json:"targets"` - // Owner is the address that the newly created token will belong to. - Owner github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=owner,proto3,casttype=github.com/iov-one/weave.Address" json:"owner,omitempty"` } func (m *RegisterTokenMsg) Reset() { *m = RegisterTokenMsg{} } @@ -228,13 +226,6 @@ func (m *RegisterTokenMsg) GetTargets() []BlockchainAddress { return nil } -func (m *RegisterTokenMsg) GetOwner() github_com_iov_one_weave.Address { - if m != nil { - return m.Owner - } - return nil -} - // TransferTokenMsg is a request to transfer an ownership of a token. The // mesage must be signed by the current token owner. Acceptance of the new // owner is not required in order to succeed. @@ -509,38 +500,38 @@ func init() { func init() { proto.RegisterFile("cmd/bnsd/x/username/codec.proto", fileDescriptor_5d21e3852038e86f) } var fileDescriptor_5d21e3852038e86f = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xce, 0x35, 0x0d, 0x4d, 0xde, 0xa4, 0x22, 0x35, 0x05, 0xac, 0x20, 0x39, 0x51, 0xc4, 0x10, - 0x09, 0xd5, 0x46, 0x41, 0x2c, 0x30, 0xd5, 0x65, 0xa9, 0x44, 0x41, 0xb2, 0xd2, 0x39, 0x3a, 0xfb, - 0xde, 0x3a, 0x56, 0x93, 0xbb, 0xc8, 0xbe, 0xc4, 0xfc, 0x0c, 0x7e, 0x01, 0x13, 0x2b, 0xff, 0xa3, - 0x63, 0x07, 0x06, 0xc4, 0x10, 0xa1, 0xe4, 0x5f, 0x30, 0x21, 0x9f, 0x3f, 0xd2, 0xc0, 0x64, 0x04, - 0xdb, 0xdd, 0xfb, 0xf1, 0xdc, 0xf3, 0x91, 0x18, 0xba, 0xde, 0x8c, 0x59, 0x2e, 0x8f, 0x98, 0xf5, - 0xc1, 0x5a, 0x44, 0x18, 0x72, 0x3a, 0x43, 0xcb, 0x13, 0x0c, 0x3d, 0x73, 0x1e, 0x0a, 0x29, 0xb4, - 0x7a, 0x5e, 0xed, 0x34, 0xef, 0x94, 0x3b, 0xc7, 0xbe, 0xf0, 0x85, 0x3a, 0x5a, 0xc9, 0x29, 0xad, - 0xf6, 0xbf, 0x10, 0xa8, 0x8d, 0xc4, 0x35, 0x72, 0xed, 0x19, 0xd4, 0x67, 0x28, 0x29, 0xa3, 0x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 0xf1, 0xb8, 0x7c, 0xb4, 0x75, 0x8e, 0xf1, 0x7b, 0x45, 0xf0, 0x33, - 0x81, 0x87, 0x67, 0x13, 0xca, 0x7d, 0x54, 0xf4, 0x46, 0xa9, 0xe6, 0x7f, 0xca, 0xd2, 0x86, 0x66, - 0xc2, 0xb2, 0x74, 0x00, 0xc0, 0x31, 0xce, 0xf8, 0xf4, 0xbf, 0x13, 0x38, 0x3c, 0x13, 0xfc, 0x2a, - 0xf0, 0x17, 0x21, 0x95, 0x81, 0x28, 0xf9, 0xe7, 0x29, 0x22, 0xdc, 0x2b, 0x1d, 0xa1, 0x66, 0xc2, - 0x83, 0x25, 0x9d, 0x06, 0x6c, 0x9c, 0x13, 0x1e, 0x2b, 0x95, 0x55, 0xa5, 0xf2, 0x48, 0xb5, 0x2e, - 0xb3, 0xce, 0xbb, 0x44, 0xee, 0x73, 0x38, 0xfe, 0x6d, 0x7e, 0x4a, 0x5d, 0x9c, 0xaa, 0x5f, 0x4f, - 0xc3, 0xd1, 0x76, 0x16, 0xde, 0x26, 0x9d, 0xbe, 0x84, 0x47, 0x97, 0x73, 0x46, 0x25, 0xee, 0x28, - 0x2c, 0x9d, 0xc1, 0x09, 0xd4, 0xe6, 0x54, 0x7a, 0x13, 0x25, 0xb2, 0x39, 0x7c, 0xbc, 0x75, 0x78, - 0x07, 0xd7, 0x49, 0xa7, 0x6c, 0xfd, 0x66, 0x6d, 0x90, 0xdb, 0xb5, 0x41, 0x7e, 0xac, 0x0d, 0xf2, - 0x71, 0x63, 0x54, 0x6e, 0x37, 0x46, 0xe5, 0xdb, 0xc6, 0xa8, 0xb8, 0xf7, 0xd4, 0x87, 0xea, 0xc5, - 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x0d, 0x73, 0x73, 0xf8, 0x04, 0x00, 0x00, + // 492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 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, 0xab, 0xa5, 0xdf, 0xb0, 0x66, 0xc1, 0xa3, + 0x25, 0x9d, 0x06, 0x6c, 0x94, 0x0b, 0x1e, 0x29, 0x97, 0x35, 0xe5, 0xf2, 0x48, 0x1d, 0x5d, 0x66, + 0x27, 0x1f, 0x12, 0xbb, 0x2f, 0xe1, 0xf8, 0xaf, 0xfe, 0x29, 0x1d, 0xe3, 0x54, 0xdf, 0x53, 0x00, + 0x6d, 0x07, 0xf0, 0x3e, 0x39, 0x31, 0x25, 0x3c, 0xb9, 0x9c, 0x33, 0x2a, 0x71, 0xc7, 0x61, 0xe9, + 0x19, 0x9c, 0x40, 0x7d, 0x4e, 0xa5, 0x37, 0x51, 0x26, 0x9b, 0x83, 0xa7, 0xdb, 0x84, 0x77, 0x78, + 0xdd, 0xb4, 0xcb, 0xd1, 0x6f, 0xd6, 0x06, 0xb9, 0x5d, 0x1b, 0xe4, 0xd7, 0xda, 0x20, 0x9f, 0x37, + 0x46, 0xe5, 0x76, 0x63, 0x54, 0x7e, 0x6c, 0x8c, 0xca, 0xf8, 0x81, 0xfa, 0xd9, 0xbc, 0xfa, 0x13, + 0x00, 0x00, 0xff, 0xff, 0x48, 0xb8, 0x85, 0xc2, 0xbc, 0x04, 0x00, 0x00, } func (m *Token) Marshal() (dAtA []byte, err error) { @@ -662,12 +653,6 @@ func (m *RegisterTokenMsg) MarshalTo(dAtA []byte) (int, error) { i += n } } - if len(m.Owner) > 0 { - dAtA[i] = 0x22 - i++ - i = encodeVarintCodec(dAtA, i, uint64(len(m.Owner))) - i += copy(dAtA[i:], m.Owner) - } return i, nil } @@ -910,10 +895,6 @@ func (m *RegisterTokenMsg) Size() (n int) { n += 1 + l + sovCodec(uint64(l)) } } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovCodec(uint64(l)) - } return n } @@ -1421,40 +1402,6 @@ func (m *RegisterTokenMsg) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCodec - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCodec - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCodec - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = append(m.Owner[:0], dAtA[iNdEx:postIndex]...) - if m.Owner == nil { - m.Owner = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCodec(dAtA[iNdEx:]) diff --git a/cmd/bnsd/x/username/codec.proto b/cmd/bnsd/x/username/codec.proto index 5cde34fc..1c382532 100644 --- a/cmd/bnsd/x/username/codec.proto +++ b/cmd/bnsd/x/username/codec.proto @@ -50,8 +50,6 @@ message RegisterTokenMsg { string username = 2; // Targets is a blockchain address list that this token should point to. repeated BlockchainAddress targets = 3 [(gogoproto.nullable) = false]; - // Owner is the address that the newly created token will belong to. - bytes owner = 4 [(gogoproto.casttype) = "github.com/iov-one/weave.Address"]; } // TransferTokenMsg is a request to transfer an ownership of a token. The diff --git a/cmd/bnsd/x/username/handlers.go b/cmd/bnsd/x/username/handlers.go index e2c0bdbd..465f207c 100644 --- a/cmd/bnsd/x/username/handlers.go +++ b/cmd/bnsd/x/username/handlers.go @@ -44,15 +44,9 @@ func (h *registerTokenHandler) Deliver(ctx weave.Context, db weave.KVStore, tx w return nil, err } - var owner weave.Address - if len(msg.Owner) != 0 { - // Permission is not required. - owner = msg.Owner - } else { - owner = x.AnySigner(ctx, h.auth).Address() - if len(owner) == 0 { - return nil, errors.Wrap(errors.ErrUnauthorized, "message must be signed") - } + owner := x.AnySigner(ctx, h.auth).Address() + if len(owner) == 0 { + return nil, errors.Wrap(errors.ErrUnauthorized, "message must be signed") } token := Token{ diff --git a/cmd/bnsd/x/username/msg.go b/cmd/bnsd/x/username/msg.go index b03234e3..ba20bb23 100644 --- a/cmd/bnsd/x/username/msg.go +++ b/cmd/bnsd/x/username/msg.go @@ -35,13 +35,6 @@ func (m *RegisterTokenMsg) Validate() error { // Username should but cannot be validated here. - // Owner field is optional. - if len(m.Owner) != 0 { - if err := m.Owner.Validate(); err != nil { - return errors.Wrap(err, "owner") - } - } - if err := validateTargets(m.Targets); err != nil { return errors.Wrap(err, "targets") } diff --git a/docs/proto/index.html b/docs/proto/index.html index ea90adb1..036bf456 100644 --- a/docs/proto/index.html +++ b/docs/proto/index.html @@ -2979,13 +2979,6 @@

RegisterTokenMsg

Targets is a blockchain address list that this token should point to.

- - owner - bytes - -

Owner is the address that the newly created token will belong to.

- - diff --git a/spec/gogo/cmd/bnsd/x/username/codec.proto b/spec/gogo/cmd/bnsd/x/username/codec.proto index 5cde34fc..1c382532 100644 --- a/spec/gogo/cmd/bnsd/x/username/codec.proto +++ b/spec/gogo/cmd/bnsd/x/username/codec.proto @@ -50,8 +50,6 @@ message RegisterTokenMsg { string username = 2; // Targets is a blockchain address list that this token should point to. repeated BlockchainAddress targets = 3 [(gogoproto.nullable) = false]; - // Owner is the address that the newly created token will belong to. - bytes owner = 4 [(gogoproto.casttype) = "github.com/iov-one/weave.Address"]; } // TransferTokenMsg is a request to transfer an ownership of a token. The diff --git a/spec/proto/cmd/bnsd/x/username/codec.proto b/spec/proto/cmd/bnsd/x/username/codec.proto index 5a398708..f80c0597 100644 --- a/spec/proto/cmd/bnsd/x/username/codec.proto +++ b/spec/proto/cmd/bnsd/x/username/codec.proto @@ -49,8 +49,6 @@ message RegisterTokenMsg { string username = 2; // Targets is a blockchain address list that this token should point to. repeated BlockchainAddress targets = 3 ; - // Owner is the address that the newly created token will belong to. - bytes owner = 4 ; } // TransferTokenMsg is a request to transfer an ownership of a token. The