-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.json
802 lines (802 loc) · 61.5 KB
/
config.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
{
"client_name": "Hop Protocol",
"commit_hash": "f486cc2f1f5086f1fd7a3bba8645bc2b0fd700c2",
"date": "April 2021",
"date_interval": "March 29 to April 14, 2021",
"issues": [
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThis method is set as `view` but can be restricted to `pure` as long as the Solidity version is `<0.8.x`.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/51418c09ffde685e7f03be3308d723aa96fad13c/code/contracts/bridges/Bridge.sol#L112\r\n\r\nAlso, the *hack* to silence the state mutability can also be removed.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/51418c09ffde685e7f03be3308d723aa96fad13c/code/contracts/bridges/Bridge.sol#L113\r\n\r\nIf you need the `view` mutability in order to allow other layer 2 implementations to first save and then retrieve the value from the contract state, keep the `view` modifier, otherwise consider switching to `pure`. Solidity does not do too many things differently but uses `STATICCALL` when calling the method to make sure the state is not changed.\r\n\r\n**Recommendation**\r\n\r\nUnless there's a reason to keep the `view`, consider changing to `pure`.\r\n",
"closed_at": "2021-04-15T12:58:23Z",
"comments": 0,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/19/comments",
"created_at": "2021-04-14T14:33:01Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/19/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/19",
"id": 857960381,
"labels": [
{
"color": "007AFF",
"default": false,
"description": null,
"id": 2866247868,
"name": "Acknowledged",
"node_id": "MDU6TGFiZWwyODY2MjQ3ODY4",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Acknowledged"
},
{
"color": "34C759",
"default": false,
"description": null,
"id": 2866247736,
"name": "Informational",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzM2",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/19/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTc5NjAzODE=",
"number": 19,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "The method `getChainId` can be restricted to `pure` in Solidity <0.8.x",
"updated_at": "2021-04-15T12:58:23Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/19",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nAll of these methods update important configurations for the bridge.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/master/code/contracts/bridges/L2_Bridge.sol#L292-L337\r\n\r\n**Recommendation**\r\n\r\nConsider emitting events with the new values (and possibly old values) when these changes go through.\r\n\r\nSimilarly can be done for `L1_Bridge`.",
"closed_at": "2021-04-16T19:44:29Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/17/comments",
"created_at": "2021-04-07T15:43:03Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/17/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/17",
"id": 852542855,
"labels": [
{
"color": "007AFF",
"default": false,
"description": null,
"id": 2866247868,
"name": "Acknowledged",
"node_id": "MDU6TGFiZWwyODY2MjQ3ODY4",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Acknowledged"
},
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/17/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTI1NDI4NTU=",
"number": 17,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Consider emitting events when updating the L2_Bridge config",
"updated_at": "2021-04-16T19:44:29Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/17",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe method is only called externally. To signal it will not be called internally by the contract or by another implementation that extends the `L2_Bridge` it could be defined as `external`.\r\n\r\n**Recommendation**\r\n\r\nConsider defining the method as `external` if it's not called internally.\r\n\r\n",
"closed_at": "2021-04-16T19:44:42Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/16/comments",
"created_at": "2021-04-07T14:06:12Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/16/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/16",
"id": 852446926,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/16/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTI0NDY5MjY=",
"number": 16,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Make `L2_Bridge.send` external",
"updated_at": "2021-04-16T19:44:42Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/16",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nAnyone can call the method `commitTransfers` to commit the current pending transfers.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/bridges/L2_Bridge.sol#L153-L160\r\n\r\nThe Bonder can call this method anytime they want.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/bridges/L2_Bridge.sol#L160\r\n\r\nBut any other actor can call the method if enough time has passed since the previous commit time.\r\n\r\nIf they specify an incorrect (unsupported) chain id, the method will still try to call `_commitTransfers`. In which case it should fail if no transfers are pending. It is better to fail earlier if the chain id is unsupported.\r\n\r\n\r\n**Recommendation**\r\n\r\nCheck the provided `destinationChainId` to be valid. \r\n\r\n```solidity\r\nrequire(supportedChainIds[chainId], \"L2_BRG: destinationChainId is not supported\");\r\n```\r\n\r\nIn case the chain was previously supported and it is disabled right now, some transfers can remain in a pending state, still uncommitted. It is better to be more explicit about each state you want to support and how.\r\n\r\nIn case there are pending transfers, you should still allow committing the transfers, even if the chain is not supported anymore, but not allow creating new pending transfers.\r\n\r\nConsider allowing pending transfers if the minimum time has passed, even if the chain id is not supported anymore, only if there are pending transfers. If the logic seems messy or too complicated to be handled in `commitTransfers`, consider creating a `flushTransfers` method just for this use case.",
"closed_at": "2021-04-15T13:08:48Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/15/comments",
"created_at": "2021-04-06T11:34:54Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/15/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/15",
"id": 851334796,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/15/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTEzMzQ3OTY=",
"number": 15,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Committing transfers should fail early if the `destinationChainId` isn't supported",
"updated_at": "2021-04-15T13:08:48Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/15",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe governance can set a minimum fee, as well as a minimum percentage by calling `setMinimumBonderFeeRequirements`.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_Bridge.sol#L334-L337\r\n\r\nThe values could be checked for sanity, especially the percentage.\r\n\r\n**Recommendation**\r\n\r\nCheck the value of `minBonderBps` to be something less than `10000`.\r\n\r\n",
"closed_at": "2021-04-15T12:16:38Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/13/comments",
"created_at": "2021-04-05T15:08:05Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/13/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/13",
"id": 850433356,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/13/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTA0MzMzNTY=",
"number": 13,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "`L2_Bridge.setMinimumBonderFeeRequirements` should check `minBonderBps` for validity",
"updated_at": "2021-04-15T12:16:38Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/13",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThere are a couple of error messages that refer to the L2 Bridge\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L50\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L53\r\n\r\nTypically the `L2_BRG` error prefix is found in `Bridge` and `L2_Bridge`.\r\n\r\nAlso, the other error messages seem to refer to the Uniswap Wrapper.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L56\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L59\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L72-L73\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L88\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L95\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L97\r\n\r\n**Recommendation**\r\n\r\nUpdate the error messages to correctly reflect the current contract.\r\n",
"closed_at": "2021-04-15T12:18:30Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/12/comments",
"created_at": "2021-04-05T14:14:16Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/12/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/12",
"id": 850396595,
"labels": [
{
"color": "34C759",
"default": false,
"description": null,
"id": 2866247736,
"name": "Informational",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzM2",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/12/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTAzOTY1OTU=",
"number": 12,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Some error messages in `L2_AmmWrapper` refer to `L2_Bridge`",
"updated_at": "2021-04-15T12:18:30Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/12",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe contract `L2_AmmWrapper` has a few storage variables.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L13-L17\r\n\r\nThese storage vars are set at deploy time.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L19-L34\r\n\r\nNone of them are changed after the initial set.\r\n\r\nThis is why they could be defined as `immutable`. Solidity does not reserve a storage slot for immutables, but every occurrence is replaced in the bytecode by the respective value. This greatly reduces gas costs.\r\n\r\nTo have a better understanding of the gas cost reduction, two contracts were created.\r\n\r\nThe first contract defines a storage variable and sets it at deploy time. It also set the variable to `public`, this way Solidity will create a getter for it. This getter is important to measure the gas cost to access it.\r\n\r\n```solidity\r\ncontract A {\r\n bool public isSet;\r\n \r\n constructor(bool _isSet) public {\r\n isSet = _isSet;\r\n }\r\n}\r\n```\r\n\r\nThe second contract uses an `immutable` instead of a storage slot. That is the only difference between the two.\r\n\r\n```solidity\r\ncontract B {\r\n bool public immutable isSet;\r\n \r\n constructor(bool _isSet) public {\r\n isSet = _isSet;\r\n }\r\n}\r\n```\r\n\r\nWe've created the following table to show the differences in gas costs between the two approaches.\r\n\r\n| | deploy gas cost | getter gas cost |\r\n| ------------ | --------------- | --------------- |\r\n| storage slot | 47801 | 988 |\r\n| immutable | 32403 | 182 |\r\n\r\nBoth examples were tested in Remix IDE, Solidity version 0.6.12, optimization runs 200.\r\n\r\n**Recommendation**\r\n\r\nChange all state variables to `immutable` to greatly reduce gas costs.\r\n\r\nSimilarly, change the state variables to `immutable` in `L2_Bridge`.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/bridges/L2_Bridge.sol#L78-L80\r\n\r\nBut also in these cases (not a complete list):\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/wrappers/ArbitrumMessengerWrapper.sol#L36-L39\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/wrappers/OptimismMessengerWrapper.sol#L29\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/24ccdb4d4528ecb4e92c3d7ac5e1909bf8de34f7/code/contracts/wrappers/XDaiMessengerWrapper.sol#L35-L36\r\n\r\nThere are instances where some state variables are never changed in other contracts. If you think you won't change them in the future, consider checking all contract constructors.\r\n\r\n**References**\r\n\r\n- [Constant and Immutable State Variables](https://docs.soliditylang.org/en/v0.6.12/contracts.html#constant-and-immutable-state-variables)",
"closed_at": "2021-04-15T13:05:40Z",
"comments": 2,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/11/comments",
"created_at": "2021-04-05T13:56:29Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/11/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/11",
"id": 850384945,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/11/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTAzODQ5NDU=",
"number": 11,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Improve gas usage in `L2_AmmWrapper`",
"updated_at": "2021-04-16T16:53:28Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/11",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe method `distribute` can only be called by the Layer 1 Bridge.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_Bridge.sol#L176-L184\r\n\r\nThe `external` method calls the `internal` method `_distribute` in order to distribute tokens.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_Bridge.sol#L263\r\n\r\nIf the `fee` is positive, it will mint some tokens for the caller.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_Bridge.sol#L264-L266\r\n\r\nIn this case, the caller is the Layer 1 Bridge as stated above.\r\n\r\nHowever, the L1 Bridge doesn't seem to have a method to move the tokens.\r\n\r\n```\r\n + L1_Bridge (Bridge)\r\n - [Pub] <Constructor> #\r\n - modifiers: Bridge\r\n - [Ext] sendToL2 ($)\r\n - [Ext] bondTransferRoot #\r\n - modifiers: onlyBonder,requirePositiveBalance\r\n - [Ext] confirmTransferRoot #\r\n - modifiers: onlyL2Bridge\r\n - [Int] _distributeTransferRoot #\r\n - [Ext] challengeTransferBond ($)\r\n - [Ext] resolveChallenge #\r\n - [Int] _additionalDebit\r\n - [Int] _requireIsGovernance #\r\n - [Ext] setGovernance #\r\n - modifiers: onlyGovernance\r\n - [Ext] setCrossDomainMessengerWrapper #\r\n - modifiers: onlyGovernance\r\n - [Ext] setChainIdDepositsPaused #\r\n - modifiers: onlyGovernance\r\n - [Ext] setChallengeAmountMultiplier #\r\n - modifiers: onlyGovernance\r\n - [Ext] setChallengeAmountDivisor #\r\n - modifiers: onlyGovernance\r\n - [Ext] setChallengePeriodAndTimeSlotSize #\r\n - modifiers: onlyGovernance\r\n - [Ext] setChallengeResolutionPeriod #\r\n - modifiers: onlyGovernance\r\n - [Ext] setMinTransferRootBondDelay #\r\n - modifiers: onlyGovernance\r\n - [Pub] getBondForTransferAmount\r\n - [Pub] getChallengeAmountForTransferAmount\r\n - [Pub] getTimeSlot\r\n```\r\n\r\nIn which case the tokens that represent the fee, will remain locked in the Layer 1 Bridge contract.\r\n\r\n**Recommendation**\r\n\r\nConsider adding an additional argument to point to the receiver of the fee and pass that along through the internal `_distribute` method. This is especially useful for the `bondWithdrawalAndDistribute` method.\r\n\r\nThe fee doesn't seem necessary if the Layer 1 Bridge calls the external `distribute` method because the amount is not bonded.",
"closed_at": "2021-04-15T12:54:30Z",
"comments": 3,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/9/comments",
"created_at": "2021-04-05T11:30:50Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/9/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/9",
"id": 850304165,
"labels": [
{
"color": "FF9500",
"default": false,
"description": null,
"id": 2866247842,
"name": "Medium",
"node_id": "MDU6TGFiZWwyODY2MjQ3ODQy",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Medium"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/9/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTAzMDQxNjU=",
"number": 9,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "`L2_Bridge._distribute` might mint tokens for the Layer 1 Bridge and they'll be locked",
"updated_at": "2021-04-15T12:54:30Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/9",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nUniswap is mentioned, make sure to replace with something like AMM.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L56\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L59\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L72-L73\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L88\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L95\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/c5a6d5eead68465168373c39891ff1c5f197567a/code/contracts/bridges/L2_AmmWrapper.sol#L97\r\n\r\n**Recommendation**\r\n\r\nMake sure to update the error messages to reflect the current contract.\r\n",
"closed_at": "2021-04-15T12:57:21Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/7/comments",
"created_at": "2021-04-05T11:14:34Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/7/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/7",
"id": 850295734,
"labels": [
{
"color": "34C759",
"default": false,
"description": null,
"id": 2866247736,
"name": "Informational",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzM2",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Informational"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/7/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NTAyOTU3MzQ=",
"number": 7,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Update comments to be more swapper agnostic",
"updated_at": "2021-04-15T12:57:21Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/7",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe Accounting contract takes care of low-level accounting and has a couple of `external` methods that handle staking and unstaking of funds.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/8e53a77cafe91a8ad6a09a99ee387b8566cd726b/code/contracts/bridges/Accounting.sol#L118-L127\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/8e53a77cafe91a8ad6a09a99ee387b8566cd726b/code/contracts/bridges/Accounting.sol#L129-L136\r\n\r\nA couple of matching events exist in the contract.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/8e53a77cafe91a8ad6a09a99ee387b8566cd726b/code/contracts/bridges/Accounting.sol#L28-L30\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/8e53a77cafe91a8ad6a09a99ee387b8566cd726b/code/contracts/bridges/Accounting.sol#L32-L34\r\n\r\nBut they are not emitted in this contract or in any contract that inherits `Accounting`.\r\n\r\n**Recommendation**\r\n\r\nEmit events when staking and unstaking.\r\n",
"closed_at": "2021-04-15T12:55:30Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/4/comments",
"created_at": "2021-03-31T11:58:05Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/4/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/4",
"id": 846521502,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/4/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NDY1MjE1MDI=",
"number": 4,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Events exist but they're not emitted in `Accounting`",
"updated_at": "2021-04-15T12:55:30Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/4",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe method `Lib_MerkleTree._ceilLog2` is used in the `getMerkleRoot` method to calculate the total siblings count.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/5e66c267c52206b7e77d5515f64d939e85539f04/code/contracts/libraries/Lib_MerkleTree.sol#L144-L147\r\n\r\nAs stated in the source code, it was copied from the Solidity examples repository.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/5e66c267c52206b7e77d5515f64d939e85539f04/code/contracts/libraries/Lib_MerkleTree.sol#L202-L203\r\n\r\nThe Solidity example repository includes this method as an example for other developers to learn how to use the language. Because it does not strive to be the optimal implementation, its purpose is to show different features of the language itself.\r\n\r\nhttps://github.com/ethereum/solidity-examples/blob/f44fe3b3b4cca94afe9c2a2d5b7840ff0fafb72e/src/bits/Bits.sol#L87-L99\r\n\r\nThis is why some of the examples in the Solidity repository might not be gas optimized.\r\n\r\nUsing `uint8` in the loop forces the compiler to create sub-optimal code.\r\n\r\nThe following Solidity contract example was used to measure the difference between using `uint8` and `uint256` with a few example inputs.\r\n\r\n```solidity\r\ncontract FindBit {\r\n function find_highest_set_bit(\r\n uint value\r\n ) \r\n public \r\n pure \r\n returns (\r\n uint\r\n ) \r\n {\r\n uint _in = value;\r\n \r\n if (_in == 1) {\r\n return 0;\r\n }\r\n\r\n // Find the highest set bit (will be floor(log_2)).\r\n // Borrowed with <3 from https://github.com/ethereum/solidity-examples\r\n uint256 val = _in;\r\n uint256 highest = 0;\r\n for (uint8 i = 128; i >= 1; i >>= 1) {\r\n if (val & (uint(1) << i) - 1 << i != 0) {\r\n highest += i;\r\n val >>= i;\r\n }\r\n }\r\n\r\n // Increment by one if this is not a perfect logarithm.\r\n if ((uint(1) << highest) != _in) {\r\n highest += 1;\r\n }\r\n\r\n return highest; \r\n }\r\n}\r\n```\r\n\r\nChanging the line from `uint8` to `uint256` \r\n\r\n```solidity\r\n for (uint8 i = 128; i >= 1; i >>= 1) {\r\n```\r\n\r\n```solidity\r\n for (uint256 i = 128; i >= 1; i >>= 1) {\r\n```\r\n\r\nGives the following different gas costs, while returning the same, identical results.\r\n\r\nSolidity version 0.8.3+commit.8d00100c and 200 optimization runs were used in Remix IDE for tests.\r\n\r\n| input | output | uint8 gas | uint256 gas | difference |\r\n| ------------------------------------------- | ------ | --------- | ----------- | ---------- |\r\n| 8 | 3 | 1876 | 1692 | 184 |\r\n| 15 | 4 | 1951 | 1767 | 184 |\r\n| 100 | 7 | 1951 | 1767 | 184 |\r\n| 128 | 7 | 1980 | 1779 | 201 |\r\n| 4294967295 (`0xffffffff`) | 32 | 2263 | 2028 | 235 |\r\n| 1099511627775 (`0xffffffffff`) | 40 | 2159 | 1941 | 218 |\r\n| 18446744073709552000 (`0xffffffffffffffff`) | 64 | 2367 | 2115 | 252 |\r\n\r\n\r\n**Recommendation**\r\n\r\nModify the loop iterator from `uint8` to `uint256` to reduce gas costs, while having the same output.\r\n\r\n**References**\r\n\r\n- [Solidity example, highest set bit](https://github.com/ethereum/solidity-examples/blob/f44fe3b3b4cca94afe9c2a2d5b7840ff0fafb72e/src/bits/Bits.sol#L87-L99)\r\n- [Optimism MerkleTree implementation](https://github.com/ethereum-optimism/contracts/blob/b3f2de7e12445bd2e420e289b537cd501035e1e1/contracts/optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol#L202-L211)\r\n",
"closed_at": "2021-04-16T19:48:43Z",
"comments": 3,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/3/comments",
"created_at": "2021-03-30T17:36:51Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/3/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/3",
"id": 844945817,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/3/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NDQ5NDU4MTc=",
"number": 3,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Optimize `_ceilLog2` by using `uint256`",
"updated_at": "2021-04-16T19:48:43Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/3",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
},
{
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "**Description**\r\n\r\nThe methods `addBonder` and `removeBonder` respectively add and remove bonders.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/cb9804f243005850597952f5152d7b9397f9968b/code/contracts/bridges/Accounting.sol#L138-L145\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/cb9804f243005850597952f5152d7b9397f9968b/code/contracts/bridges/Accounting.sol#L147-L154\r\n\r\nAlso, the constructor adds a list of bonders to the bonder list.\r\n\r\nhttps://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/blob/cb9804f243005850597952f5152d7b9397f9968b/code/contracts/bridges/Accounting.sol#L54-L59\r\n\r\nIt might be beneficial to emit events when adding and removing bonders.\r\n\r\n**Recommendation**\r\n\r\nConsider emitting events when adding or removing bonders.\r\n",
"closed_at": "2021-04-16T19:49:15Z",
"comments": 1,
"comments_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/2/comments",
"created_at": "2021-03-30T13:18:57Z",
"events_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/2/events",
"html_url": "https://github.com/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/2",
"id": 844537203,
"labels": [
{
"color": "FFCC00",
"default": false,
"description": null,
"id": 2866247779,
"name": "Minor",
"node_id": "MDU6TGFiZWwyODY2MjQ3Nzc5",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Minor"
},
{
"color": "667788",
"default": false,
"description": null,
"id": 2866247707,
"name": "Report",
"node_id": "MDU6TGFiZWwyODY2MjQ3NzA3",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/labels/Report"
}
],
"labels_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/2/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU4NDQ1MzcyMDM=",
"number": 2,
"performed_via_github_app": null,
"repository_url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04",
"state": "closed",
"title": "Emit events when adding and removing bonders",
"updated_at": "2021-04-16T19:49:15Z",
"url": "https://api.github.com/repos/monoceros-alpha/review-hopprotocol-contracts-2021-04/issues/2",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/547012?v=4",
"events_url": "https://api.github.com/users/cleanunicorn/events{/privacy}",
"followers_url": "https://api.github.com/users/cleanunicorn/followers",
"following_url": "https://api.github.com/users/cleanunicorn/following{/other_user}",
"gists_url": "https://api.github.com/users/cleanunicorn/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/cleanunicorn",
"id": 547012,
"login": "cleanunicorn",
"node_id": "MDQ6VXNlcjU0NzAxMg==",
"organizations_url": "https://api.github.com/users/cleanunicorn/orgs",
"received_events_url": "https://api.github.com/users/cleanunicorn/received_events",
"repos_url": "https://api.github.com/users/cleanunicorn/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/cleanunicorn/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cleanunicorn/subscriptions",
"type": "User",
"url": "https://api.github.com/users/cleanunicorn"
}
}
],
"person_days": "13",
"project_name": "Hop Exchange Smart Contracts",
"review_period": "2.5 weeks",
"source_repository": "https://github.com/hop-protocol/contracts.git",
"template": "./Readme.md.mustache"
}