adjusted cost again

This commit is contained in:
Kevin Froman 2021-01-24 22:05:21 +00:00
parent 5f24ea7bdd
commit 7d8781c57d
5 changed files with 15 additions and 9 deletions

View File

@ -2,6 +2,11 @@
This project uses Semantic Versioning
## 4.0.0
* Make blocks less expensive
## 3.0.0
* Use better cost system in anonvdf

View File

@ -19,9 +19,10 @@ class AnonVDFGenerator(generator.KastenBaseGenerator):
# jan 2021 disk price metric = 0.000017 USD per MB
# mobile MB transfer US/Canada = 0.0125 USD
# Max cost of block storage + American mobile data transfer = 0.0751 USD
# Goal: approximately 2 seconds of computation for 1 hour of 1 MB storage
byte_cost = 1000
second_cost = 26
byte_cost = 10
second_cost = 4
@classmethod
def get_rounds_for_ttl_seconds(cls, seconds: int, size_bytes: int):

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages
setup(name='onionrblocks',
version='3.0.0',
version='4.0.0',
description='Onionr message format',
author='Kevin Froman',
author_email='beardog@mailbox.org',

View File

@ -69,8 +69,8 @@ class TestAnonVDF(unittest.TestCase):
def test_vdf_rounds_seconds(self):
size = 10000
per_byte = 1000
per_second = 26
per_byte = 10
per_second = 4
expected_rounds = (3600 * per_second) + (size * per_byte)
self.assertEqual(anonvdf.AnonVDFGenerator.get_rounds_for_ttl_seconds(3600, size), expected_rounds)

View File

@ -7,23 +7,23 @@ class TestBlockCreator(unittest.TestCase):
def test_create_anonvdf(self):
bl = create_anonvdf_block(b"Test", "txt", 3600)
# (rounds - (size_bytes * cls.byte_cost)) // cls.second_cost
expected_rounds = (3600 * 26) + (len(bl.get_packed()) * 1000) - 1000
expected_rounds = (3600 * 4) + (len(bl.get_packed()) * 100) + 100
self.assertEqual(expected_rounds, bl.get_metadata()['rds'])
def test_create_anonvdf_half_hour(self):
bl = create_anonvdf_block(b"Test", "txt", 1800)
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (1800 * anonvdf.AnonVDFGenerator.second_cost) - 1000
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (1800 * anonvdf.AnonVDFGenerator.second_cost) + 100
self.assertEqual(expected_rounds, bl.get_metadata()['rds'])
def test_create_anonvdf_odd(self):
#(rounds - (size_bytes * cls.byte_cost)) // cls.second_cost
bl = create_anonvdf_block(b"Test", "txt", 1303)
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (1303 * anonvdf.AnonVDFGenerator.second_cost) + 1000
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (1303 * anonvdf.AnonVDFGenerator.second_cost) + 100
self.assertEqual(expected_rounds, bl.get_metadata()['rds'])
def test_create_anonvdf_verify(self):
bl = create_anonvdf_block(b"Test", "txt", 3600)
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (3600 * anonvdf.AnonVDFGenerator.second_cost) - 1000
expected_rounds = (len(bl.get_packed()) * anonvdf.AnonVDFGenerator.byte_cost) + (3600 * anonvdf.AnonVDFGenerator.second_cost) + 100
self.assertEqual(expected_rounds, bl.get_metadata()['rds'])
packed = bl.get_packed()