Skip to content

Commit 1e3565e

Browse files
jannikluhnulope
authored andcommitted
Fix protobuf field naming
Field names should be snake_case, but we're using camelCase: https://protobuf.dev/programming-guides/style/#message-field-names For most fields, the change is seamless as the Go code generator generates the same Go struct member names for the message field names. Only for the fields ending on `ID` this doesn't work and requires code changes in lots of places. Note that the wire format is not affected as it is independent of field names.
1 parent c374168 commit 1e3565e

23 files changed

+241
-240
lines changed

rolling-shutter/gnosisaccessnode/decryptionkeyshandler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ func (handler *DecryptionKeysHandler) ValidateMessage(_ context.Context, msg p2p
4444
}
4545

4646
func (handler *DecryptionKeysHandler) validateCommonFields(keys *p2pmsg.DecryptionKeys) (pubsub.ValidationResult, error) {
47-
if keys.InstanceID != handler.config.InstanceID {
47+
if keys.InstanceId != handler.config.InstanceID {
4848
return pubsub.ValidationReject,
49-
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.InstanceID, keys.GetInstanceID())
49+
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.InstanceID, keys.GetInstanceId())
5050
}
5151
if keys.Eon > math.MaxInt64 {
5252
return pubsub.ValidationReject, errors.Errorf("eon %d overflows int64", keys.Eon)

rolling-shutter/keyper/database/extend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (q *Queries) InsertDecryptionKeySharesMsg(ctx context.Context, msg *p2pmsg.
5151
for _, share := range msg.GetShares() {
5252
err := q.InsertDecryptionKeyShare(ctx, InsertDecryptionKeyShareParams{
5353
Eon: int64(msg.Eon),
54-
EpochID: share.EpochID,
54+
EpochID: share.EpochId,
5555
KeyperIndex: int64(msg.KeyperIndex),
5656
DecryptionKeyShare: share.Share,
5757
})

rolling-shutter/keyper/epochkghandler/benchmark_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func prepareKeysBenchmark(ctx context.Context, b *testing.B, dbpool *pgxpool.Poo
5959
decryptionKeys = append(decryptionKeys, key)
6060
}
6161
msg := &p2pmsg.DecryptionKeys{
62-
InstanceID: config.GetInstanceID(),
62+
InstanceId: config.GetInstanceID(),
6363
Eon: 1,
6464
Keys: decryptionKeys,
6565
}
@@ -85,13 +85,13 @@ func prepareKeySharesBenchmark(
8585
keyperIndex := 0
8686
for _, identityPreimage := range identityPreimages {
8787
share := &p2pmsg.KeyShare{
88-
EpochID: identityPreimage.Bytes(),
88+
EpochId: identityPreimage.Bytes(),
8989
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
9090
}
9191
shares = append(shares, share)
9292
}
9393
msg := &p2pmsg.DecryptionKeyShares{
94-
InstanceID: config.GetInstanceID(),
94+
InstanceId: config.GetInstanceID(),
9595
Eon: 1,
9696
KeyperIndex: uint64(keyperIndex),
9797
Shares: shares,
@@ -107,13 +107,13 @@ func prepareKeySharesBenchmark(
107107
shares := []*p2pmsg.KeyShare{}
108108
for _, identityPreimage := range identityPreimages {
109109
share := &p2pmsg.KeyShare{
110-
EpochID: identityPreimage.Bytes(),
110+
EpochId: identityPreimage.Bytes(),
111111
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
112112
}
113113
shares = append(shares, share)
114114
}
115115
msg := &p2pmsg.DecryptionKeyShares{
116-
InstanceID: config.GetInstanceID(),
116+
InstanceId: config.GetInstanceID(),
117117
Eon: 1,
118118
KeyperIndex: uint64(keyperIndex),
119119
Shares: shares,

rolling-shutter/keyper/epochkghandler/eonpublickey.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func (*EonPublicKeyHandler) MessagePrototypes() []p2pmsg.Message {
2525

2626
func (handler *EonPublicKeyHandler) ValidateMessage(_ context.Context, msg p2pmsg.Message) (pubsub.ValidationResult, error) {
2727
key := msg.(*p2pmsg.EonPublicKey)
28-
if key.GetInstanceID() != handler.config.GetInstanceID() {
28+
if key.GetInstanceId() != handler.config.GetInstanceID() {
2929
return pubsub.ValidationReject,
30-
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), key.GetInstanceID())
30+
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), key.GetInstanceId())
3131
}
3232
return pubsub.ValidationAccept, nil
3333
}

rolling-shutter/keyper/epochkghandler/key.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func (*DecryptionKeyHandler) MessagePrototypes() []p2pmsg.Message {
3535

3636
func (handler *DecryptionKeyHandler) ValidateMessage(ctx context.Context, msg p2pmsg.Message) (pubsub.ValidationResult, error) {
3737
decryptionKeys := msg.(*p2pmsg.DecryptionKeys)
38-
if decryptionKeys.GetInstanceID() != handler.config.GetInstanceID() {
38+
if decryptionKeys.GetInstanceId() != handler.config.GetInstanceID() {
3939
return pubsub.ValidationReject,
40-
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), decryptionKeys.GetInstanceID())
40+
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), decryptionKeys.GetInstanceId())
4141
}
4242

4343
eon, err := medley.Uint64ToInt64Safe(decryptionKeys.Eon)

rolling-shutter/keyper/epochkghandler/key_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestHandleDecryptionKeyIntegration(t *testing.T) {
5757
decryptionKeys = append(decryptionKeys, key)
5858
}
5959
msgs := p2ptest.MustHandleMessage(t, handler, ctx, &p2pmsg.DecryptionKeys{
60-
InstanceID: config.GetInstanceID(),
60+
InstanceId: config.GetInstanceID(),
6161
Eon: keyperConfigIndex,
6262
Keys: decryptionKeys,
6363
})
@@ -102,7 +102,7 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
102102
name: "valid decryption key",
103103
validationResult: pubsub.ValidationAccept,
104104
msg: &p2pmsg.DecryptionKeys{
105-
InstanceID: config.GetInstanceID(),
105+
InstanceId: config.GetInstanceID(),
106106
Eon: keyperConfigIndex,
107107
Keys: []*p2pmsg.Key{
108108
{
@@ -116,7 +116,7 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
116116
name: "invalid decryption key wrong epoch",
117117
validationResult: pubsub.ValidationReject,
118118
msg: &p2pmsg.DecryptionKeys{
119-
InstanceID: config.GetInstanceID(),
119+
InstanceId: config.GetInstanceID(),
120120
Eon: keyperConfigIndex,
121121
Keys: []*p2pmsg.Key{
122122
{
@@ -130,7 +130,7 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
130130
name: "invalid decryption key wrong instance ID",
131131
validationResult: pubsub.ValidationReject,
132132
msg: &p2pmsg.DecryptionKeys{
133-
InstanceID: config.GetInstanceID() + 1,
133+
InstanceId: config.GetInstanceID() + 1,
134134
Eon: keyperConfigIndex,
135135
Keys: []*p2pmsg.Key{
136136
{
@@ -144,7 +144,7 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
144144
name: "invalid decryption key empty",
145145
validationResult: pubsub.ValidationReject,
146146
msg: &p2pmsg.DecryptionKeys{
147-
InstanceID: config.GetInstanceID(),
147+
InstanceId: config.GetInstanceID(),
148148
Eon: keyperConfigIndex,
149149
Keys: []*p2pmsg.Key{},
150150
},
@@ -153,7 +153,7 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
153153
name: "invalid decryption key unordered",
154154
validationResult: pubsub.ValidationReject,
155155
msg: &p2pmsg.DecryptionKeys{
156-
InstanceID: config.GetInstanceID(),
156+
InstanceId: config.GetInstanceID(),
157157
Eon: keyperConfigIndex,
158158
Keys: []*p2pmsg.Key{
159159
{

rolling-shutter/keyper/epochkghandler/keyshare.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ func (*DecryptionKeyShareHandler) MessagePrototypes() []p2pmsg.Message {
3838

3939
func (handler *DecryptionKeyShareHandler) ValidateMessage(ctx context.Context, msg p2pmsg.Message) (pubsub.ValidationResult, error) {
4040
keyShare := msg.(*p2pmsg.DecryptionKeyShares)
41-
if keyShare.GetInstanceID() != handler.config.GetInstanceID() {
41+
if keyShare.GetInstanceId() != handler.config.GetInstanceID() {
4242
return pubsub.ValidationReject,
43-
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), keyShare.GetInstanceID())
43+
errors.Errorf("instance ID mismatch (want=%d, have=%d)", handler.config.GetInstanceID(), keyShare.GetInstanceId())
4444
}
4545
if keyShare.Eon > math.MaxInt64 {
4646
return pubsub.ValidationReject, errors.Errorf("eon %d overflows int64", keyShare.Eon)
@@ -95,12 +95,12 @@ func checkKeyShares(keyShare *p2pmsg.DecryptionKeyShares, pureDKGResult *puredkg
9595
if !shcrypto.VerifyEpochSecretKeyShare(
9696
epochSecretKeyShare,
9797
pureDKGResult.PublicKeyShares[keyShare.KeyperIndex],
98-
shcrypto.ComputeEpochID(share.EpochID),
98+
shcrypto.ComputeEpochID(share.EpochId),
9999
) {
100100
return pubsub.ValidationReject, errors.Errorf("cannot verify secret key share")
101101
}
102102

103-
if i > 0 && bytes.Compare(share.EpochID, shares[i-1].EpochID) < 0 {
103+
if i > 0 && bytes.Compare(share.EpochId, shares[i-1].EpochId) < 0 {
104104
return pubsub.ValidationReject, errors.Errorf("keyshares not ordered")
105105
}
106106
}
@@ -124,7 +124,7 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
124124
}
125125
allKeysExist := true
126126
for _, share := range msg.GetShares() {
127-
identityPreimage := identitypreimage.IdentityPreimage(share.EpochID)
127+
identityPreimage := identitypreimage.IdentityPreimage(share.EpochId)
128128
keyExists, err := db.ExistsDecryptionKey(ctx, database.ExistsDecryptionKeyParams{
129129
Eon: eon,
130130
EpochID: identityPreimage.Bytes(),
@@ -159,7 +159,7 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
159159
// aggregate epoch secret keys
160160
keys := []*p2pmsg.Key{}
161161
for _, share := range msg.GetShares() {
162-
identityPreimage := identitypreimage.IdentityPreimage(share.EpochID)
162+
identityPreimage := identitypreimage.IdentityPreimage(share.EpochId)
163163

164164
epochKG, err := handler.aggregateDecryptionKeySharesFromDB(
165165
ctx,
@@ -189,7 +189,7 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
189189
})
190190
}
191191
message := &p2pmsg.DecryptionKeys{
192-
InstanceID: handler.config.GetInstanceID(),
192+
InstanceId: handler.config.GetInstanceID(),
193193
Eon: msg.Eon,
194194
Keys: keys,
195195
}

rolling-shutter/keyper/epochkghandler/keyshare_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
4747
shares := []*p2pmsg.KeyShare{}
4848
for _, identityPreimage := range identityPreimages {
4949
share := &p2pmsg.KeyShare{
50-
EpochID: identityPreimage.Bytes(),
50+
EpochId: identityPreimage.Bytes(),
5151
Share: keys.EpochSecretKeyShare(identityPreimage, 0).Marshal(),
5252
}
5353
shares = append(shares, share)
5454
}
5555
msgs := p2ptest.MustHandleMessage(t, handler, ctx, &p2pmsg.DecryptionKeyShares{
56-
InstanceID: config.GetInstanceID(),
56+
InstanceId: config.GetInstanceID(),
5757
Eon: keyperConfigIndex,
5858
KeyperIndex: 0,
5959
Shares: shares,
@@ -65,21 +65,21 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
6565
shares = []*p2pmsg.KeyShare{}
6666
for _, identityPreimage := range identityPreimages {
6767
share := &p2pmsg.KeyShare{
68-
EpochID: identityPreimage.Bytes(),
68+
EpochId: identityPreimage.Bytes(),
6969
Share: keys.EpochSecretKeyShare(identityPreimage, 2).Marshal(),
7070
}
7171
shares = append(shares, share)
7272
}
7373
msgs = p2ptest.MustHandleMessage(t, handler, ctx, &p2pmsg.DecryptionKeyShares{
74-
InstanceID: config.GetInstanceID(),
74+
InstanceId: config.GetInstanceID(),
7575
Eon: keyperConfigIndex,
7676
KeyperIndex: 2,
7777
Shares: shares,
7878
})
7979
assert.Assert(t, len(msgs) == 1)
8080
msg, ok := msgs[0].(*p2pmsg.DecryptionKeys)
8181
assert.Check(t, ok)
82-
assert.Check(t, msg.InstanceID == config.GetInstanceID())
82+
assert.Check(t, msg.InstanceId == config.GetInstanceID())
8383
assert.Check(t, len(msg.Keys) == len(identityPreimages))
8484
for i, key := range msg.Keys {
8585
assert.Check(t, bytes.Equal(key.Identity, identityPreimages[i].Bytes()))
@@ -116,16 +116,16 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
116116
name: "valid decryption key share",
117117
validationResult: pubsub.ValidationAccept,
118118
msg: &p2pmsg.DecryptionKeyShares{
119-
InstanceID: config.GetInstanceID(),
119+
InstanceId: config.GetInstanceID(),
120120
Eon: keyperConfigIndex,
121121
KeyperIndex: keyperIndex,
122122
Shares: []*p2pmsg.KeyShare{
123123
{
124-
EpochID: identityPreimage.Bytes(),
124+
EpochId: identityPreimage.Bytes(),
125125
Share: keyshare,
126126
},
127127
{
128-
EpochID: secondIdentityPreimage.Bytes(),
128+
EpochId: secondIdentityPreimage.Bytes(),
129129
Share: secondKeyshare,
130130
},
131131
},
@@ -135,12 +135,12 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
135135
name: "invalid decryption key share wrong epoch",
136136
validationResult: pubsub.ValidationReject,
137137
msg: &p2pmsg.DecryptionKeyShares{
138-
InstanceID: config.GetInstanceID(),
138+
InstanceId: config.GetInstanceID(),
139139
Eon: keyperConfigIndex,
140140
KeyperIndex: keyperIndex,
141141
Shares: []*p2pmsg.KeyShare{
142142
{
143-
EpochID: wrongIdentityPreimage.Bytes(),
143+
EpochId: wrongIdentityPreimage.Bytes(),
144144
Share: keyshare,
145145
},
146146
},
@@ -150,12 +150,12 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
150150
name: "invalid decryption key share wrong instance ID",
151151
validationResult: pubsub.ValidationReject,
152152
msg: &p2pmsg.DecryptionKeyShares{
153-
InstanceID: config.GetInstanceID() + 1,
153+
InstanceId: config.GetInstanceID() + 1,
154154
Eon: keyperConfigIndex,
155155
KeyperIndex: keyperIndex,
156156
Shares: []*p2pmsg.KeyShare{
157157
{
158-
EpochID: identityPreimage.Bytes(),
158+
EpochId: identityPreimage.Bytes(),
159159
Share: keyshare,
160160
},
161161
},
@@ -165,12 +165,12 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
165165
name: "invalid decryption key share wrong keyper index",
166166
validationResult: pubsub.ValidationReject,
167167
msg: &p2pmsg.DecryptionKeyShares{
168-
InstanceID: config.GetInstanceID(),
168+
InstanceId: config.GetInstanceID(),
169169
Eon: keyperConfigIndex,
170170
KeyperIndex: keyperIndex + 1,
171171
Shares: []*p2pmsg.KeyShare{
172172
{
173-
EpochID: identityPreimage.Bytes(),
173+
EpochId: identityPreimage.Bytes(),
174174
Share: keyshare,
175175
},
176176
},
@@ -180,7 +180,7 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
180180
name: "invalid decryption key share empty",
181181
validationResult: pubsub.ValidationReject,
182182
msg: &p2pmsg.DecryptionKeyShares{
183-
InstanceID: config.GetInstanceID(),
183+
InstanceId: config.GetInstanceID(),
184184
Eon: keyperConfigIndex,
185185
KeyperIndex: keyperIndex,
186186
Shares: []*p2pmsg.KeyShare{},
@@ -190,16 +190,16 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
190190
name: "invalid decryption key share unordered",
191191
validationResult: pubsub.ValidationReject,
192192
msg: &p2pmsg.DecryptionKeyShares{
193-
InstanceID: config.GetInstanceID(),
193+
InstanceId: config.GetInstanceID(),
194194
Eon: keyperConfigIndex,
195195
KeyperIndex: keyperIndex,
196196
Shares: []*p2pmsg.KeyShare{
197197
{
198-
EpochID: secondIdentityPreimage.Bytes(),
198+
EpochId: secondIdentityPreimage.Bytes(),
199199
Share: secondKeyshare,
200200
},
201201
{
202-
EpochID: identityPreimage.Bytes(),
202+
EpochId: identityPreimage.Bytes(),
203203
Share: keyshare,
204204
},
205205
},

rolling-shutter/keyper/epochkghandler/sendkeyshare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (ksh *KeyShareHandler) ConstructDecryptionKeyShares(
113113
share := epochKG.ComputeEpochSecretKeyShare(identityPreimage)
114114

115115
shares = append(shares, &p2pmsg.KeyShare{
116-
EpochID: identityPreimage.Bytes(),
116+
EpochId: identityPreimage.Bytes(),
117117
Share: share.Marshal(),
118118
})
119119
}
@@ -123,7 +123,7 @@ func (ksh *KeyShareHandler) ConstructDecryptionKeyShares(
123123
return nil, err
124124
}
125125
msg := &p2pmsg.DecryptionKeyShares{
126-
InstanceID: ksh.InstanceID,
126+
InstanceId: ksh.InstanceID,
127127
Eon: keyperConfigIndex,
128128
KeyperIndex: keyperIndexUint,
129129
Shares: shares,

rolling-shutter/keyper/epochkghandler/trigger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestHandleDecryptionTriggerIntegration(t *testing.T) {
7575
assert.DeepEqual(t, msg.GetShares(),
7676
[]*p2pmsg.KeyShare{
7777
{
78-
EpochID: identityPreimage.Bytes(),
78+
EpochId: identityPreimage.Bytes(),
7979
Share: share.DecryptionKeyShare,
8080
},
8181
},

0 commit comments

Comments
 (0)