Skip to content

Commit

Permalink
feat: updates pubsub, and debug rpc calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter committed Apr 3, 2024
1 parent 7267f9e commit 8f3e584
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 63 deletions.
152 changes: 135 additions & 17 deletions content/20.api-reference/30.debug-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,56 @@ github: https://github.com/matter-labs/zksync-era/blob/main/core/lib/web3_decl/s

Traces all calls made from a specific block by its L2 hash.

| **Parameter** | **Type** | **Description** |
|---------------|------------------------|----------------------------------|
| `hash` | `H256` | The 32 byte hash defining the L2 block. |
| `options` | `TracerConfig` | Optional. See the <a href="https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig" target="_blank">TraceConfig documentation</a> for details. |
### Parameters

| **Parameter** | **Type** | **Description** | **Required** |
|---------------|------------------|------------------------------------|--------------|
| `hash` | `H256` | The 32-byte hash defining the L2 block. | Yes |
| `options` | `TracerConfig` | Optional configuration for tracing. Refer to the [TraceConfig documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig) for more details. | No |

### Returns

| **Field** | **Type** | **Description** |
|-----------|------------------|------------------------------------------------------|
| `result` | `Array<Object>` | An array of objects, each representing a traced call made from the specified block. Each object contains fields such as `type`, `from`, `to`, `gas`, `gasUsed`, `value`, `output`, `input`, `error`, `revertReason`, and `calls`. |

#### Trace Object

| **Field** | **Type** | **Description** |
|-----------------|-----------------|-----------------|
| `type` | `String` | The type of action (e.g., `Call`, `Create`, etc.). |
| `from` | `String` | The address of the sender initiating the call. |
| `to` | `String` | The address of the recipient of the call. If the type is `Create`, this field is absent since the contract has not been created yet. |
| `gas` | `String` | The amount of gas provided for the call. |
| `gasUsed` | `String` | The amount of gas used by the call. |
| `value` | `String` | The value transferred in the call. |
| `output` | `String` | The data returned by the call. For failed calls or calls that don't return data, this is `0x`. |
| `input` | `String` | The data sent to the call. |
| `error` | `String` | The error message if the call encountered an exception. |
| `revertReason` | `String` | The string reason provided by a `revert` statement, if applicable. |
| `calls` | `Array<Object>` | An array of call objects representing calls made by the current call. This field is recursive, as calls can initiate other calls. |

### Returns

| **Field** | **Type** | **Description** |
|-----------|------------------|------------------------------------------------------|
| `result` | `Array<Object>` | An array of objects, each representing a traced call made from the specified block hash. Each object contains fields such as `type`, `from`, `to`, `gas`, `gasUsed`, `value`, `output`, `input`, `error`, `revertReason`, and `calls`. |

#### Trace Object

| **Field** | **Type** | **Description** |
|-----------------|-----------------|-----------------|
| `type` | `String` | The type of operation (e.g., `Call`, `Create`, etc.), indicating the nature of the trace. |
| `from` | `String` | The address of the account that initiated the operation. |
| `to` | `String` | The recipient address of the call. For `Create` operations, this field is absent as the contract being created doesn't have an address until after the transaction completes. |
| `gas` | `String` | The amount of gas provided for the operation. |
| `gasUsed` | `String` | The amount of gas used by the operation. |
| `value` | `String` | The amount of Ether transferred during the operation. |
| `output` | `String` | The output from the operation. For operations that don't return data or failed, this is typically `0x`. |
| `input` | `String` | The data sent into the call or contract creation. |
| `error` | `String` | An error message if the operation failed. |
| `revertReason` | `String` | The reason provided by a `revert` operation, if applicable. |
| `calls` | `Array<Object>` | An array of nested calls made by this operation. This field is recursive, containing further traces of calls made by the traced operation. |

### Example Request

Expand Down Expand Up @@ -57,10 +103,34 @@ curl --request POST \

Traces all calls made from a specific block by its L2 block number.

| **Parameter** | **Type** | **Description** |
|---------------|------------------------|-----------------------------------|
| `block` | `BlockNumber` | The number of the block to trace. |
| `options` | `TracerConfig` | Optional. See the <a href="https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig" target="_blank">TraceConfig documentation</a> for details. |
### Parameters

| **Parameter** | **Type** | **Description** | **Required** |
|---------------|------------------|------------------------------------|--------------|
| `block` | `BlockNumber` | The number of the block to trace. This can be a hex-encoded number or one of the strings "earliest", "latest", or "pending". | Yes |
| `options` | `TracerConfig` | Optional configuration for tracing. For more details, refer to the [TraceConfig documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig). | No |

### Returns

| **Field** | **Type** | **Description** |
|-----------|------------------|------------------------------------------------------|
| `result` | `Array<Object>` | An array of objects, each representing a traced call made from the specified block. Each object contains fields such as `type`, `from`, `to`, `gas`, `gasUsed`, `value`, `output`, `input`, `error`, `revertReason`, and `calls`. |

#### Trace Object

