Giter VIP home page Giter VIP logo

tzstats-legacy's Introduction

Note: This repo contains v1 of the TzStats explorer and is no longer maintained. It may or may not work with the most recent TzIndex API.

Tezos Block Explorer

A block explorer for public and private Tezos blockchain networks based on the TzIndex backend available here. Supported by Blockwatch Data, Pro version available on request.

Develop

# setup dev environment
npm install

# start built-in dev server
yarn start

# build deployable app
yarn build

Running a local block explorer

You can run a local copy of TzStats and link it to your local instance of TzIndex in a few different ways. Easiest is using the Docker images built by the Makefile. If you don't have Docker installed follow the steps below.

Note: TzStats is a single-page Javascript app and the way web browsers work is that you need a local webserver to serve all files to your browser. You can setup a local Nginx or use another light-weight webserver to deliver the pre-built app or you just run the development version using yarn start.

Running the Dev Version

This is probably easier because it uses the built-in server that comes with yarn. Checkout the TzStats repo, create a new top-level file development.env with a single line TZSTATS_API_URL=http://localhost:8000, then run npm install and yarn start. You need NodeJS for this to work.

Running from Pre-Built App

Build TzStats with npm install and yarn build or copy all files from /var/www/ out of the TzStats Docker image. Then compile a local version of https://github.com/echa/serve and run serve with the following env variables: TZSTATS_API_URL (defaults to http://localhost:8000), SV_SERVER_PORT=8001 (smth other than the default port 8000 because TzIndex already uses it), SV_SERVER_ROOT=./build (the directory you built/extracted the compiled TzStats files to). Key trick is that the minified TzStats JS file contains a placeholder <[TZSTATS_API_URL]> which needs to be replaced with your local API endpoint. The embedded webserver Serve does that for you. Then navigate your browser to http://localhost:8001

Deploy (work in progress)

The contained Makefile requires a docker registry endpoint to be set.

DOCKER_REGISTRY_ADDR=<addr> make deploy

will run the following steps

  1. build React web app using yarn build
  2. build Docker image based on the serve file server
  3. publish image to private Docker registry
  4. use docker-compose to start/replace Docker container on remote host

for the deploy process to work the following ENV variables need to be specified:

DOCKER_HOST
DOCKER_REGISTRY_USER
DOCKER_REGISTRY_PASSPHRASE
BLOCKWATCH_API_KEY
DEPLOY_KEYS_PASSWORD

CI/CD pipelines usually store these in a supposedly secure way, but you'll never know, so be vigilant.

tzstats-legacy's People

Contributors

andrewpaulicek avatar andyvauliln avatar bitcoinbender avatar echa avatar stakery avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

tzstats-legacy's Issues

Improve the staking capacity calculation

Is your feature request related to a problem? Please describe.
It is very harmful to bakers if they exceed their capacity limit. P2P Validator has recently published an article that aims to establish a single approach for available staking capacity calculation and eliminate errors and confusion for end-users on various analytical resources.

Source: https://economy.p2p.org/confusion-with-calculation-of-available-staking-capacity-in-tezos-who-is-right/

Describe the solution you'd like
Use the following solution:

const CYCLE_LENGTH = 4096
const ENDORSEMENTS_PER_BLOCK = 32
const SECURITY_DEPOSIT_BAKE = 512
const SECURITY_DEPOSIT_ENDORSEMENT = 64
const PRESERVED_CYCLES = 5

SELF_BOND_REQUIREMENT = ((SECURITY_DEPOSIT_BAKE + SECURITY_DEPOSIT_ENDORSEMENT * ENDORSEMENTS_PER_BLOCK) * CYCLE_LENGTH * (PRESERVED_CYCLES+1)) / total_supply

where total_supply is derived from your API:
https://tzstats.com/docs/api/index.html#supply-table

Then use:
Total Balance / (SELF_BOND_REQUIREMENT / Staking Ratio)
where Total Balance is the Total (Self Bond) Balance of the Baker

Block: History and Display Issues

Task list for Block Screen

  • Block History
    • show time axis
    • show time since last block
    • show orphan blocks
    • show last block right of history (see design)
    • navigate between blocks using keyboard left/right arrow
    • navigate history with clicks on left/right triangles
    • on navigation to old block (e.g. by search) show history around this block
  • Block Details
    • translate Baker address to name if available
    • right-side data boxes should text-align right (e.g. baker, solvetime, etc)
    • show small numbers at high precision (e.g. gas price, fees)
    • show ꜩ suffix when amounts are zero
    • gas price is in µꜩ
    • endorsement slot boxes should link to endorser accounts with right to endorse this slot
  • Operations Graph/List
    • select operation type from graph and filter list (note: failed ops are not a type!)
    • paginate list on scroll
    • table should follow design closer (link colors)
    • table should display fees

