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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use std::{borrow::Cow, num::NonZeroU16, path::PathBuf};
use chrono::{DateTime, Utc};
use linera_base::{
crypto::{AccountPublicKey, CryptoHash, ValidatorPublicKey},
data_types::{Amount, BlockHeight, Epoch, Timestamp},
identifiers::{Account, AccountOwner, ApplicationId, ChainId, ModuleId, StreamId},
time::Duration,
vm::VmRuntime,
};
use linera_client::{
chain_listener::ChainListenerConfig,
client_options::{
ApplicationPermissionsConfig, ChainOwnershipConfig, ResourceControlPolicyConfig,
},
util,
};
use linera_rpc::config::CrossChainConfig;
use crate::{
cli::validator, query_subscription::parse_subscription_ttl, task_processor::parse_operator,
};
const DEFAULT_TOKENS_PER_CHAIN: Amount = Amount::from_millis(100);
const DEFAULT_TRANSACTIONS_PER_BLOCK: usize = 1;
const DEFAULT_WRAP_UP_MAX_IN_FLIGHT: usize = 5;
const DEFAULT_NUM_CHAINS: usize = 10;
const DEFAULT_BPS: usize = 10;
/// Specification for a validator to be added to the committee.
#[derive(Clone, Debug)]
pub struct ValidatorToAdd {
/// The validator's public key.
pub public_key: ValidatorPublicKey,
/// The validator's account public key.
pub account_key: AccountPublicKey,
/// The network address of the validator.
pub address: String,
/// The number of votes assigned to the validator.
pub votes: u64,
}
impl std::str::FromStr for ValidatorToAdd {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Vec<&str> = s.split(',').collect();
anyhow::ensure!(
parts.len() == 4,
"Validator spec must be in format: public_key,account_key,address,votes"
);
Ok(ValidatorToAdd {
public_key: parts[0].parse()?,
account_key: parts[1].parse()?,
address: parts[2].to_string(),
votes: parts[3].parse()?,
})
}
}
#[derive(Clone, clap::Args, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
/// Options controlling the behavior of the benchmark command.
pub struct BenchmarkOptions {
/// How many chains to use.
#[arg(long, default_value_t = DEFAULT_NUM_CHAINS)]
pub num_chains: usize,
/// How many tokens to assign to each newly created chain.
/// These need to cover the transaction fees per chain for the benchmark.
#[arg(long, default_value_t = DEFAULT_TOKENS_PER_CHAIN)]
pub tokens_per_chain: Amount,
/// How many transactions to put in each block.
#[arg(long, default_value_t = DEFAULT_TRANSACTIONS_PER_BLOCK)]
pub transactions_per_block: usize,
/// The application ID of a fungible token on the wallet's default chain.
/// If none is specified, the benchmark uses the native token.
#[arg(long)]
pub fungible_application_id: Option<ApplicationId>,
/// The fixed BPS (Blocks Per Second) rate that block proposals will be sent at.
#[arg(long, default_value_t = DEFAULT_BPS)]
pub bps: usize,
/// If provided, will close the chains after the benchmark is finished. Keep in mind that
/// closing the chains might take a while, and will increase the validator latency while
/// they're being closed.
#[arg(long)]
pub close_chains: bool,
/// A comma-separated list of host:port pairs to query for health metrics.
/// If provided, the benchmark will check these endpoints for validator health
/// and terminate if any validator is unhealthy.
/// Example: "127.0.0.1:21100,validator-1.some-network.linera.net:21100"
#[arg(long)]
pub health_check_endpoints: Option<String>,
/// The maximum number of in-flight requests to validators when wrapping up the benchmark.
/// While wrapping up, this controls the concurrency level when processing inboxes and
/// closing chains.
#[arg(long, default_value_t = DEFAULT_WRAP_UP_MAX_IN_FLIGHT)]
pub wrap_up_max_in_flight: usize,
/// Confirm before starting the benchmark.
#[arg(long)]
pub confirm_before_start: bool,
/// How long to run the benchmark for. If not provided, the benchmark will run until
/// it is interrupted.
#[arg(long)]
pub runtime_in_seconds: Option<u64>,
/// The delay between chains, in milliseconds. For example, if set to 200ms, the first
/// chain will start, then the second will start 200 ms after the first one, the third
/// 200 ms after the second one, and so on.
/// This is used for slowly ramping up the TPS, so we don't pound the validators with the full
/// TPS all at once.
#[arg(long)]
pub delay_between_chains_ms: Option<u64>,
/// Path to YAML file containing chain IDs to send transfers to.
/// If not provided, only transfers between chains in the same wallet.
#[arg(long)]
pub config_path: Option<PathBuf>,
/// Transaction distribution mode. If false (default), distributes transactions evenly
/// across chains within each block. If true, sends all transactions in each block
/// to a single chain, rotating through chains for subsequent blocks.
#[arg(long)]
pub single_destination_per_block: bool,
}
impl Default for BenchmarkOptions {
fn default() -> Self {
Self {
num_chains: DEFAULT_NUM_CHAINS,
tokens_per_chain: DEFAULT_TOKENS_PER_CHAIN,
transactions_per_block: DEFAULT_TRANSACTIONS_PER_BLOCK,
wrap_up_max_in_flight: DEFAULT_WRAP_UP_MAX_IN_FLIGHT,
fungible_application_id: None,
bps: DEFAULT_BPS,
close_chains: false,
health_check_endpoints: None,
confirm_before_start: false,
runtime_in_seconds: None,
delay_between_chains_ms: None,
config_path: None,
single_destination_per_block: false,
}
}
}
#[derive(Clone, clap::Subcommand, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
/// The benchmarking subcommands.
pub enum BenchmarkCommand {
/// Start a single benchmark process, maintaining a given TPS.
Single {
/// The benchmark options.
#[command(flatten)]
options: BenchmarkOptions,
},
/// Run multiple benchmark processes in parallel.
Multi {
/// The benchmark options.
#[command(flatten)]
options: BenchmarkOptions,
/// The number of benchmark processes to run in parallel.
#[arg(long, default_value = "1")]
processes: usize,
/// The faucet (which implicitly defines the network)
#[arg(long)]
faucet: String,
/// If specified, a directory with a random name will be created in this directory, and the
/// client state will be stored there.
/// If not specified, a temporary directory will be used for each client.
#[arg(long)]
client_state_dir: Option<String>,
/// The delay between starting the benchmark processes, in seconds.
/// If --cross-wallet-transfers is true, this will be ignored.
#[arg(long, default_value = "10")]
delay_between_processes: u64,
/// Whether to send transfers between chains in different wallets.
#[arg(long)]
cross_wallet_transfers: bool,
},
}
impl BenchmarkCommand {
/// Returns the number of transactions per block configured for this benchmark.
pub fn transactions_per_block(&self) -> usize {
match self {
Self::Single { options } => options.transactions_per_block,
Self::Multi { options, .. } => options.transactions_per_block,
}
}
}
use crate::util::{
DEFAULT_PAUSE_AFTER_GQL_MUTATIONS_SECS, DEFAULT_PAUSE_AFTER_LINERA_SERVICE_SECS,
};
/// The subcommands of the Linera client binary.
#[derive(Clone, clap::Subcommand)]
pub enum ClientCommand {
/// Transfer funds
Transfer {
/// Sending chain ID (must be one of our chains)
#[arg(long = "from")]
sender: Account,
/// Recipient account
#[arg(long = "to")]
recipient: Account,
/// Amount to transfer
amount: Amount,
},
/// Open (i.e. activate) a new chain deriving the UID from an existing one.
OpenChain {
/// Chain ID (must be one of our chains).
#[arg(long = "from")]
chain_id: Option<ChainId>,
/// The new owner (otherwise create a key pair and remember it)
#[arg(long = "owner")]
owner: Option<AccountOwner>,
/// The initial balance of the new chain. This is subtracted from the parent chain's
/// balance.
#[arg(long = "initial-balance", default_value = "0")]
balance: Amount,
/// Whether to create a super owner for the new chain.
#[arg(long)]
super_owner: bool,
},
/// Open (i.e. activate) a new multi-owner chain deriving the UID from an existing one.
OpenMultiOwnerChain {
/// Chain ID (must be one of our chains).
#[arg(long = "from")]
chain_id: Option<ChainId>,
/// Options configuring the new chain's ownership.
#[clap(flatten)]
ownership_config: ChainOwnershipConfig,
/// Options configuring the new chain's application permissions.
#[clap(flatten)]
application_permissions_config: ApplicationPermissionsConfig,
/// The initial balance of the new chain. This is subtracted from the parent chain's
/// balance.
#[arg(long = "initial-balance", default_value = "0")]
balance: Amount,
},
/// Display who owns the chain, and how the owners work together proposing blocks.
ShowOwnership {
/// The ID of the chain whose owners will be changed.
#[clap(long)]
chain_id: Option<ChainId>,
},
/// Change who owns the chain, and how the owners work together proposing blocks.
///
/// Specify the complete set of new owners, by public key. Existing owners that are
/// not included will be removed.
ChangeOwnership {
/// The ID of the chain whose owners will be changed.
#[clap(long)]
chain_id: Option<ChainId>,
/// Options configuring the new chain's ownership.
#[clap(flatten)]
ownership_config: ChainOwnershipConfig,
},
/// Change the preferred owner of a chain.
SetPreferredOwner {
/// The ID of the chain whose preferred owner will be changed.
#[clap(long)]
chain_id: Option<ChainId>,
/// The new preferred owner.
#[arg(long)]
owner: AccountOwner,
},
/// Changes the application permissions configuration.
ChangeApplicationPermissions {
/// The ID of the chain to which the new permissions will be applied.
#[arg(long)]
chain_id: Option<ChainId>,
/// Options configuring the new chain's application permissions.
#[clap(flatten)]
application_permissions_config: ApplicationPermissionsConfig,
},
/// Close an existing chain.
///
/// A closed chain cannot execute operations or accept messages anymore.
/// It can still reject incoming messages, so they bounce back to the sender.
CloseChain {
/// Chain ID (must be one of our chains)
chain_id: ChainId,
},
/// Print out the network description.
ShowNetworkDescription,
/// Read the current native-token balance of the given account directly from the local
/// state.
///
/// NOTE: The local balance does not reflect messages that are waiting to be picked in
/// the local inbox, or that have not been synchronized from validators yet. Use
/// `linera sync` then either `linera query-balance` or `linera process-inbox &&
/// linera local-balance` for a consolidated balance.
LocalBalance {
/// The account to read, written as `OWNER@CHAIN-ID` or simply `CHAIN-ID` for the
/// chain balance. By default, we read the chain balance of the default chain in
/// the wallet.
account: Option<Account>,
},
/// Simulate the execution of one block made of pending messages from the local inbox,
/// then read the native-token balance of the account from the local state.
///
/// NOTE: The balance does not reflect messages that have not been synchronized from
/// validators yet. Call `linera sync` first to do so.
QueryBalance {
/// The account to query, written as `OWNER@CHAIN-ID` or simply `CHAIN-ID` for the
/// chain balance. By default, we read the chain balance of the default chain in
/// the wallet.
account: Option<Account>,
},
/// (DEPRECATED) Synchronize the local state of the chain with a quorum validators, then query the
/// local balance.
///
/// This command is deprecated. Use `linera sync && linera query-balance` instead.
SyncBalance {
/// The account to query, written as `OWNER@CHAIN-ID` or simply `CHAIN-ID` for the
/// chain balance. By default, we read the chain balance of the default chain in
/// the wallet.
account: Option<Account>,
},
/// Synchronize the local state of the chain with a quorum validators.
Sync {
/// The chain to synchronize with validators. If omitted, synchronizes the
/// default chain of the wallet.
chain_id: Option<ChainId>,
/// Stop synchronizing at this block height (exclusive). For instance,
/// `--next-height 0` downloads zero blocks, `--next-height 10` downloads
/// blocks 0 through 9.
#[arg(long)]
next_height: Option<BlockHeight>,
/// Stop synchronizing at the first block with a timestamp greater than this
/// value. The format is `YYYY-MM-DDTHH:MM:SS` or
/// `YYYY-MM-DD HH:MM:SS` in UTC.
#[arg(long)]
until_block_time: Option<Timestamp>,
},
/// Process all pending incoming messages from the inbox of the given chain by creating as many
/// blocks as needed to execute all (non-failing) messages. Failing messages will be
/// marked as rejected and may bounce to their sender depending on their configuration.
ProcessInbox {
/// The chain to process. If omitted, uses the default chain of the wallet.
chain_id: Option<ChainId>,
},
/// Deprecates all committees up to and including the specified one.
RevokeEpochs {
/// The highest epoch to deprecate.
epoch: Epoch,
},
/// View or update the resource control policy
ResourceControlPolicy {
/// Set the price per unit of Wasm fuel.
#[arg(long)]
wasm_fuel_unit: Option<Amount>,
/// Set the price per unit of EVM fuel.
#[arg(long)]
evm_fuel_unit: Option<Amount>,
/// Set the price per read operation.
#[arg(long)]
read_operation: Option<Amount>,
/// Set the price per write operation.
#[arg(long)]
write_operation: Option<Amount>,
/// Set the price per byte read from runtime.
#[arg(long)]
byte_runtime: Option<Amount>,
/// Set the price per byte read.
#[arg(long)]
byte_read: Option<Amount>,
/// Set the price per byte written.
#[arg(long)]
byte_written: Option<Amount>,
/// Set the base price to read a blob.
#[arg(long)]
blob_read: Option<Amount>,
/// Set the base price to publish a blob.
#[arg(long)]
blob_published: Option<Amount>,
/// Set the price to read a blob, per byte.
#[arg(long)]
blob_byte_read: Option<Amount>,
/// The price to publish a blob, per byte.
#[arg(long)]
blob_byte_published: Option<Amount>,
/// Set the price per byte stored.
#[arg(long)]
byte_stored: Option<Amount>,
/// Set the base price of sending an operation from a block..
#[arg(long)]
operation: Option<Amount>,
/// Set the additional price for each byte in the argument of a user operation.
#[arg(long)]
operation_byte: Option<Amount>,
/// Set the base price of sending a message from a block..
#[arg(long)]
message: Option<Amount>,
/// Set the additional price for each byte in the argument of a user message.
#[arg(long)]
message_byte: Option<Amount>,
/// Set the price per query to a service as an oracle.
#[arg(long)]
service_as_oracle_query: Option<Amount>,
/// Set the price for performing an HTTP request.
#[arg(long)]
http_request: Option<Amount>,
/// Set the maximum amount of Wasm fuel per block.
#[arg(long)]
maximum_wasm_fuel_per_block: Option<u64>,
/// Set the maximum amount of EVM fuel per block.
#[arg(long)]
maximum_evm_fuel_per_block: Option<u64>,
/// Set the maximum time in milliseconds that a block can spend executing services as oracles.
#[arg(long)]
maximum_service_oracle_execution_ms: Option<u64>,
/// Set the maximum size of a block, in bytes.
#[arg(long)]
maximum_block_size: Option<u64>,
/// Set the maximum size of data blobs, compressed bytecode and other binary blobs,
/// in bytes.
#[arg(long)]
maximum_blob_size: Option<u64>,
/// Set the maximum number of published blobs per block.
#[arg(long)]
maximum_published_blobs: Option<u64>,
/// Set the maximum size of decompressed contract or service bytecode, in bytes.
#[arg(long)]
maximum_bytecode_size: Option<u64>,
/// Set the maximum size of a block proposal, in bytes.
#[arg(long)]
maximum_block_proposal_size: Option<u64>,
/// Set the maximum read data per block.
#[arg(long)]
maximum_bytes_read_per_block: Option<u64>,
/// Set the maximum write data per block.
#[arg(long)]
maximum_bytes_written_per_block: Option<u64>,
/// Set the maximum size of oracle responses.
#[arg(long)]
maximum_oracle_response_bytes: Option<u64>,
/// Set the maximum size in bytes of a received HTTP response.
#[arg(long)]
maximum_http_response_bytes: Option<u64>,
/// Set the maximum amount of time allowed to wait for an HTTP response.
#[arg(long)]
http_request_timeout_ms: Option<u64>,
/// Set the list of hosts that contracts and services can send HTTP requests to.
///
/// Besides hostnames, the following special flags are recognized:
///
/// - `FLAG_ZERO_HASH.linera.network`: Skip hashing of the execution state
/// (return all zeros instead).
/// - `FLAG_FREE_REJECT.linera.network`: Make bouncing messages free of charge.
/// - `FLAG_MANDATORY_APPS_NEED_ACCEPTED_MESSAGE.linera.network`: Require
/// accepted (not rejected) incoming messages to satisfy mandatory application
/// checks.
/// - `FLAG_FREE_APPLICATION_ID_<APP_ID>.linera.network`: Waive all message-
/// and event-related fees for the given application ID (see also
/// `--free-application-ids`).
#[arg(long, value_delimiter = ',')]
http_request_allow_list: Option<Vec<String>>,
/// Set the list of application IDs for which message- and event-related fees are waived.
///
/// This is a convenience flag that adds
/// `FLAG_FREE_APPLICATION_ID_<APP_ID>.linera.network` entries to the HTTP
/// request allow list.
#[arg(long, value_delimiter = ',')]
free_application_ids: Option<Vec<String>>,
},
/// Run benchmarks to test network performance.
#[command(subcommand)]
Benchmark(BenchmarkCommand),
/// Create genesis configuration for a Linera deployment.
/// Create initial user chains and print information to be used for initialization of validator setup.
/// This will also create an initial wallet for the owner of the initial "root" chains.
CreateGenesisConfig {
/// Sets the file describing the public configurations of all validators
#[arg(long = "committee")]
committee_config_path: PathBuf,
/// The output config path to be consumed by the server
#[arg(long = "genesis")]
genesis_config_path: PathBuf,
/// Known initial balance of the chain
#[arg(long, default_value = "0")]
initial_funding: Amount,
/// The start timestamp: no blocks can be created before this time.
#[arg(long)]
start_timestamp: Option<DateTime<Utc>>,
/// Number of initial (aka "root") chains to create in addition to the admin chain.
num_other_initial_chains: u32,
/// Configure the resource control policy (notably fees) according to pre-defined
/// settings.
#[arg(long, default_value = "no-fees")]
policy_config: ResourceControlPolicyConfig,
/// Set the price per unit of Wasm fuel.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
wasm_fuel_unit_price: Option<Amount>,
/// Set the price per unit of EVM fuel.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
evm_fuel_unit_price: Option<Amount>,
/// Set the price per read operation.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
read_operation_price: Option<Amount>,
/// Set the price per write operation.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
write_operation_price: Option<Amount>,
/// Set the price per byte read from runtime.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
byte_runtime_price: Option<Amount>,
/// Set the price per byte read.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
byte_read_price: Option<Amount>,
/// Set the price per byte written.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
byte_written_price: Option<Amount>,
/// Set the base price to read a blob.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
blob_read_price: Option<Amount>,
/// Set the base price to publish a blob.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
blob_published_price: Option<Amount>,
/// Set the price to read a blob, per byte.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
blob_byte_read_price: Option<Amount>,
/// Set the price to publish a blob, per byte.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
blob_byte_published_price: Option<Amount>,
/// Set the price per byte stored.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
byte_stored_price: Option<Amount>,
/// Set the base price of sending an operation from a block..
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
operation_price: Option<Amount>,
/// Set the additional price for each byte in the argument of a user operation.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
operation_byte_price: Option<Amount>,
/// Set the base price of sending a message from a block..
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
message_price: Option<Amount>,
/// Set the additional price for each byte in the argument of a user message.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
message_byte_price: Option<Amount>,
/// Set the price per query to a service as an oracle.
#[arg(long)]
service_as_oracle_query_price: Option<Amount>,
/// Set the price for performing an HTTP request.
#[arg(long)]
http_request_price: Option<Amount>,
/// Set the maximum amount of Wasm fuel per block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_wasm_fuel_per_block: Option<u64>,
/// Set the maximum amount of EVM fuel per block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_evm_fuel_per_block: Option<u64>,
/// Set the maximum time in milliseconds that a block can spend executing services as oracles.
#[arg(long)]
maximum_service_oracle_execution_ms: Option<u64>,
/// Set the maximum size of a block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_block_size: Option<u64>,
/// Set the maximum size of decompressed contract or service bytecode, in bytes.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_bytecode_size: Option<u64>,
/// Set the maximum size of data blobs, compressed bytecode and other binary blobs,
/// in bytes.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_blob_size: Option<u64>,
/// Set the maximum number of published blobs per block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_published_blobs: Option<u64>,
/// Set the maximum size of a block proposal, in bytes.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_block_proposal_size: Option<u64>,
/// Set the maximum read data per block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_bytes_read_per_block: Option<u64>,
/// Set the maximum write data per block.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_bytes_written_per_block: Option<u64>,
/// Set the maximum size of oracle responses.
/// (This will overwrite value from `--policy-config`)
#[arg(long)]
maximum_oracle_response_bytes: Option<u64>,
/// Set the maximum size in bytes of a received HTTP response.
#[arg(long)]
maximum_http_response_bytes: Option<u64>,
/// Set the maximum amount of time allowed to wait for an HTTP response.
#[arg(long)]
http_request_timeout_ms: Option<u64>,
/// Set the list of hosts that contracts and services can send HTTP requests to.
///
/// Besides hostnames, the following special flags are recognized:
///
/// - `FLAG_ZERO_HASH.linera.network`: Skip hashing of the execution state
/// (return all zeros instead).
/// - `FLAG_FREE_REJECT.linera.network`: Make bouncing messages free of charge.
/// - `FLAG_MANDATORY_APPS_NEED_ACCEPTED_MESSAGE.linera.network`: Require
/// accepted (not rejected) incoming messages to satisfy mandatory application
/// checks.
/// - `FLAG_FREE_APPLICATION_ID_<APP_ID>.linera.network`: Waive all message-
/// and event-related fees for the given application ID (see also
/// `--free-application-ids`).
#[arg(long, value_delimiter = ',')]
http_request_allow_list: Option<Vec<String>>,
/// Set the list of application IDs for which message- and event-related fees are waived.
///
/// This is a convenience flag that adds
/// `FLAG_FREE_APPLICATION_ID_<APP_ID>.linera.network` entries to the HTTP
/// request allow list.
#[arg(long, value_delimiter = ',')]
free_application_ids: Option<Vec<String>>,
/// Force this wallet to generate keys using a PRNG and a given seed. USE FOR
/// TESTING ONLY.
#[arg(long)]
testing_prng_seed: Option<u64>,
/// A unique name to identify this network.
#[arg(long)]
network_name: Option<String>,
},
/// Watch the network for notifications.
Watch {
/// The chain ID to watch.
chain_id: Option<ChainId>,
/// Show all notifications from all validators.
#[arg(long)]
raw: bool,
},
/// Run a GraphQL service to explore and extend the chains of the wallet.
Service {
/// Configuration for the chain listener backing the service.
#[command(flatten)]
config: ChainListenerConfig,
/// The port on which to run the server
#[arg(long)]
port: NonZeroU16,
/// The port to expose metrics on.
#[cfg(with_metrics)]
#[arg(long)]
metrics_port: NonZeroU16,
/// Application IDs of operator applications to watch.
/// When specified, a task processor is started alongside the node service.
#[arg(long = "operator-application-ids")]
operator_application_ids: Vec<ApplicationId>,
/// A controller to execute a dynamic set of applications running on a dynamic set of
/// chains.
#[arg(long = "controller-id")]
controller_application_id: Option<ApplicationId>,
/// Supported operators and their binary paths.
/// Format: `name=path` or just `name` (uses name as path).
/// Example: `--operators my-operator=/path/to/binary`
#[arg(long = "operators", value_parser = parse_operator)]
operators: Vec<(String, PathBuf)>,
/// Delay in seconds before retrying a failed operator task batch.
/// Only relevant when operators are configured via `--operator-application-ids`
/// or `--controller-id`.
#[arg(long, default_value = "5")]
task_retry_delay_secs: u64,
/// Run in read-only mode: disallow mutations and prevent queries from scheduling
/// operations. Use this when exposing the service to untrusted clients.
#[arg(long)]
read_only: bool,
/// Enable the application query response cache with the given per-chain capacity.
/// Each entry stores a serialized GraphQL response keyed by
/// (application_id, request_bytes). Incompatible with `--long-lived-services`.
#[arg(long, env = "LINERA_QUERY_CACHE_SIZE")]
query_cache_size: Option<usize>,
/// Allow a named GraphQL subscription query.
/// The operation name is extracted from the query string.
/// Repeatable.
/// Example: `--allow-subscription 'query CounterValue { getCounter { value } }'`
#[arg(long = "allow-subscription")]
allowed_subscriptions: Vec<String>,
/// Set a minimum TTL (in seconds) for a subscription query's cached result.
/// When set, invalidations that arrive before the TTL expires are deferred
/// until the remaining time elapses. Format: `Name=Secs`.
/// Repeatable.
/// Example: `--subscription-ttl-secs CounterValue=30`
#[arg(long = "subscription-ttl-secs", value_parser = parse_subscription_ttl)]
subscription_ttls: Vec<(String, u64)>,
/// Start in paused mode: do not synchronize chains from the network.
/// The service will serve queries from local state only, without downloading
/// new blocks or processing incoming messages.
#[arg(long)]
pause: bool,
},
/// Run a GraphQL service that exposes a faucet where users can claim tokens.
/// This gives away the chain's tokens, and is mainly intended for testing.
Faucet {
/// The chain that gives away its tokens.
chain_id: Option<ChainId>,
/// The port on which to run the server
#[arg(long, default_value = "8080")]
port: u16,
/// The port for prometheus to scrape.
#[cfg(with_metrics)]
#[arg(long, default_value = "9090")]
metrics_port: u16,
/// The number of tokens to send to each new chain.
#[arg(long)]
amount: Amount,
/// The number of tokens to send per daily claim. Set to 0 to disable daily claims.
#[arg(long, default_value = "0")]
daily_claim_amount: Amount,
/// The end timestamp: The faucet will rate-limit the token supply so it runs out of money
/// no earlier than this.
#[arg(long)]
limit_rate_until: Option<DateTime<Utc>>,
/// Configuration for the faucet chain listener.
#[command(flatten)]
config: ChainListenerConfig,
/// Path to the persistent storage file for faucet mappings.
#[arg(long)]
storage_path: PathBuf,
/// Maximum number of operations to include in a single block (default: 100).
#[arg(long, default_value = "100")]
max_batch_size: usize,
},
/// Publish module.
PublishModule {
/// Path to the Wasm file for the application "contract" bytecode.
contract: PathBuf,
/// Path to the Wasm file for the application "service" bytecode.
service: PathBuf,
/// The virtual machine runtime to use.
#[arg(long, default_value = "wasm")]
vm_runtime: VmRuntime,
/// An optional chain ID to publish the module. The default chain of the wallet
/// is used otherwise.
publisher: Option<ChainId>,
},
/// Publish a module along with the JSON-encoded `Formats` description loaded
/// from an insta SNAP file. The publication and the formats-registry write
/// happen atomically in a single block.
PublishModuleWithFormats {
/// Path to the Wasm file for the application "contract" bytecode.
contract: PathBuf,
/// Path to the Wasm file for the application "service" bytecode.
service: PathBuf,
/// Path to the insta SNAP file containing the YAML serialization of the
/// application's `Formats`.
formats: PathBuf,
/// The application ID of the formats registry that will receive the
/// JSON-encoded formats.
registry_application_id: ApplicationId,
/// The virtual machine runtime to use.
#[arg(long, default_value = "wasm")]
vm_runtime: VmRuntime,
/// An optional chain ID to publish the module. The default chain of the wallet
/// is used otherwise.
publisher: Option<ChainId>,
},
/// Print events from a specific chain and stream from a specified index.
ListEventsFromIndex {
/// The chain to query. If omitted, query the default chain of the wallet.
chain_id: Option<ChainId>,
/// The stream being considered.
#[arg(long)]
stream_id: StreamId,
/// Index of the message to start with
#[arg(long, default_value = "0")]
start_index: u32,
},
/// Publish a data blob of binary data.
PublishDataBlob {
/// Path to data blob file to be published.
blob_path: PathBuf,
/// An optional chain ID to publish the blob. The default chain of the wallet
/// is used otherwise.
publisher: Option<ChainId>,
},
// TODO(#2490): Consider removing or renaming this.
/// Verify that a data blob is readable.
ReadDataBlob {
/// The hash of the content.
hash: CryptoHash,
/// An optional chain ID to verify the blob. The default chain of the wallet
/// is used otherwise.
reader: Option<ChainId>,
},
/// Describe an existing application: print its `ApplicationDescription` (module
/// ID, creator chain, parameters and required dependencies) as JSON. The
/// description is content-addressed and fetched from the validators, so the
/// application need not be registered on the wallet's default chain.
DescribeApplication {
/// The ID of the application to describe.
application_id: ApplicationId,
},
/// Create an application.
CreateApplication {
/// The module ID of the application to create.
module_id: ModuleId,
/// An optional chain ID to host the application. The default chain of the wallet
/// is used otherwise.
creator: Option<ChainId>,
/// The shared parameters as JSON string.
#[arg(long)]
json_parameters: Option<String>,
/// Path to a JSON file containing the shared parameters.
#[arg(long)]
json_parameters_path: Option<PathBuf>,
/// The instantiation argument as a JSON string.
#[arg(long)]
json_argument: Option<String>,
/// Path to a JSON file containing the instantiation argument.
#[arg(long)]
json_argument_path: Option<PathBuf>,
/// The list of required dependencies of application, if any.
#[arg(long, num_args(0..))]
required_application_ids: Option<Vec<ApplicationId>>,
},
/// Create an application, and publish the required module.
PublishAndCreate {
/// Path to the Wasm file for the application "contract" bytecode.
contract: PathBuf,
/// Path to the Wasm file for the application "service" bytecode.
service: PathBuf,
/// The virtual machine runtime to use.
#[arg(long, default_value = "wasm")]
vm_runtime: VmRuntime,
/// An optional chain ID to publish the module. The default chain of the wallet
/// is used otherwise.
publisher: Option<ChainId>,
/// The shared parameters as JSON string.
#[arg(long)]
json_parameters: Option<String>,
/// Path to a JSON file containing the shared parameters.
#[arg(long)]
json_parameters_path: Option<PathBuf>,
/// The instantiation argument as a JSON string.
#[arg(long)]
json_argument: Option<String>,
/// Path to a JSON file containing the instantiation argument.
#[arg(long)]
json_argument_path: Option<PathBuf>,
/// The list of required dependencies of application, if any.
#[arg(long, num_args(0..))]
required_application_ids: Option<Vec<ApplicationId>>,
},
/// Create an unassigned key pair.
Keygen,
/// Link the owner to the chain.
/// Expects that the caller has a private key corresponding to the `public_key`,
/// otherwise block proposals will fail when signing with it.
Assign {
/// The owner to assign.
#[arg(long)]
owner: AccountOwner,
/// The ID of the chain.
#[arg(long)]
chain_id: ChainId,
},
/// Retry a block we unsuccessfully tried to propose earlier.
///
/// As long as a block is pending most other commands will fail, since it is unsafe to propose
/// multiple blocks at the same height.
RetryPendingBlock {
/// The chain with the pending block. If not specified, the wallet's default chain is used.
chain_id: Option<ChainId>,
},
/// Execute a raw user operation on an application.
///
/// The operation bytes are provided as a hex string (BCS-encoded).
ExecuteOperation {
/// The application to send the operation to.
#[arg(long)]
application_id: ApplicationId,
/// BCS-encoded operation bytes as a hex string.
#[arg(long)]
operation: String,
/// Chain ID to submit the operation on. Defaults to the wallet's default chain.
#[arg(long)]
chain_id: Option<ChainId>,
},
/// Show the contents of the wallet.
#[command(subcommand)]
Wallet(WalletCommand),
/// Show the information about a chain.
#[command(subcommand)]
Chain(ChainCommand),
/// Manage Linera projects.
#[command(subcommand)]
Project(ProjectCommand),
/// Manage a local Linera Network.
#[command(subcommand)]
Net(NetCommand),
/// Manage validators in the committee.
#[command(subcommand)]
Validator(validator::Command),
/// Operation on the storage.
#[command(subcommand)]
Storage(DatabaseToolCommand),
/// Print CLI help in Markdown format, and exit.
#[command(hide = true)]
HelpMarkdown,
/// Extract a Bash and GraphQL script embedded in a markdown file and print it on
/// `stdout`.
#[command(hide = true)]
ExtractScriptFromMarkdown {
/// The source file
path: PathBuf,
/// Insert a pause of N seconds after calls to `linera service`.
#[arg(long, default_value = DEFAULT_PAUSE_AFTER_LINERA_SERVICE_SECS, value_parser = util::parse_secs)]
pause_after_linera_service: Duration,
/// Insert a pause of N seconds after GraphQL queries.
#[arg(long, default_value = DEFAULT_PAUSE_AFTER_GQL_MUTATIONS_SECS, value_parser = util::parse_secs)]
pause_after_gql_mutations: Duration,
},
/// Generate shell completion scripts
Completion {
/// The shell to generate completions for
#[arg(value_enum)]
shell: clap_complete::Shell,
},
}
impl ClientCommand {
/// Returns the log file name to use based on the [`ClientCommand`] that will run.
pub fn log_file_name(&self) -> Cow<'static, str> {
match self {
ClientCommand::Transfer { .. }
| ClientCommand::OpenChain { .. }
| ClientCommand::OpenMultiOwnerChain { .. }
| ClientCommand::ShowOwnership { .. }
| ClientCommand::ChangeOwnership { .. }
| ClientCommand::SetPreferredOwner { .. }
| ClientCommand::ChangeApplicationPermissions { .. }
| ClientCommand::CloseChain { .. }
| ClientCommand::ShowNetworkDescription
| ClientCommand::LocalBalance { .. }
| ClientCommand::QueryBalance { .. }
| ClientCommand::SyncBalance { .. }
| ClientCommand::Sync { .. }
| ClientCommand::ProcessInbox { .. }
| ClientCommand::ResourceControlPolicy { .. }
| ClientCommand::RevokeEpochs { .. }
| ClientCommand::CreateGenesisConfig { .. }
| ClientCommand::PublishModule { .. }
| ClientCommand::PublishModuleWithFormats { .. }
| ClientCommand::ListEventsFromIndex { .. }
| ClientCommand::PublishDataBlob { .. }
| ClientCommand::ReadDataBlob { .. }
| ClientCommand::DescribeApplication { .. }
| ClientCommand::CreateApplication { .. }
| ClientCommand::PublishAndCreate { .. }
| ClientCommand::Keygen
| ClientCommand::Assign { .. }
| ClientCommand::Wallet { .. }
| ClientCommand::Chain { .. }
| ClientCommand::Validator { .. }
| ClientCommand::RetryPendingBlock { .. }
| ClientCommand::ExecuteOperation { .. } => "client".into(),
ClientCommand::Benchmark(BenchmarkCommand::Single { .. }) => "single-benchmark".into(),
ClientCommand::Benchmark(BenchmarkCommand::Multi { .. }) => "multi-benchmark".into(),
ClientCommand::Net { .. } => "net".into(),
ClientCommand::Project { .. } => "project".into(),
ClientCommand::Watch { .. } => "watch".into(),
ClientCommand::Storage { .. } => "storage".into(),
ClientCommand::Service { port, .. } => format!("service-{port}").into(),
ClientCommand::Faucet { .. } => "faucet".into(),
ClientCommand::HelpMarkdown
| ClientCommand::ExtractScriptFromMarkdown { .. }
| ClientCommand::Completion { .. } => "tool".into(),
}
}
}
#[derive(Clone, clap::Parser)]
/// The subcommands for managing the storage database.
pub enum DatabaseToolCommand {
/// Delete all the namespaces in the database
DeleteAll,
/// Delete a single namespace from the database
DeleteNamespace,
/// Check existence of a namespace in the database
CheckExistence,
/// Initialize a namespace in the database
Initialize {
/// The path to the genesis configuration file.
#[arg(long = "genesis")]
genesis_config_path: PathBuf,
},
/// List the namespaces in the database
ListNamespaces,
/// List the blob IDs in the database
ListBlobIds,
/// List the chain IDs in the database
ListChainIds,
}
#[expect(clippy::large_enum_variant)]
#[derive(Clone, clap::Parser)]
/// The subcommands for managing a local Linera network.
pub enum NetCommand {
/// Start a Local Linera Network
Up {
/// The number of initial "root" chains created in the genesis config on top of
/// the default "admin" chain. All initial chains belong to the first "admin"
/// wallet. It is recommended to use at least one other initial chain for the
/// faucet.
#[arg(long, default_value = "2")]
other_initial_chains: u32,
/// The initial amount of native tokens credited in the initial "root" chains,
/// including the default "admin" chain.
#[arg(long, default_value = "1000000")]
initial_amount: u128,
/// The number of validators in the local test network.
#[arg(long, default_value = "1")]
validators: usize,
/// The number of shards per validator in the local test network.
#[arg(long, default_value = "1")]
shards: usize,
/// Configure the resource control policy (notably fees) according to pre-defined
/// settings.
#[arg(long, default_value = "no-fees")]
policy_config: ResourceControlPolicyConfig,
/// The configuration for cross-chain messages.
#[clap(flatten)]
cross_chain_config: CrossChainConfig,
/// Force this wallet to generate keys using a PRNG and a given seed. USE FOR
/// TESTING ONLY.
#[arg(long)]
testing_prng_seed: Option<u64>,
/// Run with a specific path where the wallet and validator input files are.
/// If none, then a temporary directory is created.
#[arg(long)]
path: Option<String>,
/// External protocol used, either `grpc` or `grpcs`.
#[arg(long, default_value = "grpc")]
external_protocol: String,
/// If present, a faucet is started using the chain provided by --faucet-chain, or
/// the first non-admin chain if not provided.
#[arg(long, default_value = "false")]
with_faucet: bool,
/// When using --with-faucet, this specifies the chain on which the faucet will be started.
/// If this is `n`, the `n`-th non-admin chain (lexicographically) in the wallet is selected.
#[arg(long)]
faucet_chain: Option<u32>,
/// The port on which to run the faucet server
#[arg(long, default_value = "8080")]
faucet_port: NonZeroU16,
/// The number of tokens to send to each new chain created by the faucet.
#[arg(long, default_value = "1000")]
faucet_amount: Amount,
/// Whether to start a block exporter for each validator.
#[arg(long, default_value = "false")]
with_block_exporter: bool,
/// The number of block exporters to start.
#[arg(long, default_value = "1")]
num_block_exporters: usize,
/// The address of the block exporter.
#[arg(long, default_value = "localhost")]
exporter_address: String,
/// The port on which to run the block exporter.
#[arg(long, default_value = "8081")]
exporter_port: NonZeroU16,
/// Set the list of hosts that contracts and services can send HTTP requests to.
#[arg(long, value_delimiter = ',')]
http_request_allow_list: Option<Vec<String>>,
},
/// Print a bash helper script to make `linera net up` easier to use. The script is
/// meant to be installed in `~/.bash_profile` or sourced when needed.
Helper,
}
#[derive(Clone, clap::Subcommand)]
/// The subcommands for managing the wallet.
pub enum WalletCommand {
/// Show the contents of the wallet.
Show {
/// The chain to show the metadata.
chain_id: Option<ChainId>,
/// Only print a non-formatted list of the wallet's chain IDs.
#[arg(long)]
short: bool,
/// Print only the chains that we have a key pair for.
#[arg(long)]
owned: bool,
},
/// Change the wallet default chain.
SetDefault {
/// The chain to set as the default.
chain_id: ChainId,
},
/// Initialize a wallet from the genesis configuration.
Init {
/// The path to the genesis configuration for a Linera deployment. Either this or `--faucet`
/// must be specified.
#[arg(long = "genesis")]
genesis_config_path: Option<PathBuf>,
/// The address of a faucet.
#[arg(long = "faucet")]
faucet: Option<String>,
/// Force this wallet to generate keys using a PRNG and a given seed. USE FOR
/// TESTING ONLY.
#[arg(long)]
testing_prng_seed: Option<u64>,
},
/// Request a new chain from a faucet and add it to the wallet.
RequestChain {
/// The address of a faucet.
#[arg(long)]
faucet: String,
/// Whether this chain should become the default chain.
#[arg(long)]
set_default: bool,
},
/// Export the genesis configuration to a JSON file.
///
/// By default, exports the genesis config from the current wallet. Alternatively,
/// use `--faucet` to retrieve the genesis config directly from a faucet URL.
ExportGenesis {
/// Path to save the genesis configuration JSON file.
output: PathBuf,
/// The address of a faucet to retrieve the genesis config from.
/// If not specified, the genesis config is read from the current wallet.
#[arg(long)]
faucet: Option<String>,
},
/// Add a new followed chain (i.e. a chain without keypair) to the wallet.
FollowChain {
/// The chain ID.
chain_id: ChainId,
/// Synchronize the new chain and download all its blocks from the validators.
#[arg(long)]
sync: bool,
},
/// Forgets the specified chain's keys. The chain will still be followed by the
/// wallet.
ForgetKeys {
/// The chain whose keys will be forgotten.
chain_id: ChainId,
},
/// Forgets the specified chain, including the associated key pair.
ForgetChain {
/// The chain to forget.
chain_id: ChainId,
},
}
#[derive(Clone, clap::Subcommand)]
/// The subcommands for inspecting chains.
pub enum ChainCommand {
/// Show the contents of a block.
ShowBlock {
/// The height of the block.
height: BlockHeight,
/// The chain to show the block (if not specified, the default chain from the
/// wallet is used).
chain_id: Option<ChainId>,
},
/// Show the chain description of a chain.
ShowChainDescription {
/// The chain ID to show (if not specified, the default chain from the wallet is
/// used).
chain_id: Option<ChainId>,
},
}
#[derive(Clone, clap::Parser)]
/// The subcommands for managing Linera projects.
pub enum ProjectCommand {
/// Create a new Linera project.
New {
/// The project name. A directory of the same name will be created in the current directory.
name: String,
/// Use the given clone of the Linera repository instead of remote crates.
#[arg(long)]
linera_root: Option<PathBuf>,
},
/// Test a Linera project.
///
/// Equivalent to running `cargo test` with the appropriate test runner.
Test {
/// The path of the root of the Linera project to test.
path: Option<PathBuf>,
},
/// Build and publish a Linera project.
PublishAndCreate {
/// The path of the root of the Linera project.
/// Defaults to current working directory if unspecified.
path: Option<PathBuf>,
/// Specify the name of the Linera project.
/// This is used to locate the generated bytecode files. The generated bytecode files should
/// be of the form `<name>_{contract,service}.wasm`.
///
/// Defaults to the package name in Cargo.toml, with dashes replaced by
/// underscores.
name: Option<String>,
/// An optional chain ID to publish the module. The default chain of the wallet
/// is used otherwise.
publisher: Option<ChainId>,
/// The virtual machine runtime to use.
#[arg(long, default_value = "wasm")]
vm_runtime: VmRuntime,
/// The shared parameters as JSON string.
#[arg(long)]
json_parameters: Option<String>,
/// Path to a JSON file containing the shared parameters.
#[arg(long)]
json_parameters_path: Option<PathBuf>,
/// The instantiation argument as a JSON string.
#[arg(long)]
json_argument: Option<String>,
/// Path to a JSON file containing the instantiation argument.
#[arg(long)]
json_argument_path: Option<PathBuf>,
/// The list of required dependencies of application, if any.
#[arg(long, num_args(0..))]
required_application_ids: Option<Vec<ApplicationId>>,
},
}