Skip to content

Commit

Permalink
do not reject unpaid customers for now, storage contracts are still i…
Browse files Browse the repository at this point in the history
…n progress
  • Loading branch information
vesellov committed Jul 12, 2024
1 parent bd49593 commit d20934d
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 20 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Change Log
==========

2024-06-17 Veselin Penev [[email protected]](mailto:[email protected])
2024-07-12 Veselin Penev [[email protected]](mailto:[email protected])

* refreshed requirements.txt
* do not reject unpaid customers for now, storage contracts are still in progress
* fixed ed25519 to pynacl migration in Bismuth polysign
* removed un-used files



Expand Down
13 changes: 11 additions & 2 deletions bitdust/customer/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def get_supplier_contracts_dir(supplier_idurl):


def save_storage_contract(supplier_idurl, json_data):
if _Debug:
lg.args(_DebugLevel, s=supplier_idurl, json_data=json_data)
supplier_contracts_dir = get_supplier_contracts_dir(supplier_idurl)
if not os.path.isdir(supplier_contracts_dir):
bpio._dirs_make(supplier_contracts_dir)
Expand All @@ -85,13 +87,18 @@ def list_storage_contracts(supplier_idurl):
json_data = jsn.loads_text(local_fs.ReadTextFile(contract_path))
l.append(json_data)
l.sort(key=lambda json_data: utime.unpack_time(json_data['started']))
if _Debug:
lg.args(_DebugLevel, s=supplier_idurl, l=l)
return l


def list_contracted_suppliers():
customer_contracts_dir = settings.ServiceDir('service_customer_contracts')
if not os.path.isdir(customer_contracts_dir):
bpio._dirs_make(customer_contracts_dir)
supplier_idurls = []
for supplier_contracts_prefix in os.listdir(settings.ServiceDir('service_customer_contracts')):
supplier_contracts_dir = os.path.join(settings.ServiceDir('service_customer_contracts'), supplier_contracts_prefix)
for supplier_contracts_prefix in os.listdir(customer_contracts_dir):
supplier_contracts_dir = os.path.join(customer_contracts_dir, supplier_contracts_prefix)
for contract_filename in os.listdir(supplier_contracts_dir):
contract_path = os.path.join(supplier_contracts_dir, contract_filename)
json_data = jsn.loads_text(local_fs.ReadTextFile(contract_path))
Expand All @@ -113,6 +120,8 @@ def pay_for_storage():
return False
now = utime.utcnow_to_sec1970()
my_customer_prefix = my_id.getIDURL().unique_name()
if _Debug:
lg.args(_DebugLevel, my_balance=cur_balance, my_customer_prefix=my_customer_prefix)
for supplier_idurl in list_contracted_suppliers():
supplier_contracts = list_storage_contracts(supplier_idurl)
unpaid_contracts = []
Expand Down
9 changes: 9 additions & 0 deletions bitdust/interface/web_html_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@
<a href="%(site_url)s/index.html#ecosystem">Ecosystem</a>
</li>
<!-- Nav Item -->
<!--
<li>
<a href="%(site_url)s/index.html#roadmap">Roadmap</a>
</li>
-->
<!-- Nav Item -->
<!--
<li>
<a href="%(site_url)s/index.html#team">Team</a>
</li>
-->
<!-- Nav Item -->
<li class="active">
<a href="%(wikipath)s">Wiki</a>
Expand Down Expand Up @@ -100,6 +104,11 @@
Get Started
</a>
<!-- Navbar Button -->
<a href="https://forms.gle/RkJW3L7NTamZ5K8m6" target="_blank"
class="btn btn-sm ui-gradient-peach pull-right">
Give Feedback
</a>
</div><!-- .container -->
</nav> <!-- nav -->
Expand Down
12 changes: 6 additions & 6 deletions bitdust/main/config_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def reset(conf_obj):
conf_obj.setDefaultValue('services/backups/keep-local-copies-enabled', 'true')
conf_obj.setDefaultValue('services/backups/wait-suppliers-enabled', 'true')

conf_obj.setDefaultValue('services/blockchain-id/enabled', 'false')
conf_obj.setDefaultValue('services/blockchain-id/enabled', 'true')