Screen Shot 2019-08-13 at 1 21 16 PM

Market screen layout and data issues

Describe the bug
Layout flow on the market screen looks broken and some market data is missing (i.e. USDT, CAD pairs and HitBTC exchange). See my comments in the screenshot. This bug is for tracking the issue so we don't forget.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/market
  2. See layout, hover on heatmap and read tooltip

Expected behavior

  • price chart and heatmap should be same width so data aligns between these charts
  • data in the heatmap is ordered so that a column shows data from one day, instead squares belonging to the same day are ordered left-to-right
  • USDT, CAD pairs and HitBTC exchange is missing

Screenshots
Screen Shot 2019-07-28 at 9 31 31 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Landing: Staking Activity

Still called "Tezos supply" in the design, but that's wrong.

  1. Rename card title to "Staking Activity"
  2. Calculate correct numbers (see below)
  3. Change number font to smaller size (14px) matching the font size next to graphs

The data is available at /explorer/chain and the mapping is as follows:

Design            Unit   Struct Field or Formula
--------------------------------------------------------
Staking Ratio     %      supply.staking*100/supply.total
Active Bakers     -      delegates
Inflation         %      inflation_rate_1y
Staking Reward    %      inflation_rate_1y / (supply.staking / supply.total)

Market screen data is off

Describe the bug
Exchange volume data on the market screen seems to display only a single market for each exchange. E.g. Kraken has 4.35 Mill tz traded in last 24h but we show only 1.6 M which is the number for Kraken XTZ_USD volume alone.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/market
  2. See 'Volumes by Exchanges'

Expected behavior
Volume numbers should reflect all pairs traded on an exchange. To do that sum up the volume_base field across all XTZ_* markets per exchange. Be flexible in the number of exhanges and markets as the backend may add more.

The reference screenshot below is taken from Blockwatch backend which shows correct volumes.

Screenshots
Screen Shot 2019-07-31 at 1 22 36 PM
Screen Shot 2019-07-31 at 1 36 14 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Landing: Price & Volume Charts

  1. Increase graph height to show more action
  2. Place numbers that are currently under the graphs on the right side in vertical layout
    2.1 Labels and Order for Price History:
    - Open Price
    - Close Price
    - Highest Price
    - Lowest Price
    2.2 Labels and Order for On-Chain Volume
    - 24h Transactions
    - 24h Volume
    - 30d Avergae Transactions
    - 30d Average Volume
  3. Snap X and Y to graph point

Screen Shot 2019-08-12 at 12 14 00 PM

  1. Format dates as Mon, Aug 05
  2. Replace current horizontal dashed min/max lines with 3 equi-distant horizontal grid lines (solid white 30% transparency) and show their value at right side
  3. Background color for cards has changed in design, see Invision
  4. Replace gradient used to fill graph areas with solid 20% transparent color (base color is same as graph color)

Landing: Search field lacks error handling

For successful searches where an account, block or operation exists, the search functionalty works. Any kind of error breaks it though (seems there is no error handling in place at all):

  1. stores data when fetch failed, e.g. for block 5000000
  2. does not display error message when fetch fails for an address/block/election/cycle
  3. goes to block screen and shows spinner when searching for non existing block height
  4. does not translate account names to addresses
  5. does not show auto-suggestion when searching for account names
  6. goes to account screen and shows spinner when searching for non existing account
  7. does not search for protocol proposals (e.g. Babylon)
  8. mistakenly detects "Babylon" as block hash (because of prefix B)

Small Tezos values are displayed as zero

Describe the bug
Fees, gas price, and burned coins are usually very small (<1tz). The current display rounding displays 0 tz in such cases even if the true value is >0.

Also

  • Op & Account screen "Burned" is missing tz as unit
  • Block screen "Gas Limit" is 0

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/operation/opVmCMvLtzEx7A9WH8z9Jh7Wjak35QPXzed1DeavtisG92WstiD or https://alpha.tzstats.com/block/BLr7VLxPfKPjArRfxC62ac6fUoTpyvPiikHXHPj5zsriXUiBfKy or https://alpha.tzstats.com/account/tz1Xdjztinrid4z7mLaQtAQF24zXzE9ia4ab
  2. Look at fee and gas price

Expected behavior
Fee should be 1.42 mtz, Gas Price should be 0.13922 µtz. Note that the gas price returned in API calls has a different unit quantity that other monetary values. It is 10^-6 tz or µtz (micro Tezos).

