@@ -241,25 +241,49 @@ def deploy_neofs_contract(self):
241
241
"There should be at least a single IR instance configured(not started) to deploy neofs contract"
242
242
)
243
243
neo_go = self .neo_go ()
244
+ neo_go .nep17 .balance (
245
+ self .main_chain .wallet .address ,
246
+ "GAS" ,
247
+ f"http://{ self .main_chain .rpc_address } " ,
248
+ wallet_config = self .main_chain .neo_go_config ,
249
+ )
244
250
neo_go .nep17 .transfer (
245
251
"GAS" ,
246
252
self .default_wallet .address ,
247
253
f"http://{ self .main_chain .rpc_address } " ,
248
- from_address = self .inner_ring_nodes [ - 1 ]. alphabet_wallet .address ,
254
+ from_address = self .main_chain . wallet .address ,
249
255
amount = 9000 ,
250
256
force = True ,
251
257
wallet_config = self .main_chain .neo_go_config ,
252
258
await_ = True ,
253
259
)
254
- ir_alphabet_pubkey_from_neogo = wallet_utils .get_last_public_key_from_wallet_with_neogo (
255
- self .neo_go (), self .inner_ring_nodes [- 1 ].alphabet_wallet .path
260
+
261
+ for ir_node in self .inner_ring_nodes :
262
+ accounts = wallet_utils .get_accounts_from_wallet (ir_node .alphabet_wallet .path , self .default_password )
263
+ for acc in accounts :
264
+ neo_go .nep17 .transfer (
265
+ "GAS" ,
266
+ acc .address ,
267
+ f"http://{ self .main_chain .rpc_address } " ,
268
+ from_address = self .main_chain .wallet .address ,
269
+ amount = 9000 ,
270
+ force = True ,
271
+ wallet_config = self .main_chain .neo_go_config ,
272
+ await_ = True ,
273
+ )
274
+
275
+ pub_keys_of_existing_ir_nodes = " " .join (
276
+ wallet_utils .get_last_public_key_from_wallet_with_neogo (
277
+ self .neo_go (),
278
+ ir_node .alphabet_wallet .path ,
279
+ ).splitlines ()
256
280
)
257
281
result = neo_go .contract .deploy (
258
282
input_file = f"{ self .neofs_contract_dir } /neofs/neofs_contract.nef" ,
259
283
manifest = f"{ self .neofs_contract_dir } /neofs/config.json" ,
260
284
force = True ,
261
285
rpc_endpoint = f"http://{ self .main_chain .rpc_address } " ,
262
- post_data = f"[ true ffffffffffffffffffffffffffffffffffffffff [ { ir_alphabet_pubkey_from_neogo } ] [ InnerRingCandidateFee 10 WithdrawFee 10 ] ]" ,
286
+ post_data = f"[ true ffffffffffffffffffffffffffffffffffffffff [ { pub_keys_of_existing_ir_nodes } ] [ InnerRingCandidateFee 10 WithdrawFee 10 ] ]" ,
263
287
wallet_config = self .default_wallet_neogo_config ,
264
288
)
265
289
contract_hash = result .stdout .split ("Contract: " )[- 1 ].strip ()
@@ -306,34 +330,34 @@ def generate_storage_wallet(
306
330
307
331
@allure .step ("Generate alphabet wallets" )
308
332
def generate_alphabet_wallets (
309
- self ,
310
- network_config : Optional [str ] = None ,
311
- size : Optional [int ] = 1 ,
333
+ self , network_config : Optional [str ] = None , size : Optional [int ] = 1 , alphabet_wallets_dir : Optional [str ] = None
312
334
) -> list [NodeWallet ]:
313
335
neofs_adm = self .neofs_adm (network_config )
314
336
315
- neofs_adm .fschain .generate_alphabet (alphabet_wallets = self .alphabet_wallets_dir , size = size )
337
+ if not alphabet_wallets_dir :
338
+ alphabet_wallets_dir = self .alphabet_wallets_dir
339
+ neofs_adm .fschain .generate_alphabet (alphabet_wallets = alphabet_wallets_dir , size = size )
316
340
317
341
generated_wallets = []
318
342
319
- for generated_wallet in os .listdir (self . alphabet_wallets_dir ):
343
+ for generated_wallet in os .listdir (alphabet_wallets_dir ):
320
344
# neo3 package requires some attributes to be set
321
- with open (os .path .join (self . alphabet_wallets_dir , generated_wallet ), "r" ) as wallet_file :
345
+ with open (os .path .join (alphabet_wallets_dir , generated_wallet ), "r" ) as wallet_file :
322
346
wallet_json = json .load (wallet_file )
323
347
324
348
wallet_json ["name" ] = None
325
349
for acc in wallet_json ["accounts" ]:
326
350
acc ["extra" ] = None
327
351
328
- with open (os .path .join (self . alphabet_wallets_dir , generated_wallet ), "w" ) as wallet_file :
352
+ with open (os .path .join (alphabet_wallets_dir , generated_wallet ), "w" ) as wallet_file :
329
353
json .dump (wallet_json , wallet_file )
330
354
331
355
generated_wallets .append (
332
356
NodeWallet (
333
- path = os .path .join (self . alphabet_wallets_dir , generated_wallet ),
357
+ path = os .path .join (alphabet_wallets_dir , generated_wallet ),
334
358
password = self .default_password ,
335
359
address = wallet_utils .get_last_address_from_wallet (
336
- os .path .join (self . alphabet_wallets_dir , generated_wallet ), self .default_password
360
+ os .path .join (alphabet_wallets_dir , generated_wallet ), self .default_password
337
361
),
338
362
)
339
363
)
@@ -686,6 +710,8 @@ def __init__(self, neofs_env: NeoFSEnv):
686
710
self .p2p_address = f"{ self .neofs_env .domain } :{ NeoFSEnv .get_available_port ()} "
687
711
self .pprof_address = f"{ self .neofs_env .domain } :{ NeoFSEnv .get_available_port ()} "
688
712
self .prometheus_address = f"{ self .neofs_env .domain } :{ NeoFSEnv .get_available_port ()} "
713
+ self .wallet_dir = self .neofs_env ._generate_temp_dir (prefix = "mainchain_wallet" )
714
+ self .wallet = None
689
715
self .stdout = "Not initialized"
690
716
self .stderr = "Not initialized"
691
717
self .process = None
@@ -715,21 +741,31 @@ def start(self, wait_until_ready=True):
715
741
if self .process is not None :
716
742
raise RuntimeError ("This main chain instance has already been started" )
717
743
718
- alphabet_wallet = self .neofs_env .inner_ring_nodes [- 1 ].alphabet_wallet
744
+ self .wallet = self .neofs_env .generate_alphabet_wallets (alphabet_wallets_dir = self .wallet_dir )[0 ]
745
+
746
+ standby_committee = wallet_utils .get_last_public_key_from_wallet_with_neogo (
747
+ self .neofs_env .neo_go (), self .wallet .path
748
+ )
719
749
720
750
ir_alphabet_pubkey_from_neogo = wallet_utils .get_last_public_key_from_wallet_with_neogo (
721
- self .neofs_env .neo_go (), alphabet_wallet .path
751
+ self .neofs_env .neo_go (), self . neofs_env . inner_ring_nodes [ - 1 ]. alphabet_wallet .path
722
752
)
723
753
754
+ if len (self .neofs_env .inner_ring_nodes ) > 1 :
755
+ ir_public_keys = ir_alphabet_pubkey_from_neogo .splitlines ()
756
+ else :
757
+ ir_public_keys = [ir_alphabet_pubkey_from_neogo ]
758
+
724
759
logger .info (f"Generating main chain config at: { self .main_chain_config_path } " )
725
760
main_chain_config_template = "main_chain.yaml"
726
761
727
762
NeoFSEnv .generate_config_file (
728
763
config_template = main_chain_config_template ,
729
764
config_path = self .main_chain_config_path ,
730
765
custom = Path (main_chain_config_template ).is_file (),
731
- wallet = alphabet_wallet ,
732
- public_key = ir_alphabet_pubkey_from_neogo ,
766
+ wallet = self .wallet ,
767
+ standby_committee = standby_committee ,
768
+ ir_public_keys = ir_public_keys ,
733
769
main_chain_boltdb = self .main_chain_boltdb ,
734
770
p2p_address = self .p2p_address ,
735
771
rpc_address = self .rpc_address ,
@@ -738,12 +774,10 @@ def start(self, wait_until_ready=True):
738
774
prometheus_address = self .prometheus_address ,
739
775
)
740
776
logger .info (f"Generating CLI config at: { self .cli_config } " )
741
- NeoFSEnv .generate_config_file (
742
- config_template = "cli_cfg.yaml" , config_path = self .cli_config , wallet = alphabet_wallet
743
- )
777
+ NeoFSEnv .generate_config_file (config_template = "cli_cfg.yaml" , config_path = self .cli_config , wallet = self .wallet )
744
778
logger .info (f"Generating NEO GO config at: { self .neo_go_config } " )
745
779
NeoFSEnv .generate_config_file (
746
- config_template = "neo_go_cfg.yaml" , config_path = self .neo_go_config , wallet = alphabet_wallet
780
+ config_template = "neo_go_cfg.yaml" , config_path = self .neo_go_config , wallet = self . wallet
747
781
)
748
782
logger .info (f"Launching Main Chain:{ self } " )
749
783
self ._launch_process ()
@@ -839,18 +873,31 @@ def generate_cli_config(self):
839
873
)
840
874
841
875
@allure .step ("Start Inner Ring node" )
842
- def start (self , wait_until_ready = True , with_main_chain = False ):
876
+ def start (
877
+ self ,
878
+ wait_until_ready = True ,
879
+ with_main_chain = False ,
880
+ pub_keys_of_existing_ir_nodes = None ,
881
+ seed_node_addresses_of_existing_ir_nodes = None ,
882
+ fschain_autodeploy = True ,
883
+ ):
843
884
if self .process is not None :
844
885
raise RuntimeError ("This inner ring node instance has already been started" )
845
886
logger .info (f"Generating IR config at: { self .ir_node_config_path } " )
846
887
ir_config_template = "ir.yaml"
847
888
848
- pub_keys_of_existing_ir_nodes = [
849
- wallet_utils .get_last_public_key_from_wallet (ir_node .alphabet_wallet .path , ir_node .alphabet_wallet .password )
850
- for ir_node in self .neofs_env .inner_ring_nodes
851
- ]
889
+ if not pub_keys_of_existing_ir_nodes :
890
+ pub_keys_of_existing_ir_nodes = [
891
+ wallet_utils .get_last_public_key_from_wallet (
892
+ ir_node .alphabet_wallet .path , ir_node .alphabet_wallet .password
893
+ )
894
+ for ir_node in self .neofs_env .inner_ring_nodes
895
+ ]
852
896
853
- seed_node_addresses_of_existing_ir_nodes = [ir_node .p2p_address for ir_node in self .neofs_env .inner_ring_nodes ]
897
+ if not seed_node_addresses_of_existing_ir_nodes :
898
+ seed_node_addresses_of_existing_ir_nodes = [
899
+ ir_node .p2p_address for ir_node in self .neofs_env .inner_ring_nodes
900
+ ]
854
901
855
902
NeoFSEnv .generate_config_file (
856
903
config_template = ir_config_template ,
@@ -868,6 +915,7 @@ def start(self, wait_until_ready=True, with_main_chain=False):
868
915
len (self .neofs_env .inner_ring_nodes ) - (len (self .neofs_env .inner_ring_nodes ) - 1 ) / 3 - 1
869
916
),
870
917
set_roles_in_genesis = str (False if len (self .neofs_env .inner_ring_nodes ) == 1 else True ).lower (),
918
+ fschain_autodeploy = fschain_autodeploy ,
871
919
control_public_key = wallet_utils .get_last_public_key_from_wallet (
872
920
self .alphabet_wallet .path , self .alphabet_wallet .password
873
921
),
0 commit comments