Merge remote-tracking branch 'origin/main' into max_minor_ui_fix

This commit is contained in:
GroovieGermanikus 2023-12-06 21:48:22 +01:00
commit d1c2f80bfe
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
5 changed files with 93 additions and 92 deletions

41
app.py
View File

@ -2,7 +2,6 @@ from flask import Flask, render_template, request, make_response, redirect
from flask_htmx import HTMX
import time
import re
from os import environ
import transaction_database
import transaction_details_database
import recent_blocks_database
@ -85,7 +84,7 @@ def get_block(slot):
def is_slot_number(raw_string):
return re.fullmatch("[0-9]+", raw_string) is not None
return re.fullmatch("[0-9,]+", raw_string) is not None
def is_block_hash(raw_string):
@ -114,6 +113,7 @@ def search():
return render_template('_search_noresult.html', config=this_config)
if is_slot_number(search_string):
search_string = search_string.replace(',', '')
maprows = list(recent_blocks_database.find_block_by_slotnumber(int(search_string)))
if len(maprows):
return render_template('_blockslist.html', config=this_config, blocks=maprows)
@ -151,3 +151,40 @@ def get_transaction_details(signature):
return render_template('transaction_details.html', config=this_config, transaction=maprows[0])
else:
return "Transaction not found", 404
# format 123456789 to "123,456,789"
@webapp.template_filter('lamports')
def lamports_filter(number: int):
if number is None:
return ""
else:
# https://realpython.com/python-formatted-output/#the-group-subcomponent
# return format(number, ",.2f")
return format(number, ",")
@webapp.template_filter('slotnumber')
def slotnumber_filter(number: int):
if number is None:
return ""
else:
return format(number, ",")
@webapp.template_filter('count')
def count_filter(number: int):
if number is None:
return ""
else:
return format(number, ",")
# railway version: None -> None
@webapp.template_filter('map_count')
def mapcount_filter(number: int):
if number is None:
return None
else:
return format(number, ",")

View File

@ -15,7 +15,7 @@
<tr>
<td>
<span class="text-primary">
<a hx-boost="true" href="/block/{{ block.slot }}">{{ block.slot }}</a>
<a hx-boost="true" href="/block/{{ block.slot }}">{{ block.slot | slotnumber }}</a>
</span>
</td>
<td>
@ -69,7 +69,7 @@
<div class="font-monospace">
<span class="d-inline-block" style="min-width:4em">
<span class="text-primary">{{ block.prioritization_fees.p_min }} </span>
<span class="text-primary">{{ block.prioritization_fees.p_min | lamports }} </span>
</span>
<span class="d-inline-block" style="min-width:4em">
<span class="text-primary">{{ block.prioritization_fees.p_median }} </span>
@ -78,7 +78,7 @@
<span class="text-primary">{{ block.prioritization_fees.p_90 }} </span>
</span>
<span class="d-inline-block" style="min-width:4em">
<span class="text-primary">{{ block.prioritization_fees.p_max }}</span>
<span class="text-primary">{{ block.prioritization_fees.p_max | lamports }}</span>
</span>
</div>

View File

@ -30,7 +30,7 @@
<td>
<div class="d-flex align-items-center font-monospace" style="width:400px">
<div class="text-truncate">
<a href="/transaction/{{tx.signature}}">{{tx.signature}}</a>
<a href="/transaction/{{tx.signature}}">{{ tx.signature }}</a>
</div>
</div>
</td>
@ -40,8 +40,8 @@
{% for error in tx.errors_array %}
<tr>
<td>
<span class="font-monospace text-danger" title="Slot {{error.slot}}">
{{error.count}}x&nbsp;&nbsp;{{error.error}}
<span class="font-monospace text-danger" title="Slot {{ error.slot | slotnumber }}">
{{ error.count | count }}x&nbsp;&nbsp;{{ error.error }}
</span>
</td>
</tr>
@ -49,8 +49,8 @@
</table>
</div>
</td>
<td class="text-end"><span class="font-monospace">{{ tx.cu_requested|default('', True) }}</span></td>
<td class="text-end">{{ tx.prioritization_fees|default('', True) }}</td>
<td class="text-end"><span class="font-monospace">{{ tx.cu_requested | lamports }}</span></td>
<td class="text-end">{{ tx.prioritization_fees | lamports }}</td>
</tr>
{% endfor %}

