Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add standard eth and geth rpc configs #1

Merged
merged 9 commits into from
Jun 25, 2024
Merged

Conversation

koushiro
Copy link
Collaborator

@koushiro koushiro commented Jun 18, 2024

Changes

  • add standard ethererum rpc config (it's the template)
  • add geth rpc config (use it in producation env)
  • add prometheus into configs/demo_config.yml

Notes

Based on the specific use case, comment the unused RPC methods, like,

  • For internal use or external explorer: use eth, txpool, net, debug RPC methods
  • For user: use eth, net RPC methods

You can call the rpc_methods RPC method to find out which RPC methods are currently supported by subway.

curl -X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc": "2.0", "id": 1, "method": "rpc_methods", "params": []}' \
"http://127.0.0.1:8545" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1901  100  1835  100    66  2608k  96069 --:--:-- --:--:-- --:--:-- 1856k
{
  "jsonrpc": "2.0",
  "result": {
    "methods": [
      "debug_accountRange",
      "debug_chaindbCompact",
      "debug_chaindbProperty",
      "debug_dbAncient",
      "debug_dbAncients",
      "debug_dbGet",
      "debug_dumpBlock",
      "debug_getAccessibleState",
      "debug_getBadBlocks",
      "debug_getModifiedAccountsByHash",
      "debug_getModifiedAccountsByNumber",
      "debug_getRawBlock",
      "debug_getRawHeader",
      "debug_getRawReceipts",
      "debug_getRawTransaction",
      "debug_getTrieFlushInterval",
      "debug_intermediateRoots",
      "debug_preimage",
      "debug_printBlock",
      "debug_setHead",
      "debug_setTrieFlushInterval",
      "debug_standardTraceBadBlockToFile",
      "debug_standardTraceBlockToFile",
      "debug_storageRangeAt",
      "debug_traceBadBlock",
      "debug_traceBlock",
      "debug_traceBlockByHash",
      "debug_traceBlockByNumber",
      "debug_traceBlockFromFile",
      "debug_traceCall",
      "debug_traceChain",
      "debug_traceTransaction",
      "eth_accounts",
      "eth_blobBaseFee",
      "eth_blockNumber",
      "eth_call",
      "eth_chainId",
      "eth_coinbase",
      "eth_createAccessList",
      "eth_estimateGas",
      "eth_feeHistory",
      "eth_gasPrice",
      "eth_getBalance",
      "eth_getBlockByHash",
      "eth_getBlockByNumber",
      "eth_getBlockReceipts",
      "eth_getBlockTransactionCountByHash",
      "eth_getBlockTransactionCountByNumber",
      "eth_getCode",
      "eth_getFilterChanges",
      "eth_getFilterLogs",
      "eth_getLogs",
      "eth_getProof",
      "eth_getStorageAt",
      "eth_getTransactionByBlockHashAndIndex",
      "eth_getTransactionByBlockNumberAndIndex",
      "eth_getTransactionByHash",
      "eth_getTransactionCount",
      "eth_getTransactionReceipt",
      "eth_getUncleCountByBlockHash",
      "eth_getUncleCountByBlockNumber",
      "eth_maxPriorityFeePerGas",
      "eth_newBlockFilter",
      "eth_newFilter",
      "eth_newPendingTransactionFilter",
      "eth_sendRawTransaction",
      "eth_sendTransaction",
      "eth_sign",
      "eth_signTransaction",
      "eth_subscribe",
      "eth_syncing",
      "eth_uninstallFilter",
      "eth_unsubscribe",
      "net_listening",
      "net_peerCount",
      "net_version",
      "txpool_content",
      "txpool_contentFrom",
      "txpool_inspect",
      "txpool_status"
    ],
    "version": 1
  },
  "id": 1
}

Example

cargo build --release
./target/release/subway -c configs/demo_config.yml

configs/demo_config.yml:

  client:
    endpoints:
      - wss://op-demo.alt.technology/ws
  eth_api:
    stale_timeout_seconds: 180 # rotate endpoint if no new blocks for 3 minutes
  telemetry:
    provider: none
  prometheus:
    port: 9616
    listen_address: "0.0.0.0"
    prefix: "subway"
  cache:
    default_ttl_seconds: 60
    default_size: 500
  server:
    port: 8545
    listen_address: '0.0.0.0'
    max_connections: 2000
    max_batch_size: 10
    cors: all
middlewares:
  methods:
    - whitelist
    - response
    - block_tag
    - cache
    - upstream
  subscriptions:
    - upstream

rpcs: rpc_configs/geth.yml

@koushiro koushiro marked this pull request as ready for review June 20, 2024 02:15
@koushiro koushiro changed the base branch from master to develop June 20, 2024 02:56
@koushiro koushiro linked an issue Jun 20, 2024 that may be closed by this pull request
@yjhmelody yjhmelody merged commit 3f603b4 into develop Jun 25, 2024
3 checks passed
@yjhmelody yjhmelody deleted the add-rpc-configs branch June 25, 2024 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subway: add new ethereum APIs config
2 participants