| **Field** | **Type** | **Description** |
|-----------------|-----------------|-----------------|
| `type` | `String` | The type of operation (e.g., `Call`, `Create`, etc.), indicating the nature of the trace. |
| `from` | `String` | The address of the account that initiated the operation. |
| `to` | `String` | The recipient address of the call. For `Create` operations, this field is absent as the contract being created doesn't have an address until after the transaction completes. |
| `gas` | `String` | The amount of gas provided for the operation. |
| `gasUsed` | `String` | The amount of gas used by the operation. |
| `value` | `String` | The amount of Ether transferred during the operation. |
| `output` | `String` | The output from the operation. For operations that don't return data or failed, this is typically `0x`. |
| `input` | `String` | The data sent into the call or contract creation. |
| `error` | `String` | An error message if the operation failed. |
| `revertReason` | `String` | The reason provided by a `revert` operation, if applicable. |
| `calls` | `Array<Object>` | An array of nested calls made by this operation. This field is recursive, containing further traces of calls made by the traced operation. |

### Example Request

Expand Down Expand Up @@ -107,11 +177,35 @@ curl --request POST \

Traces a call made at a specific block, by block number or hash.

| **Parameter** | **Type** | **Description** |
|---------------|------------------------|----------------------------------------------|
| `request` | `CallRequest` | The call request to trace. |
| `block` | `BlockId` | Optional. The block identifier, by number or hash. |
| `options` | `TracerConfig` | Optional. See the <a href="https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig" target="_blank">TraceConfig documentation</a> for details. |
### Parameters

| **Parameter** | **Type** | **Description** | **Required** |
|---------------|------------------|----------------------------------------------|--------------|
| `request` | `CallRequest` | The call request to trace, containing fields like `from`, `to`, `data`, and optionally `gas`, `gasPrice`, and `value`. | Yes |
| `block` | `BlockId` | Optional. The block identifier, which can be a block number as a hex-encoded number or a block hash. If not specified, the latest block is used. | No |
| `options` | `TracerConfig` | Optional. Configuration options for the trace. For more details, refer to the [TraceConfig documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig). | No |

### Returns

| **Field** | **Type** | **Description** |
|-----------|------------------|------------------------------------------------------|
| `result` | `Array<Object>` | An array of objects, each representing a traced call made from the specified block. Each object contains fields such as `type`, `from`, `to`, `gas`, `gasUsed`, `value`, `output`, `input`, `error`, `revertReason`, and `calls`. |

#### Trace Object

| **Field** | **Type** | **Description** |
|-----------------|-----------------|-----------------|
| `type` | `String` | The type of operation (e.g., `Call`, `Create`, etc.), indicating the nature of the trace. |
| `from` | `String` | The address of the account that initiated the operation. |
| `to` | `String` | The recipient address of the call. For `Create` operations, this field is absent as the contract being created doesn't have an address until after the transaction completes. |
| `gas` | `String` | The amount of gas provided for the operation. |
| `gasUsed` | `String` | The amount of gas used by the operation. |
| `value` | `String` | The amount of Ether transferred during the operation. |
| `output` | `String` | The output from the operation. For operations that don't return data or failed, this is typically `0x`. |
| `input` | `String` | The data sent into the call or contract creation. |
| `error` | `String` | An error message if the operation failed. |
| `revertReason` | `String` | The reason provided by a `revert` operation, if applicable. |
| `calls` | `Array<Object>` | An array of nested calls made by this operation. This field is recursive, containing further traces of calls made by the traced operation. |

### Example Request

Expand Down Expand Up @@ -163,10 +257,34 @@ curl --request POST \
Uses the <a href="https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#call-tracer" target="_block">EVM's `callTracer`</a>
to return a debug trace of a specific transaction given by its transaction hash.

| **Parameter** | **Type** | **Description** |
|---------------|------------------------|---------------------------------------|
| `tx_hash` | `H256` | The 32 byte hash of the transaction to trace. |
| `options` | `TracerConfig` | Optional. See the <a href="https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig" target="_blank">TraceConfig documentation</a> for details. |
### Parameters

| **Parameter** | **Type** | **Description** | **Required** |
|---------------|------------------|---------------------------------------|--------------|
| `tx_hash` | `H256` | The 32-byte hash of the transaction to trace. | Yes |
| `options` | `TracerConfig` | Optional configuration for the trace. For more details, refer to the [TraceConfig documentation](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig). | No |

### Returns

| **Field** | **Type** | **Description** |
|-----------|------------------|------------------------------------------------------|
| `result` | `Array<Object>` | An array of objects, each representing a traced call made from the specified block. Each object contains fields such as `type`, `from`, `to`, `gas`, `gasUsed`, `value`, `output`, `input`, `error`, `revertReason`, and `calls`. |

#### Trace Object

