Giter Site home page Giter Site logo

blockscout / blockscout Goto Github PK

View Code? Open in Web Editor NEW
3.2K 89.0 2.1K 187.21 MB

Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.

Home Page: http://docs.blockscout.com

License: GNU General Public License v3.0

JavaScript 3.13% Elixir 83.87% HTML 5.68% Shell 0.06% Dockerfile 0.02% Makefile 0.07% SCSS 3.22% Solidity 3.92% Vyper 0.03%
elixir blockchain explorer ethereum

blockscout's Issues

Address 404 page

We're currently showing a 404 page if the address is not in our DB. Instead, we should be showing the address page with a 0 balance. The address exists, we either did not update the balance yet or the address has not balance.

Example

The two links below point to the same address on ETH Mainnet (0x6937cb25eb54bc013b9c13c47ab38eb63edd1493) as seen on Etherscan and BlockScout.

Etherscan:
https://etherscan.io/address/0x6937cb25eb54bc013b9c13c47ab38eb63edd1493

BlockScout:
https://www.blockscout.com/eth/mainnet/address/0x6937cb25eb54bc013b9c13c47ab38eb63edd1493

Acceptance Criteria

The address page for an address that is not in our DB should look like the following:

  • Address' coin balance should be zero.
  • Address' USD balance should be zero.
  • Address' transactions count should be zero.
  • The transactions tab should load with a gray area and a message: There are no transactions for this address.
  • The tokens tab should load with a gray area and a message: There are no tokens for this address.
  • The internal transactions tab should load with a gray area and a message: There are no internal transactions for this address.

Internal Transactions Worker

Every transaction has at least 1 internal transaction with the same value as the transaction. More transactions can be included in internal transactions. The sum of all internal transactions is the correct amount transferred in the transaction.

    method: "trace_replayTransaction",
    params: [desiredTransactionHash, ['trace']],
    jsonrpc: "2.0",
    id: "1"
}, function (err, out) {
    console.log(out);
}```

404 page for not found Block.

If the user navigates to the Block details page for a block that we have not indexed or is in the future we should show the block details page with the message that this block has not been processed yet.

Example:

Both links below show the block details page for a block that is the future, as seen on Etherscan and BlockScout:

Etherscan:
https://etherscan.io/block/125127248

BlockScout:
https://www.blockscout.com/eth/mainnet/blocks/125127248/transactions

Acceptance Criteria

The block details page for a block that we have not indexed yet or that is in the future should show no block related information, but just a message based on the following criteria:

  • If the block number is below the tip of the chain, the message should be:
    • "This block has not been processed yet".
  • If the block number is above the tip of the chain, the message should be:
    • "Easy Cowboy! This block doesn't exist yet!"

The image below is an example of how that page should be for the first case:

Block Worker

Fetching a block provides all information on that block
Next step is to fetch the transaction and transaction receipt.

  "number": 3,
  "hash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "parentHash": "0x2302e1c0b972d00932deb5dab9eb2982f570597d9d42504c05d9c2147eaf9c88",
  "nonce": "0xfb6e1a62d119228b",
  "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "transactionsRoot": "0x3a1b03875115b79539e5bd33fb00d8f7b7cd61929d5a3c574f507b8acf415bee",
  "stateRoot": "0xf1133199d44695dfa8fd1bcfe424d82854b5cebef75bddd7e40ea94cda515bcb",
  "miner": "0x8888f1f195afa192cfee860698584c030f4c9db1",
  "difficulty": BigNumber,
  "totalDifficulty": BigNumber,
  "size": 616,
  "extraData": "0x",
  "gasLimit": 3141592,
  "gasUsed": 21662,
  "timestamp": 1429287689,
  "transactions": [
    "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
  ],
  "uncles": []
}```

Contributor sees a list of tokens associated with the Address on the Address Details page.

This issue includes a section that shows the number of different tokens the address owns, as well as the balances for each of those token.

screen shot 2018-07-16 at 14 55 17

https://projects.invisionapp.com/share/8EMX9IOR2V9#/screens/303733376

