Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved constants to separate file #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mechafil/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""MechaFIL: Mechanistic model for the Filecoin Economy"""

__version__ = "1.7"
__version__ = "1.10"
__author__ = "Maria Silva <[email protected]>, Tom Mellan <[email protected]>, Kiran Karra <[email protected]>"
__all__ = []

Expand Down
4 changes: 4 additions & 0 deletions mechafil/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EXBI = 2**60
EIB = EXBI # a convenience alias
EXA = 10**18
PIB = 2**50
4 changes: 1 addition & 3 deletions mechafil/data_spacescope.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import os
import json

EXBI = 2**60
PIB = 2**50

DEFAULT_SPACESCOPE_CHUNK_SIZE_IN_DAYS = 90
DEFAULT_AUTH_CONFIG = os.path.join(os.path.dirname(__file__), 'cfg', 'spacescope_auth.json')

from .data import NETWORK_START
from .constants import EXBI, PIB

class SpacescopeDataConnection:
auth_token = ""
Expand Down
4 changes: 1 addition & 3 deletions mechafil/data_starboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import datetime
from typing import Tuple

EXBI = 2**60
PIB = 2**50

from .constants import EXBI, PIB

def get_historical_network_stats(
start_date: datetime.date, current_date: datetime.date, end_date: datetime.date
Expand Down
18 changes: 11 additions & 7 deletions mechafil/minting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import numpy as np
import pandas as pd

from .constants import EXA, EXBI, PIB
from .data import get_storage_baseline_value, \
get_cum_capped_rb_power, get_cum_capped_qa_power

EXBI = 2**60
PIB = 2**50

LAMBDA = np.log(2) / (
6.0 * 365
) # minting exponential reward decay rate (6yrs half-life)
Expand All @@ -17,13 +17,18 @@
GROWTH_RATE = float(
np.log(2) / 365.0
) # daily baseline growth rate (the "g" from https://spec.filecoin.io/#section-systems.filecoin_token)

# NOTE: the baseline storage value is the baseline storage power at the genesis
# The spec notes that this value is 2.888888888, but the actual data from starboard
# shows that the value is 2.766213637444971. We use the actual data here.
#
# Query:
# 3189227188947035000 from https://observable-api.starboard.ventures/api/v1/observable/network-storage-capacity/new_baseline_power
BASELINE_STORAGE = (
2.766213637444971
* EXBI
* EXA
# the b_0 from https://spec.filecoin.io/#section-systems.filecoin_token
)
# TODO: understand why the baseline value from startboard differs from the spec!
# 3189227188947035000 from https://observable-api.starboard.ventures/api/v1/observable/network-storage-capacity/new_baseline_power

def compute_minting_trajectory_df(
start_date: datetime.date,
Expand Down Expand Up @@ -89,8 +94,7 @@ def compute_baseline_power_array(


def network_time(cum_capped_power: float) -> float:
EXA_TO_EIB = (10**18) / (2**60)
b0 = BASELINE_STORAGE * EXA_TO_EIB
b0 = BASELINE_STORAGE
g = GROWTH_RATE
return (1 / g) * np.log(((g * cum_capped_power) / b0) + 1)

Expand Down
71 changes: 42 additions & 29 deletions notebooks/backtest.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="mechaFIL",
version="1.9",
version="1.10",
author="Maria Silva, Tom Mellan, Kiran Karra",
author_email="[email protected], [email protected], [email protected]",
description="Mechanistic model for the Filecoin Economy",
Expand Down