| **Field** | **Type** | **Description** |
|-----------------|-----------------|-----------------|
| `type` | `String` | The type of operation (e.g., `Call`, `Create`, etc.), indicating the nature of the trace. |
| `from` | `String` | The address of the account that initiated the operation. |
| `to` | `String` | The recipient address of the call. For `Create` operations, this field is absent as the contract being created doesn't have an address until after the transaction completes. |
| `gas` | `String` | The amount of gas provided for the operation. |
| `gasUsed` | `String` | The amount of gas used by the operation. |
| `value` | `String` | The amount of Ether transferred during the operation. |
| `output` | `String` | The output from the operation. For operations that don't return data or failed, this is typically `0x`. |
| `input` | `String` | The data sent into the call or contract creation. |
| `error` | `String` | An error message if the operation failed. |
| `revertReason` | `String` | The reason provided by a `revert` operation, if applicable. |
| `calls` | `Array<Object>` | An array of nested calls made by this operation. This field is recursive, containing further traces of calls made by the traced operation. |

### Example Request

Expand Down
93 changes: 54 additions & 39 deletions content/20.api-reference/35.ethereum-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Ethereum JSON-RPC API
description:
---

zkSync Era supports the standard [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/).
zkSync Era supports the standard <a href="https://ethereum.org/en/developers/docs/apis/json-rpc/" target="_blank">Ethereum JSON-RPC API</a>.
Here you can find the JSON-RPC API methods for the `eth_` namespace.

## `eth_chainId`
Expand Down Expand Up @@ -583,7 +583,7 @@ curl --request POST \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1
"id": 1,
"method": "eth_getFilterChanges",
"params": [
"0x127e9eca4f7751fb4e5cb5291ad8b455"
Expand Down Expand Up @@ -810,7 +810,7 @@ curl --request POST \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1
"id": 1,
"method": "eth_getBlockByHash",
"params": [
"0x5046bdc714b2a9b40e9fbfdfc5140371c1b03b40335d908de92a7686dcc067e9",
Expand Down Expand Up @@ -898,7 +898,7 @@ curl --request POST \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1
"id": 1,
"method": "eth_getBlockTransactionCountByNumber",
"params": ["0x1d1551e"]
}'
Expand Down Expand Up @@ -1512,7 +1512,7 @@ A single string indicating the protocol version. The version is prefixed with an

| **Field** | **Type** | **Description** |
|-----------|----------|------------------------------------------------------|
| `result` | `String` | The Ethereum protocol version supported by the node. |
| `result` | `String` | The protocol version supported by the node. |

### Example Request

Expand Down Expand Up @@ -1590,40 +1590,16 @@ curl --request POST \

Returns a list of addresses owned by the client.

### Example Request

```sh
curl --request POST \
--url https://mainnet.era.zksync.io/ \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 2,
"method": "eth_accounts",
"params": []
}'
```

### Example Response

```json
{
"jsonrpc": "2.0",
"result": [],
"id": 2
}
```

## `eth_coinbase`

Returns the client's coinbase address.

### Parameters

This method does not require any parameters.

### Returns

| **Field** | **Type** | **Description** |
|-----------|-----------------|------------------------------------------------------|
| `result` | `Array<String>` | An array of account addresses owned by the client. |

### Example Request

```sh
Expand All @@ -1633,7 +1609,7 @@ curl --request POST \
--data '{
"jsonrpc": "2.0",
"id": 2,
"method": "eth_coinbase",
"method": "eth_accounts",
"params": []
}'
```
Expand All @@ -1643,7 +1619,7 @@ curl --request POST \
```json
{
"jsonrpc": "2.0",
"result": "0x0000000000000000000000000000000000000000",
"result": [],
"id": 2
}
```
Expand All @@ -1664,6 +1640,15 @@ Retrieves the fee history for the requested blocks.

### Returns

The method returns an object containing the following fields:

| **Field** | **Type** | **Description** |
|------------------|---------------------|---------------------------------------------------------|
| `oldestBlock` | `String` | The block number (in hex) of the oldest block queried. |
| `baseFeePerGas` | `Array<String>` | An array of base fees per gas, represented in hex, for each block. |
| `gasUsedRatio` | `Array<Float>` | An array of ratios of gas used by each block, represented as floats. |
| `reward` | `Array<Array<String>>` | An array of arrays containing the transaction fee rewards at specified percentiles, each represented in hex. |

### Example Request

```sh
Expand All @@ -1672,9 +1657,13 @@ curl --request POST \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 2,
"id": 1,
"method": "eth_feeHistory",
"params": []
"params": [
"10",
"0x3039",
[25.0, 50.0, 75.0]
]
}'
```

Expand All @@ -1683,8 +1672,25 @@ curl --request POST \
```json
{
"jsonrpc": "2.0",
"result": "",
"id": 2
"result": {
"oldestBlock": "0x302a",
"baseFeePerGas": [
"0xee6b280",
"0xee6b280",
"0xee6b280",
],
"gasUsedRatio": [
0.0,
0.0,
0.0,
],
"reward": [
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
["0x0", "0x0", "0x0"],
]
},
"id": 1
}
```

Expand All @@ -1697,8 +1703,17 @@ Retrieves the version of the client software.

### Parameters

This method does not require any parameters.

### Returns

A single string indicating the client version. The version is prefixed with an identifier
(e.g. "zkSync" for zkSync) followed by a version number.

| **Field** | **Type** | **Description** |
|-----------|----------|------------------------------------------------------|
| `result` | `String` | The client version supported by the node. |

### Example Request

```sh
Expand Down
Loading

0 comments on commit 8f3e584

Please sign in to comment.