diff --git a/script/research/blockchain-explorer/site/app.py b/script/research/blockchain-explorer/site/app.py index c7292bbfb7f1..b7f69092c29e 100644 --- a/script/research/blockchain-explorer/site/app.py +++ b/script/research/blockchain-explorer/site/app.py @@ -15,18 +15,34 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import asyncio -from flask import Flask, request, render_template - import rpc +from flask import Flask, request, render_template app = Flask(__name__) @app.route('/') async def index(): + # Fetch data from RPC blocks = await rpc.get_last_n_blocks("10") - stats = await rpc.get_basic_statistics() - return render_template('index.html', blocks=blocks, stats=stats) + basic_stats = await rpc.get_basic_statistics() + + # Fetch the metric statistics + metric_stats = await rpc.get_metric_statistics() + has_metrics = metric_stats and isinstance(metric_stats, list) + + # Get the latest metric statistics, or use None if no metrics are found + if has_metrics: + latest_metric_stats = metric_stats[-1] + else: + latest_metric_stats = None + + # Render template + return render_template( + 'index.html', + blocks=blocks, + basic_stats=basic_stats, + metric_stats=latest_metric_stats, + ) @app.route('/search', methods=['GET', 'POST']) async def search(): @@ -45,6 +61,7 @@ async def block(header_hash): transactions = await rpc.get_block_transactions(header_hash) return render_template('block.html', block=block, transactions=transactions) + @app.route('/transaction/') async def transaction(transaction_hash): transaction = await rpc.get_transaction(transaction_hash) @@ -57,3 +74,4 @@ def page_not_found(e): @app.errorhandler(500) def page_not_found(e): return render_template('500.html'), 500 + diff --git a/script/research/blockchain-explorer/site/rpc.py b/script/research/blockchain-explorer/site/rpc.py index f107c5eac728..fdae34e47690 100644 --- a/script/research/blockchain-explorer/site/rpc.py +++ b/script/research/blockchain-explorer/site/rpc.py @@ -94,6 +94,10 @@ async def get_last_n_blocks(n: str): async def get_basic_statistics(): return await query("statistics.get_basic_statistics", []) +# Retrieve fee data statistics from blockchain-explorer daemon +async def get_metric_statistics(): + return await query("statistics.get_metric_statistics", []) + # Retrieve the block information of given header hash from blockchain-explorer daemon async def get_block(header_hash: str): return await query("blocks.get_block_by_hash", [header_hash]) diff --git a/script/research/blockchain-explorer/site/templates/index.html b/script/research/blockchain-explorer/site/templates/index.html index e8e061237412..51ad67253dd6 100644 --- a/script/research/blockchain-explorer/site/templates/index.html +++ b/script/research/blockchain-explorer/site/templates/index.html @@ -53,16 +53,56 @@

-

Statistics

+

Basic Statistics

    -
  • Height: {{ stats[0] }}
  • -
  • Epoch: {{ stats[1] }}
  • -
  • Last block: {{ stats[2] }}
  • -
  • Total blocks: {{ stats[3] }}
  • -
  • Total transactions: {{ stats[4] }}
  • +
  • Height: {{ basic_stats[0] }}
  • +
  • Epoch: {{ basic_stats[1] }}
  • +
  • Last block: {{ basic_stats[2] }}
  • +
  • Total blocks: {{ basic_stats[3] }}
  • +
  • Total transactions: {{ basic_stats[4] }}
+ +
+
+

Total Network Gas Consumption Statistics

+ + Total Gas +
    +
  • Average: {{ metric_stats[0] }}
  • +
  • Minimum: {{ metric_stats[1] }}
  • +
  • Maximum: {{ metric_stats[2] }}
  • +
+ + WASM Gas +
    +
  • Average: {{ metric_stats[3] }}
  • +
  • Minimum: {{ metric_stats[4] }}
  • +
  • Maximum: {{ metric_stats[5] }}
  • +
+ + ZK Circuits Gas +
    +
  • Average: {{ metric_stats[6] }}
  • +
  • Minimum: {{ metric_stats[7] }}
  • +
  • Maximum: {{ metric_stats[8] }}
  • +
+ + Signatures Gas +
    +
  • Average: {{ metric_stats[9] }}
  • +
  • Minimum: {{ metric_stats[10] }}
  • +
  • Maximum: {{ metric_stats[11] }}
  • +
+ + Deployments Gas +
    +
  • Average: {{ metric_stats[12] }}
  • +
  • Minimum: {{ metric_stats[13] }}
  • +
  • Maximum: {{ metric_stats[14] }}
  • +
+
{% endblock %} diff --git a/script/research/blockchain-explorer/site/templates/transaction.html b/script/research/blockchain-explorer/site/templates/transaction.html index fef8ff9134bf..c0213846844d 100644 --- a/script/research/blockchain-explorer/site/templates/transaction.html +++ b/script/research/blockchain-explorer/site/templates/transaction.html @@ -28,10 +28,20 @@

+

Summary

+

Gas Consumption

+
    +
  • Total: {{ transaction[4] }}
  • +
  • WASM: {{ transaction[5] }}
  • +
  • ZK Circuits: {{ transaction[6] }}
  • +
  • Signatures: {{ transaction[7] }}
  • +
  • Deployments: {{ transaction[8] }}
  • +