From dcf8e2936beeba19c70d7d6d1c0efcf4465d7571 Mon Sep 17 00:00:00 2001 From: Alexander Leitner Date: Mon, 8 Jul 2019 13:07:30 -0400 Subject: [PATCH] Update vouchers to use time.Time instead of timestamp (#2478) * Update vouchers to use time.Time instead of timestamp --- pkg/pb/vouchers.pb.go | 70 ++++++++++++++------------- pkg/pb/vouchers.proto | 2 +- proto.lock | 12 ++++- satellite/vouchers/endpoint.go | 11 +---- storagenode/storagenodedb/vouchers.go | 10 ++-- storagenode/vouchers/verification.go | 8 +-- storagenode/vouchers/vouchers_test.go | 46 +++++------------- 7 files changed, 65 insertions(+), 94 deletions(-) diff --git a/pkg/pb/vouchers.pb.go b/pkg/pb/vouchers.pb.go index 7c32354f1..94341d481 100644 --- a/pkg/pb/vouchers.pb.go +++ b/pkg/pb/vouchers.pb.go @@ -8,15 +8,17 @@ import ( fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - timestamp "github.com/golang/protobuf/ptypes/timestamp" + _ "github.com/golang/protobuf/ptypes/timestamp" grpc "google.golang.org/grpc" math "math" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -54,13 +56,13 @@ func (VoucherResponse_Status) EnumDescriptor() ([]byte, []int) { // Voucher is a signed message verifying that a node has been vetted by a particular satellite type Voucher struct { - SatelliteId NodeID `protobuf:"bytes,1,opt,name=satellite_id,json=satelliteId,proto3,customtype=NodeID" json:"satellite_id"` - StorageNodeId NodeID `protobuf:"bytes,2,opt,name=storage_node_id,json=storageNodeId,proto3,customtype=NodeID" json:"storage_node_id"` - Expiration *timestamp.Timestamp `protobuf:"bytes,3,opt,name=expiration,proto3" json:"expiration,omitempty"` - SatelliteSignature []byte `protobuf:"bytes,4,opt,name=satellite_signature,json=satelliteSignature,proto3" json:"satellite_signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + SatelliteId NodeID `protobuf:"bytes,1,opt,name=satellite_id,json=satelliteId,proto3,customtype=NodeID" json:"satellite_id"` + StorageNodeId NodeID `protobuf:"bytes,2,opt,name=storage_node_id,json=storageNodeId,proto3,customtype=NodeID" json:"storage_node_id"` + Expiration time.Time `protobuf:"bytes,3,opt,name=expiration,proto3,stdtime" json:"expiration"` + SatelliteSignature []byte `protobuf:"bytes,4,opt,name=satellite_signature,json=satelliteSignature,proto3" json:"satellite_signature,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Voucher) Reset() { *m = Voucher{} } @@ -87,11 +89,11 @@ func (m *Voucher) XXX_DiscardUnknown() { var xxx_messageInfo_Voucher proto.InternalMessageInfo -func (m *Voucher) GetExpiration() *timestamp.Timestamp { +func (m *Voucher) GetExpiration() time.Time { if m != nil { return m.Expiration } - return nil + return time.Time{} } func (m *Voucher) GetSatelliteSignature() []byte { @@ -187,30 +189,30 @@ func init() { func init() { proto.RegisterFile("vouchers.proto", fileDescriptor_3659b9a115b8060d) } var fileDescriptor_3659b9a115b8060d = []byte{ - // 358 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x4f, 0x4b, 0xf3, 0x40, - 0x10, 0xc6, 0x9b, 0xbe, 0x25, 0x29, 0x93, 0xbe, 0x69, 0x5d, 0x2f, 0x31, 0x97, 0x96, 0x9c, 0x0a, - 0x42, 0x4a, 0x23, 0x88, 0x78, 0xb2, 0x7f, 0x72, 0x88, 0x94, 0x22, 0x69, 0xe9, 0xc1, 0x4b, 0x49, - 0xcd, 0x1a, 0x03, 0x6d, 0x36, 0x66, 0x37, 0xe2, 0x77, 0xf2, 0x8b, 0xf8, 0x19, 0x3c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xce, 0x41, 0x13, 0x2f, 0xe4, 0xc1, 0x75, 0xf7, 0xc4, 0xa9, 0x5e, - 0x2c, 0x59, 0x49, 0xa0, 0x2b, 0x50, 0x29, 0x0b, 0x59, 0x41, 0x79, 0x5c, 0xc3, 0xed, 0xfd, 0x66, - 0xc5, 0x5e, 0x67, 0xc1, 0xb9, 0x40, 0xf0, 0xf6, 0x10, 0xd4, 0xb2, 0x82, 0x74, 0xd0, 0xfc, 0xf9, - 0x6a, 0x34, 0xf3, 0xa7, 0x9d, 0x1a, 0x6a, 0x41, 0x73, 0x34, 0x99, 0x78, 0x77, 0x4b, 0x6f, 0xda, - 0x51, 0x0e, 0x2a, 0xf0, 0x6e, 0xbd, 0xc9, 0x41, 0xd5, 0xdd, 0x19, 0x34, 0xc5, 0x52, 0x8a, 0x6e, - 0x40, 0x13, 0x21, 0x90, 0x79, 0xe4, 0x26, 0xef, 0x58, 0x67, 0x7f, 0xba, 0xb1, 0x6b, 0xe3, 0xc6, - 0x7d, 0x3d, 0xdb, 0x6c, 0x54, 0xfe, 0xe4, 0x8b, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x98, 0xd8, - 0xc2, 0xb8, 0x47, 0x02, 0x00, 0x00, + // 368 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xcf, 0x4e, 0xab, 0x40, + 0x14, 0xc6, 0x4b, 0x6f, 0x03, 0xe4, 0xd0, 0x4b, 0x7b, 0xe7, 0x6e, 0x90, 0x0d, 0x0d, 0xab, 0x26, + 0x26, 0x34, 0xc5, 0xc4, 0xb8, 0xb4, 0x2d, 0x2c, 0x30, 0x4d, 0x63, 0x68, 0xd3, 0x85, 0x9b, 0x86, + 0xca, 0x88, 0x24, 0x2d, 0x83, 0xcc, 0x60, 0x7c, 0x0c, 0xdf, 0xc3, 0x17, 0xf1, 0x19, 0x5c, 0xd4, + 0x07, 0xf0, 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9e, 0x68, 0x4a, 0x12, 0x8a, 0xd1, 0x29, + 0x48, 0x55, 0x99, 0xbc, 0x02, 0xc5, 0xfe, 0x67, 0x35, 0x65, 0xd7, 0x6c, 0x4d, 0xa0, 0x0b, 0x10, + 0x29, 0x0b, 0x58, 0x4e, 0xf9, 0xe1, 0xaa, 0x3d, 0xf8, 0xc9, 0x56, 0x7b, 0xad, 0x25, 0xe7, 0xfc, + 0x8a, 0x37, 0xc7, 0x20, 0x96, 0x2f, 0x48, 0x01, 0xc9, 0x5b, 0xac, 0x27, 0x73, 0xcf, 0xe9, 0xb7, + 0x50, 0x17, 0xe4, 0xc9, 0x6c, 0xe6, 0x5e, 0xaf, 0x5c, 0xa7, 0x2f, 0x14, 0xca, 0x77, 0xaf, 0xdc, + 0x59, 0xa1, 0xda, 0xf6, 0x1c, 0xe4, 0x6a, 0x29, 0x45, 0x97, 0x20, 0x55, 0x47, 0x20, 0xed, 0xc8, + 0x9f, 0x7c, 0xa2, 0x9f, 0xfc, 0x9a, 0xc6, 0x6c, 0x4d, 0x3b, 0x37, 0xed, 0x74, 0xbb, 0x15, 0x79, + 0xdd, 0x67, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x1f, 0x45, 0xc2, 0x51, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/pkg/pb/vouchers.proto b/pkg/pb/vouchers.proto index d25a3e497..e93d786da 100644 --- a/pkg/pb/vouchers.proto +++ b/pkg/pb/vouchers.proto @@ -14,7 +14,7 @@ message Voucher { bytes satellite_id = 1 [(gogoproto.customtype) = "NodeID", (gogoproto.nullable) = false]; bytes storage_node_id = 2 [(gogoproto.customtype) = "NodeID", (gogoproto.nullable) = false]; - google.protobuf.Timestamp expiration = 3; + google.protobuf.Timestamp expiration = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; bytes satellite_signature = 4; } diff --git a/proto.lock b/proto.lock index b669d18f3..0dbdcfd3f 100644 --- a/proto.lock +++ b/proto.lock @@ -3748,7 +3748,17 @@ { "id": 3, "name": "expiration", - "type": "google.protobuf.Timestamp" + "type": "google.protobuf.Timestamp", + "options": [ + { + "name": "(gogoproto.stdtime)", + "value": "true" + }, + { + "name": "(gogoproto.nullable)", + "value": "false" + } + ] }, { "id": 4, diff --git a/satellite/vouchers/endpoint.go b/satellite/vouchers/endpoint.go index 6ccb91638..adab10695 100644 --- a/satellite/vouchers/endpoint.go +++ b/satellite/vouchers/endpoint.go @@ -7,10 +7,9 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/zeebo/errs" "go.uber.org/zap" - monkit "gopkg.in/spacemonkeygo/monkit.v2" + "gopkg.in/spacemonkeygo/monkit.v2" "storj.io/storj/pkg/auth/signing" "storj.io/storj/pkg/identity" @@ -68,16 +67,10 @@ func (endpoint *Endpoint) Request(ctx context.Context, req *pb.VoucherRequest) ( return &pb.VoucherResponse{Status: pb.VoucherResponse_REJECTED}, nil } - expirationTime := time.Now().UTC().Add(endpoint.expiration) - expiration, err := ptypes.TimestampProto(expirationTime) - if err != nil { - return nil, Error.Wrap(err) - } - unsigned := &pb.Voucher{ SatelliteId: endpoint.satellite.ID(), StorageNodeId: peer.ID, - Expiration: expiration, + Expiration: time.Now().Add(endpoint.expiration), } voucher, err := signing.SignVoucher(ctx, endpoint.satellite, unsigned) diff --git a/storagenode/storagenodedb/vouchers.go b/storagenode/storagenodedb/vouchers.go index bbfe53589..a5015cfbb 100644 --- a/storagenode/storagenodedb/vouchers.go +++ b/storagenode/storagenodedb/vouchers.go @@ -10,7 +10,6 @@ import ( "time" "github.com/gogo/protobuf/proto" - "github.com/golang/protobuf/ptypes" "storj.io/storj/pkg/pb" "storj.io/storj/pkg/storj" @@ -30,10 +29,7 @@ func (db *vouchersdb) Put(ctx context.Context, voucher *pb.Voucher) (err error) defer mon.Task()(&ctx)(&err) id := voucher.SatelliteId - expiration, err := ptypes.Timestamp(voucher.GetExpiration()) - if err != nil { - return ErrInfo.Wrap(err) - } + expiration := voucher.Expiration.UTC() voucherSerialized, err := proto.Marshal(voucher) if err != nil { @@ -58,7 +54,7 @@ func (db *vouchersdb) Put(ctx context.Context, voucher *pb.Voucher) (err error) func (db *vouchersdb) NeedVoucher(ctx context.Context, satelliteID storj.NodeID, expirationBuffer time.Duration) (need bool, err error) { defer mon.Task()(&ctx)(&err) - expiresBefore := time.Now().UTC().Add(expirationBuffer) + expiresBefore := time.Now().Add(expirationBuffer) // query returns row if voucher is good. If not, it is either expiring or does not exist row := db.db.QueryRow(` @@ -91,7 +87,7 @@ func (db *vouchersdb) GetValid(ctx context.Context, satellites []storj.NodeID) ( args = append(args, id) } - args = append(args, time.Now().UTC()) + args = append(args, time.Now()) row := db.db.QueryRow(db.InfoDB.Rebind(` SELECT voucher_serialized diff --git a/storagenode/vouchers/verification.go b/storagenode/vouchers/verification.go index 1baa1b96a..7390b9356 100644 --- a/storagenode/vouchers/verification.go +++ b/storagenode/vouchers/verification.go @@ -7,7 +7,6 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/zeebo/errs" "storj.io/storj/internal/errs2" @@ -33,12 +32,7 @@ func (service *Service) VerifyVoucher(ctx context.Context, satellite storj.NodeI return ErrVerify.New("Satellite ID does not match expected: (%v) (%v)", voucher.SatelliteId, satellite) } - expiration, err := ptypes.Timestamp(voucher.GetExpiration()) - if err != nil { - return err - } - - if expiration.Before(time.Now().UTC()) { + if voucher.Expiration.Before(time.Now()) { return ErrVerify.New("Voucher is already expired") } diff --git a/storagenode/vouchers/vouchers_test.go b/storagenode/vouchers/vouchers_test.go index 86fbd344a..b3f74dc71 100644 --- a/storagenode/vouchers/vouchers_test.go +++ b/storagenode/vouchers/vouchers_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/golang/protobuf/ptypes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -36,13 +35,10 @@ func TestVouchersDB(t *testing.T) { satellite := testidentity.MustPregeneratedSignedIdentity(0, storj.LatestIDVersion()) storagenode := testidentity.MustPregeneratedSignedIdentity(1, storj.LatestIDVersion()) - expiration, err := ptypes.TimestampProto(time.Now().UTC().Add(24 * time.Hour)) - require.NoError(t, err) - voucher := &pb.Voucher{ SatelliteId: satellite.ID, StorageNodeId: storagenode.ID, - Expiration: expiration, + Expiration: time.Now().Add(24 * time.Hour), } // Test GetValid returns nil result and nil error when result is not found @@ -59,13 +55,7 @@ func TestVouchersDB(t *testing.T) { require.NoError(t, err) require.Equal(t, voucher.SatelliteId, result.SatelliteId) require.Equal(t, voucher.StorageNodeId, result.StorageNodeId) - - expectedTime, err := ptypes.Timestamp(voucher.GetExpiration()) - require.NoError(t, err) - actualTime, err := ptypes.Timestamp(result.GetExpiration()) - require.NoError(t, err) - - require.Equal(t, expectedTime, actualTime) + require.True(t, voucher.Expiration.Equal(result.Expiration)) // test NeedVoucher returns true if voucher expiration falls within expirationBuffer period // voucher expiration is 24 hours from now @@ -87,8 +77,7 @@ func TestVouchersDB(t *testing.T) { require.False(t, need) // Test Put with duplicate satellite id updates voucher info - voucher.Expiration, err = ptypes.TimestampProto(time.Now().UTC().Add(48 * time.Hour)) - require.NoError(t, err) + voucher.Expiration = time.Now().Add(48 * time.Hour) err = vdb.Put(ctx, voucher) require.NoError(t, err) @@ -96,12 +85,7 @@ func TestVouchersDB(t *testing.T) { result, err = vdb.GetValid(ctx, []storj.NodeID{satellite.ID}) require.NoError(t, err) - expectedTime, err = ptypes.Timestamp(voucher.GetExpiration()) - require.NoError(t, err) - actualTime, err = ptypes.Timestamp(result.GetExpiration()) - require.NoError(t, err) - - require.Equal(t, expectedTime, actualTime) + require.True(t, voucher.Expiration.Equal(result.Expiration)) }) } @@ -173,12 +157,7 @@ func TestVouchersService(t *testing.T) { require.NoError(t, err) // assert old expiration is before new expiration - oldExpiration, err := ptypes.Timestamp(oldVoucher.GetExpiration()) - require.NoError(t, err) - newExpiration, err := ptypes.Timestamp(newVoucher.GetExpiration()) - require.NoError(t, err) - - assert.True(t, oldExpiration.Before(newExpiration)) + assert.True(t, oldVoucher.Expiration.Before(newVoucher.Expiration)) }) } @@ -203,44 +182,41 @@ func TestVerifyVoucher(t *testing.T) { { // passing satelliteID: satellite0.ID(), storagenodeID: storagenode.ID(), - expiration: time.Now().UTC().Add(24 * time.Hour), + expiration: time.Now().Add(24 * time.Hour), invalidSignature: false, err: "", }, { // incorrect satellite ID satelliteID: teststorj.NodeIDFromString("satellite"), storagenodeID: storagenode.ID(), - expiration: time.Now().UTC().Add(24 * time.Hour), + expiration: time.Now().Add(24 * time.Hour), invalidSignature: false, err: fmt.Sprintf("verification: Satellite ID does not match expected: (%v) (%v)", teststorj.NodeIDFromString("satellite"), satellite0.ID()), }, { // incorrect storagenode ID satelliteID: satellite0.ID(), storagenodeID: teststorj.NodeIDFromString("storagenode"), - expiration: time.Now().UTC().Add(24 * time.Hour), + expiration: time.Now().Add(24 * time.Hour), invalidSignature: false, err: fmt.Sprintf("verification: Storage node ID does not match expected: (%v) (%v)", teststorj.NodeIDFromString("storagenode"), storagenode.ID()), }, { // expired voucher satelliteID: satellite0.ID(), storagenodeID: storagenode.ID(), - expiration: time.Now().UTC().Add(-24 * time.Hour), + expiration: time.Now().Add(-24 * time.Hour), invalidSignature: false, err: "verification: Voucher is already expired", }, { // invalid signature satelliteID: satellite0.ID(), storagenodeID: storagenode.ID(), - expiration: time.Now().UTC().Add(24 * time.Hour), + expiration: time.Now().Add(24 * time.Hour), invalidSignature: true, err: fmt.Sprintf("verification: invalid voucher signature: signature verification error: signature is not valid"), }, } for _, tt := range tests { - expiration, err := ptypes.TimestampProto(tt.expiration) - require.NoError(t, err) - var signer signing.Signer if tt.invalidSignature { signer = signing.SignerFromFullIdentity(satellite1.Identity) @@ -251,7 +227,7 @@ func TestVerifyVoucher(t *testing.T) { voucher, err := signing.SignVoucher(ctx, signer, &pb.Voucher{ SatelliteId: tt.satelliteID, StorageNodeId: tt.storagenodeID, - Expiration: expiration, + Expiration: tt.expiration, }) require.NoError(t, err)