Appearance
Connecting
This page describes the current version
Methods, limits and answers can change between v0.x versions.
Cinder serves the user JSON-RPC API of an Ethereum node. The goal is the same answer as reth for the same question, byte for byte. This page tells how to reach the API, and lists the namespaces and methods that Cinder implements. For the differences from reth, read Differences from reth.
Where the API runs
Two modes serve the API:
- Engine mode with
--http. The node that follows the chain also serves the API. This mode has the transaction pool, soeth_sendRawTransactionandtxpool_*work. - Serve mode (
cinder --serve --db DIR). A separate process opens the database of a running node as read-only and serves the API from it. More than one such process can run, each on its own port. This mode has no transaction pool:eth_sendRawTransactionandtxpool_*get the error -32601, butrpc_modulesstill liststxpoolwhentxpoolis in the namespace list.
The API has no authentication. HTTP and WebSocket use the same port. The server starts a thread for each connection. It keeps at most 500 open connections (--rpc-max-connections N). At the limit, a new connection closes the connection that was idle for the longest time. If none is idle, it closes the connection whose request headers are not complete for the longest time. If there is no such connection, the new connection gets HTTP status 429, and the server closes it. The server closes an HTTP connection that sends no request for 120 s. Each request reads the database in its own MDBX read transaction, so requests do not stop the node from writing blocks. For the address and port flags, read Configuring.
The server accepts batches. There is no limit on the number of requests in a batch, but a request body larger than 64 MiB gets the HTTP status 413. A method that Cinder does not know gets the error -32601 with the text Method not found, as in reth.
Request limits
The HTTP server applies these checks to each request (from 0.9.7):
- The headers of a request must arrive in 30 s from its first byte, else the connection closes. The full request (its headers and its body) must arrive in 60 s from its first byte. When the body is not complete after that time, the request gets HTTP status 408, and the connection closes.
- The server reads request bodies with
Transfer-Encoding: chunked. - A header block larger than 64 KiB gets HTTP status 431.
- A request gets HTTP status 400, and the connection closes, when a header line is not valid, when
Content-Lengthis not a number, when twoContent-Lengthvalues are different, or when the request hasTransfer-EncodingandContent-Lengthtogether. - A WebSocket client that sends no frame and receives nothing for 120 s gets a ping. When no frame comes in the next 30 s, the server closes the connection. A client that answers pings stays connected.
Compressed answers
The HTTP server compresses an answer when the request asks for it, as reth does. Send Accept-Encoding: gzip (or deflate) with the request. The rules are those of reth:
- An answer of 32 bytes or more gets the header
Vary: accept-encoding. A smaller answer goes as it is. - The encoding with the highest
qweight inAccept-Encodingwins. On equal weights, gzip comes first, then deflate. An entry withq=0is never selected. The server ignores the tokens that it does not know. If no encoding is acceptable, the answer goes as it is. - The server ignores all of an
Accept-Encodingheader that has a byte outside visible ASCII, as reth. Tab and space count as visible here. An example: forgzip, éthe answer is not compressed. The otherAccept-Encodingheaders of the request still count. 0.9.6 and earlier read such a header and compressed the answer (#280). deflateis the zlib format, as in reth.- WebSocket messages and the Engine API port are never compressed.
Compression applies in engine mode and in serve mode. To turn it off, use --http-disable-compression (reth's spelling --http.disable-compression also works). Compression costs some CPU time for each answer, and large answers become several times smaller. Thus it helps a client on a slow link that gets full blocks, traces or wide eth_getLogs ranges. Compression is on by default from v0.9.6. Versions up to 0.9.5 do not compress answers. For the differences from reth (no br and no zstd), read Differences from reth.
Namespaces and methods
The method reference lists every method with its status, its parameters and the comparison with reth. This section tells what each namespace does and its limits.
By default the node serves eth, net and web3, as reth. To serve debug, trace, txpool or rpc, give the list with --http-api for HTTP and --ws-api for WebSocket (reth's --http.api and --ws.api also work), for example --http-api eth,net,web3,debug,trace. A method of a namespace that the node does not serve gets -32601 Method not found, as in reth. Read JSON-RPC namespaces.
rpc_modules is in the rpc namespace. It returns the namespaces that the transport serves, of eth, net, web3, txpool, debug, trace and rpc.
--rpc-timeout D gives each request a time limit. A request that runs longer gets -32603 request timed out. Read JSON-RPC time limit.
eth: chain, blocks and transactions
eth_chainId,eth_blockNumber,eth_syncing,eth_protocolVersion,eth_config(EIP-7910).eth_syncingalways returnsfalse.eth_getBlockByNumber,eth_getBlockByHash,eth_getHeaderByNumber,eth_getHeaderByHash,eth_getBlockReceipts,eth_getBlockTransactionCountByNumberandByHash, and the uncle methods.eth_getTransactionByHash(pool transactions included),eth_getTransactionByBlockHashAndIndexandByBlockNumberAndIndex,eth_getTransactionReceipt,eth_getTransactionBySenderAndNonce.eth_getRawTransactionByHash,eth_getRawTransactionByBlockHashAndIndexandByBlockNumberAndIndex.eth_getLogs, at most 100 000 blocks and 20 000 logs for each request. From 0.9.5, a log filter row for each block lets the node skip the receipts of the blocks without a match, so a filter with few matches is fast. Read Log filter rows. On the older blocks of a database of an earlier version, runcinder --build-log-filtersonce.
eth: state and calls
eth_getBalance,eth_getTransactionCount,eth_getCode,eth_getStorageAt,eth_getStorageValues(at most 1 024 slots),eth_getAccount(at the latest block only),eth_getAccountInfo.eth_getProof(EIP-1186), at the latest block only, as reth with its default proof window.eth_call,eth_callMany,eth_estimateGas(the algorithm of reth),eth_createAccessList,eth_simulateV1,eth_fillTransaction.- State overrides and block overrides for the calls, applied as reth applies them.
authorizationList(EIP-7702) in calls.
The gas cap is --rpc-gascap (default 50 000 000, as reth). A call without a gas limit runs with the gas cap. If the call has a gas price, the limit is the gas that the sender can pay for, at most the gas cap. A larger gas limit gets the gas cap.
eth: fees, transactions in, filters
eth_gasPrice,eth_maxPriorityFeePerGas(the gas price oracle of reth),eth_feeHistory,eth_blobBaseFee.eth_sendRawTransaction. The node checks the transaction with the admission rules of reth, in the same order, with the same error codes and texts. The fee cap is--rpc-txfeecap(default 1.0 ether, as reth). The node announces an admitted transaction to its peers. This needs--p2p.eth_newFilter,eth_newBlockFilter,eth_newPendingTransactionFilter,eth_getFilterChanges,eth_getFilterLogs,eth_uninstallFilter. The node keeps at most 1 024 filters, and one client can have at most 256 of them. Read Filters.- The signing and mining methods (
eth_sign,eth_sendTransaction,eth_getWork,eth_miningand others) give the same answers as reth. Cinder keeps no accounts and does not mine.
net, web3, txpool
net_version,net_listening,net_peerCount. Without--p2p,net_listeningreturnsfalseandnet_peerCountreturns 0.web3_clientVersion,web3_sha3.txpool_status,txpool_content,txpool_contentFrom,txpool_inspect. The node splits the pool into pending and queued transactions as reth does.
debug
- Raw data:
debug_getRawHeader,debug_getRawBlock,debug_getRawTransaction,debug_getRawReceipts,debug_codeByHash. - Tracing:
debug_traceTransaction,debug_traceBlockByNumber,debug_traceBlockByHash,debug_traceBlock,debug_traceCall,debug_traceCallMany. See Tracing. - The stubs of reth (
debug_memStats,debug_setHead,debug_storageRangeAtand others) returnnullas in reth.debug_seedHashreturns a zero hash.debug_chainConfigreturns the object of reth. The profiling and logging methods of other clients (debug_cpuProfile,debug_verbosityand others) get -32601,Method not found, as in reth 2.7.
trace
trace_transaction, trace_block, trace_get, trace_filter, trace_replayTransaction, trace_replayBlockTransactions, trace_call, trace_callMany, trace_rawTransaction.
The indices of trace_get are a trace address, as in reth 2.7: [] is the top call of the transaction, ["0x0"] is its first sub-call, and ["0x0","0x1"] is the second sub-call of that one.
Tracing
To trace a transaction, the node executes its block again on the state of the parent block. So tracing works for the last 128 blocks.
debug_trace* methods accept these tracers:
| Tracer | Options |
|---|---|
| default (struct logger) | disableStack, enableMemory, disableStorage, enableReturnData |
callTracer | withLog, onlyTopCall |
flatCallTracer | includePrecompiles |
prestateTracer | diffMode, disableCode, disableStorage |
erc7562Tracer | withLog, ignoredOpcodes, stackTopItemsSize |
4byteTracer, noopTracer | none |
muxTracer | a set of callTracer, flatCallTracer, prestateTracer, 4byteTracer and noopTracer |
| JavaScript (the source code of a tracer object) | timeout, and the tracer configuration in tracerConfig |
A JavaScript tracer runs in a sandboxed worker process. For its limits, read Differences from reth. The copies that its helper functions make (toHex, slice, the db functions and others) count toward --rpc-js-memory-mb. A copy that is larger than the remaining memory gives the error out of memory. 0.9.6 and earlier did not count these copies (#324).
trace_* methods accept the trace types trace, vmTrace and stateDiff.
Some rules from reth apply:
- An answer larger than 160 MiB gets the error -32008,
Response is too big. In a batch, this limit applies to each answer and to the full batch answer, as in reth. When the full batch answer becomes larger than 160 MiB, the node stops the batch, and the answer is one error -32011,The batch response was too large. The tracers count the size of their answer while they record (#382): the struct logger,vmTrace,callTracer,flatCallTracer,muxTracer,erc7562Tracer,prestateTracerand the call traces of thetracenamespace. When the answer becomes too large, they stop recording, and the request gets -32008 before the node writes the answer.debug_traceCallManyandtrace_callManycount the answers of all their calls against one limit (#390). 0.9.6 and earlier counted only for the struct logger andvmTrace, and started the count again for each call of a bundle. When the memory for a trace runs out, the request gets -32603out of memory. For the struct logger, 0.9.4 and earlier gave an empty object instead of this error. After a request that used more than 64 MiB of the scratch memory of its connection thread, the node gives the memory above 64 MiB back to the system (#383). trace_filterrefuses a range wheretoBlockminusfromBlockis more than 100. So a range of 101 blocks passes.debug_traceCallwithtxIndexruns the call on the parent state after the transactions of the block before that index.- The error texts and revert reasons are those that reth gives.
Filters
Filters follow the semantics of reth:
- The first poll includes the head at the time the client installed the filter.
- A log filter with an explicit range uses that range on every poll.
- A filter expires 5 minutes after its last poll.
- A pending transaction filter returns the hashes of the transactions that the pool admitted. It needs the transaction pool, so serve mode does not have it.
These limits are of Cinder (from 0.9.7). reth has no such limits:
- The node keeps at most 1 024 filters for all clients together.
- One client can have at most 256 filters (
--rpc-filters-per-client N, 0 for no such limit). A new filter over this limit gets -32603,too many filters. The node identifies a client by its IPv4 address or by the first 64 bits of its IPv6 address. - A client on the same host (127.0.0.0/8 or ::1) has no limit of its own. Thus a proxy on the same host as the node removes the limit for all clients behind it. Behind a proxy on another host, all clients have the address of the proxy: set
--rpc-filters-per-client 0there. - When the node has 1 024 filters, a new filter replaces the least recently polled filter of the client that has the most filters.
- A log filter has at most 1 024 addresses and topic values together. A larger filter gets -32602.
Subscriptions over WebSocket
A client opens a WebSocket on the JSON-RPC port. Every method works over the WebSocket, and these methods work only there:
eth_subscribewithnewHeads,logs(withaddressandtopics),newPendingTransactions(hashes, or full transactions withtrue) andsyncing.eth_unsubscribe.
Over HTTP, these two methods get -32603, Internal error, as in reth. eth_subscribe needs eth in --ws-api (it is in the default list).
A connection can have at most 128 subscriptions. All connections together can have at most 4 096 logs subscriptions (--rpc-max-log-subscriptions N, 0 for no such limit). reth has no such limit. Over either limit, eth_subscribe gets -32000, too many subscriptions. A logs filter has at most 1 024 addresses and topic values together. When a block becomes the head, the node sends the notifications at once. cinder --serve checks the database for new blocks every 50 ms, because another process writes the database. The notifications are:
newHeadssends the object ofeth_getHeaderByNumberfor each new block.logssends one notification for each log.newPendingTransactionssends the transactions that are ready for a block, as the listener of reth does. Serve mode has no transaction pool, so this subscription gets no notifications there.
If more than 64 new blocks arrive between two checks, the node sends only the newest 64. Each connection has a queue of at most 1 024 messages and 16 MiB. A client that reads slowly does not delay the other clients. When its queue is full, a new notification replaces the oldest notification in the queue, and the connection stays open, as in reth. On a reorg, the node sends the headers of the new branch again. Each logs subscription first gets the logs of the removed blocks again with removed: true, oldest first. The node keeps one copy of the logs of the last 8 blocks for all logs subscriptions for this purpose.