conf_obj.setDefaultValue('services/blockchain-authority/enabled', 'false')
conf_obj.setDefaultValue('services/blockchain-authority/registration-bonus-coins', 100)
Expand All @@ -96,21 +96,21 @@ def reset(conf_obj):
conf_obj.setDefaultValue('services/blockchain-explorer/host', '127.0.0.1')
conf_obj.setDefaultValue('services/blockchain-explorer/web-port', 19080)

conf_obj.setDefaultValue('services/bismuth-blockchain/enabled', 'false')
conf_obj.setDefaultValue('services/bismuth-blockchain/enabled', 'true')

conf_obj.setDefaultValue('services/bismuth-node/enabled', 'false')
conf_obj.setDefaultValue('services/bismuth-node/host', '127.0.0.1')
conf_obj.setDefaultValue('services/bismuth-node/tcp-port', 15658)

conf_obj.setDefaultValue('services/bismuth-wallet/enabled', 'false')
conf_obj.setDefaultValue('services/bismuth-wallet/enabled', 'true')

conf_obj.setDefaultValue('services/bismuth-pool/enabled', 'false')
conf_obj.setDefaultValue('services/bismuth-pool/host', '127.0.0.1')
conf_obj.setDefaultValue('services/bismuth-pool/tcp-port', 18525)

conf_obj.setDefaultValue('services/bismuth-miner/enabled', 'false')

conf_obj.setDefaultValue('services/bismuth-identity/enabled', 'false')
conf_obj.setDefaultValue('services/bismuth-identity/enabled', 'true')

conf_obj.setDefaultValue('services/broadcasting/enabled', 'false')
conf_obj.setDefaultValue('services/broadcasting/routing-enabled', 'false')
Expand All @@ -122,7 +122,7 @@ def reset(conf_obj):
conf_obj.setDefaultValue('services/customer/needed-space', diskspace.MakeStringFromBytes(settings.DefaultNeededBytes()))
conf_obj.setDefaultValue('services/customer/suppliers-number', settings.DefaultDesiredSuppliers())

conf_obj.setDefaultValue('services/customer-contracts/enabled', 'false')
conf_obj.setDefaultValue('services/customer-contracts/enabled', 'true')

conf_obj.setDefaultValue('services/customer-family/enabled', 'true')

Expand Down Expand Up @@ -247,7 +247,7 @@ def reset(conf_obj):
conf_obj.setDefaultValue('services/supplier/enabled', 'true')
conf_obj.setDefaultValue('services/supplier/donated-space', diskspace.MakeStringFromBytes(settings.DefaultDonatedBytes()))

conf_obj.setDefaultValue('services/supplier-contracts/enabled', 'false')
conf_obj.setDefaultValue('services/supplier-contracts/enabled', 'true')
conf_obj.setDefaultValue('services/supplier-contracts/initial-duration-hours', 6)
conf_obj.setDefaultValue('services/supplier-contracts/duration-raise-factor', 2.0)

Expand Down
2 changes: 1 addition & 1 deletion bitdust/services/service_blockchain_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def start(self):

def stop(self):
from bitdust.blockchain import blockchain_registrator
if self.sync_my_transactions_loop.running:
if self.sync_my_transactions_loop and self.sync_my_transactions_loop.running:
self.sync_my_transactions_loop.stop()
self.sync_my_transactions_loop = None
blockchain_registrator.A('shutdown')
Expand Down
2 changes: 1 addition & 1 deletion bitdust/services/service_customer_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def start(self):
return True

def stop(self):
if self.payment_loop.running:
if self.payment_loop and self.payment_loop.running:
self.payment_loop.stop()
self.payment_loop = None
return True
Expand Down
3 changes: 2 additions & 1 deletion bitdust/supplier/customer_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ def on_service_supplier_request(json_payload, newpacket, info):
current_contract = {}
if current_contract and current_contract.get('deny'):
lg.warn('contract processing denied with user %s' % customer_idurl)
return p2p_service.SendFail(newpacket, 'deny:' + jsn.dumps(current_contract))
# TODO: disabled for now...
# return p2p_service.SendFail(newpacket, 'deny:' + jsn.dumps(current_contract))
# check if this is a new customer or an existing one
# for existing one, we have to first release currently allocated resources
if customer_idurl in current_customers:
Expand Down
4 changes: 3 additions & 1 deletion bitdust/supplier/customers_rejector.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ def doVerifyStorageContracts(self, *args, **kwargs):
rejected_customers = storage_contract.verify_all_current_customers_contracts()
if rejected_customers:
lg.warn('found unpaid customers: %r' % rejected_customers)
self.automat('found-unpaid-customers', rejected_customers)
# TODO: disabled for now...
# self.automat('found-unpaid-customers', rejected_customers)
self.automat('contracts-verified')
else:
lg.info('all customers have valid contracts')
self.automat('contracts-verified')
Expand Down
10 changes: 5 additions & 5 deletions bitdust_forks/Bismuth/polysign/signer_ed25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Union

