Giter Club home page Giter Club logo

eos-evm-miner's Introduction

EOS EVM Miner

GitHub release (latest by date) Build Status

Accepts Ethereum transactions and relays them to EOS EVM network.

References

$ wget https://github.com/pinax-network/eos-evm-miner/releases/download/v0.5.0/eos-evm-miner
$ chmod +x ./eos-evm-miner
  • Ubuntu
  • MacOS
  • Windows

Build from source

Install Bun

curl -fsSL https://bun.sh/install | bash

Generate a standalone Bun executable

$ git clone https://github.com/pinax-network/eos-evm-miner.git
$ cd eos-evm-miner
$ bun build --compile ./bin/cli.ts --outfile eos-evm-miner

Quickstart

$ eos-evm-miner start --verbose


        ███████╗ ██████╗ ███████╗    ███████╗██╗   ██╗███╗   ███╗
        ██╔════╝██╔═══██╗██╔════╝    ██╔════╝██║   ██║████╗ ████║
        █████╗  ██║   ██║███████╗    █████╗  ██║   ██║██╔████╔██║
        ██╔══╝  ██║   ██║╚════██║    ██╔══╝  ╚██╗ ██╔╝██║╚██╔╝██║
        ███████╗╚██████╔╝███████║    ███████╗ ╚████╔╝ ██║ ╚═╝ ██║
        ╚══════╝ ╚═════╝ ╚══════╝    ╚══════╝  ╚═══╝  ╚═╝     ╚═╝
                EOS EVM Miner listening @ 127.0.0.1:50305
              Prometheus metrics listening @ 127.0.0.1:9102
                   Your miner account is miner.enf
        PUB_K1_8bxdSx2gET6suSZxz6dWoxux2ysNG3ADJu3n5nWvMEQ6vvRXtS

Help

$ eos-evm-miner start --help

Usage: @enf/eos-evm-miner start [options]

Start JSON RPC Server

