Update checkImplicitDefaults
Marco Munizaga committed
Jul 26, 2022 at 05:21 UTC
7245e8dd11c8c630695d538792f990c0405a4ac4
2 files changed
+196
-142
core/node/libp2p/rcmgr_defaults.go
+194
-142
@@ -107,6 +107,7 @@ func checkImplicitDefaults() {
107
}
108
109
// Check 2: did go-libp2p's SetDefaultServiceLimits change?
110
+ // We compare the baseline (min specs), and check if we went down in any limits.
111
l := rcmgr.DefaultLimits
112
libp2p.SetDefaultServiceLimits(&l)
113
limits := l.AutoScale()
@@ -121,13 +122,45 @@ func checkImplicitDefaults() {
122
log.Fatal(err)
123
}
124
if len(changes) > 0 {
124
- ok = false
125
- log.Errorf("===> OOF! go-libp2p changed DefaultServiceLimits\n"+
126
- "=> changes ('test' represents the old value):\n%s\n"+
127
- "=> go-libp2p SetDefaultServiceLimits update needs a review:\n"+
128
- "Please inspect if changes impact go-ipfs users, and update expectedDefaultServiceLimits in rcmgr_defaults.go to remove this message",
129
- strings.Join(changes, "\n"),
130
- )
125
+ oldState := map[string]int{}
126
+ type Op struct {
127
+ Op string
128
+ Path string
129
+ Value int
130
+ }
131
+ for _, changeStr := range changes {
132
+ change := Op{}
133
+ err := json.Unmarshal([]byte(changeStr), &change)
134
+ if err != nil {
135
+ continue
136
+ }
137
+ if change.Op == "test" {
138
+ oldState[change.Path] = change.Value
139
+ }
140
+ }
141
+
142
+ for _, changeStr := range changes {
143
+ change := Op{}
144
+ err := json.Unmarshal([]byte(changeStr), &change)
145
+ if err != nil {
146
+ continue
147
+ }
148
+ if change.Op == "replace" {
149
+ oldVal, okFound := oldState[change.Path]
150
+ if okFound && oldVal > change.Value {
151
+ ok = false
152
+ fmt.Printf("reduced value for %s. Old: %v; new: %v\n", change.Path, oldVal, change.Value)
153
+ }
154
+ }
155
+ }
156
+
157
+ if !ok {
158
+ log.Errorf("===> OOF! go-libp2p reduced DefaultServiceLimits\n" +
159
+ "=> See the aboce reduced values for info.\n" +
160
+ "=> go-libp2p SetDefaultServiceLimits update needs a review:\n" +
161
+ "Please inspect if changes impact go-ipfs users, and update expectedDefaultServiceLimits in rcmgr_defaults.go to remove this message",
162
+ )
163
+ }
164
}
165
if !ok {
166
log.Fatal("daemon will refuse to run with the resource manager until this is resolved")
@@ -377,111 +410,131 @@ const expectedDefaultLimits = `{
410
}
411
}`
412
380
-// https://github.com/libp2p/go-libp2p/blob/v0.18.0/limits.go#L17
413
+// Generated from the default limits and scaling to 0 (base limit).
414
const expectedDefaultServiceLimits = `{
382
- "SystemLimits": {
383
- "Streams": 16384,
384
- "StreamsInbound": 4096,
385
- "StreamsOutbound": 16384,
386
- "Conns": 1024,
387
- "ConnsInbound": 256,
388
- "ConnsOutbound": 1024,
389
- "FD": 512,
390
- "Memory": 1073741824
391
- },
392
- "TransientLimits": {
393
- "Streams": 512,
394
- "StreamsInbound": 128,
395
- "StreamsOutbound": 512,
415
+ "System": {
416
+ "Streams": 2048,
417
+ "StreamsInbound": 1024,
418
+ "StreamsOutbound": 2048,
419
"Conns": 128,
420
+ "ConnsInbound": 64,
421
+ "ConnsOutbound": 128,
422
+ "FD": 256,
423
+ "Memory": 134217728
424
+ },
425
+ "Transient": {
426
+ "Streams": 256,
427
+ "StreamsInbound": 128,
428
+ "StreamsOutbound": 256,
429
+ "Conns": 64,
430
"ConnsInbound": 32,
431
+ "ConnsOutbound": 64,
432
+ "FD": 64,
433
+ "Memory": 33554432
434
+ },
435
+ "AllowlistedSystem": {
436
+ "Streams": 2048,
437
+ "StreamsInbound": 1024,
438
+ "StreamsOutbound": 2048,
439
+ "Conns": 128,
440
+ "ConnsInbound": 64,
441
"ConnsOutbound": 128,
399
- "FD": 128,
400
- "Memory": 67108864
442
+ "FD": 256,
443
+ "Memory": 134217728
444
},
402
- "DefaultServiceLimits": {
403
- "Streams": 8192,
404
- "StreamsInbound": 2048,
405
- "StreamsOutbound": 8192,
406
- "Conns": 0,
407
- "ConnsInbound": 0,
408
- "ConnsOutbound": 0,
409
- "FD": 0,
410
- "Memory": 67108864
445
+ "AllowlistedTransient": {
446
+ "Streams": 256,
447
+ "StreamsInbound": 128,
448
+ "StreamsOutbound": 256,
449
+ "Conns": 64,
450
+ "ConnsInbound": 32,
451
+ "ConnsOutbound": 64,
452
+ "FD": 64,
453
+ "Memory": 33554432
454
},
412
- "DefaultServicePeerLimits": {
413
- "Streams": 512,
414
- "StreamsInbound": 256,
415
- "StreamsOutbound": 512,
455
+ "ServiceDefault": {
456
+ "Streams": 4096,
457
+ "StreamsInbound": 1024,
458
+ "StreamsOutbound": 4096,
459
"Conns": 0,
460
"ConnsInbound": 0,
461
"ConnsOutbound": 0,
462
"FD": 0,
420
- "Memory": 16777216
463
+ "Memory": 67108864
464
},
422
- "ServiceLimits": {
465
+ "Service": {
466
"libp2p.autonat": {
424
- "Streams": 128,
425
- "StreamsInbound": 128,
426
- "StreamsOutbound": 128,
467
+ "Streams": 64,
468
+ "StreamsInbound": 64,
469
+ "StreamsOutbound": 64,
470
"Conns": 0,
471
"ConnsInbound": 0,
472
"ConnsOutbound": 0,
473
"FD": 0,
431
- "Memory": 67108864
474
+ "Memory": 4194304
475
},
476
"libp2p.holepunch": {
434
- "Streams": 256,
435
- "StreamsInbound": 128,
436
- "StreamsOutbound": 128,
477
+ "Streams": 64,
478
+ "StreamsInbound": 32,
479
+ "StreamsOutbound": 32,
480
"Conns": 0,
481
"ConnsInbound": 0,
482
"ConnsOutbound": 0,
483
"FD": 0,
441
- "Memory": 67108864
484
+ "Memory": 4194304
485
},
486
"libp2p.identify": {
444
- "Streams": 256,
445
- "StreamsInbound": 128,
446
- "StreamsOutbound": 128,
487
+ "Streams": 128,
488
+ "StreamsInbound": 64,
489
+ "StreamsOutbound": 64,
490
"Conns": 0,
491
"ConnsInbound": 0,
492
"ConnsOutbound": 0,
493
"FD": 0,
451
- "Memory": 67108864
494
+ "Memory": 4194304
495
},
496
"libp2p.ping": {
454
- "Streams": 128,
455
- "StreamsInbound": 128,
456
- "StreamsOutbound": 128,
497
+ "Streams": 64,
498
+ "StreamsInbound": 64,
499
+ "StreamsOutbound": 64,
500
"Conns": 0,
501
"ConnsInbound": 0,
502
"ConnsOutbound": 0,
503
"FD": 0,
461
- "Memory": 67108864
504
+ "Memory": 4194304
505
},
506
"libp2p.relay/v1": {
464
- "Streams": 1024,
465
- "StreamsInbound": 1024,
466
- "StreamsOutbound": 1024,
507
+ "Streams": 256,
508
+ "StreamsInbound": 256,
509
+ "StreamsOutbound": 256,
510
"Conns": 0,
511
"ConnsInbound": 0,
512
"ConnsOutbound": 0,
513
"FD": 0,
471
- "Memory": 67108864
514
+ "Memory": 16777216
515
},
516
"libp2p.relay/v2": {
474
- "Streams": 1024,
475
- "StreamsInbound": 1024,
476
- "StreamsOutbound": 1024,
517
+ "Streams": 256,
518
+ "StreamsInbound": 256,
519
+ "StreamsOutbound": 256,
520
"Conns": 0,
521
"ConnsInbound": 0,
522
"ConnsOutbound": 0,
523
"FD": 0,
481
- "Memory": 67108864
524
+ "Memory": 16777216
525
}
526
},
484
- "ServicePeerLimits": {
527
+ "ServicePeerDefault": {
528
+ "Streams": 256,
529
+ "StreamsInbound": 128,
530
+ "StreamsOutbound": 256,
531
+ "Conns": 0,
532
+ "ConnsInbound": 0,
533
+ "ConnsOutbound": 0,
534
+ "FD": 0,
535
+ "Memory": 16777216
536
+ },
537
+ "ServicePeer": {
538
"libp2p.autonat": {
539
"Streams": 2,
540
"StreamsInbound": 2,
@@ -490,7 +543,7 @@ const expectedDefaultServiceLimits = `{
543
"ConnsInbound": 0,
544
"ConnsOutbound": 0,
545
"FD": 0,
493
- "Memory": 557056
546
+ "Memory": 1048576
547
},
548
"libp2p.holepunch": {
549
"Streams": 2,
@@ -500,7 +553,7 @@ const expectedDefaultServiceLimits = `{
553
"ConnsInbound": 0,
554
"ConnsOutbound": 0,
555
"FD": 0,
503
- "Memory": 557056
556
+ "Memory": 1048576
557
},
558
"libp2p.identify": {
559
"Streams": 32,
@@ -510,7 +563,7 @@ const expectedDefaultServiceLimits = `{
563
"ConnsInbound": 0,
564
"ConnsOutbound": 0,
565
"FD": 0,
513
- "Memory": 8912896
566
+ "Memory": 1048576
567
},
568
"libp2p.ping": {
569
"Streams": 4,
@@ -520,7 +573,7 @@ const expectedDefaultServiceLimits = `{
573
"ConnsInbound": 0,
574
"ConnsOutbound": 0,
575
"FD": 0,
523
- "Memory": 1114112
576
+ "Memory": 8590458880
577
},
578
"libp2p.relay/v1": {
579
"Streams": 64,
@@ -530,7 +583,7 @@ const expectedDefaultServiceLimits = `{
583
"ConnsInbound": 0,
584
"ConnsOutbound": 0,
585
"FD": 0,
533
- "Memory": 17825792
586
+ "Memory": 1048576
587
},
588
"libp2p.relay/v2": {
589
"Streams": 64,
@@ -540,122 +593,122 @@ const expectedDefaultServiceLimits = `{
593
"ConnsInbound": 0,
594
"ConnsOutbound": 0,
595
"FD": 0,
543
- "Memory": 17825792
596
+ "Memory": 1048576
597
}
598
},
546
- "DefaultProtocolLimits": {
547
- "Streams": 4096,
548
- "StreamsInbound": 1024,
549
- "StreamsOutbound": 4096,
599
+ "ProtocolDefault": {
600
+ "Streams": 2048,
601
+ "StreamsInbound": 512,
602
+ "StreamsOutbound": 2048,
603
"Conns": 0,
604
"ConnsInbound": 0,
605
"ConnsOutbound": 0,
606
"FD": 0,
607
"Memory": 67108864
608
},
556
- "DefaultProtocolPeerLimits": {
557
- "Streams": 512,
558
- "StreamsInbound": 128,
559
- "StreamsOutbound": 256,
560
- "Conns": 0,
561
- "ConnsInbound": 0,
562
- "ConnsOutbound": 0,
563
- "FD": 0,
564
- "Memory": 16777216
565
- },
566
- "ProtocolLimits": {
609
+ "Protocol": {
610
"/ipfs/id/1.0.0": {
568
- "Streams": 4096,
569
- "StreamsInbound": 1024,
570
- "StreamsOutbound": 4096,
611
+ "Streams": 128,
612
+ "StreamsInbound": 64,
613
+ "StreamsOutbound": 64,
614
"Conns": 0,
615
"ConnsInbound": 0,
616
"ConnsOutbound": 0,
617
"FD": 0,
575
- "Memory": 33554432
618
+ "Memory": 4194304
619
},
620
"/ipfs/id/push/1.0.0": {
578
- "Streams": 4096,
579
- "StreamsInbound": 1024,
580
- "StreamsOutbound": 4096,
621
+ "Streams": 128,
622
+ "StreamsInbound": 64,
623
+ "StreamsOutbound": 64,
624
"Conns": 0,
625
"ConnsInbound": 0,
626
"ConnsOutbound": 0,
627
"FD": 0,
585
- "Memory": 33554432
628
+ "Memory": 4194304
629
},
630
"/ipfs/ping/1.0.0": {
588
- "Streams": 4096,
589
- "StreamsInbound": 1024,
590
- "StreamsOutbound": 4096,
631
+ "Streams": 64,
632
+ "StreamsInbound": 64,
633
+ "StreamsOutbound": 64,
634
"Conns": 0,
635
"ConnsInbound": 0,
636
"ConnsOutbound": 0,
637
"FD": 0,
595
- "Memory": 67108864
638
+ "Memory": 4194304
639
},
640
"/libp2p/autonat/1.0.0": {
598
- "Streams": 4096,
599
- "StreamsInbound": 1024,
600
- "StreamsOutbound": 4096,
641
+ "Streams": 64,
642
+ "StreamsInbound": 64,
643
+ "StreamsOutbound": 64,
644
"Conns": 0,
645
"ConnsInbound": 0,
646
"ConnsOutbound": 0,
647
"FD": 0,
605
- "Memory": 67108864
648
+ "Memory": 4194304
649
},
650
"/libp2p/circuit/relay/0.1.0": {
608
- "Streams": 1280,
609
- "StreamsInbound": 1280,
610
- "StreamsOutbound": 1280,
651
+ "Streams": 640,
652
+ "StreamsInbound": 640,
653
+ "StreamsOutbound": 640,
654
"Conns": 0,
655
"ConnsInbound": 0,
656
"ConnsOutbound": 0,
657
"FD": 0,
615
- "Memory": 67108864
658
+ "Memory": 16777216
659
},
660
"/libp2p/circuit/relay/0.2.0/hop": {
618
- "Streams": 1280,
619
- "StreamsInbound": 1280,
620
- "StreamsOutbound": 1280,
661
+ "Streams": 640,
662
+ "StreamsInbound": 640,
663
+ "StreamsOutbound": 640,
664
"Conns": 0,
665
"ConnsInbound": 0,
666
"ConnsOutbound": 0,
667
"FD": 0,
625
- "Memory": 67108864
668
+ "Memory": 16777216
669
},
670
"/libp2p/circuit/relay/0.2.0/stop": {
628
- "Streams": 1280,
629
- "StreamsInbound": 1280,
630
- "StreamsOutbound": 1280,
671
+ "Streams": 640,
672
+ "StreamsInbound": 640,
673
+ "StreamsOutbound": 640,
674
"Conns": 0,
675
"ConnsInbound": 0,
676
"ConnsOutbound": 0,
677
"FD": 0,
635
- "Memory": 67108864
678
+ "Memory": 16777216
679
},
680
"/libp2p/dcutr": {
638
- "Streams": 4096,
639
- "StreamsInbound": 1024,
640
- "StreamsOutbound": 4096,
681
+ "Streams": 64,
682
+ "StreamsInbound": 32,
683
+ "StreamsOutbound": 32,
684
"Conns": 0,
685
"ConnsInbound": 0,
686
"ConnsOutbound": 0,
687
"FD": 0,
645
- "Memory": 67108864
688
+ "Memory": 4194304
689
},
690
"/p2p/id/delta/1.0.0": {
648
- "Streams": 4096,
649
- "StreamsInbound": 1024,
650
- "StreamsOutbound": 4096,
691
+ "Streams": 128,
692
+ "StreamsInbound": 64,
693
+ "StreamsOutbound": 64,
694
"Conns": 0,
695
"ConnsInbound": 0,
696
"ConnsOutbound": 0,
697
"FD": 0,
655
- "Memory": 33554432
698
+ "Memory": 4194304
699
}
700
},
658
- "ProtocolPeerLimits": {
701
+ "ProtocolPeerDefault": {
702
+ "Streams": 256,
703
+ "StreamsInbound": 64,
704
+ "StreamsOutbound": 128,
705
+ "Conns": 0,
706
+ "ConnsInbound": 0,
707
+ "ConnsOutbound": 0,
708
+ "FD": 0,
709
+ "Memory": 16777216
710
+ },
711
+ "ProtocolPeer": {
712
"/ipfs/id/1.0.0": {
713
"Streams": 32,
714
"StreamsInbound": 16,
@@ -664,7 +717,7 @@ const expectedDefaultServiceLimits = `{
717
"ConnsInbound": 0,
718
"ConnsOutbound": 0,
719
"FD": 0,
667
- "Memory": 8912896
720
+ "Memory": 8590458880
721
},
722
"/ipfs/id/push/1.0.0": {
723
"Streams": 32,
@@ -674,7 +727,7 @@ const expectedDefaultServiceLimits = `{
727
"ConnsInbound": 0,
728
"ConnsOutbound": 0,
729
"FD": 0,
677
- "Memory": 8912896
730
+ "Memory": 8590458880
731
},
732
"/ipfs/ping/1.0.0": {
733
"Streams": 4,
@@ -684,7 +737,7 @@ const expectedDefaultServiceLimits = `{
737
"ConnsInbound": 0,
738
"ConnsOutbound": 0,
739
"FD": 0,
687
- "Memory": 1114112
740
+ "Memory": 8590458880
741
},
742
"/libp2p/autonat/1.0.0": {
743
"Streams": 2,
@@ -694,7 +747,7 @@ const expectedDefaultServiceLimits = `{
747
"ConnsInbound": 0,
748
"ConnsOutbound": 0,
749
"FD": 0,
697
- "Memory": 557056
750
+ "Memory": 1048576
751
},
752
"/libp2p/circuit/relay/0.1.0": {
753
"Streams": 128,
@@ -704,7 +757,7 @@ const expectedDefaultServiceLimits = `{
757
"ConnsInbound": 0,
758
"ConnsOutbound": 0,
759
"FD": 0,
707
- "Memory": 35651584
760
+ "Memory": 33554432
761
},
762
"/libp2p/circuit/relay/0.2.0/hop": {
763
"Streams": 128,
@@ -714,7 +767,7 @@ const expectedDefaultServiceLimits = `{
767
"ConnsInbound": 0,
768
"ConnsOutbound": 0,
769
"FD": 0,
717
- "Memory": 35651584
770
+ "Memory": 33554432
771
},
772
"/libp2p/circuit/relay/0.2.0/stop": {
773
"Streams": 128,
@@ -724,7 +777,7 @@ const expectedDefaultServiceLimits = `{
777
"ConnsInbound": 0,
778
"ConnsOutbound": 0,
779
"FD": 0,
727
- "Memory": 35651584
780
+ "Memory": 33554432
781
},
782
"/libp2p/dcutr": {
783
"Streams": 2,
@@ -734,7 +787,7 @@ const expectedDefaultServiceLimits = `{
787
"ConnsInbound": 0,
788
"ConnsOutbound": 0,
789
"FD": 0,
737
- "Memory": 557056
790
+ "Memory": 1048576
791
},
792
"/p2p/id/delta/1.0.0": {
793
"Streams": 32,
@@ -744,21 +797,20 @@ const expectedDefaultServiceLimits = `{
797
"ConnsInbound": 0,
798
"ConnsOutbound": 0,
799
"FD": 0,
747
- "Memory": 8912896
800
+ "Memory": 8590458880
801
}
802
},
750
- "DefaultPeerLimits": {
751
- "Streams": 1024,
752
- "StreamsInbound": 512,
753
- "StreamsOutbound": 1024,
754
- "Conns": 16,
755
- "ConnsInbound": 8,
756
- "ConnsOutbound": 16,
757
- "FD": 8,
803
+ "PeerDefault": {
804
+ "Streams": 512,
805
+ "StreamsInbound": 256,
806
+ "StreamsOutbound": 512,
807
+ "Conns": 8,
808
+ "ConnsInbound": 4,
809
+ "ConnsOutbound": 8,
810
+ "FD": 4,
811
"Memory": 67108864
812
},
760
- "PeerLimits": null,
761
- "ConnLimits": {
813
+ "Conn": {
814
"Streams": 0,
815
"StreamsInbound": 0,
816
"StreamsOutbound": 0,
@@ -768,7 +820,7 @@ const expectedDefaultServiceLimits = `{
820
"FD": 1,
821
"Memory": 1048576
822
},
771
- "StreamLimits": {
823
+ "Stream": {
824
"Streams": 1,
825
"StreamsInbound": 1,
826
"StreamsOutbound": 1,
test/sharness/t0139-swarm-rcmgr.sh
+2
@@ -2,6 +2,8 @@
2
#
3
test_description="Test ipfs swarm ResourceMgr config and commands"
4
5
+export IPFS_CHECK_RCMGR_DEFAULTS=1
6
+
7
. lib/test-lib.sh
8
9
test_init_ipfs