Giter Site home page Giter Site logo

harukama / aleo-explorer Goto Github PK

View Code? Open in Web Editor NEW
75.0 5.0 57.0 1.77 MB

Open source explorer for the Aleo network

Home Page: https://testnet3.aleoscan.io

License: GNU Affero General Public License v3.0

Python 72.70% Jinja 14.30% PLpgSQL 10.63% JavaScript 0.46% CSS 1.41% Makefile 0.07% Batchfile 0.08% Dockerfile 0.36%
aleo blockchain

aleo-explorer's Introduction

Aleo Explorer

The "official" instance

Description

A blockchain explorer for Aleo.

It contains a node that connects to another peer to fetch blockchain data. This node is NOT validating blocks. Only connect to peers that you trust.

Prerequisites

Usage

  1. Import the database schema from pg_dump.sql.
  2. Configure through .env file. See .env.example for reference.
  3. Install aleo-explorer-rust to the current Python environment.
  4. Compile aleo-explorer-wasm, install to webui/static/rust{.js,_bg.wasm} with wasm-bindgen.
  5. Run main.py.

Use in docker

docker-compose up -d

(currently lacking pg_hint_plan)

A better frontend?

Yeah, I'm not really a frontend developer. I know it's ugly, but I'm focusing on features here.

You are welcome to contribute a better frontend, as long as you keep the current one as a function baseline reference. You can also create an entirely new frontend outside this repository; all you really need is the blockchain data in the database.

License

AGPL-3.0-or-later

aleo-explorer's People

Contributors

catusax avatar harukama avatar nsxsnx avatar snowtigersoft avatar snyk-bot avatar t0rs0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aleo-explorer's Issues

save_block error