Options:
  --private-key <string>       Miner private key (ex: "PVT_K1_...")
  --account <string>           Miner account name (ex: "miner.evm")
  --permission <string>        Miner permission (default: "active")
  -p --port <int>              JSON RPC listens on port number, listen for
                               incoming Ethereum transactions. (default:
                               "50305")
  --hostname <string>          JSON RPC listens on hostname, listen for
                               incoming Ethereum transactions (ex: "127.0.0.1)"
  --metrics-listen-port <int>  The process will listen on this port for
                               Prometheus metrics requests (default: "9102")
  --metrics-disabled           If set, will not send metrics to Prometheus
  --verbose                    Enable verbose logging
  --lock-gas-price             Lock gas price as hex value (ex: "0x22ecb25c00")
  -h, --help                   display help for command

Docker environment

docker build -t eos-evm-miner .
docker run -it --rm -p 50305:50305 --env-file .env eos-evm-miner start

Deploy to Cloud Run

https://console.cloud.google.com/run

gcloud run deploy

Environment Variables

.env

# miner (required)
PRIVATE_KEY=PVT_K1_...
MINER_ACCOUNT=miner.enf

# miner (optional)
MINER_PERMISSION=active

# RPC EOS (optional)
RPC_ENDPOINT=https://eos.api.eosnation.io
CHAIN_ID=aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906

# RPC EVM (optional)
RPC_EVM_ENDPOINT=https://api.evm.eosnetwork.com

# JSON RPC (optional)
PORT=50305
HOSTNAME=127.0.0.1
LOCK_GAS_PRICE=0x22ecb25c00
LOCK_CHAIN_ID=0x4571
LOCK_GENESIS_TIME="2023-04-05T02:18:09"

# Prometheus Metrics
PROMETHEUS_PORT=9102
METRICS_DISABLED=false

# CLI (optional)
VERBOSE=true

Testing

$ bun test
bun test v0.6.7 (59d7c47e)
[0.28ms] ".env"

src/eth_sendRawTransaction.spec.ts:
✓ eth_sendRawTransaction [1.45ms]

src/eth_gasPrice.spec.ts:
✓ eth_gasPrice [226.88ms]

Features

  • JSON RPC methods (Request to EOS RPC)

    • eth_gasPrice - Returns the current gas price on the network in wei.
    • eth_sendRawTransaction - Creates new message call transaction or a contract creation for signed transactions.
    • eth_chainId - Returns the current network/chain ID, used to sign replay-protected transaction introduced in EIP-155.
    • eth_blockNumber - Returns the latest block number of the blockchain.
    • eth_getBalance - Returns the balance of given account address in wei.
    • net_version - Returns the current network id.
    • eth_getCode - Returns the compiled bytecode of a smart contract.
  • JSON RPC methods (Proxy to EVM RPC)

    • eth_estimateGas - Returns an estimation of gas for a given transaction.
    • eth_getTransactionCount - Returns the number of transactions sent from an address.
    • eth_getTransactionReceipt - Returns the receipt of a transaction by transaction hash.
    • eth_getBlockByHash - Returns information of the block matching the given block hash.
    • eth_getBlockByNumber - Returns information of the block matching the given block number.
    • eth_call - Executes a new message call immediately without creating a transaction on the block chain.
    • ... and all other supported EVM method calls
  • CLI commands

    • start - start miner JSON RPC server
    • claim - claim miner rewards
    • open - open miner balance
    • powerup - powerup miner CPU & NET
  • Bun binary builds

  • Docker Container

    • Alpine Docker image
    • "Distroless" Docker image
  • Prometheus metrics

    • total eth_gasPrice requests & success
    • total eth_sendRawTransaction requests & success

eos-evm-miner's People

Contributors

deniscarriere avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eos-evm-miner's Issues

remove default value of `--lock-genesis-time`

https://github.com/pinax-network/eos-evm-miner/blob/main/src/eth_blockNumber.ts

I am facing incorrect return value from miner endpoint. I think it is related to the wrong calculation within eth_blockNumber.ts. Metamask based on the latest block number to query tx count. Therefore, it related a incorrect value:

Request:

curl http://jungle4evm-arch41.mar.eosn.io:50305 -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'

Result from miner:

{"jsonrpc":"2.0","id":83,"result":"0x5d1537"}

Result from rpc:

{"id":83,"jsonrpc":"2.0","result":"0x6e3d16"}

Remove jayson dependency since not ESM

  • must be ESM compatible
  • must work with bun
$ bun ./bin/cli.ts start
[0.06ms] ".env"
1071 |   _dispatchSubcommand(commandName, operands, unknown) {
1072 |     const subCommand = this._findCommand(commandName);
1073 |     if (!subCommand) this.help({ error: true });
1074 | 
1075 |     let hookResult;
1076 |     hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, 'preSubcommand');
                     ^
ReferenceError: Cannot access uninitialized variable.
      at _dispatchSubcommand (/Users/denis/Github/eos-evm-miner/node_modules/commander/lib/command.js:1076:17)
      at parse (/Users/denis/Github/eos-evm-miner/node_modules/commander/lib/command.js:909:4)
      at /Users/denis/Github/eos-evm-miner/bin/cli.ts:29:0

🚀 Feature request: Health check Metrics for Monitoring

  • Add /v1/chain/get_info endpoint to the miner for monitoring

❌ ChatGPT

About

Currently miner only providing two function eth_getPrice and eth_sendRawTransaction. eth_getPrice is the providing local value instead of remote value from EOS nodes rpc. There are too many factor to cause eth_sendRawTransaction not working property

Is your proposal related to a problem?

The current functionality of the miner has limitations that make it difficult to control and debug in certain environments. Specifically, the eth_getPrice function provides a local value instead of fetching the remote value from the EOS node RPC. Additionally, there are multiple factors that can cause issues with the eth_sendRawTransaction function, further complicating the debugging process.

Describe the solution you'd like

I would like to propose the addition of Health Check Metrics for Monitoring to enhance the miner functionality. This feature would address the existing limitations and provide a more reliable and manageable environment for controlling and debugging. The Health Check Metrics would serve the following purposes:

  • Fetching the remote value from the EOS node RPC periodically for eth_getPrice to ensure eos node connectivity.
  • Expose /v1/chain/get_info endpoint to the miner for monitoring

Describe alternatives you've considered

I have explored alternative solutions for improving the miner functionality. Some alternatives considered were:

  1. Using the existing eth_getPrice function as the health probe. However, this approach would only should the miner status and not ensure all function work properly.

Additional context

Adding Health Check Metrics for Monitoring would greatly enhance the usability and reliability of the miner. It would provide developers with accurate data and better visibility into any potential issues, enabling them to monitor and maintain the system more effectively. This feature request aligns with the goal of improving the overall user experience and ensuring smooth operation of the application.

Please let me know if you need any further information or if there are any specific requirements for the feature request.

🚀 Feature request: Count the number of transactions sent via eth_sendRawTransaction

  • Add prometheus exporter
    • count the number of transactions sent via eth_sendRawTransaction

❌ ChatGPT

About

Add prometheus exporter to the miner with count the number of transactions sent via eth_sendRawTransaction

Is your proposal related to a problem?

Currently, there is no built-in functionality in the miner to count the number of transactions sent via the eth_sendRawTransaction function. This lack of visibility makes it challenging to track and analyse the transaction volume, which can be crucial for monitoring and optimising system performance.

Describe the solution you'd like

I would like to propose the addition of a transaction counter feature to the miner. This feature would provide the capability to count the number of transactions sent using the eth_sendRawTransaction function. The transaction counter would increment every time a transaction is successfully sent, allowing users to accurately monitor and analyze the transaction volume over time.

Describe alternatives you've considered

While there are alternative methods to count transactions sent via eth_sendRawTransaction, such as tracking events on chain event by the specific miner, these approaches can be cumbersome and time-consuming. Having an integrated transaction counter within the miner would offer a more convenient and efficient solution for users.

Additional context

The transaction counter feature would significantly enhance the usability and monitoring capabilities of the miner. It would enable developers to gain insights into the transaction volume and assess the impact of changes or optimizations made to the system. This feature request aligns with the goal of providing users with valuable metrics and enhancing their ability to monitor and manage their EVM transactions effectively.

Please let me know if you need any further information or if there are any specific requirements for the feature request.

The local address is hardcoded

EOS EVM Miner listening @ http://127.0.0.1:${port.toString()}

127.0.0.1 binds it only to the localhost
0.0.0.0 binds to all IP addresses
There is no option to define which interface is listening.

Hard coded 127.0.0.1 is confusing.

Fail to getting gas price from nodeos

I am trying to call the eth_gasPrice without setting a lock gas price. Referring to the code, the miner should able to get the price from chain.

From pinax-network/eos-evm-miner
Server side error

2023-06-08 12:00:32.521	ERROR		Error getting gas price from nodeos: TypeError: fetch failed

Client side error

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"There was an error getting the gas price from this EOS EVM miner."}}

From the original repo,
Values can be fetched successfully from tx_wrapper
Server side logs

number of RPC endpoints = 1, using http://jungle4-nodeos-peer.service.march.consul.eosn.io:8888
server is listening at 127.0.0.1:3335
{"method":"eth_gasPrice","params":[],"id":1,"jsonrpc":"2.0"}
result: 150000000000

Client Result

{"jsonrpc":"2.0","id":1,"result":"0x22ecb25c00"}

Source code: https://github.com/eosnetworkfoundation/eos-evm/blob/main/peripherals/tx_wrapper/index.js#LL139C1-L153C1

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.