-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miner.yaml
1050 lines (1010 loc) · 40.2 KB
/
miner.yaml
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
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ============================= #
# !!! Do NOT edit this file !!! #
# ============================= #
# Instead edit template-eth-default-vpc.template.yml and run 'import-files.py' again
# Use this template if you wish to stand up the instances in the "Default VPC"
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
RepoUrl: https://github.com/mludvig/aws-ethereum-miner
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Miner Configuration
Parameters:
- EthWallet
- Hashrate
- Label:
default: Instance Configuration
Parameters:
- InstanceTypes
- PricingPlan
Parameters:
InstanceTypes:
Description: |
Instance types to choose from. Can be "*" to use all available, or wildcards e.g. "g4dn.*,g5.*",
or a list of specific instances e.g. "p3.2xlarge,p3.8xlarge". The most cost effective combination
of available instances will be used first.
Type: String
Default: "g4ad.xlarge"
Hashrate:
Description: |
Required hashrate in MH/s. AWS will start the most cost effective available
instances to achieve this Hashrate. Minimum is 25 (1x g4dn.xlarge).
Type: Number
Default: 250
MinValue: 25
EthWallet:
Type: String
Description: Ethereum Wallet Address
Default: "0xBE0eACFA90d800A2504a9aDB4249DCa435C7F579"
MoneroWallet:
Type: String
Description: Monero Wallet Address
Default: "48T6LkYf5Ec3rxRuSvLJgXPkDqfjpQ7ubJ7MLCiSQ23VM2SKCuSLcAybSJch5rotHJ1UxiD5fQjMVfoRWzberAAd5dpWio3"
PricingPlan:
Type: String
Description: Spot or On-Demand or Both
AllowedValues:
- spot
- ondemand
- both
Default: spot
Mappings:
ImageMap:
ap-northeast-1:
CudaX8664: ami-057223d0b465ef6c8
CudaARM64: ami-0d4cb079ff538035a
RadeonX8664: ami-0920895676fcb4966
ap-northeast-2:
CudaX8664: ami-04974804b5c32ad3f
CudaARM64: ami-03b82416ff1761578
RadeonX8664: ami-0f103c00fa9bafb0e
ap-south-1:
CudaX8664: ami-0138f84dea0009e24
CudaARM64: ami-007d5bdb59f189296
RadeonX8664: ami-0eeb53661d79e3b9c
ap-southeast-1:
CudaX8664: ami-028fec8125dca56aa
CudaARM64: ami-0ecdf52d29e6a9965
RadeonX8664: ami-00d3ca16eff5adb63
ap-southeast-2:
CudaX8664: ami-07b457617d5ab5026
CudaARM64: ami-0b8be1b9abcbfa2a5
RadeonX8664: ami-0a04fe46aa8bcaaf7
ca-central-1:
CudaX8664: ami-00cbba349f2627bef
CudaARM64: ami-043fb0afe679cdceb
RadeonX8664: ami-04ad2df5b2bf97fd5
eu-central-1:
CudaX8664: ami-0527e1e1ca0929e8c
CudaARM64: ami-084c2c0e33a1d191e
RadeonX8664: ami-01f76f27dba711db3
eu-north-1:
CudaX8664: ami-070fab14d346eec81
CudaARM64: ami-076ff23b1a1cb45c6
RadeonX8664: ami-08dc54829d51009d9
eu-west-1:
CudaX8664: ami-052dfb972e5a6cdd0
CudaARM64: ami-09967bb61234a3fc7
RadeonX8664: ami-05f8a1fbb5cd80c47
eu-west-2:
CudaX8664: ami-0126c804cd6d92090
CudaARM64: ami-0cdf91452a2046168
RadeonX8664: ami-0bc7c7f3180e6e855
eu-west-3:
CudaX8664: ami-0fe47281cdcb0102b
CudaARM64: ami-0ceee0282ab931a2f
RadeonX8664: ami-083e41b99285e8504
sa-east-1:
CudaX8664: ami-0ad6f33841de28c4c
CudaARM64: ami-0954de81019e3325c
RadeonX8664: ami-06bf11059e19f03c9
us-east-1:
CudaX8664: ami-04822dc0e04836a86
CudaARM64: ami-0356788caa912eb19
RadeonX8664: ami-0476917f2861069bf
us-east-2:
CudaX8664: ami-0b3cc42a259739f29
CudaARM64: ami-06ccef90a16c90466
RadeonX8664: ami-0f28b3a6ec09b33d5
us-west-1:
CudaX8664: ami-00158baf36cd6ace7
CudaARM64: ami-08d53625a57e71d23
RadeonX8664: ami-092ae28e6514057a0
us-west-2:
CudaX8664: ami-013f60ec8ba5a9ca4
CudaARM64: ami-0fe8b41c830a026d6
RadeonX8664: ami-0356d91a89300f274
CapacityAllocation:
spot:
OnDemandPct: "0"
both:
OnDemandPct: "50"
ondemand:
OnDemandPct: "100"
Resources:
InstanceFilter:
Type: Custom::InstanceFilter
Properties:
ServiceToken: !GetAtt InstanceFilterLambda.Arn
InstanceTypesWanted: !Ref InstanceTypes
InstanceTypesAttributes:
# WeightedCapacity is the instance type Hashrate in MH/s
- InstanceType: g4ad.xlarge
WeightedCapacity: "48"
LaunchTemplateSpecification:
LaunchTemplateId: !Ref LaunchTemplateRadeonX8664
Version: !GetAtt LaunchTemplateRadeonX8664.LatestVersionNumber
- InstanceType: g4ad.8xlarge
WeightedCapacity: "96"
LaunchTemplateSpecification:
LaunchTemplateId: !Ref LaunchTemplateRadeonX8664
Version: !GetAtt LaunchTemplateRadeonX8664.LatestVersionNumber
_ExcludeInRegions:
- ca-central-1
- InstanceType: g4ad.16xlarge
WeightedCapacity: "192"
LaunchTemplateSpecification:
LaunchTemplateId: !Ref LaunchTemplateRadeonX8664
Version: !GetAtt LaunchTemplateRadeonX8664.LatestVersionNumber
_ExcludeInRegions:
- ca-central-1
- InstanceType: g5g.xlarge
WeightedCapacity: "25"
LaunchTemplateSpecification:
LaunchTemplateId: !Ref LaunchTemplateCudaARM64
Version: !GetAtt LaunchTemplateCudaARM64.LatestVersionNumber
- InstanceType: g5.xlarge
WeightedCapacity: "56"
- InstanceType: g5.24xlarge
WeightedCapacity: "226"
- InstanceType: g5.48xlarge
WeightedCapacity: "452"
- InstanceType: g4dn.xlarge
WeightedCapacity: "25"
- InstanceType: g4dn.2xlarge
WeightedCapacity: "25"
- InstanceType: g4dn.12xlarge
WeightedCapacity: "100"
- InstanceType: g4dn.metal
WeightedCapacity: "204"
- InstanceType: p3.2xlarge
WeightedCapacity: "93"
- InstanceType: p3.8xlarge
WeightedCapacity: "372"
- InstanceType: p3.16xlarge
WeightedCapacity: "744"
- InstanceType: p3dn.24xlarge
WeightedCapacity: "692"
## p4d.24xlarge doesn't work with ethminer
#- InstanceType: p4d.24xlarge
# WeightedCapacity: "999" # It's in fact ~1400 but the max value allowed here is 999
InstanceFilterLambda:
Type: AWS::Lambda::Function
Properties:
Code:
# Lambda source is in src/lambdas/instance-filter.py
ZipFile: |
#!/usr/bin/env python3
import os
import json
import urllib3
import datetime
import boto3
http=urllib3.PoolManager()
ec2=boto3.client("ec2")
VPC_ID=os.getenv("VPC_ID")
SUCCESS="SUCCESS"
FAILED="FAILED"
def send(event,context,status,data={},reason=None):
responseUrl=event["ResponseURL"]
responseBody={"Status":status,"PhysicalResourceId":context.log_stream_name,"StackId":event["StackId"],"RequestId":event["RequestId"],"LogicalResourceId":event["LogicalResourceId"],"Reason":reason or "See the details in CloudWatch Log Stream: {}".format(context.log_stream_name),}
if data:
responseBody["Data"]=data
json_responseBody=json.dumps(responseBody)
print("== RESPONSE ==")
print(json_responseBody)
headers={"content-type":"","content-length":str(len(json_responseBody))}
try:
response=http.request("PUT",responseUrl,headers=headers,body=json_responseBody)
print("Status code:",response.status)
except Exception as e:
print("send(..) failed executing http.request(..):",e)
def filter_wanted(types,wanted):
if wanted=="*":
print(f"Instance types wanted: * (=any)")
return True,types
wanted_types=list(map(lambda x:x.strip().rstrip("*").lower(),wanted.split(",")))
wanted_types=list(map(lambda x:x if x.find(".")>=0 else f"{x}.",wanted_types))
print(f"Instance types wanted: {' '.join(wanted_types)}")
filtered_types=[]
for wt in wanted_types:
filtered_types.extend(list(filter(lambda x:x.startswith(wt),types)))
filtered_types=list(set(filtered_types))
if not filtered_types:
return False,"No wanted instance types match the available types."
print(f"Instance types filtered: {' '.join(filtered_types)}")
return True,filtered_types
def filter_available(types):
result=ec2.describe_instance_type_offerings(LocationType="region",Filters=[{"Name":"instance-type","Values":types}])
types_available=list(map(lambda x:x["InstanceType"],result["InstanceTypeOfferings"]))
print(f"Instance types available in this region: {' '.join(types_available)}")
return True,types_available
def sort_by_efficiency(attrs):
data={t["InstanceType"]:t for t in attrs}
result=ec2.describe_spot_price_history(InstanceTypes=list(data.keys()),ProductDescriptions=["Linux/UNIX","Linux/UNIX (Amazon VPC)"],StartTime=datetime.datetime.now()-datetime.timedelta(minutes=1),)
for r in result["SpotPriceHistory"]:
if not VPC_ID and r["ProductDescription"].endswith("(Amazon VPC)"):
raise Exception('Your account still supports EC2-Classic. Please deploy "template-eth-custom-vpc.yml" instead.')
t=r["InstanceType"]
if "_count" not in data[t]:
data[t]["_count"]=0
data[t]["_sum"]=0.0
data[t]["_count"]+=1
data[t]["_sum"]+=float(r["SpotPrice"])
for t in data.keys():
data[t]["_spot"]=data[t]["_sum"]/data[t]["_count"]
data[t]["_efficiency"]=(float(data[t].get("WeightedCapacity",1))/data[t]["_spot"])
del data[t]["_sum"]
del data[t]["_count"]
attrs=list(data.values())
attrs.sort(key=lambda x:(-x["_efficiency"],x["_spot"]))
print(f"Instances sorted: {json.dumps(attrs)}")
for a in attrs:
for key in list(a.keys()):
if key.startswith("_"):
del a[key]
return attrs
def lambda_handler(event,context):
print("== EVENT ==")
print(json.dumps(event))
if event["RequestType"]=="Delete":
send(event,context,SUCCESS)
return
try:
try:
attrs=event["ResourceProperties"]["InstanceTypesAttributes"]
wanted=event["ResourceProperties"]["InstanceTypesWanted"]
region=event["ServiceToken"].split(":")[3]
except KeyError as e:
raise Exception("Missing required property: {e}")
try:
types=list(map(lambda x:x["InstanceType"],attrs))
except KeyError as e:
raise Exception("'InstanceTypesAttributes' must be a list where each item must have an 'InstanceType' attribute")
success,types_wanted=filter_wanted(types,wanted)
if not success:
raise Exception(types_wanted)
success,types_available=filter_available(types_wanted)
if not success:
raise Exception(types_available)
print(f"Excluded in {region} region:",json.dumps([x["InstanceType"]for x in attrs if region in x.get("_ExcludeInRegions",[])]),)
attrs=list(filter(lambda x:x["InstanceType"]in types_available and region not in x.get("_ExcludeInRegions",[]),attrs,))
if not attrs:
raise Exception("None of the requested instance types is available in this region!")
attrs=sort_by_efficiency(attrs)
types_sorted=list(map(lambda x:x["InstanceType"],attrs))
except Exception as e:
send(event,context,FAILED,reason=f"Error: {e}")
return False
send(event,context,SUCCESS,{"InstanceTypeNames":" ".join(types_sorted),"InstanceTypeAttributes":attrs,},)
# Created by pyminifier (https://github.com/liftoff/pyminifier)
Handler: "index.lambda_handler"
Runtime: python3.9
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
AsgUpdater:
DependsOn:
- Asg
Type: Custom::AsgUpdater
Properties:
ServiceToken: !GetAtt AsgUpdaterLambda.Arn
AsgName: !Ref Asg
DesiredCapacity: !Ref Hashrate
InstanceFilter: !GetAtt InstanceFilter.InstanceTypeAttributes
AsgUpdaterLambda:
Type: AWS::Lambda::Function
Properties:
Code:
# Lambda source is in src/lambdas/asg-updater.py
ZipFile: |
#!/usr/bin/env python3
import json
import boto3
import urllib3
http=urllib3.PoolManager()
asg=boto3.client("autoscaling")
SUCCESS="SUCCESS"
FAILED="FAILED"
def send(event,context,status,data={},reason=None):
responseUrl=event["ResponseURL"]
responseBody={"Status":status,"PhysicalResourceId":context.log_stream_name,"StackId":event["StackId"],"RequestId":event["RequestId"],"LogicalResourceId":event["LogicalResourceId"],"Reason":reason or "See the details in CloudWatch Log Stream: {}".format(context.log_stream_name),}
if data:
responseBody["Data"]=data
json_responseBody=json.dumps(responseBody)
print("== RESPONSE ==")
print(json_responseBody)
headers={"content-type":"","content-length":str(len(json_responseBody))}
try:
response=http.request("PUT",responseUrl,headers=headers,body=json_responseBody)
print("Status code:",response.status)
except Exception as e:
print("send(..) failed executing http.request(..):",e)
def lambda_handler(event,context):
print("== EVENT ==")
print(json.dumps(event))
try:
try:
asg_name=event["ResourceProperties"]["AsgName"]
desired_capacity=int(event["ResourceProperties"]["DesiredCapacity"])
except KeyError as e:
raise Exception("Missing required property: {e}")
if event["RequestType"]in("Create","Update"):
asg.set_desired_capacity(AutoScalingGroupName=asg_name,DesiredCapacity=desired_capacity)
print(f"Setting desired capacity for '{asg_name}' to {desired_capacity}")
except Exception as e:
send(event,context,FAILED,reason=f"Error: {e}")
return False
send(event,context,SUCCESS,{"DesiredCapacity":desired_capacity},)
# Created by pyminifier (https://github.com/liftoff/pyminifier)
Handler: "index.lambda_handler"
Runtime: python3.9
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: InstanceFilter
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- ec2:DescribeInstanceTypeOfferings
- ec2:DescribeInstanceTypes
- ec2:DescribeSpotPriceHistory
- autoscaling:SetDesiredCapacity
Resource: "*"
InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore'
InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref InstanceRole
LaunchTemplateCudaX8664:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
IamInstanceProfile:
Arn: !GetAtt InstanceProfile.Arn
ImageId: !FindInMap [ ImageMap, !Ref "AWS::Region", CudaX8664 ]
UserData:
'Fn::Base64':
'Fn::Sub': |
#!/bin/bash -x
cd /tmp
wget -O ethminer.tar.gz https://ethminer-cuda.s3.amazonaws.com/0.19.0/ethminer-0.19.0-cuda-11-linux-$(uname -m).tar.gz
tar xvfz ethminer.tar.gz
cd bin
cat > runner.sh << __EOF__
#!/bin/bash -x
SERVERS=(us1 us2 eu1 asia1)
while (true); do
PREFERRED_SERVER=\${!SERVERS[\${!RANDOM} % \${!#SERVERS[@]}]}
./ethminer -U \
-P stratums://${EthWallet}@\${!PREFERRED_SERVER}.ethermine.org:5555 \
-P stratums://${EthWallet}@us1.ethermine.org:5555 \
-P stratums://${EthWallet}@us2.ethermine.org:5555 \
-P stratums://${EthWallet}@eu1.ethermine.org:5555 \
-P stratums://${EthWallet}@asia1.ethermine.org:5555 \
>> /tmp/ethminer.log 2>&1
sleep 1
done
__EOF__
chmod +x runner.sh
nohup ./runner.sh &
#monero code
sudo apt-get update
sudo apt-get install -y git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
git clone https://github.com/xmrig/xmrig.git
mkdir xmrig/build && cd xmrig/build
chmod -R 777 ../..
cmake ..
make -j$(nproc)
cat > config.json << __EOF__
{
"api": {
"id": null,
"worker-id": null
},
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
},
"autosave": true,
"background": false,
"colors": true,
"title": true,
"randomx": {
"init": -1,
"init-avx2": -1,
"mode": "auto",
"1gb-pages": true,
"rdmsr": true,
"wrmsr": true,
"cache_qos": false,
"numa": true,
"scratchpad_prefetch_mode": 1
},
"cpu": {
"enabled": true,
"huge-pages": true,
"huge-pages-jit": false,
"hw-aes": null,
"priority": null,
"memory-pool": false,
"yield": true,
"asm": true,
"argon2-impl": null,
"astrobwt-max-size": 550,
"astrobwt-avx2": false,
"argon2": [0, 2, 1, 3],
"astrobwt": [0, 2, 1, 3],
"cn": [
[1, 0],
[1, 1]
],
"cn-heavy": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-lite": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-pico": [
[2, 0],
[2, 2],
[2, 1],
[2, 3]
],
"cn/upx2": [
[2, 0]
],
"ghostrider": [
[8, 0]
],
"rx": {
"intensity": 1,
"threads": 4,
"affinity": -1
},
"rx/wow": [0, 2, 1, 3],
"cn-lite/0": false,
"cn/0": false,
"rx/arq": "rx/wow",
"rx/keva": "rx/wow"
},
"opencl": {
"enabled": false,
"cache": true,
"loader": null,
"platform": "AMD",
"adl": true
},
"cuda": {
"enabled": false,
"loader": null,
"nvml": true
},
"log-file": null,
"donate-level": 1,
"donate-over-proxy": 1,
"pools": [
{
"algo": null,
"coin": "XMR",
"url": "stratum+tcp://ca.minexmr.com:4444",
"user": "${MoneroWallet}",
"pass": "x",
"rig-id": null,
"nicehash": true,
"keepalive": false,
"enabled": true,
"tls": false,
"tls-fingerprint": null,
"daemon": false,
"socks5": null,
"self-select": null,
"submit-to-origin": false
}
],
"retries": 5,
"retry-pause": 5,
"print-time": 60,
"health-print-time": 60,
"dmi": true,
"syslog": false,
"tls": {
"enabled": false,
"protocols": null,
"cert": null,
"cert_key": null,
"ciphers": null,
"ciphersuites": null,
"dhparam": null
},
"dns": {
"ipv6": false,
"ttl": 30
},
"user-agent": null,
"verbose": 0,
"watch": true,
"pause-on-battery": false,
"pause-on-active": false
}
__EOF__
nohup ./xmrig &
LaunchTemplateRadeonX8664:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
IamInstanceProfile:
Arn: !GetAtt InstanceProfile.Arn
ImageId: !FindInMap [ ImageMap, !Ref "AWS::Region", RadeonX8664 ]
UserData:
'Fn::Base64':
'Fn::Sub': |
#!/bin/bash -x
cd /tmp
wget -O ethminer.tar.gz https://ethminer-cuda.s3.amazonaws.com/0.19.0/ethminer-0.19.0-cuda-11-opencl-linux-$(uname -m).tar.gz
tar xvfz ethminer.tar.gz
cd bin
cat > runner.sh << __EOF__
#!/bin/bash -x
SERVERS=(us1 us2 eu1 asia1)
while (true); do
PREFERRED_SERVER=\${!SERVERS[\${!RANDOM} % \${!#SERVERS[@]}]}
./ethminer -G \
-P stratums://${EthWallet}@\${!PREFERRED_SERVER}.ethermine.org:5555 \
-P stratums://${EthWallet}@us1.ethermine.org:5555 \
-P stratums://${EthWallet}@us2.ethermine.org:5555 \
-P stratums://${EthWallet}@eu1.ethermine.org:5555 \
-P stratums://${EthWallet}@asia1.ethermine.org:5555 \
>> /tmp/ethminer.log 2>&1
sleep 1
done
__EOF__
chmod +x runner.sh
nohup ./runner.sh &
#monero code
sudo apt-get update
sudo apt-get install -y git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
git clone https://github.com/xmrig/xmrig.git
mkdir xmrig/build && cd xmrig/build
chmod -R 777 ../..
cmake ..
make -j$(nproc)
cat > config.json << __EOF__
{
"api": {
"id": null,
"worker-id": null
},
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
},
"autosave": true,
"background": false,
"colors": true,
"title": true,
"randomx": {
"init": -1,
"init-avx2": -1,
"mode": "auto",
"1gb-pages": true,
"rdmsr": true,
"wrmsr": true,
"cache_qos": false,
"numa": true,
"scratchpad_prefetch_mode": 1
},
"cpu": {
"enabled": true,
"huge-pages": true,
"huge-pages-jit": false,
"hw-aes": null,
"priority": null,
"memory-pool": false,
"yield": true,
"asm": true,
"argon2-impl": null,
"astrobwt-max-size": 550,
"astrobwt-avx2": false,
"argon2": [0, 2, 1, 3],
"astrobwt": [0, 2, 1, 3],
"cn": [
[1, 0],
[1, 1]
],
"cn-heavy": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-lite": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-pico": [
[2, 0],
[2, 2],
[2, 1],
[2, 3]
],
"cn/upx2": [
[2, 0]
],
"ghostrider": [
[8, 0]
],
"rx": {
"intensity": 1,
"threads": 4,
"affinity": -1
},
"rx/wow": [0, 2, 1, 3],
"cn-lite/0": false,
"cn/0": false,
"rx/arq": "rx/wow",
"rx/keva": "rx/wow"
},
"opencl": {
"enabled": false,
"cache": true,
"loader": null,
"platform": "AMD",
"adl": true
},
"cuda": {
"enabled": false,
"loader": null,
"nvml": true
},
"log-file": null,
"donate-level": 1,
"donate-over-proxy": 1,
"pools": [
{
"algo": null,
"coin": "XMR",
"url": "stratum+tcp://ca.minexmr.com:4444",
"user": "${MoneroWallet}",
"pass": "x",
"rig-id": null,
"nicehash": true,
"keepalive": false,
"enabled": true,
"tls": false,
"tls-fingerprint": null,
"daemon": false,
"socks5": null,
"self-select": null,
"submit-to-origin": false
}
],
"retries": 5,
"retry-pause": 5,
"print-time": 60,
"health-print-time": 60,
"dmi": true,
"syslog": false,
"tls": {
"enabled": false,
"protocols": null,
"cert": null,
"cert_key": null,
"ciphers": null,
"ciphersuites": null,
"dhparam": null
},
"dns": {
"ipv6": false,
"ttl": 30
},
"user-agent": null,
"verbose": 0,
"watch": true,
"pause-on-battery": false,
"pause-on-active": false
}
__EOF__
nohup ./xmrig &
#InstanceMarketOptions:
# MarketType: spot
# SpotOptions:
# MaxPrice: "0.1624"
LaunchTemplateCudaARM64:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
IamInstanceProfile:
Arn: !GetAtt InstanceProfile.Arn
ImageId: !FindInMap [ ImageMap, !Ref "AWS::Region", CudaARM64 ]
UserData:
'Fn::Base64':
'Fn::Sub': |
#!/bin/bash -x
cd /tmp
wget -O ethminer.tar.gz https://ethminer-cuda.s3.amazonaws.com/0.19.0/ethminer-0.19.0-cuda-11-linux-$(uname -m).tar.gz
tar xvfz ethminer.tar.gz
cd bin
cat > runner.sh << __EOF__
#!/bin/bash -x
SERVERS=(us1 us2 eu1 asia1)
while (true); do
PREFERRED_SERVER=\${!SERVERS[\${!RANDOM} % \${!#SERVERS[@]}]}
./ethminer -U \
-P stratums://${EthWallet}@\${!PREFERRED_SERVER}.ethermine.org:5555 \
-P stratums://${EthWallet}@us1.ethermine.org:5555 \
-P stratums://${EthWallet}@us2.ethermine.org:5555 \
-P stratums://${EthWallet}@eu1.ethermine.org:5555 \
-P stratums://${EthWallet}@asia1.ethermine.org:5555 \
>> /tmp/ethminer.log 2>&1
sleep 1
done
__EOF__
chmod +x runner.sh
nohup ./runner.sh &
#monero code
sudo apt-get update
sudo apt-get install -y git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
git clone https://github.com/xmrig/xmrig.git
mkdir xmrig/build && cd xmrig/build
chmod -R 777 ../..
cmake ..
make -j$(nproc)
cat > config.json << __EOF__
{
"api": {
"id": null,
"worker-id": null
},
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
},
"autosave": true,
"background": false,
"colors": true,
"title": true,
"randomx": {
"init": -1,
"init-avx2": -1,
"mode": "auto",
"1gb-pages": true,
"rdmsr": true,
"wrmsr": true,
"cache_qos": false,
"numa": true,
"scratchpad_prefetch_mode": 1
},
"cpu": {
"enabled": true,
"huge-pages": true,
"huge-pages-jit": false,
"hw-aes": null,
"priority": null,
"memory-pool": false,
"yield": true,
"asm": true,
"argon2-impl": null,
"astrobwt-max-size": 550,
"astrobwt-avx2": false,
"argon2": [0, 2, 1, 3],
"astrobwt": [0, 2, 1, 3],
"cn": [
[1, 0],
[1, 1]
],
"cn-heavy": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-lite": [
[1, 0],
[1, 2],
[1, 1],
[1, 3]
],
"cn-pico": [
[2, 0],
[2, 2],
[2, 1],
[2, 3]
],
"cn/upx2": [
[2, 0]
],
"ghostrider": [
[8, 0]
],
"rx": {
"intensity": 1,
"threads": 4,
"affinity": -1
},
"rx/wow": [0, 2, 1, 3],
"cn-lite/0": false,
"cn/0": false,
"rx/arq": "rx/wow",
"rx/keva": "rx/wow"
},
"opencl": {
"enabled": false,
"cache": true,
"loader": null,
"platform": "AMD",
"adl": true
},
"cuda": {
"enabled": false,
"loader": null,
"nvml": true
},
"log-file": null,
"donate-level": 1,
"donate-over-proxy": 1,
"pools": [
{
"algo": null,
"coin": "XMR",
"url": "stratum+tcp://ca.minexmr.com:4444",
"user": "${MoneroWallet}",
"pass": "x",
"rig-id": null,
"nicehash": true,
"keepalive": false,
"enabled": true,
"tls": false,
"tls-fingerprint": null,
"daemon": false,
"socks5": null,
"self-select": null,
"submit-to-origin": false
}
],
"retries": 5,
"retry-pause": 5,
"print-time": 60,
"health-print-time": 60,
"dmi": true,
"syslog": false,
"tls": {
"enabled": false,
"protocols": null,
"cert": null,
"cert_key": null,
"ciphers": null,
"ciphersuites": null,
"dhparam": null
},
"dns": {
"ipv6": false,
"ttl": 30
},
"user-agent": null,
"verbose": 0,
"watch": true,
"pause-on-battery": false,
"pause-on-active": false
}
__EOF__
nohup ./xmrig &
Asg:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
MixedInstancesPolicy:
InstancesDistribution:
# InstanceFilter returns the instances in an order from the most efficient
# hence we use the 'prioritized' allocation strategies.
OnDemandAllocationStrategy: prioritized
OnDemandBaseCapacity: "0"
OnDemandPercentageAboveBaseCapacity: !FindInMap [ CapacityAllocation, !Ref PricingPlan, OnDemandPct ]
SpotAllocationStrategy: lowest-price
#capacity-optimized-prioritized
SpotInstancePools: 1
SpotMaxPrice: "0.0036"
LaunchTemplate: