-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
263 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Namada Mainnet Genesis files | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla mauris magna, blandit non posuere a, tempor vel nibh. Integer lacinia quam tempor hendrerit porta. Ut quis congue elit. | ||
|
||
## Voting power distrubiton | ||
|
||
![Voting Power Distribution](../images/validators.png "Voting Power Distribution") | ||
|
||
## Validators | ||
|
||
|
||
- address: `tnam1q8nzq9m5v8upn6jkjsljf25mzf2n9u7qfyc8kwje` | ||
- alias: `Unknown alias` | ||
- commission: `1.0%` | ||
- max commission rate change: `1.0%` | ||
- total voting power: `10000.0` | ||
- email: `[email protected]` | ||
- website: `Unknown website` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Namada Mainnet Genesis files | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla mauris magna, blandit non posuere a, tempor vel nibh. Integer lacinia quam tempor hendrerit porta. Ut quis congue elit. | ||
|
||
## Voting power distrubiton | ||
|
||
![Voting Power Distribution](../images/validators.png "Voting Power Distribution") | ||
|
||
## Validators | ||
|
||
{% for validator in validators %} | ||
- address: `{{ validator.address }}` | ||
- alias: `{{ validator.alias or 'Unknown alias' }}` | ||
- commission: `{{ validator.commission_rate }}%` | ||
- max commission rate change: `{{ validator.max_commission_rate_change }}%` | ||
- total voting power: `{{ validator.voting_power }}` | ||
- email: `{{ validator.email }}` | ||
- website: `{{ validator.website or 'Unknown website' }}` | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,83 @@ | ||
from collections import defaultdict | ||
import glob | ||
import toml | ||
import plotly.graph_objects as go | ||
from jinja2 import Environment, FileSystemLoader | ||
|
||
def build_graph(validators): | ||
fig = go.Figure() | ||
fig.add_trace(go.Bar( | ||
x=[validator['address'] for validator in validators], | ||
y=[validator['voting_power'] for validator in validators], | ||
name='validators', | ||
marker_color='indianred', | ||
)) | ||
|
||
fig.update_layout(xaxis={'categoryorder':'total descending'}) | ||
fig.update_xaxes(tickangle=75) | ||
|
||
fig.write_image("images/validators.png") | ||
|
||
|
||
def build_readme(validators): | ||
environment = Environment(loader=FileSystemLoader("scripts/artifacts")) | ||
template = environment.get_template("README.jinja") | ||
|
||
content = template.render({"validators": validators}) | ||
|
||
with open("genesis/README.md", mode="w", encoding="utf-8") as message: | ||
message.write(content) | ||
|
||
|
||
def read_unsafe_toml(file_path): | ||
try: | ||
return toml.load(open(file_path, "r")) | ||
except Exception as e: | ||
return None | ||
|
||
|
||
def parse_validators(): | ||
validator_files = glob.glob("transactions/*-validator.toml") | ||
bond_files = glob.glob("transactions/*-bond.toml") | ||
|
||
bonds = [] | ||
target_vp = defaultdict(int) | ||
for file in bond_files: | ||
bonds_toml = read_unsafe_toml(file) | ||
if bonds_toml is None: | ||
continue | ||
|
||
for bond in bonds_toml['bond']: | ||
bonds.append({ | ||
'source': bond['source'], | ||
'validator': bond['validator'], | ||
'amount': bond['amount'], | ||
}) | ||
target_vp[bond['validator']] += float(bond['amount']) | ||
|
||
validators = [] | ||
for file in validator_files: | ||
validators_toml = read_unsafe_toml(file) | ||
if validators_toml is None: | ||
continue | ||
|
||
for validator in validators_toml['validator_account']: | ||
validators.append({ | ||
'address': validator['address'], | ||
'commission_rate': float(validator['commission_rate']) * 100, | ||
'max_commission_rate_change': float(validator['max_commission_rate_change']) * 100, | ||
'email': validator['metadata']['email'], | ||
'alias': validator['metadata']['alias'] if 'alias' in validator['metadata'] else None, | ||
'website': validator['metadata']['website'] if 'website' in validator['metadata'] else None, | ||
'voting_power': target_vp[validator['address']] if validator['address'] in target_vp else 0 | ||
}) | ||
|
||
return sorted(validators, key=lambda d: d['voting_power']) | ||
|
||
def main(): | ||
exit(0) | ||
validators = parse_validators() | ||
build_graph(validators) | ||
build_readme(validators) | ||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters