hippius 0.2.51__py3-none-any.whl → 0.2.53__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hippius-0.2.51.dist-info → hippius-0.2.53.dist-info}/METADATA +1 -1
- {hippius-0.2.51.dist-info → hippius-0.2.53.dist-info}/RECORD +7 -7
- hippius_sdk/__init__.py +1 -1
- hippius_sdk/cli_handlers.py +150 -118
- hippius_sdk/ipfs.py +32 -21
- {hippius-0.2.51.dist-info → hippius-0.2.53.dist-info}/WHEEL +0 -0
- {hippius-0.2.51.dist-info → hippius-0.2.53.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
hippius_sdk/__init__.py,sha256=
|
1
|
+
hippius_sdk/__init__.py,sha256=oO-2itSSL6zSBvfbDXJ2kIX1nI_0bMldoJJFFVD6P6c,1474
|
2
2
|
hippius_sdk/cli.py,sha256=3TocM--b4stdOYS8_ixZMzThZvJZVmmWqEqz_PHvWxo,22188
|
3
3
|
hippius_sdk/cli_assets.py,sha256=rjH3Z5A1CQr2d5CIAAAb0WMCjoZZlMWcdo0f93KqluE,635
|
4
|
-
hippius_sdk/cli_handlers.py,sha256=
|
4
|
+
hippius_sdk/cli_handlers.py,sha256=zwLpOMW_sorPZRP8LWxhR9ITZSdOzUxucDy7wXrcMJw,157852
|
5
5
|
hippius_sdk/cli_parser.py,sha256=bg1jqQ9IXBkZVeKUAkjDWXFz67DMXs5Mzt3MXnW0lcQ,30134
|
6
6
|
hippius_sdk/cli_rich.py,sha256=_jTBYMdHi2--fIVwoeNi-EtkdOb6Zy_O2TUiGvU3O7s,7324
|
7
7
|
hippius_sdk/client.py,sha256=6W50r7-WcMyZNI1j3NOKMpcSMlB819AMKM9w06YqMx0,24302
|
@@ -14,12 +14,12 @@ hippius_sdk/db/setup_database.sh,sha256=STp03qxkp2RmIVr6YZIcvQQm-_LLUOb6Jobh-52H
|
|
14
14
|
hippius_sdk/db_utils.py,sha256=-x0rbN0as7Tn3PJPZBYCgreZe52FLH40ppA1TLxsg90,1851
|
15
15
|
hippius_sdk/errors.py,sha256=LScJJmawVAx7aRzqqQguYSkf9iazSjEQEBNlD_GXZ6Y,1589
|
16
16
|
hippius_sdk/incentives.py,sha256=0_xpaxNBmbK-0mvTm87vwBaZF-daM7hxm0dKYgkuXh4,16908
|
17
|
-
hippius_sdk/ipfs.py,sha256=
|
17
|
+
hippius_sdk/ipfs.py,sha256=rCAuSEiO1B2FCs3WQpNb2rpSJfRJkt6PWUD7KsmF6B8,105376
|
18
18
|
hippius_sdk/ipfs_core.py,sha256=xsY0Ox6anmrkbrxkRr2RXzEukB-EEaW_oMvO0Va3vjQ,13148
|
19
19
|
hippius_sdk/key_storage.py,sha256=HWV9mM5Zkq_xxn7A72L7gvlYBtcmMwOyeFdtl8ExlmE,8315
|
20
20
|
hippius_sdk/substrate.py,sha256=4a7UIE4UqGcDW7luKTBgSDqfb2OIZusB39G1UiRs_YU,50158
|
21
21
|
hippius_sdk/utils.py,sha256=rJ611yvwKSyiBpYU3w-SuyQxoghMGU-ePuslrPv5H5g,7388
|
22
|
-
hippius-0.2.
|
23
|
-
hippius-0.2.
|
24
|
-
hippius-0.2.
|
25
|
-
hippius-0.2.
|
22
|
+
hippius-0.2.53.dist-info/METADATA,sha256=TWhWHeH2ok1GkBtYeGatgYBMlDrCMw5mpMWJwKTfJA4,30088
|
23
|
+
hippius-0.2.53.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
24
|
+
hippius-0.2.53.dist-info/entry_points.txt,sha256=bFAZjW3vndretf9-8s587jA2ebMVI7puhn_lVs8jPc8,149
|
25
|
+
hippius-0.2.53.dist-info/RECORD,,
|
hippius_sdk/__init__.py
CHANGED
@@ -26,7 +26,7 @@ from hippius_sdk.config import (
|
|
26
26
|
from hippius_sdk.ipfs import IPFSClient, S3PublishResult, S3DownloadResult
|
27
27
|
from hippius_sdk.utils import format_cid, format_size, hex_to_ipfs_cid
|
28
28
|
|
29
|
-
__version__ = "0.2.
|
29
|
+
__version__ = "0.2.53"
|
30
30
|
__all__ = [
|
31
31
|
"HippiusClient",
|
32
32
|
"IPFSClient",
|
hippius_sdk/cli_handlers.py
CHANGED
@@ -3744,53 +3744,61 @@ def handle_verify_node(
|
|
3744
3744
|
# Get current account info
|
3745
3745
|
account = get_active_account()
|
3746
3746
|
if not account:
|
3747
|
-
error(
|
3747
|
+
error(
|
3748
|
+
"No active account. Please set up an account first with 'hippius account create' or 'hippius seed set'"
|
3749
|
+
)
|
3748
3750
|
return 1
|
3749
|
-
|
3751
|
+
|
3750
3752
|
account_address = get_account_address(account)
|
3751
3753
|
if not account_address:
|
3752
3754
|
error(f"Could not get address for account '{account}'")
|
3753
3755
|
return 1
|
3754
|
-
|
3755
|
-
info(
|
3756
|
-
|
3756
|
+
|
3757
|
+
info(
|
3758
|
+
f"Verifying existing node using account: [bold cyan]{account}[/bold cyan] ({account_address})"
|
3759
|
+
)
|
3760
|
+
|
3757
3761
|
# Import and use incentives.py functionality
|
3758
3762
|
from hippius_sdk.incentives import (
|
3759
|
-
load_ipfs_seed,
|
3760
|
-
|
3763
|
+
load_ipfs_seed,
|
3764
|
+
load_main_seed,
|
3765
|
+
encode_account_id,
|
3766
|
+
verify_peer_id,
|
3767
|
+
blake2_256,
|
3768
|
+
manual_encode_challenge,
|
3761
3769
|
)
|
3762
3770
|
from substrateinterface import SubstrateInterface, Keypair
|
3763
3771
|
from nacl.signing import SigningKey
|
3764
3772
|
import base58
|
3765
3773
|
import secrets
|
3766
3774
|
from binascii import hexlify
|
3767
|
-
|
3775
|
+
|
3768
3776
|
# Initialize SubstrateInterface
|
3769
3777
|
substrate = SubstrateInterface(url=client.substrate_client.url)
|
3770
|
-
|
3778
|
+
|
3771
3779
|
# Get genesis hash and current block
|
3772
3780
|
genesis_hash_hex = substrate.get_block_hash(0)
|
3773
3781
|
genesis_hash = bytes.fromhex(genesis_hash_hex[2:])
|
3774
3782
|
current_block_number = substrate.get_block_number(None)
|
3775
|
-
|
3783
|
+
|
3776
3784
|
log(f"Current block number: {current_block_number}")
|
3777
|
-
|
3785
|
+
|
3778
3786
|
# Process node_id
|
3779
3787
|
if node_id.startswith("0x"):
|
3780
3788
|
node_id_bytes = bytes.fromhex(node_id[2:])
|
3781
3789
|
else:
|
3782
3790
|
node_id_bytes = base58.b58decode(node_id)
|
3783
|
-
|
3791
|
+
|
3784
3792
|
# Load IPFS and main seeds
|
3785
3793
|
ipfs_seed, peerid_from_config = load_ipfs_seed(ipfs_config, ipfs_priv_b64)
|
3786
3794
|
main_seed = load_main_seed(node_priv_hex)
|
3787
|
-
|
3795
|
+
|
3788
3796
|
# Create signing keys
|
3789
3797
|
main_sk = SigningKey(main_seed)
|
3790
3798
|
main_pk = bytes(main_sk.verify_key)
|
3791
3799
|
ipfs_sk = SigningKey(ipfs_seed)
|
3792
3800
|
ipfs_pk = bytes(ipfs_sk.verify_key)
|
3793
|
-
|
3801
|
+
|
3794
3802
|
# Handle IPFS peer ID
|
3795
3803
|
if ipfs_peer_id:
|
3796
3804
|
ipfs_peer_id_bytes = base58.b58decode(ipfs_peer_id)
|
@@ -3798,116 +3806,124 @@ def handle_verify_node(
|
|
3798
3806
|
ipfs_peer_id_bytes = base58.b58decode(peerid_from_config)
|
3799
3807
|
else:
|
3800
3808
|
# For verification, IPFS peer ID might not be required for all node types
|
3801
|
-
ipfs_peer_id_bytes = b
|
3802
|
-
|
3809
|
+
ipfs_peer_id_bytes = b""
|
3810
|
+
|
3803
3811
|
# Verify keys match node IDs
|
3804
3812
|
if not verify_peer_id(main_pk, node_id_bytes, "Ed25519"):
|
3805
3813
|
error("Main public key does not match node ID")
|
3806
3814
|
return 1
|
3807
|
-
|
3808
|
-
if ipfs_peer_id_bytes and not verify_peer_id(
|
3815
|
+
|
3816
|
+
if ipfs_peer_id_bytes and not verify_peer_id(
|
3817
|
+
ipfs_pk, ipfs_peer_id_bytes, "Ed25519"
|
3818
|
+
):
|
3809
3819
|
error("IPFS public key does not match peer ID")
|
3810
3820
|
return 1
|
3811
|
-
|
3821
|
+
|
3812
3822
|
# Create challenge data
|
3813
3823
|
domain_bytes = domain.encode()
|
3814
|
-
domain24 = b"HIPPIUS::REGISTER::v1" + b"\x00"*3
|
3824
|
+
domain24 = b"HIPPIUS::REGISTER::v1" + b"\x00" * 3
|
3815
3825
|
node_id_hash = blake2_256(node_id_bytes)
|
3816
3826
|
ipfs_peer_id_hash = blake2_256(ipfs_peer_id_bytes)
|
3817
|
-
|
3818
|
-
nonce = (
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3827
|
+
|
3828
|
+
nonce = (
|
3829
|
+
bytes.fromhex(nonce_hex[2:])
|
3830
|
+
if nonce_hex and nonce_hex.startswith("0x")
|
3831
|
+
else bytes.fromhex(nonce_hex)
|
3832
|
+
if nonce_hex
|
3833
|
+
else secrets.token_bytes(32)
|
3834
|
+
)
|
3835
|
+
|
3822
3836
|
expires_at_block = current_block_number + expires_in
|
3823
3837
|
account_bytes = encode_account_id(account_address)
|
3824
|
-
|
3838
|
+
|
3825
3839
|
challenge_data = {
|
3826
|
-
|
3827
|
-
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3831
|
-
|
3832
|
-
|
3833
|
-
|
3840
|
+
"domain": domain24,
|
3841
|
+
"genesis_hash": genesis_hash,
|
3842
|
+
"account": account_bytes,
|
3843
|
+
"node_id_hash": node_id_hash,
|
3844
|
+
"ipfs_peer_id_hash": ipfs_peer_id_hash,
|
3845
|
+
"block_number": current_block_number,
|
3846
|
+
"nonce": nonce,
|
3847
|
+
"expires_at": expires_at_block,
|
3834
3848
|
}
|
3835
|
-
|
3849
|
+
|
3836
3850
|
challenge_bytes = manual_encode_challenge(challenge_data, block_width)
|
3837
|
-
|
3851
|
+
|
3838
3852
|
# Sign challenge
|
3839
3853
|
main_sig = main_sk.sign(challenge_bytes).signature
|
3840
3854
|
ipfs_sig = ipfs_sk.sign(challenge_bytes).signature
|
3841
|
-
|
3855
|
+
|
3842
3856
|
# Build call parameters for verify_existing_node
|
3843
3857
|
call_params = {
|
3844
3858
|
"node_id": node_id,
|
3845
|
-
"node_id_hex": "0x"+hexlify(node_id_bytes).decode(),
|
3846
|
-
"ipfs_id_hex": "0x"+hexlify(ipfs_peer_id_bytes).decode(),
|
3859
|
+
"node_id_hex": "0x" + hexlify(node_id_bytes).decode(),
|
3860
|
+
"ipfs_id_hex": "0x" + hexlify(ipfs_peer_id_bytes).decode(),
|
3847
3861
|
"main_key_type": "Ed25519",
|
3848
|
-
"main_public_key": "0x"+main_pk.hex(),
|
3849
|
-
"main_sig": "0x"+main_sig.hex(),
|
3862
|
+
"main_public_key": "0x" + main_pk.hex(),
|
3863
|
+
"main_sig": "0x" + main_sig.hex(),
|
3850
3864
|
"ipfs_key_type": "Ed25519",
|
3851
|
-
"ipfs_public_key": "0x"+ipfs_pk.hex(),
|
3852
|
-
"ipfs_sig": "0x"+ipfs_sig.hex(),
|
3853
|
-
"challenge_bytes": "0x"+challenge_bytes.hex(),
|
3865
|
+
"ipfs_public_key": "0x" + ipfs_pk.hex(),
|
3866
|
+
"ipfs_sig": "0x" + ipfs_sig.hex(),
|
3867
|
+
"challenge_bytes": "0x" + challenge_bytes.hex(),
|
3854
3868
|
}
|
3855
|
-
|
3869
|
+
|
3856
3870
|
if dry_run:
|
3857
3871
|
log("Dry run mode - printing payload without submitting")
|
3858
3872
|
payload = {
|
3859
|
-
"genesis_hash_hex": "0x"+genesis_hash.hex(),
|
3873
|
+
"genesis_hash_hex": "0x" + genesis_hash.hex(),
|
3860
3874
|
"current_block_number": current_block_number,
|
3861
|
-
"challenge_bytes_hex": "0x"+challenge_bytes.hex(),
|
3875
|
+
"challenge_bytes_hex": "0x" + challenge_bytes.hex(),
|
3862
3876
|
"call_module": "Registration",
|
3863
3877
|
"call_function": "verify_existing_node",
|
3864
|
-
"call_params": call_params
|
3878
|
+
"call_params": call_params,
|
3865
3879
|
}
|
3866
3880
|
console.print(json.dumps(payload, indent=2))
|
3867
3881
|
return 0
|
3868
|
-
|
3882
|
+
|
3869
3883
|
# Get keypair for signing
|
3870
3884
|
from hippius_sdk.config import get_seed_phrase
|
3885
|
+
|
3871
3886
|
seed_phrase = get_seed_phrase()
|
3872
3887
|
if not seed_phrase:
|
3873
3888
|
error("No seed phrase available for signing transaction")
|
3874
3889
|
return 1
|
3875
|
-
|
3890
|
+
|
3876
3891
|
kp = Keypair.create_from_uri(seed_phrase)
|
3877
|
-
|
3892
|
+
|
3878
3893
|
# Submit transaction
|
3879
3894
|
log("Submitting node verification transaction...")
|
3880
3895
|
log(f"Using module: [bold cyan]Registration[/bold cyan]")
|
3881
3896
|
call = substrate.compose_call(
|
3882
3897
|
call_module="Registration",
|
3883
3898
|
call_function="verify_existing_node",
|
3884
|
-
call_params=call_params
|
3899
|
+
call_params=call_params,
|
3885
3900
|
)
|
3886
3901
|
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=kp)
|
3887
3902
|
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
|
3888
|
-
|
3903
|
+
|
3889
3904
|
result = {
|
3890
3905
|
"extrinsic_hash": receipt.extrinsic_hash,
|
3891
3906
|
"is_success": receipt.is_success,
|
3892
3907
|
"error_message": receipt.error_message,
|
3893
|
-
"triggered_events": [str(event) for event in receipt.triggered_events]
|
3908
|
+
"triggered_events": [str(event) for event in receipt.triggered_events],
|
3894
3909
|
}
|
3895
|
-
|
3910
|
+
|
3896
3911
|
if receipt.is_success:
|
3897
3912
|
success(f"Node verification successful!")
|
3898
3913
|
success(f"Transaction hash: {receipt.extrinsic_hash}")
|
3899
3914
|
else:
|
3900
3915
|
error(f"Node verification failed: {receipt.error_message}")
|
3901
|
-
|
3916
|
+
|
3902
3917
|
log("Full result:")
|
3903
3918
|
console.print(json.dumps(result, indent=2))
|
3904
|
-
|
3919
|
+
|
3905
3920
|
return 0 if receipt.is_success else 1
|
3906
|
-
|
3921
|
+
|
3907
3922
|
except Exception as e:
|
3908
3923
|
error(f"Error verifying node: {e}")
|
3909
|
-
if hasattr(e,
|
3924
|
+
if hasattr(e, "__traceback__"):
|
3910
3925
|
import traceback
|
3926
|
+
|
3911
3927
|
traceback.print_exc()
|
3912
3928
|
return 1
|
3913
3929
|
|
@@ -3930,53 +3946,61 @@ def handle_verify_coldkey_node(
|
|
3930
3946
|
# Get current account info
|
3931
3947
|
account = get_active_account()
|
3932
3948
|
if not account:
|
3933
|
-
error(
|
3949
|
+
error(
|
3950
|
+
"No active account. Please set up an account first with 'hippius account create' or 'hippius seed set'"
|
3951
|
+
)
|
3934
3952
|
return 1
|
3935
|
-
|
3953
|
+
|
3936
3954
|
account_address = get_account_address(account)
|
3937
3955
|
if not account_address:
|
3938
3956
|
error(f"Could not get address for account '{account}'")
|
3939
3957
|
return 1
|
3940
|
-
|
3941
|
-
info(
|
3942
|
-
|
3958
|
+
|
3959
|
+
info(
|
3960
|
+
f"Verifying existing coldkey node using account: [bold cyan]{account}[/bold cyan] ({account_address})"
|
3961
|
+
)
|
3962
|
+
|
3943
3963
|
# Import and use incentives.py functionality
|
3944
3964
|
from hippius_sdk.incentives import (
|
3945
|
-
load_ipfs_seed,
|
3946
|
-
|
3965
|
+
load_ipfs_seed,
|
3966
|
+
load_main_seed,
|
3967
|
+
encode_account_id,
|
3968
|
+
verify_peer_id,
|
3969
|
+
blake2_256,
|
3970
|
+
manual_encode_challenge,
|
3947
3971
|
)
|
3948
3972
|
from substrateinterface import SubstrateInterface, Keypair
|
3949
3973
|
from nacl.signing import SigningKey
|
3950
3974
|
import base58
|
3951
3975
|
import secrets
|
3952
3976
|
from binascii import hexlify
|
3953
|
-
|
3977
|
+
|
3954
3978
|
# Initialize SubstrateInterface
|
3955
3979
|
substrate = SubstrateInterface(url=client.substrate_client.url)
|
3956
|
-
|
3980
|
+
|
3957
3981
|
# Get genesis hash and current block
|
3958
3982
|
genesis_hash_hex = substrate.get_block_hash(0)
|
3959
3983
|
genesis_hash = bytes.fromhex(genesis_hash_hex[2:])
|
3960
3984
|
current_block_number = substrate.get_block_number(None)
|
3961
|
-
|
3985
|
+
|
3962
3986
|
log(f"Current block number: {current_block_number}")
|
3963
|
-
|
3987
|
+
|
3964
3988
|
# Process node_id
|
3965
3989
|
if node_id.startswith("0x"):
|
3966
3990
|
node_id_bytes = bytes.fromhex(node_id[2:])
|
3967
3991
|
else:
|
3968
3992
|
node_id_bytes = base58.b58decode(node_id)
|
3969
|
-
|
3993
|
+
|
3970
3994
|
# Load IPFS and main seeds
|
3971
3995
|
ipfs_seed, peerid_from_config = load_ipfs_seed(ipfs_config, ipfs_priv_b64)
|
3972
3996
|
main_seed = load_main_seed(node_priv_hex)
|
3973
|
-
|
3997
|
+
|
3974
3998
|
# Create signing keys
|
3975
3999
|
main_sk = SigningKey(main_seed)
|
3976
4000
|
main_pk = bytes(main_sk.verify_key)
|
3977
4001
|
ipfs_sk = SigningKey(ipfs_seed)
|
3978
4002
|
ipfs_pk = bytes(ipfs_sk.verify_key)
|
3979
|
-
|
4003
|
+
|
3980
4004
|
# Handle IPFS peer ID
|
3981
4005
|
if ipfs_peer_id:
|
3982
4006
|
ipfs_peer_id_bytes = base58.b58decode(ipfs_peer_id)
|
@@ -3984,115 +4008,123 @@ def handle_verify_coldkey_node(
|
|
3984
4008
|
ipfs_peer_id_bytes = base58.b58decode(peerid_from_config)
|
3985
4009
|
else:
|
3986
4010
|
# For verification, IPFS peer ID might not be required for all node types
|
3987
|
-
ipfs_peer_id_bytes = b
|
3988
|
-
|
4011
|
+
ipfs_peer_id_bytes = b""
|
4012
|
+
|
3989
4013
|
# Verify keys match node IDs
|
3990
4014
|
if not verify_peer_id(main_pk, node_id_bytes, "Ed25519"):
|
3991
4015
|
error("Main public key does not match node ID")
|
3992
4016
|
return 1
|
3993
|
-
|
3994
|
-
if ipfs_peer_id_bytes and not verify_peer_id(
|
4017
|
+
|
4018
|
+
if ipfs_peer_id_bytes and not verify_peer_id(
|
4019
|
+
ipfs_pk, ipfs_peer_id_bytes, "Ed25519"
|
4020
|
+
):
|
3995
4021
|
error("IPFS public key does not match peer ID")
|
3996
4022
|
return 1
|
3997
|
-
|
4023
|
+
|
3998
4024
|
# Create challenge data
|
3999
4025
|
domain_bytes = domain.encode()
|
4000
|
-
domain24 = b"HIPPIUS::REGISTER::v1" + b"\x00"*3
|
4026
|
+
domain24 = b"HIPPIUS::REGISTER::v1" + b"\x00" * 3
|
4001
4027
|
node_id_hash = blake2_256(node_id_bytes)
|
4002
4028
|
ipfs_peer_id_hash = blake2_256(ipfs_peer_id_bytes)
|
4003
|
-
|
4004
|
-
nonce = (
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4029
|
+
|
4030
|
+
nonce = (
|
4031
|
+
bytes.fromhex(nonce_hex[2:])
|
4032
|
+
if nonce_hex and nonce_hex.startswith("0x")
|
4033
|
+
else bytes.fromhex(nonce_hex)
|
4034
|
+
if nonce_hex
|
4035
|
+
else secrets.token_bytes(32)
|
4036
|
+
)
|
4037
|
+
|
4008
4038
|
expires_at_block = current_block_number + expires_in
|
4009
4039
|
account_bytes = encode_account_id(account_address)
|
4010
|
-
|
4040
|
+
|
4011
4041
|
challenge_data = {
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4042
|
+
"domain": domain24,
|
4043
|
+
"genesis_hash": genesis_hash,
|
4044
|
+
"account": account_bytes,
|
4045
|
+
"node_id_hash": node_id_hash,
|
4046
|
+
"ipfs_peer_id_hash": ipfs_peer_id_hash,
|
4047
|
+
"block_number": current_block_number,
|
4048
|
+
"nonce": nonce,
|
4049
|
+
"expires_at": expires_at_block,
|
4020
4050
|
}
|
4021
|
-
|
4051
|
+
|
4022
4052
|
challenge_bytes = manual_encode_challenge(challenge_data, block_width)
|
4023
|
-
|
4053
|
+
|
4024
4054
|
# Sign challenge
|
4025
4055
|
main_sig = main_sk.sign(challenge_bytes).signature
|
4026
4056
|
ipfs_sig = ipfs_sk.sign(challenge_bytes).signature
|
4027
|
-
|
4057
|
+
|
4028
4058
|
# Build call parameters for verify_existing_coldkey_node
|
4029
4059
|
call_params = {
|
4030
4060
|
"node_id": node_id,
|
4031
|
-
"node_id_hex": "0x"+hexlify(node_id_bytes).decode(),
|
4032
|
-
"ipfs_id_hex": "0x"+hexlify(ipfs_peer_id_bytes).decode(),
|
4061
|
+
"node_id_hex": "0x" + hexlify(node_id_bytes).decode(),
|
4062
|
+
"ipfs_id_hex": "0x" + hexlify(ipfs_peer_id_bytes).decode(),
|
4033
4063
|
"main_key_type": "Ed25519",
|
4034
|
-
"main_public_key": "0x"+main_pk.hex(),
|
4035
|
-
"main_sig": "0x"+main_sig.hex(),
|
4064
|
+
"main_public_key": "0x" + main_pk.hex(),
|
4065
|
+
"main_sig": "0x" + main_sig.hex(),
|
4036
4066
|
"ipfs_key_type": "Ed25519",
|
4037
|
-
"ipfs_public_key": "0x"+ipfs_pk.hex(),
|
4038
|
-
"ipfs_sig": "0x"+ipfs_sig.hex(),
|
4039
|
-
"challenge_bytes": "0x"+challenge_bytes.hex(),
|
4067
|
+
"ipfs_public_key": "0x" + ipfs_pk.hex(),
|
4068
|
+
"ipfs_sig": "0x" + ipfs_sig.hex(),
|
4069
|
+
"challenge_bytes": "0x" + challenge_bytes.hex(),
|
4040
4070
|
}
|
4041
|
-
|
4071
|
+
|
4042
4072
|
if dry_run:
|
4043
4073
|
log("Dry run mode - printing payload without submitting")
|
4044
4074
|
payload = {
|
4045
|
-
"genesis_hash_hex": "0x"+genesis_hash.hex(),
|
4075
|
+
"genesis_hash_hex": "0x" + genesis_hash.hex(),
|
4046
4076
|
"current_block_number": current_block_number,
|
4047
|
-
"challenge_bytes_hex": "0x"+challenge_bytes.hex(),
|
4077
|
+
"challenge_bytes_hex": "0x" + challenge_bytes.hex(),
|
4048
4078
|
"call_module": "Registration",
|
4049
4079
|
"call_function": "verify_existing_coldkey_node",
|
4050
|
-
"call_params": call_params
|
4080
|
+
"call_params": call_params,
|
4051
4081
|
}
|
4052
4082
|
console.print(json.dumps(payload, indent=2))
|
4053
4083
|
return 0
|
4054
|
-
|
4084
|
+
|
4055
4085
|
# Get keypair for signing
|
4056
4086
|
from hippius_sdk.config import get_seed_phrase
|
4087
|
+
|
4057
4088
|
seed_phrase = get_seed_phrase()
|
4058
4089
|
if not seed_phrase:
|
4059
4090
|
error("No seed phrase available for signing transaction")
|
4060
4091
|
return 1
|
4061
|
-
|
4092
|
+
|
4062
4093
|
kp = Keypair.create_from_uri(seed_phrase)
|
4063
|
-
|
4094
|
+
|
4064
4095
|
# Submit transaction
|
4065
4096
|
log("Submitting coldkey node verification transaction...")
|
4066
4097
|
log(f"Using module: [bold cyan]Registration[/bold cyan]")
|
4067
4098
|
call = substrate.compose_call(
|
4068
4099
|
call_module="Registration",
|
4069
4100
|
call_function="verify_existing_coldkey_node",
|
4070
|
-
call_params=call_params
|
4101
|
+
call_params=call_params,
|
4071
4102
|
)
|
4072
4103
|
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=kp)
|
4073
4104
|
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
|
4074
|
-
|
4105
|
+
|
4075
4106
|
result = {
|
4076
4107
|
"extrinsic_hash": receipt.extrinsic_hash,
|
4077
4108
|
"is_success": receipt.is_success,
|
4078
4109
|
"error_message": receipt.error_message,
|
4079
|
-
"triggered_events": [str(event) for event in receipt.triggered_events]
|
4110
|
+
"triggered_events": [str(event) for event in receipt.triggered_events],
|
4080
4111
|
}
|
4081
|
-
|
4112
|
+
|
4082
4113
|
if receipt.is_success:
|
4083
4114
|
success(f"Coldkey node verification successful!")
|
4084
4115
|
success(f"Transaction hash: {receipt.extrinsic_hash}")
|
4085
4116
|
else:
|
4086
4117
|
error(f"Coldkey node verification failed: {receipt.error_message}")
|
4087
|
-
|
4118
|
+
|
4088
4119
|
log("Full result:")
|
4089
4120
|
console.print(json.dumps(result, indent=2))
|
4090
|
-
|
4121
|
+
|
4091
4122
|
return 0 if receipt.is_success else 1
|
4092
|
-
|
4123
|
+
|
4093
4124
|
except Exception as e:
|
4094
4125
|
error(f"Error verifying coldkey node: {e}")
|
4095
|
-
if hasattr(e,
|
4126
|
+
if hasattr(e, "__traceback__"):
|
4096
4127
|
import traceback
|
4128
|
+
|
4097
4129
|
traceback.print_exc()
|
4098
4130
|
return 1
|
hippius_sdk/ipfs.py
CHANGED
@@ -2117,15 +2117,26 @@ class IPFSClient:
|
|
2117
2117
|
|
2118
2118
|
logger.info(f"Got {len(objects)=} from {store_node=}")
|
2119
2119
|
# filter out just the one file cid, ignore dirs, it's usually the first item,
|
2120
|
-
# but hey let's not risk it
|
2120
|
+
# but hey let's not risk it. IPFS may convert + to spaces in filenames.
|
2121
2121
|
for o in objects:
|
2122
2122
|
if o["Name"] == file_name:
|
2123
2123
|
cid = o["Hash"]
|
2124
2124
|
break
|
2125
2125
|
else:
|
2126
|
-
|
2127
|
-
|
2128
|
-
)
|
2126
|
+
# If exact match fails, try to find by matching the basename only
|
2127
|
+
# This handles cases where IPFS modifies the filename (e.g., + to space)
|
2128
|
+
target_basename = os.path.basename(file_name)
|
2129
|
+
for o in objects:
|
2130
|
+
if os.path.basename(o["Name"]) == target_basename:
|
2131
|
+
cid = o["Hash"]
|
2132
|
+
logger.info(
|
2133
|
+
f"Found file by basename match: {o['Name']} (original: {file_name})"
|
2134
|
+
)
|
2135
|
+
break
|
2136
|
+
else:
|
2137
|
+
raise KeyError(
|
2138
|
+
f"Store call failed, {file_name=} not found in {objects=}"
|
2139
|
+
)
|
2129
2140
|
else:
|
2130
2141
|
cid = result["Hash"]
|
2131
2142
|
logger.info(f"Content uploaded to store node {store_node} with CID: {cid}")
|
@@ -2294,9 +2305,6 @@ class IPFSClient:
|
|
2294
2305
|
encrypted_data += chunk
|
2295
2306
|
return encrypted_data
|
2296
2307
|
|
2297
|
-
# Stream and decrypt the content using hybrid buffered approach
|
2298
|
-
import nacl.secret
|
2299
|
-
|
2300
2308
|
# Collect all encrypted data first
|
2301
2309
|
logger.debug("Buffering encrypted content for decryption")
|
2302
2310
|
encrypted_data = b""
|
@@ -2344,16 +2352,16 @@ class IPFSClient:
|
|
2344
2352
|
os.path.dirname(os.path.abspath(output_path)), exist_ok=True
|
2345
2353
|
)
|
2346
2354
|
|
2347
|
-
|
2348
|
-
|
2349
|
-
download_url = f"{download_node.rstrip('/')}/api/v0/cat?arg={cid}"
|
2355
|
+
# Use gateway style instead of cat API for better HTTP semantics
|
2356
|
+
download_url = f"{download_node.rstrip('/')}/ipfs/{cid}"
|
2350
2357
|
|
2351
2358
|
# Download file into memory
|
2352
2359
|
file_data = bytearray()
|
2353
|
-
async with
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2360
|
+
async with httpx.AsyncClient() as client:
|
2361
|
+
async with client.stream("GET", download_url) as response:
|
2362
|
+
response.raise_for_status()
|
2363
|
+
async for chunk in response.aiter_bytes(chunk_size=8192):
|
2364
|
+
file_data.extend(chunk)
|
2357
2365
|
|
2358
2366
|
# Convert to bytes for consistency
|
2359
2367
|
file_data = bytes(file_data)
|
@@ -2523,15 +2531,18 @@ class IPFSClient:
|
|
2523
2531
|
HippiusIPFSError: If IPFS stream fails
|
2524
2532
|
"""
|
2525
2533
|
try:
|
2526
|
-
|
2527
|
-
download_url = f"{download_node.rstrip('/')}/
|
2534
|
+
# Use gateway style instead of cat API for better HTTP semantics
|
2535
|
+
download_url = f"{download_node.rstrip('/')}/ipfs/{cid}"
|
2528
2536
|
|
2529
|
-
async with
|
2530
|
-
|
2531
|
-
|
2537
|
+
async with httpx.AsyncClient() as client:
|
2538
|
+
async with client.stream("GET", download_url) as response:
|
2539
|
+
response.raise_for_status()
|
2540
|
+
logger.info(
|
2541
|
+
f"Started streaming from {download_node} for CID: {cid}"
|
2542
|
+
)
|
2532
2543
|
|
2533
|
-
|
2534
|
-
|
2544
|
+
async for chunk in response.aiter_bytes(chunk_size=8192):
|
2545
|
+
yield chunk
|
2535
2546
|
|
2536
2547
|
except Exception as e:
|
2537
2548
|
raise HippiusIPFSError(f"Failed to stream from {download_node}: {str(e)}")
|
File without changes
|
File without changes
|