View File

@ -18,7 +18,7 @@
<div class="container mt-n2">
<div class="header">
<div class="header-body"><h6 class="header-pretitle">Details</h6>
<h2 class="header-title">Block {{block.slot}}</h2></div>
<h2 class="header-title">Block {{ block.slot | slotnumber }}</h2></div>
</div>
<div class="card">
<div class="card-header"><h3 class="card-header-title mb-0 d-flex align-items-center">Overview</h3>
@ -28,7 +28,7 @@
<tbody class="list">
<tr>
<td class="w-100">Slot</td>
<td class="text-lg-end font-monospace"><span class="font-monospace"><a href="https://explorer.solana.com//block/{{block.slot}}?cluster={{config.cluster}}">{{block.slot}}</a></span></td>
<td class="text-lg-end font-monospace"><span class="font-monospace"><a href="https://explorer.solana.com//block/{{block.slot}}?cluster={{config.cluster}}">{{ block.slot | slotnumber }}</a></span></td>
</tr>
<tr>
<td class="w-100">Blockhash</td>
@ -37,35 +37,35 @@
</tr>
<tr>
<td class="w-100">Processed Transactions</td>
<td class="text-lg-end font-monospace"><span>{{block.processed_transactions}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.processed_transactions | count }}</span></td>
</tr>
<tr>
<td class="w-100">Successful Transactions</td>
<td class="text-lg-end font-monospace"><span>{{block.successful_transactions}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.successful_transactions | count }}</span></td>
</tr>
<tr>
<td class="w-100">Banking Stage Errors</td>
<td class="text-lg-end font-monospace"><span>{{block.banking_stage_errors or 'n/a'}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.banking_stage_errors | map_count or 'n/a'}}</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees Median</td>
<td class="text-lg-end font-monospace"><span>{{block.supp_infos.p_median}} micro-lamports/CU</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.supp_infos.p_median | lamports }} micro-lamports/CU</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees Min</td>
<td class="text-lg-end font-monospace"><span>{{block.supp_infos.p_min}} micro-lamports/CU</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.supp_infos.p_min | lamports }} micro-lamports/CU</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees Max</td>
<td class="text-lg-end font-monospace"><span>{{block.supp_infos.p_max}} micro-lamports/CU</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.supp_infos.p_max | lamports }} micro-lamports/CU</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees p75</td>
<td class="text-lg-end font-monospace"><span>{{block.supp_infos.p_75}} micro-lamports/CU</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.supp_infos.p_75 | lamports }} micro-lamports/CU</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees p90</td>
<td class="text-lg-end font-monospace"><span>{{block.supp_infos.p_90}} micro-lamports/CU</span></td>
<td class="text-lg-end font-monospace"><span>{{ block.supp_infos.p_90 | lamports }} micro-lamports/CU</span></td>
</tr>
</tbody>
</table>
@ -76,8 +76,8 @@
<div class="header-body pt-0">
<ul class="nav nav-tabs nav-overflow header-tabs">
<!-- note: local anchors are not hx-boost'ed -->
<li class="nav-item"><a hx-boost="false" class="nav-link" href="#write-locked-accounts">Write locked accounts</a></li>
<li class="nav-item"><a hx-boost="false" class="nav-link" href="#read-locked-accounts">Read locked accounts</a></li>
<li class="nav-item"><a class="nav-link" href="#write-locked-accounts">Write locked accounts</a></li>
<li class="nav-item"><a class="nav-link" href="#read-locked-accounts">Read locked accounts</a></li>
</ul>
</div>
</div>
@ -108,11 +108,11 @@
class="font-monospace"><span class="">{{write_account.key}}</span></span>
</div>
</a></td>
<td>{{write_account.cu_requested}}</td>
<td>{{write_account.cu_consumed}}</td>
<td>{{write_account.min_pf}}</td>
<td>{{write_account.median_pf}}</td>
<td>{{write_account.max_pf}}</td>
<td>{{ write_account.cu_requested | lamports }}</td>
<td>{{ write_account.cu_consumed | lamports }}</td>
<td>{{ write_account.min_pf | lamports }}</td>
<td>{{ write_account.median_pf | lamports }}</td>
<td>{{ write_account.max_pf | lamports }}</td>
</tr>
{% endfor %}
</tbody>
@ -145,11 +145,11 @@
class="font-monospace"><span class="">{{write_account.key}}</span></span>
</div>
</a></td>
<td>{{write_account.cu_requested}}</td>
<td>{{write_account.cu_consumed}}</td>
<td>{{write_account.min_pf}}</td>
<td>{{write_account.median_pf}}</td>
<td>{{write_account.max_pf}}</td>
<td>{{ write_account.cu_requested | lamports }}</td>
<td>{{ write_account.cu_consumed | lamports }}</td>
<td>{{ write_account.min_pf | lamports }}</td>
<td>{{ write_account.median_pf | lamports }}</td>
<td>{{ write_account.max_pf | lamports }}</td>
</tr>
{% endfor %}
</tbody>