import base58
import ed25519
from nacl.signing import SigningKey, VerifyKey
from polysign.signer import Signer, SignerType, SignerSubType


Expand Down Expand Up @@ -60,10 +60,10 @@ def from_seed(self, seed: str='', subtype: SignerSubType=SignerSubType.MAINNET_R
try:
# print("SEED", seed)
# TODO: check flow, there may be many unnecessary hex-byte-hex-bytes conversions from top to bottom
key = ed25519.SigningKey(bytes.fromhex(seed))
key = SigningKey(bytes.fromhex(seed))
hexa = key.to_ascii(encoding="hex").decode('utf-8')
# print("ED25519 Privk Key", hexa) # e5b42f3c-3fe02e16-1d42ff47-07a174a5 715b2badc7d4d3aebbea9081bd9123d5
verifying_key = key.get_verifying_key()
verifying_key = key.verify_key
public_key = verifying_key.to_ascii(encoding="hex").decode('utf-8')
# public_key = hexa[32:]
# print("ED25519 Public Key", public_key)
Expand Down Expand Up @@ -105,8 +105,8 @@ def verify_signature(cls, signature: Union[bytes, str], public_key: Union[bytes,
"""Verify signature from raw signature. Address may be used to determine the sig subtype"""
try:
# print("verif", signature, public_key, len(public_key))
verifying_key = ed25519.VerifyingKey(public_key)
verifying_key.verify(signature, buffer)
verifying_key = VerifyKey(public_key)
verifying_key.verify(buffer, signature)
except Exception as e:
print(e)
raise ValueError(f"Invalid ED25519 signature from {address}")
Expand Down
2 changes: 1 addition & 1 deletion bitdust_forks/Bismuth/polysign/signerfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def address_to_signer(cls, address: str) -> Type[Signer]:
else:
return SignerECDSA

raise ValueError("Unsupported Address type")
raise ValueError("Unsupported Address type: %r" % address)

@classmethod
def address_is_valid(cls, address: str) -> bool:
Expand Down
7 changes: 7 additions & 0 deletions regress/testsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ def start_dht_seed(node, wait_seconds=0, dht_seeds='', attached_layers='', verbo
# use shorter key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/message-broker/enabled false;'
Expand Down Expand Up @@ -793,6 +794,7 @@ async def start_identity_server_async(node, loop, verbose=True):
cmd += 'bitdust set logs/packet-enabled true;'
cmd += 'bitdust set services/gateway/p2p-timeout 20;'
cmd += 'bitdust set personal/private-key-size 1024;'
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/message-broker/enabled false;'
Expand Down Expand Up @@ -825,6 +827,7 @@ async def start_stun_server_async(node, loop, dht_seeds=''):
# use short key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/message-broker/enabled false;'
Expand Down Expand Up @@ -862,6 +865,7 @@ async def start_proxy_server_async(
# use short key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/proxy-transport/enabled false;'
Expand Down Expand Up @@ -919,6 +923,7 @@ async def start_supplier_async(
# use short key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/proxy-server/enabled false;'
# configure ID servers
Expand Down Expand Up @@ -984,6 +989,7 @@ async def start_message_broker_async(
# use short key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/customer/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/proxy-server/enabled false;'
Expand Down Expand Up @@ -1066,6 +1072,7 @@ async def start_customer_async(
# use short key to run tests faster
cmd += 'bitdust set personal/private-key-size 1024;'
# disable unrelated services
cmd += 'bitdust set services/bismuth-blockchain/enabled false;'
cmd += 'bitdust set services/supplier/enabled false;'
cmd += 'bitdust set services/message-broker/enabled false;'
cmd += 'bitdust set services/proxy-server/enabled false;'
Expand Down

0 comments on commit d20934d

Please sign in to comment.