Screenshots
Screen Shot 2019-07-31 at 12 45 03 PM
Screen Shot 2019-07-31 at 12 45 18 PM
Screen Shot 2019-07-31 at 1 00 08 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Search History does not close sometimes

Describe the bug
After some sequences of interactions with the search field the dropdown menu does not close when clicking outside the box.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Landing Page
  2. Enter 500000 into the search field and press Enter
  3. See the app correctly navigates to block screen, history closes and search field is still in focus
  4. Click outside the search field to focus another element
  5. Click into the search field to focus it again (history dropdown correctly opens)
  6. Now move the mouse pointer outside the search field without crossing/hovering the history dropdown and click left (history dropdown does not close)

Expected behavior
History dropdown closes on any kind of focus change away from the search field.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68.0.1

Block page shows only 20 ops after scroll

Describe the bug
Scrolling down on block page reveals more ops (it seems as if more ops are loaded), but they arent. The list never contains more than the default of 20 ops.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/block/540674
  2. Scroll down to '....'
  3. See the operation list expand, but no longer than 20 ops.

Expected behavior
While scrolling, the list should auto-update and continue loading operations until all are displayed. (Hint: max values recently observed go up to 900 ops per block)

Screenshots
Screen Shot 2019-07-31 at 12 13 49 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Block history squares and x-axis are unaligned

Describe the bug
On my screen (Mac Retina 1,680 × 1,050) the alignment between block history squares and the timeline axis is off. The chain of squares ends somewhere at 75% width of the axis. Also timestamp labels run backwards in time (left is earlier than right)

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/block/BMc7TLD3VsxnjWL4mc2fAga3ALvaLr48HzwusHcqLNuo9gJCQXH
  2. Look closely at block history axis and chain of blocks

Expected behavior
Time labels should be increasing from left to right. Chain of squares and time axis should be aligned.

Screenshots
Screen Shot 2019-07-31 at 11 49 57 AM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Search history does not detect duplicates

Describe the bug
Searching multiple times for the same block hash and clicking on history items adds duplicate entries to the history.

To Reproduce
Steps to reproduce the behavior:

  1. Go to htts://alpha.tzstats.com
  2. Paste BM6HsxWWGjHVV9s6jDPL1XdgmG9atUyTmsBvVSbhxf3Yr761x3J into search bar
  3. Hit Enter
  4. Open History and click on the new item
  5. See duplicates being added

Expected behavior
Search history detects and removes duplicates.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Price change indicator shows wrong direction

Describe the bug
The market price went up today, but the indicator is pointing downwards.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com
  2. See Navigation Bar / Price

Expected behavior
Show uptick symbol when price change is positive, downtick symbol when negative, neutral symbol when no change.

Screenshots
Screen Shot 2019-07-31 at 11 00 53 AM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Compilation errors

I cloned the repository and ran npm install, using NodeJS v16.5.0 in Ubuntu 20.04.2. Upon running yarn start, a webpage started loading, but then in the console, I saw:

Failed to compile.