View File

@ -32,7 +32,7 @@
<td class="text-lg-end font-monospace">
<span class="font-monospace">
<a href="https://explorer.solana.com/tx/{{transaction.signature}}?cluster={{config.cluster}}">
{{transaction.signature}}
{{ transaction.signature }}
</a>
</span>
</td>
@ -40,34 +40,34 @@
<tr>
<td class="w-100">Executed</td>
<td class="text-lg-end font-monospace">
<span>{{transaction.is_executed}}</span></td>
<span>{{ transaction.is_executed }}</span></td>
</tr>
<tr>
<td class="w-100">Confirmed</td>
<td class="text-lg-end font-monospace">
<span>{{transaction.is_confirmed}}</span></td>
<span>{{ transaction.is_confirmed }}</span></td>
</tr>
<tr>
<td class="w-100">Processed slot</td>
<td class="text-lg-end font-monospace">
<span><a hx-boost="true" href="/block/{{transaction.processed_slot}}">{{transaction.processed_slot}}</a></span></td>
<span><a hx-boost="true" href="/block/{{transaction.processed_slot}}">{{ transaction.processed_slot | slotnumber }}</a></span></td>
</tr>
<tr>
<td class="w-100">First notification slot</td>
<td class="text-lg-end font-monospace">
<span><a hx-boost="true" href="/block/{{transaction.first_notification_slot}}">{{transaction.first_notification_slot}}</a></span></td>
<span><a hx-boost="true" href="/block/{{transaction.first_notification_slot}}">{{ transaction.first_notification_slot | slotnumber }}</a></span></td>
</tr>
<tr>
<td class="w-100">CU Requested</td>
<td class="text-lg-end font-monospace"><span>{{transaction.cu_requested}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ transaction.cu_requested | lamports }}</span></td>
</tr>
<tr>
<td class="w-100">Prioritization Fees</td>
<td class="text-lg-end font-monospace"><span>{{transaction.prioritization_fees}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ transaction.prioritization_fees | lamports }}</span></td>
</tr>
<tr>
<td class="w-100">UTC timestamp</td>
<td class="text-lg-end font-monospace"><span>{{transaction.timestamp_formatted}}</span></td>
<td class="text-lg-end font-monospace"><span>{{ transaction.timestamp_formatted }}</span></td>
</tr>
</tbody>
</table>
@ -79,7 +79,7 @@
<ul class="nav nav-tabs nav-overflow header-tabs">
<!-- note: local anchors are not hx-boost'ed -->
{% for slot in transaction.relevant_slots %}
<li class="nav-item"><a class="nav-link" href="#relevant-slot-{{slot}}">Slot: {{slot}}</a></li>
<li class="nav-item"><a class="nav-link" href="#relevant-slot-{{slot}}">Slot: {{ slot | slotnumber }}</a></li>
{% endfor %}
</ul>
</div>
@ -88,7 +88,7 @@
{% for slot in transaction.relevant_slots %}
<div id="relevant-slot-{{slot}}" class="card">
<div class="card-header align-items-center"><h3 class="card-header-title">Errors in Slot {{slot}}</h3></div>
<div class="card-header align-items-center"><h3 class="card-header-title">Errors in Slot {{ slot | slotnumber }}</h3></div>
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
@ -103,10 +103,10 @@
{% if error.slot == slot %}
<tr>
<td>
<span class="text-danger">{{error.error}}</span>
<span class="text-danger">{{ error.error }}</span>
</td>
<td>
<span class="text-danger">{{error.count}}</span>
<span class="text-danger">{{ error.count | count }}</span>
</td>
</tr>
{% endif %}
@ -118,22 +118,6 @@
<div id="write-locked-accounts">
<div class="card-header align-items-center"><h3 class="card-header-title">Write-Locked Accounts</h3></div>
<<<<<<< Updated upstream
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
<thead>
<tr>
<th class="text-muted">Account</th>
<th class="text-muted">CU Requested</th>
<th class="text-muted">CU Consumed</th>
<th class="text-muted">Median Prio Fees</th>
<th class="text-muted">Min Prio Fees</th>
<th class="text-muted">Max Prio Fees</th>
</tr>
</thead>
<tbody>
{% for write_account in transaction.write_lock_info[slot] %}
=======
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
<thead>
@ -148,22 +132,20 @@
</thead>
<tbody>
{% for write_account in transaction.write_lock_info %}
{% if write_account.slot == slot %}
>>>>>>> Stashed changes
<tr>
<td>
<a href="https://explorer.solana.com/account/{{ write_account.key }}?cluster={{config.cluster}}">
<div class="d-none d-lg-flex align-items-center "><span class="font-size-tiny me-2"><span
class=""></span></span><span
class="font-monospace"><span class="">{{write_account.key}}</span></span>
class="font-monospace"><span class="">{{ write_account.key }}</span></span>
</div>
</a>
</td>
<td>{{write_account.cu_requested}}</td>
<td>{{write_account.cu_consumed}}</td>
<td>{{write_account.min_pf}}</td>
<td>{{write_account.median_pf}}</td>
<td>{{write_account.max_pf}}</td>
<td>{{ write_account.cu_requested | lamports }}</td>
<td>{{ write_account.cu_consumed | lamports }}</td>
<td>{{ write_account.min_pf | lamports }}</td>
<td>{{ write_account.median_pf | lamports }}</td>
<td>{{ write_account.max_pf | lamports }}</td>
</tr>
{% endfor %}
@ -175,22 +157,6 @@
<div id="read-locked-accounts">
<div class="card-header align-items-center"><h3 class="card-header-title">Read-Locked Accounts</h3></div>
<<<<<<< Updated upstream
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
<thead>
<tr>
<th class="text-muted">Account</th>
<th class="text-muted">CU Requested</th>
<th class="text-muted">CU Consumed</th>
<th class="text-muted">Median Prio Fees</th>
<th class="text-muted">Min Prio Fees</th>
<th class="text-muted">Max Prio Fees</th>
</tr>
</thead>
<tbody>
{% for read_account in transaction.read_lock_info[slot] %}
=======
<div class="table-responsive mb-0">
<table class="table table-sm table-nowrap card-table">
<thead>
@ -205,23 +171,21 @@
</thead>
<tbody>
{% for read_account in transaction.read_lock_info %}
{% if read_account.slot == slot %}
>>>>>>> Stashed changes
<tr>
<td>
<a href="https://explorer.solana.com/account/{{ read_account.key }}?cluster={{config.cluster}}">
<div class="d-none d-lg-flex align-items-center">
<span class="font-size-tiny me-2">
<span class="font-monospace">{{read_account.key}}</span>
<span class="font-monospace">{{ read_account.key }}</span>
</span>
</div>
</a>
</td>
<td>{{read_account.cu_requested}}</td>
<td>{{read_account.cu_consumed}}</td>
<td>{{read_account.min_pf}}</td>
<td>{{read_account.median_pf}}</td>
<td>{{read_account.max_pf}}</td>
<td>{{ read_account.cu_requested | lamports }}</td>
<td>{{ read_account.cu_consumed | lamports }}</td>
<td>{{ read_account.min_pf | lamports }}</td>
<td>{{ read_account.median_pf | lamports }}</td>
<td>{{ read_account.max_pf | lamports }}</td>
</tr>
{% endfor %}