Acceptance criteria

  • Add a dropdown list that shows (as a default value) the count of different tokens the associated address has.
    • Example: if the address has tokens from ABC, XYZ, and ASDF, it should show 3 tokens contracts
  • When clicked, the dropdown shows the list of tokens the associated address has, with the following information for each token:
    • The token name
      • Some tokens might have no name. In this case, show a truncated version of the token contract address (Example: 0x16bd3...)
    • How much tokens that address has (followed by its symbol)
      • For ERC20 tokens, the balance of fungible tokens
        • Formatted as currency (thousands and decimal separators) and considering the token's decimals info (if there is no decimals info, display the formatted amount)
        • Example: 999,000.02 FREH
      • For ERC721 tokens, the balance of non-fungible tokens
        • Example: 803,843 CK
      • In case the token has no symbol, show nothing next to the amount.
  • Add two separator items as follows:
    • If the address has at least 1 ERC721 Token, show ERC721 Token followed by the number of different tokens: ERC721 Tokens (7)
    • If the address has at least 1 ERC20 Token, show ERC20 Token followed by the number of different tokens: ERC20 Tokens (3)
    • ERC20 tokens are listed below the ERC20 separator, as well as ERC721 tokens are listed below ERC721 separator.
  • The tokens should be ordered by name within each list (ERC20 and ERC721)
  • When an item in the list is clicked, the user should be redirected to the token details page for that specific token.
  • When the address has no tokens, the entire block should be hidden.

Out of scope

This issue does not include conversions for USD or any other currency (including POA and ETH).

So, the following items don't belong to the acceptance criteria:

  • Show the address' token balance in USD (sum of all token holdings converted to USD)
  • Within the dropdown:
    • the USD exchange rate for that specific token
    • how much USD that amount of token is worth

This issue does not include the search field, which will be created by #424.

Details

  • Getting a token Balance for an Address
    • We'll need to interact with the Token contract using the balanceOf function that will be available after #70 is merged.

Dependencies

Tasks

  • Investigate how we should fetch the Tokens balance;
    • Should we index the balance of the address token?
    • Should we fetch the balance directly from the blockchain?
      • When the request to the token address fails, what should we show to the user?
  • It won't show the Token holding box when the address doesn't have tokens (check with Andrew & GasLight);
  • Build the Token holding box with:
    • Title "Token Holdings";
    • Numbers of Tokens that the address has;
    • Icon to open the drop-down;
  • Create an API to list the tokens from an address;
  • Build the Dropdown with:
    • List of tokens split by token type (ERC-20 and ERC-721)
    • Each line must have the Token's name, Token's symbol or a Token address (when the token doesn't have the symbol) and amount of tokens.
    • Each line must have a link to the Token Details Page;

Include a Token details page

The issue includes a Token details page, where the Contributor can see information about that Token, such as its Total Supply and Token Transfers.

The Contributor should be redirected to that page everytime she clicks on a Token link (described in the Acceptance Criteria).

screen shot 2018-07-16 at 18 59 10

https://projects.invisionapp.com/share/8EMX9IOR2V9#/screens/308372327

Acceptance criteria

  • The page should have a section with:
    • the Token name
    • the Token contract Address
    • how many Addresses were involved in Token Transfers
      • Addresses that appear both in "to_address" as in "from_address"
    • how many Token Transfers have happened
    • the decimals places for that Token
  • The page should have a section with the Token Total Supply
  • The page should have a Token Transfers tab that lists all Token Transfers made from that Token to/from the Address.
  • Each Token Transfer in the list should show:
    • The Tx hash in which the transfer has happened
    • The ID of the Block in which the transfer has happened
    • The Token Transfer From Address
    • The Token Transfer To Address
    • The number of tokens transferred
    • How much time ago has the transfer happened
  • Token links should redirect to the Token/Address Details page
    • In the Tx details page, when clicking on the Token Symbol/Name.
    • In the Address Tx List, when clicking on the Token Symbol/Name.
    • In the Address Token balances dropdown list, when clicking on a Token.
  • The token transfer list should be paginated.
  • The token transfer list should be ordered by date, from the most recent to the older one.

Out of scope

  • The Price section, on the top of the page
  • Conversions to USD
  • Filtering the information in the page by address (#425)

Observations

  • There's a chance of reusing this TokenTransfer tab in a future issue

Dependencies

Tasks

  • Create a script to populate dummy data in the database to use as test
  • Create Token's route (token/)
  • Create Token's view (HTML + CSS)
    • Create Total Supply box
    • Create the list of token transfers
    • Show the contract style in the hash link when the address is a contract
  • Create API to get tokens info (name, address, decimal places, total supply)
    • Query to count the number of addresses that were involved in token transfers
    • Query to count the number or token transfers
  • Create API to get token transfers info
    • Query to list all token transfers considering pagination

Start all Workers when Phoenix is Started

Fetching Blocks = Transactions
Pending Transactions
Fetching Transactions = Internal Transactions & Events
Transaction Receipt = Status of transactions and gas used
Internal Transactions = Correct Balances
Events = Token Data

Store Token Transfers in DB during Indexing

Events hold the information for Token Transfers. Querying an event against this abi will provide to, from, value, and contract

[
  {
    "constant": true,
    "inputs": [],
    "name": "name",
    "outputs": [
      {
        "name": "",
        "type": "string"
      }
    ],
    "payable": false,
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "decimals",
    "outputs": [
      {
        "name": "",
        "type": "uint8"
      }
    ],
    "payable": false,
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "totalSupply",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [
      {
        "name": "_owner",
        "type": "address"
      }
    ],
    "name": "balanceOf",
    "outputs": [
      {
        "name": "balance",
        "type": "uint256"
      }
    ],
    "payable": false,
    "type": "function"
  },
  {
    "constant": true,
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "name": "",
        "type": "string"
      }
    ],
    "payable": false,
    "type": "function"
  }
]

We are already indexing logs.

(Bug) Nothing is being indexed

the project compiles fine, the database is created, the server is running smoothly, frontend works fine.

i'm using local parity with this config:

[parity]
chain = "spec.json"

[footprint]
pruning = "archive"
tracing = "on"

i tried both master and production branches.

the problem: the database is not populated, nothing is being indexed.

screen shot 2018-03-06 at 3 50 32 pm

Add the Reward value of a Block in the Block Tile and Block Details Page

As a Contributor, I want to see the Validator Reward earned for a Block on the Block details page and block tile on the blockscout.

Example: https://etherscan.io/block/6843636

The current reward is 1 POA plus the Gas Used that is rewarded to the Validator that validated that block. There is also an emission reward of 1 POA that is sent to an address defined in the spec.json file.
The information for block rewards is obtained from the Parity block_trace call.

Acceptance Criteria

  • On the block tile, it must display the total amount of reward of the block validated; This block tile is currently located on the homepage, blocks page, and address Validations tab
  • In the blocks details page, all information about the rewards must be displayed on the right bottom box (Where originally is placed the info about the Gas Used) ;
    • The Gas Used information should be reallocated to the main box of the block details (right after the nonce);
  • In the block details page, it must be displayed each type of reward separately.
    • EmissionReward;
    • Gas Fee;
    • Uncle Reward (If it has);

Transaction Receipt Worker

Fetching this provides the status of the transaction getTransactionReceipt(hashString [, callback]) and any token transfers that took place.

{
  "transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
  "transactionIndex": 0,
  "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "blockNumber": 3,
  "contractAddress": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  "cumulativeGasUsed": 314159,
  "gasUsed": 30234,
  "logs": [{
         // logs as returned by getFilterLogs, etc.
     }, ...],
  "status": "0x1"
}

Digging deeper into token transfers we should be storing logs in a new table. Here is an example of a transaction receipt with a token transfer.

[blockHash] => 0xe27b7449243c1dab51e144f0f444692b1d38788e7624b7dccba9dec967903423
    [blockNumber] => 0x153d30
    [contractAddress] => 
    [cumulativeGasUsed] => 0x1d94d
    [gasUsed] => 0x1d94d
    [logs] => Array
        (
            [0] => stdClass Object
                (
                    [address] => 0x375eaf694f43b0f07c03b757ccfaeda1b10c0d5c
                    [blockHash] => 0xe27b7449243c1dab51e144f0f444692b1d38788e7624b7dccba9dec967903423
                    [blockNumber] => 0x153d30
                    [data] => 0x000000000000000000000000000000000000000000000000112210f47de98115
                    [logIndex] => 0x0
                    [topics] => Array
                        (
                            [0] => 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
                            [1] => 0x0000000000000000000000000000000000000000000000000000000000000000
                            [2] => 0x00000000000000000000000023b9f67665a2d511c83ee97fea5d63a2fcca5a9e
                        )

                    [transactionHash] => 0xf9d7cd5574052fde8ce9d129032e7ee8d1b1eb517fc0d0f23d3336ca6e1f294a
                    [transactionIndex] => 0x0
                    [transactionLogIndex] => 0x0
                    [type] => mined
                )

        )

    [logsBloom] => 0x00000000000000000000000000000000000000004000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000020000020000000000000000010800000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000020020000000000000000000100000000000000000000000000000000000000000000
    [root] => 
    [status] => 0x1
    [transactionHash] => 0xf9d7cd5574052fde8ce9d129032e7ee8d1b1eb517fc0d0f23d3336ca6e1f294a
    [transactionIndex] => 0x0
)

With this output we can tell this is a token transfer from the first value in the topics array. This is the global hash for a token transfer 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef.

The 2nd value under the topics array is who sent this transfer. In the example above, the tokens were minted/mined. In a normal transfer, this will be an address.

The 3rd value under the topics array is where the transfer of tokens is going.

The datavalue is the hexed equivalent of the token transfer value. 0x000000000000000000000000000000000000000000000000112210f47de98115

It's also important to note that there can be multiple token transfers in a single transaction.

Here are a couple examples from Etherscan:
screen shot 2018-04-11 at 1 08 09 pm
screen shot 2018-04-11 at 1 08 20 pm

https://etherscan.io/tx/0xcd40dcead6ea4d1533872e91074118428bca4d2a2e6edbd64833e621569e2d2a

screen shot 2018-04-11 at 1 08 37 pm

screen shot 2018-04-11 at 1 08 48 pm

https://etherscan.io/tx/0xcd40dcead6ea4d1533872e91074118428bca4d2a2e6edbd64833e621569e2d2a

Correctly show balances

Balances are not currently being calculated correctly.

Internal transactions are not being counted in balance. Totaling all internal transactions will provide the correct balance.

Transaction Details 404 page

If a transaction does not exist yet, we should not show a standard 404 page. Instead, we should show the TX details page but with a message stating that our node hasn't picked up the transaction yet and the page will update automatically when it does.

  1. If the user is on the correct route for the transaction details page but the tx hash is not found in the DB, we should show the normal transaction details page but with a message stating to please be patient while our nodes search for the transaction.
  2. We should subscribe to both pending transactions and incoming blocks to find the transaction hash.
  3. If the tx hash is found, refresh the page to show either the pending state or collated state.

Aceptance Criterias

  • Verify the TxHash in order to identify if the hash is or not valid and show to the user the correct page behavior:

    • For invalid hashes:
      • Show a warning message when the TxHash is invalid;
    • For pending transactions:
      • Show the TxDetails Page when it's valid but doesn't exist. Suggested sentence: Please be patient while our nodes search for the transaction.
      • Show a spinner for the pending transactions;
      • Show complementary information about the pending transaction process;
  • As soon as the txHash get processed the Hash's TxDetail Page needs to be refreshed with it's current state.

Tasks

  • Change controller to not redirect to the 404 page and insert the transaction hash when it is valid;
    • Send the hash to the realtime indexer to be indexed;
    • Alter view to show message of "Transaction not indexed yet."
  • Subscribe to pending "transactions" and "incoming blocks" websockets so when the transaction is indexed show in the view;
  • When the transaction hash is invalid show message: "Transaction hash invalid."

Transaction Worker

Below is information collected from getTransaction(transactionHash [, callback])

We must now fetch the transaction receipt to obtain the status of the transaction

  "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
  "nonce": 2,
  "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "blockNumber": 3,
  "transactionIndex": 0,
  "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
  "value": BigNumber,
  "gas": 314159,
  "gasPrice": BigNumber,
  "input": "0x57cb2fc4"
}```

Contributor sees the Internal Transactions for an Account.

Contributor sees Internal Transactions for Address

To Do:

  • show information in table
  • filter by to, from or all
  • order the internal transactions by block index desc, parent transaction index in block desc, then internal transaction index desc in parent transaction
  • refactor rest of address page feature tests to use page module
  • filter out internal transactions that represent the parent transaction

Table:
ParentTxHash, Block, Age, From, To, Value

screen shot 2018-04-01 at 5 39 14 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.