Traceback (most recent call last):
File "/home/ps/aleo-explorer-python/aleo-explorer/node/node.py", line 80, in worker
await self.parse_message(Frame.load(BytesIO(frame)))
File "/home/ps/aleo-explorer-python/aleo-explorer/node/node.py", line 105, in parse_message
await self.explorer_request(explorer.Request.ProcessBlock(block))
File "/home/ps/aleo-explorer-python/aleo-explorer/explorer/explorer.py", line 48, in node_request
await self.add_block(request.block)
File "/home/ps/aleo-explorer-python/aleo-explorer/explorer/explorer.py", line 130, in add_block
await self.db.save_block(block)
File "/home/ps/aleo-explorer-python/aleo-explorer/db.py", line 1304, in save_block
await self._save_block(block)
File "/home/ps/aleo-explorer-python/aleo-explorer/db.py", line 27, in wrapper
return await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/db.py", line 891, in save_block
block_reward += await block.get_total_priority_fee(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 3449, in get_total_priority_fee
return sum([(await t.get_fee_breakdown(db)).priority_fee for t in self.transactions])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 3449, in
return sum([(await t.get_fee_breakdown(db)).priority_fee for t in self.transactions])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 2610, in get_fee_breakdown
finalize_costs = await execution.finalize_costs(db)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 2401, in finalize_costs
program = await get_program(db, str(transition.program_id))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/util/global_cache.py", line 16, in get_program
program = Program.load(BytesIO(program))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 885, in load
i = Struct.load(data)
^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_block.py", line 151, in load
members = Vec[Tuple[Identifier, PlaintextType], u16].load(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/generic.py", line 135, in load
return cls(list(value_type.load(data) for _ in range(size)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/generic.py", line 135, in
return cls(list(value_type.load(data) for _ in range(size)))
^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/generic.py", line 100, in load
value.append(t.load(data))
^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 684, in load
return ArrayPlaintextType.load(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 785, in load
array_type = ArrayType.load(data)
^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 750, in load
plaintext_type = PlaintextType.load(data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 684, in load
return ArrayPlaintextType.load(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 785, in load
array_type = ArrayType.load(data)
^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 750, in load
plaintext_type = PlaintextType.load(data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/vm_instruction.py", line 678, in load
type
= cls.Type.load(data)
^^^^^^^^^^^^^^^^^^^
File "/home/ps/aleo-explorer-python/aleo-explorer/aleo_types/basic.py", line 217, in load
self = cls(struct.unpack("<B", data.read(1))[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 711, in call
return cls.new(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in new
raise ve_exc
ValueError: 32 is not a valid PlaintextType.Type

When P2P_BLOCK_BATCH_SIZE is greater than 1, running results in an error.

The error is as follows:

Arguments: ('ProtocolViolation',)
Application startup failed. Exiting.
Traceback (most recent call last):
  File "node.py", line 70, in worker
    size = await self.reader.readexactly(4)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/streams.py", line 730, in readexactly
    raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 4 expected bytes

P2P_BLOCK_BATCH_SIZE=1, it's ok

Can't get correct coinbase reward

Hi! I'm digging into the explorer and trying to get how the rewards calculation works and can't get my head around it. I've checked out your rewards calculation code, extracted it into snippet, tried to get the same result as in the frontend, but getting different (bigger) rewards. What am I missing?

def retarget(prev_target, prev_block_timestamp, block_timestamp, half_life, inverse, anchor_time):
    drift = max(block_timestamp - prev_block_timestamp, 1) - anchor_time
    if drift == 0:
        return prev_target
    if inverse:
        drift = -drift
    exponent = int((1 << 16) * drift / half_life)
    integral = exponent >> 16
    fractional = exponent - (integral << 16)
    fractional_multiplier = (1 << 16) + ((195_766_423_245_049 * fractional + 971_821_376 * pow(fractional, 2) + 5_127 * pow(fractional, 3) + pow(2, 47)) >> 48)
    candidate_target = prev_target * fractional_multiplier
    shifts = integral - 16
    if shifts < 0:
        candidate_target = max(candidate_target >> -shifts, 1)
    else:
        candidate_target = max(candidate_target << shifts, 1)
    candidate_target = min(candidate_target, 2 ** 64 - 1)
    return candidate_target

def get_coinbase_reward(current_height, current_timestamp, previous_timestamp) -> int:
    anchor_reward = 13
    y10_anchor_height = 31536000 // 25 * 10
    remaining_blocks = y10_anchor_height - current_height
    if remaining_blocks <= 0:
        return 0
    return retarget(remaining_blocks * anchor_reward, previous_timestamp, current_timestamp, 25, True, 25)

print(get_coinbase_reward(427323, 1674120477, 1674120464) // 2)
# => 110476440

The result in the frontend is 72.902145, I get 110.476440.

About the data fetch issue

Hi, I tried to run the Aleo Explorer on my local yesterday, but it seems the data fetch is not quite stable. I know the explorer using the P2P to index the data, but after indexing around 100 blocks, the node connection is always lost. Is it the node issue or the explorer is in an unstable state? I ask because I found the explorer UI is also broken if I already have some data in the DB.

BTW, just curious to know why the project using P2P to index data instead of RPC?

`/api/v1/mapping/get_value/[program_id]/[key]` endpoint fails for key structs which keys are not in the definition order

Cannot build from docker compose

So I tried to build from the docker compose file, but cffi is failing in the building process

19.88 Building wheels for collected packages: minify-html, cffi
19.88   Building wheel for minify-html (pyproject.toml): started
86.33   Building wheel for minify-html (pyproject.toml): still running...
218.6   Building wheel for minify-html (pyproject.toml): still running...
295.5   Building wheel for minify-html (pyproject.toml): still running...
295.8   Building wheel for minify-html (pyproject.toml): finished with status 'done'
295.8   Created wheel for minify-html: filename=minify_html-0.11.5-cp311-cp311-linux_aarch64.whl size=745669 sha256=9c92da54afc409c45fe8ca3d8f37f75751aa8eeaec4e976001aa5ae9e68c76e4
295.8   Stored in directory: /root/.cache/pip/wheels/7a/9c/31/f30e452c46b8288b7a2bee2c52dde60828f710172e9600a9dc
295.8   Building wheel for cffi (pyproject.toml): started
296.7   Building wheel for cffi (pyproject.toml): finished with status 'error'
296.7   error: subprocess-exited-with-error
296.7
296.7   × Building wheel for cffi (pyproject.toml) did not run successfully.
296.7   │ exit code: 1
296.7   ╰─> [61 lines of output]
296.7       Package libffi was not found in the pkg-config search path.
296.7       Perhaps you should add the directory containing `libffi.pc'
296.7       to the PKG_CONFIG_PATH environment variable
296.7       Package 'libffi', required by 'virtual:world', not found
296.7       Package libffi was not found in the pkg-config search path.
296.7       Perhaps you should add the directory containing `libffi.pc'
296.7       to the PKG_CONFIG_PATH environment variable
296.7       Package 'libffi', required by 'virtual:world', not found
296.7       Package libffi was not found in the pkg-config search path.
296.7       Perhaps you should add the directory containing `libffi.pc'
296.7       to the PKG_CONFIG_PATH environment variable
296.7       Package 'libffi', required by 'virtual:world', not found
296.7       Package libffi was not found in the pkg-config search path.
296.7       Perhaps you should add the directory containing `libffi.pc'
296.7       to the PKG_CONFIG_PATH environment variable
296.7       Package 'libffi', required by 'virtual:world', not found
296.7       Package libffi was not found in the pkg-config search path.
296.7       Perhaps you should add the directory containing `libffi.pc'
296.7       to the PKG_CONFIG_PATH environment variable
296.7       Package 'libffi', required by 'virtual:world', not found
296.7       running bdist_wheel
296.7       running build
296.7       running build_py
296.7       creating build
296.7       creating build/lib.linux-aarch64-cpython-311
296.7       creating build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/pkgconfig.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/error.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/recompiler.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/vengine_gen.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/ffiplatform.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/commontypes.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/api.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/lock.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/_imp_emulation.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/backend_ctypes.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/vengine_cpy.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/setuptools_ext.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/cffi_opcode.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/__init__.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/_shimmed_dist_utils.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/verifier.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/model.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/cparser.py -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/_cffi_include.h -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/parse_c_type.h -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/_embedding.h -> build/lib.linux-aarch64-cpython-311/cffi
296.7       copying src/cffi/_cffi_errors.h -> build/lib.linux-aarch64-cpython-311/cffi
296.7       warning: build_py: byte-compiling is disabled, skipping.
296.7
296.7       running build_ext
296.7       building '_cffi_backend' extension
296.7       creating build/temp.linux-aarch64-cpython-311
296.7       creating build/temp.linux-aarch64-cpython-311/src
296.7       creating build/temp.linux-aarch64-cpython-311/src/c
296.7       gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.11 -c src/c/_cffi_backend.c -o build/temp.linux-aarch64-cpython-311/src/c/_cffi_backend.o
296.7       src/c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
296.7          15 | #include <ffi.h>
296.7             |          ^~~~~~~
296.7       compilation terminated.
296.7       error: command '/usr/bin/gcc' failed with exit code 1
296.7       [end of output]
296.7
296.7   note: This error originates from a subprocess, and is likely not a problem with pip.
296.7   ERROR: Failed building wheel for cffi
296.7 Successfully built minify-html
296.7 Failed to build cffi
296.7 ERROR: Failed to build one or more wheels
------
failed to solve: process "/bin/sh -c set -eux;     pip wheel -w /dist/  -r /app/requirements.txt" did not complete successfully: exit code: 1

I'm building a Ubuntu machine from AWS
CPU ARMv8 (AWS Graviton2)

any suggestion on how to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.