./src/components/Layout/Searchbar/Searchbar.js
Syntax error: Unexpected token (102:11)

  100 |       <ContainerDimensions>
  101 |         {({ width, height }) => (
> 102 |           <>
      |            ^
  103 |             <SearchWrapper>
  104 |               {enterPress && search(value)}
  105 |               <SearchInput

I see that Searchbar.js hasn't changed in a while though, which is puzzling. I'm using commit e52cffa.

In the local directory, I have a file development.env which contains 1 line: TZSTATS_API_URL=http://localhost:8000.

tzindex was running, connected to a Docker flextesa image. I built it locally and ran ./tzindex run --rpcurl http://localhost:20000.

I had expected the page at http://localhost:3000 to be rendered without compilation errors.

App overscrolls on small size screen

Describe the bug
App overscrolls the bottom on small screen.
If i increase Browser Zoom further the overscroll gets bigger accordingly.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/ in Browser
  2. Browser Zoom into the app
  3. Scroll down to very bottom
  4. See error

Screenshots
Capture
Look closely at the bottom

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome

Additional context
Increase App Canvas Size, according to the size of the sidebar

Some links on operation screen are broken

Describe the bug
Related to #11 but on operation screen: links to block and operation create broken URLs

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/operation/opVmCMvLtzEx7A9WH8z9Jh7Wjak35QPXzed1DeavtisG92WstiD
  2. Click on Block Hash or Op Hash in Op Details Card
  3. See broken URL in address bar

Expected behavior
Block hash should be a correct link to the block. Operation hash should not be a link, but clicking should copy to op hash to clipboard.

Screenshots
Screen Shot 2019-07-31 at 12 53 22 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

App crash on hovering over a graph

Describe the bug
When hovering over the staking bond graph on a baker account the app crashes hard. See screenshot. Error message:

Error: Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=sliceTooltip for the full message or use the non-minified dev environment for full errors and additional helpful warnings. 

Invariant Violation: "Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=sliceTooltip for the full message or use the non-minified dev environment for full errors and additional helpful warnings. "

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/account/tz3RDC3Jdn4j15J7bBHZd29EUee9gVB1CxD9
  2. Hover over Staking Bond Graph
  3. App crashes with blank screen

Expected behavior
No crash

Screenshots
Screen Shot 2019-07-29 at 3 59 51 PM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Landing: Search History

  1. Stretch dropdown to full width of search input field
  2. Use solid background color in dropdown

Search field not cleared after navigation

Describe the bug
When navigating via the search field to an account or block, the contents of the field is not cleared after navigation.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com
  2. Click on Search Field
  3. Enter an account hash, e.g. tz3RDC3Jdn4j15J7bBHZd29EUee9gVB1CxD9
  4. Click 'Explore'

Expected behavior
The app navigates to the account screen and clears the search field to accept new input.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

[API] /account returns not documented structure

How it is described:
https://api.tzstats.com/explorer/account/tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m
Response:

{
  "address": "tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m",
  "address_type": "secp256k1",
  "delegate": "tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m",
  "manager": "",
  "pubkey": "sppk7bn9MKAWDUFwqowcxA1zJgp12yn2kEnMQJP3WmqSZ4W8WQhLqJN",
  "first_in": 360996,
  "first_out": 360997,
  "last_in": 798547,
  "last_out": 798547,
  "first_seen": 360996,
  "last_seen": 798547,
  "delegated_since": 0,
  "delegate_since": 361000,
  "first_in_time": "2019-03-20T23:10:52Z",
  "first_out_time": "2019-03-20T23:11:52Z",
  "last_in_time": "2020-01-27T15:48:29Z",
  "last_out_time": "2020-01-27T15:48:29Z",
  "first_seen_time": "2019-03-20T23:10:52Z",
  "last_seen_time": "2020-01-27T15:48:29Z",
  "delegated_since_time": "0001-01-01T00:00:00Z",
  "delegate_since_time": "2019-03-20T23:14:52Z",
  "total_received": 4202918.18456,
  "total_sent": 2249591.094354,
  "total_burned": 0,
  "total_fees_paid": 0.085097,
  "total_rewards_earned": 1172359.071348,
  "total_fees_earned": 191.42406,
  "total_lost": 0,
  "frozen_deposits": 2824832,
  "frozen_rewards": 87364.083332,
  "frozen_fees": 22.206582,
  "unclaimed_balance": 0,
  "spendable_balance": 213659.210603,
  "total_balance": 3038513.417185,
  "delegated_balance": 24983342.325077,
  "total_delegations": 31,
  "active_delegations": 13,
  "is_funded": true,
  "is_activated": false,
  "is_vesting": false,
  "is_spendable": true,
  "is_delegatable": false,
  "is_delegated": false,
  "is_revealed": true,
  "is_delegate": true,
  "is_active_delegate": true,
  "is_contract": false,
  "blocks_baked": 15107,
  "blocks_missed": 53,
  "blocks_stolen": 337,
  "blocks_endorsed": 238342,
  "slots_endorsed": 472966,
  "slots_missed": 530,
  "n_ops": 238992,
  "n_ops_failed": 0,
  "n_tx": 65,
  "n_delegation": 1,
  "n_origination": 0,
  "n_proposal": 2,
  "n_ballot": 3,
  "token_gen_min": 2,
  "token_gen_max": 8144,
  "grace_period": 200,
  "staking_balance": 28021855.742262,
  "rolls": 3502,
  "rich_rank": 29,
  "traffic_rank": 0,
  "flow_rank": 0,
  "last_bake_height": 798530,
  "last_bake_block": "BKxWH3nQ29jkZfED3QpqBkU9vhGcixqRoHsKjbA7YKHTK9nBXNi",
  "last_bake_time": "2020-01-27T15:31:29Z",
  "last_endorse_height": 798547,
  "last_endorse_block": "BKmFFRn7HJbhfygiibGk88DoLTLqKAGta3xvrEQbaBneYQ2vBNg",
  "last_endorse_time": "2020-01-27T15:48:29Z",
  "next_bake_height": 798562,
  "next_bake_priority": 0,
  "next_bake_time": "2020-01-27T16:03:29Z",
  "next_endorse_height": 798549,
  "next_endorse_time": "2020-01-27T15:50:29Z"
}

How it works with another address:
https://api.tzstats.com/explorer/account/tz1VFiQwFL36Ru7EtugLjXVh3dqp9B4KRSAV
Response:

{
  "address": "tz1VFiQwFL36Ru7EtugLjXVh3dqp9B4KRSAV",
  "address_type": "ed25519",
  "delegate": "tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke",
  "manager": "",
  "pubkey": "edpkuqrs2A3DjNnVVYJEbkk5Lf18PzXwryZxnzwUNaDENhwDdw6iQo",
  "first_in": 678309,
  "first_out": 678311,
  "last_in": 794781,
  "last_out": 793743,
  "first_seen": 678309,
  "last_seen": 794781,
  "delegated_since": 793743,
  "delegate_since": 0,
  "first_in_time": "2019-11-03T18:27:17Z",
  "first_out_time": "2019-11-03T18:29:17Z",
  "last_in_time": "2020-01-25T00:39:33Z",
  "last_out_time": "2020-01-24T07:17:44Z",
  "first_seen_time": "2019-11-03T18:27:17Z",
  "last_seen_time": "2020-01-25T00:39:33Z",
  "delegated_since_time": "2020-01-24T07:17:44Z",
  "delegate_since_time": "0001-01-01T00:00:00Z",
  "total_received": 111.326197,
  "total_sent": 19.04,
  "total_burned": 0.771,
  "total_fees_paid": 0.2742,
  "total_rewards_earned": 0,
  "total_fees_earned": 0,
  "total_lost": 0,
  "frozen_deposits": 0,
  "frozen_rewards": 0,
  "frozen_fees": 0,
  "unclaimed_balance": 0,
  "spendable_balance": 91.240997,
  "total_balance": 91.240997,
  "delegated_balance": 0,
  "total_delegations": 0,
  "active_delegations": 0,
  "is_funded": true,
  "is_activated": false,
  "is_vesting": false,
  "is_spendable": true,
  "is_delegatable": false,
  "is_delegated": true,
  "is_revealed": true,
  "is_delegate": false,
  "is_active_delegate": false,
  "is_contract": false,
  "blocks_baked": 0,
  "blocks_missed": 0,
  "blocks_stolen": 0,
  "blocks_endorsed": 0,
  "slots_endorsed": 0,
  "slots_missed": 0,
  "n_ops": 26,
  "n_ops_failed": 1,
  "n_tx": 21,
  "n_delegation": 4,
  "n_origination": 0,
  "n_proposal": 0,
  "n_ballot": 0,
  "token_gen_min": 3,
  "token_gen_max": 11163,
  "grace_period": 0,
  "staking_balance": 0,
  "rolls": 0,
  "rich_rank": 23549,
  "traffic_rank": 0,
  "flow_rank": 0,
  "last_bake_height": 0,
  "last_bake_block": "",
  "last_bake_time": "0001-01-01T00:00:00Z",
  "last_endorse_height": 0,
  "last_endorse_block": "",
  "last_endorse_time": "0001-01-01T00:00:00Z",
  "next_bake_height": 0,
  "next_bake_priority": 0,
  "next_bake_time": "0001-01-01T00:00:00Z",
  "next_endorse_height": 0,
  "next_endorse_time": "0001-01-01T00:00:00Z",
  "delegate_account": {
    "address": "tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke",
    "address_type": "ed25519",
    "delegate": "tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke",
    "manager": "",
    "pubkey": "edpkvNz7AFBaPLxgRXTQa7wKSCEGw9vwxmaQQA1p2Fx5KAH2oYu9jL",
    "first_in": 259217,
    "first_out": 259219,
    "last_in": 798453,
    "last_out": 798453,
    "first_seen": 259217,
    "last_seen": 798453,
    "delegated_since": 0,
    "delegate_since": 267088,
    "first_in_time": "2019-01-06T18:46:51Z",
    "first_out_time": "2019-01-06T18:48:51Z",
    "last_in_time": "2020-01-27T14:13:49Z",
    "last_out_time": "2020-01-27T14:13:49Z",
    "first_seen_time": "2019-01-06T18:46:51Z",
    "last_seen_time": "2020-01-27T14:13:49Z",
    "delegated_since_time": "0001-01-01T00:00:00Z",
    "delegate_since_time": "2019-01-12T11:49:35Z",
    "total_received": 19561.091364,
    "total_sent": 7080.706701,
    "total_burned": 0.031,
    "total_fees_paid": 6.902242,
    "total_rewards_earned": 8579.599998,
    "total_fees_earned": 0.853818,
    "total_lost": 0,
    "frozen_deposits": 17280,
    "frozen_rewards": 538.4,
    "frozen_fees": 0.036448,
    "unclaimed_balance": 0,
    "spendable_balance": 3235.468789,
    "total_balance": 20515.505236999998,
    "delegated_balance": 193420.775675,
    "total_delegations": 245,
    "active_delegations": 114,
    "is_funded": true,
    "is_activated": false,
    "is_vesting": false,
    "is_spendable": true,
    "is_delegatable": false,
    "is_delegated": false,
    "is_revealed": true,
    "is_delegate": true,
    "is_active_delegate": true,
    "is_contract": false,
    "blocks_baked": 114,
    "blocks_missed": 8,
    "blocks_stolen": 3,
    "blocks_endorsed": 3423,
    "slots_endorsed": 3440,
    "slots_missed": 127,
    "n_ops": 8165,
    "n_ops_failed": 0,
    "n_tx": 4731,
    "n_delegation": 1,
    "n_origination": 0,
    "n_proposal": 3,
    "n_ballot": 6,
    "token_gen_min": 3,
    "token_gen_max": 5185,
    "grace_period": 200,
    "staking_balance": 213936.280912,
    "rolls": 26,
    "rich_rank": 2461,
    "traffic_rank": 0,
    "flow_rank": 0,
    "last_bake_height": 0,
    "last_bake_block": "",
    "last_bake_time": "0001-01-01T00:00:00Z",
    "last_endorse_height": 0,
    "last_endorse_block": "",
    "last_endorse_time": "0001-01-01T00:00:00Z",
    "next_bake_height": 0,
    "next_bake_priority": 0,
    "next_bake_time": "0001-01-01T00:00:00Z",
    "next_endorse_height": 0,
    "next_endorse_time": "0001-01-01T00:00:00Z"
  }
}

There is "delegate_account": {} inside second response

Search field does not accept return key

Describe the bug
When entering some search term into the search field and then pressing Return, the app does nothing.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com
  2. Click on 'Search Field'
  3. Enter an existing account or block hash, e.g. tz3RDC3Jdn4j15J7bBHZd29EUee9gVB1CxD9
  4. Press Return

Expected behavior
App navigates to the searched topic.

Desktop (please complete the following information):

  • OS: OSX
  • Browser Firefox
  • Version 68

Delegate activation rules

The Blockwatch/TzStats indexer maintains an internal representation of the full blockchain state which is constructed from replaying block receipts (plus pulling snapshot index and rights from context). Anything else like supply, consensus and voting rolls, balance and delegation history, etc is derived from these receipts.

This approach works for all balance updates, but diverges from a node's context for the active delegate set. Ideally, all events that lead to registration, deactivation and reactivation of a delegate should be observable in receipts and there should be a consistent set of rules. This issue tracks our research towards understanding these rules and how they changed across versions.

From available documentation here and here and some reverse engineering our current set of delegate activation rules is as follows:

  • Registration/Activation
    • a tz1/2/3 account sends a delegation operation and sets itself as delegate (example, example)
    • a tz1/2/3 account is defined as delegate in the genesis block, a.k.a. the 8 Foundation Bakers (example)
    • 🔥 a tz1/2/3 account sends an origination operation and sets itself as delegate on the created contract (example)
  • Deactivation
    • 🔥 a registered delegate is listed in the block header field metadata.deactivated which gets populated in the last block of a cycle (example)
  • Reactivation
    • an inactive delegate registers again using a delegation operation to self like above (example)
    • an inactive delegate receives a transaction operation (example)
    • an inactive delegate bakes or endorses a block (because it still has rights, example)

Problems with the approach above 🔥

  1. some deactivations are missing from block.metadata.deactivated (example, example, example, example)
    • all the examples are marked inactive in the context, but they were never signalled in block metadata; a full dump of all deactivations extracted from block headers until block 552,960 (cycle 134) is availabe at this Gist
    • Note: early protocol versions until block 200,704 created many duplicate deactivations, although that's not an issue here the same code change that fixed duplicates may have broken signalling of some deactivations afterwards
  2. delegate registration through origination is inconsistent: (a) sometimes such accounts become delegates immediatly (example), (b) sometimes they magically become delegates later (example), (c) sometimes they don't become delegates at all (example)

Open Questions

  • How come that some originate+delegate operations register the caller as delegate and some do not?
  • Before which block (if any specific block) or which release did an incoming transaction reactivate an inactive delegate? Is this still the case?

Defunct links on block screen

Describe the bug
All the links to ops and accounts on the block screen are rendered as links, but clicking them has no effectl.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/block/BKqW2MMMqiTpTaoBkSM7JJxyZXfAbxosm1rtfii42byirctQr5Y
  2. Click on any of the links on this page
  3. Nothing happens

Expected behavior
App navigates to the clicked account or operation.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Search by block height is broken

Describe the bug
When searching for an exisiting block by height, the app shows an empty screen with spinner and the url changes to https://alpha.tzstats.com/block/undefined

When in this state, then after entering a valid block hash into the search field, e.g. BLtfCRg9zymuPJLy4H2vrdyn2QqafGQMSNYXxYjDQnxKqKTQ9XZ and clicking 'Explore' the app navigates to a valid url but still shows a spinner.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com
  2. Click on Search Field
  3. Enter an existing block height, e.g. 500000
  4. Click 'Explore'

Expected behavior
App navigates to block 500000.

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Some links on block screen are broken

Describe the bug
On block screen, link to baker account does not work. Also, when clicking on block

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/block/BMc7TLD3VsxnjWL4mc2fAga3ALvaLr48HzwusHcqLNuo9gJCQXH
  2. Click on Baker Link (nothing happens)
  3. Click on Block Hash (seems to be a link)
  4. Observe the broken URL

Expected behavior
Clicking on baker should link to baker account. Block hash should not be a link (just copy to clipboard).

Screenshots
Screen Shot 2019-07-31 at 11 46 28 AM

Desktop (please complete the following inormation):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Periodically update navigation bar contents

Is your feature request related to a problem? Please describe.
The navigation bar should always display fresh information about the most recent blockchain and market state. Right now it never updates after initial load. This can lead to arkward situations when you navigate to the block page and see a block that is newer than the one displayed in the nav bar.

Describe the solution you'd like
Auto-refresh chain data using the following algorithm:

10  Set a first timer to chain.timestamp + 70 sec
20  On expiry, try fetching `/explorer/chain` data
30  If a new block height is observed
40      refresh display
50      goto 10
60  else
70      set second timer to now + 15 sec
80      if a new block height is observed
90        refresh display
100       goto 10
110     else
120       goto 70
130     endif
140 endif

Auto-refresh market data every minute.

Describe alternatives you've considered
Letting the user refresh manually is undesired. The app should always display fresh data. Instead of polling we could implement long-poll or websockets on the backend to reduce server and network load.

Additional context
Screen Shot 2019-07-31 at 1 02 54 PM

Landing: Navigation bar

A few minor issues with navigation bar styling and text. Issue is supposed to track change requests and progress.

  1. Add "Cycle ends in" label to cycle clock

Screen Shot 2019-08-12 at 12 24 46 PM

2. Fix CSS on Governance box

Screen Shot 2019-08-12 at 12 28 26 PM

3. Fix health display

Screen Shot 2019-08-12 at 12 34 44 PM

Screen Shot 2019-08-12 at 1 53 51 PM

Health data will be available from /explorer/chain as new field health, data range will be [0,100]. Formula for mapping is Math.ceil(6*health/100)-1 which results in

0 := health <= 16.6% (Catastrophic)
1 := 16.6% < health <= 33.3% (Very bad)
2 := 33.3% < health <= 50% (Bad)
3 := 50% < health <= 66.6% (Fair)
4 := 66.6% < health <= 83.3% (Good)
5 := 83.3% < health < 100% (Very good)
5* := 100% = health (Excellent)

To guard against zero health use ordinal = health?(Math.ceil(6*health/100)-1):0;

  1. Design change: new background color, check latest invision.

  2. Design change: clickable cards have a new triangle top right, see Invision

Block navigation is broken

Describe the bug
When I'm on the block screen and click a link to another block (e.g. the current block in the navigation sidebar) the URL changes, but nothing happens.

The same problem appears when using browser history. History control works on accounts screen, so the problem seems to be limited to blocks.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com/block/BLpfZpRXApaRupvASy8R21NNEfdULHWBnUcpF5JurLrJkEjYD5F
  2. Click on 'Last Block' in nav Sidebar
  3. Page does not reload

Expected behavior
App navigates to the linked block

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Crash when hovering searchbar

Describe the bug
I just experienced a crash (white page) while quickly moving my mouse pointer over the search bar and out of the browser window.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://alpha.tzstats.com
  2. Move your mouse pointer over the search bar and out again
  3. Crash

Expected behavior
No crash displaying a white page.

Screenshots
Screen Shot 2019-07-31 at 11 02 04 AM

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Firefox
  • Version: 68

Link local Tzstat with local tzindex

Hello @echa,

Following the directives you explained to me on the tzindex repository, I have been trying for 2 days to connect my local tzindex with a local Tzstats. Unfortunately, I might be missing something, because it still doesn't connect.

Here are below the instructions you gave me (to avoid going back and forth on the tzindex repo) :

About your last question, you can run a local copy of https://github.com/blockwatch-cc/tzstats and link it to your local instance of tzindexer in a few different ways. Easiest by far is using the provided Docker images.

The way tzstats and web browsers work is that you need a local webserver to serve all files. You can setup a local nginx or use my embedded webserver serve. Key trick is that the TzStats JS file contains a template variable which gets replaced to point to the API endpoint.

1. Checkout the tzstats repo, create a new top-level file development.env with a single line TZSTATS_API_URL=http://localhost:8000, run npm install and then yarn start. You need NodeJS for this to work.
2. Copy all files from /var/www/ out of the tzstats Docker image, compile a local version of https://github.com/echa/serve and run serve with the following env variables: TZSTATS_API_URL (http://localhost:8000), SV_SERVER_PORT (smth other than the default port 8000 because tzindexer already uses it), SV_SERVER_ROOT (the directory you extracted the compiled tzstats files to).
For further questions, please use the tzstats repo.

In order to be as explicit as possible, here are the steps I followed :
0. Run a local tzindex, on port 8000. After the previous issue, it is now functional. I have been able to access it through the API, example -> localhost:8000/explorer/status showed that tzindex was synced

  1. Cloned the TzStats repo and cd inside
  2. vim development.env file, containing one line -> TZSTATS_API_URL=http://localhost:8000
  3. npm install, then yarn start
    --> At this point, the yarn start command launched a server on localhost:3000. It was a TzStats copy, but it was saying that it was not synced/ not connected yet, and the animated loading wheel was active.

==> Seeing that it wasn't working at this point, I continued to follow your instructions

(on a new shell, I let the Port 3000 server running on the previous one)

  1. Pulled the TzStats container from docker, ran it and copied the www/ directory inside the local TzStats directory. Thus, I had a www/ directory inside my TzStats directory. Once done, I stopped the container
  2. Cloned your serve repo inside the local TzStats directory too, cd inside and go build main.go
  3. Added the local env variables you specified
    -> export SV_SERVER_ROOT=/home/tzstats/www
    -> export SV_SERVER_PORT=7777
    -> export TZSTATS_API_URL=http://localhost:8000
  4. I then cd inside the serve directory and ran the main executable that I just built ./main
    --> This time, it ran the same page as the yarn start command, but listening on port 7777.

Again, it didn't sync with my local tzindex.

Am I doing something wrong ?

I have been seeing something weird on the Tzindex logs, don't know if it is related ->

2020/01/05 23:10:08.466025 TRCE DATA query: supply table non-indexed field 'h' for cond 0, fallback to table scan
2020/01/05 23:10:08.466295 ERRO SRVR BW-02fd8f72a866a15f02bb90971bf9151a69125b95 Error sending response: json: unsupported value: NaN in struct &server.ExplorerCycle{Cycle:0, StartHeight:1, EndHeight:64, StartTime:time.Time{wall:0x0, ext:63713288405, loc:(*time.Location)(nil)}, EndTime:time.Time{wall:0x0, ext:63713290437, loc:(*time.Location)(nil)}, Progress:100, IsComplete:true, IsSnapshot:true, IsActive:false, SnapshotHeight:0, SnapshotIndex:0, Rolls:0, RollOwners:0, StakingSupply:0, StakingPercent:NaN, ActiveBakers:3, ActiveEndorsers:0, MissedPriorities:45, MissedEndorsements:2080, N2Baking:0, N2Endorsement:0, NOrphans:1, SolveTimeMin:0, SolveTimeMax:8121393, SolveTimeMean:124975.93846153843, PriorityMin:0, PriorityMax:4, PriorityMean:0.6923076923076922, EndorsementRate:-1.5625, EndorsementsMin:0, EndorsementsMax:0, EndorsementsMean:0, SeedNonceRate:0, WorstBakedBlock:56, WorstEndorsedBlock:0, SnapshotCycle:(*server.ExplorerCycle)(0xc0000da420), FollowerCycle:(*server.ExplorerCycle)(0xc0000da840), expires:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}```

Thank you,
Guillaume

Election: Missing links and style issues

To finalize our election screen, there's only a few tiny problems left:

  1. From Proposal Name link to Blog Post
  2. From Proposal Hash link to Source Archive
  3. From Proposal Source link to Account
  4. Add Blocy Icon to account
  5. Right align Start/End Block text
  6. Make Quorum a 2-line entry like participation (both on stage 2 and 4)
  7. Do not show Nay graph section when zero
  8. Replace sad smiley with a neutral UTF8 character or an embedded SVG icon
  9. On empty elections (no proposal was submitted) change step 1 title to 'No proposal submitted'

Screen Shot 2019-08-12 at 3 01 53 PM

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.