Skip to content

Commit

Permalink
Merge branch 'main' into 1371-add-pub-network-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsmike62 committed Aug 4, 2023
2 parents c2db632 + 681e735 commit c8248c6
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 21 deletions.
32 changes: 20 additions & 12 deletions docs/private-networks/how-to/send-transactions/revert-reason.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract VendingMachine {

## Enable revert reason

Use the [`--revert-reason-enabled`](../../../public-networks/reference/cli/options.md#revert-reason-enabled) command line option to include the revert reason in the transaction receipt, [`eth_estimateGas`](../../../public-networks/reference/api/index.md#eth_estimategas) error, [`eth_call`](../../../public-networks/reference/api/index.md#eth_call) error, and [`trace`](../../../public-networks/reference/trace-types.md#trace) response in Hyperledger Besu.
Use the [`--revert-reason-enabled`](../../../public-networks/reference/cli/options.md#revert-reason-enabled) command line option to include the revert reason in the transaction receipt and the [`trace`](../../../public-networks/reference/trace-types.md#trace) response in Hyperledger Besu.

:::caution

Expand All @@ -54,11 +54,11 @@ With revert reason enabled, the transaction receipt returned by [`eth_getTransac

:::info

The revert reason is not included in the transactions receipt's root hash. Not including the revert reason in the transactions receipt's root hash means the revert reason is only available to nodes that execute the transaction when importing the block. That is, the revert reason is not available if using fast synchronization ([`--sync-mode=FAST`](../../../public-networks/reference/cli/options.md#sync-mode)).
The revert reason is not included in the transaction receipt's root hash. Not including the revert reason in the transactions receipt's root hash means the revert reason is only available to nodes that execute the transaction when importing the block. That is, the revert reason is not available if using fast synchronization ([`--sync-mode=FAST`](../../../public-networks/reference/cli/options.md#sync-mode)).

:::

```json
```json title="Example of transaction receipt"
{
"jsonrpc": "2.0",
"id": 1,
Expand All @@ -80,15 +80,9 @@ The revert reason is not included in the transactions receipt's root hash. Not i
}
```

The error returned by [`eth_estimateGas`](../../../public-networks/reference/api/index.md#eth_estimategas) and [`eth_call`](../../../public-networks/reference/api/index.md#eth_call) includes the revert reason as an ABI-encoded string in the `data` field.
With revert reason enabled, the list items in the [`trace`](../../../public-networks/reference/trace-types.md#trace) response returned by [`trace_replayBlockTransactions`](../../../public-networks/reference/api/index.md#trace_replayblocktransactions), [`trace_block`](../../../public-networks/reference/api/index.md#trace_block), and [`trace_transaction`](../../../public-networks/reference/api/index.md#trace_transaction) include the revert reason as an ABI-encoded string.

```json title="Exampleof `eth_estimateGas`and`eth_call` error" { "jsonrpc": "2.0", "id": 3, "error": { "code": -32000, "message": "Execution reverted", "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a4e6f7420656e6f7567682045746865722070726f76696465642e000000000000" } }

````
The list items in the [`trace`](../../../public-networks/reference/trace-types.md#trace) response returned by [`trace_replayBlockTransactions`](../../../public-networks/reference/api/index.md#trace_replayblocktransactions), [`trace_block`](../../../public-networks/reference/api/index.md#trace_block), and [`trace_transaction`](../../../public-networks/reference/api/index.md#trace_transaction) include the revert reason as an ABI-encoded string.
```json title="Example of `trace` response list item"
```json title="Example of trace response list item"
{
"jsonrpc": "2.0",
"id": 415,
Expand All @@ -114,7 +108,21 @@ The list items in the [`trace`](../../../public-networks/reference/trace-types.m
}
]
}
````
```

By default, the error returned by [`eth_estimateGas`](../../../public-networks/reference/api/index.md#eth_estimategas) and [`eth_call`](../../../public-networks/reference/api/index.md#eth_call) includes the revert reason as an ABI-encoded string in the `data` field.

```json title="Example of eth_estimateGas and eth_call error"
{
"jsonrpc": "2.0",
"id": 3,
"error": {
"code": -32000,
"message": "Execution reverted",
"data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a4e6f7420656e6f7567682045746865722070726f76696465642e000000000000"
}
}
```

## Revert reason format

Expand Down
103 changes: 96 additions & 7 deletions docs/public-networks/how-to/use-besu-api/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,119 @@ tags:

# Use GraphQL over HTTP

GraphQL can reduce the overhead needed for common queries. For example, instead of querying each receipt in a block, GraphQL can get the same result with a single query for the entire block.
GraphQL can reduce the overhead needed for common queries.
For example, instead of querying each receipt in a block, GraphQL can get the same result with a
single query for the entire block.

The [Besu GraphQL schema] describes the GraphQL implementation for Ethereum. Enable the GraphQL service using [command line options](index.md#enable-api-access).
The [Besu GraphQL schema] describes the GraphQL implementation for Ethereum.
Enable the GraphQL service using [command line options](index.md#enable-api-access).

:::note

GraphQL is not supported over WebSocket.

:::

Access the GraphQL endpoint at `http://<HOST>:<PORT>/graphql`. Configure `<HOST>` and `<PORT>` using [`graphql-http-host`](../../reference/cli/options.md#graphql-http-host) and [`graphql-http-port`](../../reference/cli/options.md#graphql-http-port). The default endpoint is `http://127.0.0.1:8547/graphql`.
Access the GraphQL endpoint at `http://<HOST>:<PORT>/graphql`.
Configure `<HOST>` and `<PORT>` using [`graphql-http-host`](../../reference/cli/options.md#graphql-http-host)
and [`graphql-http-port`](../../reference/cli/options.md#graphql-http-port).
The default endpoint is `http://127.0.0.1:8547/graphql`.

## GraphQL requests with cURL

[Hyperledger Besu JSON-RPC API methods](../../reference/api/index.md) with an equivalent [GraphQL](graphql.md) query include a GraphQL request and result in the method example.
[Hyperledger Besu JSON-RPC API methods](../../reference/api/index.md) with an equivalent
[GraphQL](graphql.md) query include a GraphQL request and result in the method example.

The following [`syncing`](../../reference/api/index.md#eth_syncing) request returns data about the synchronization status.
For example, the following request returns the block number:

<!--tabs-->

# Request

```bash
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{block{number}}"}' http://localhost:8547/graphql
```

# Response

```json
{
"data" : {
"block" : {
"number" : "0x281"
}
}
}
```

<!--/tabs-->

The following request returns the gas price:

<!--tabs-->

# Request

```bash
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{gasPrice}"}' http://localhost:8547/graphql
```

# Response

```json
{
"data" : {
"gasPrice" : "0x0"
}
}
```

<!--/tabs-->

The following [`syncing`](../../reference/api/index.md#eth_syncing) request returns data about the
synchronization status:

<!--tabs-->

# Request

```bash
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{syncing{startingBlock currentBlock highestBlock}}"}' http://localhost:8547/graphql
```

# Response

```json
{
"data" : {
"syncing" : {
"startingBlock" : 665,
"currentBlock" : 3190,
"highestBlock" : 26395
}
}
}
```

<!--/tabs-->

:::info note
In some cases, for example, when your node is fully synced, the syncing request returns a `null` response:

```json
{
"data" : {
"syncing" : null
}
}
```
:::

## GraphQL requests with GraphiQL app

The third-party tool, [GraphiQL](https://github.com/skevy/graphiql-app), provides a tabbed interface for editing and testing GraphQL queries and mutations. GraphiQL also provides access to the [Besu GraphQL schema] from within the app.
The third-party tool, [GraphiQL](https://github.com/skevy/graphiql-app), provides a tabbed interface
for editing and testing GraphQL queries and mutations.
GraphiQL also provides access to the [Besu GraphQL schema] from within the app.

![GraphiQL](../../../assets/images/GraphiQL.png)

Expand All @@ -43,7 +131,8 @@ The third-party tool, [GraphiQL](https://github.com/skevy/graphiql-app), provide

:::info

Besu does not execute pending transactions so results from `account`, `call`, and `estimateGas` for Pending do not reflect pending transactions.
Besu does not execute pending transactions so results from `account`, `call`, and `estimateGas` for
Pending do not reflect pending transactions.

:::

Expand Down
4 changes: 2 additions & 2 deletions docs/public-networks/reference/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ Invokes a contract function locally and does not change the state of the blockch
You can interact with contracts using [`eth_sendRawTransaction`](#eth_sendrawtransaction) or `eth_call`.
If revert reason is enabled with [`--revert-reason-enabled`](../cli/options.md#revert-reason-enabled), the `eth_call` error response includes the [revert reason](../../../private-networks/how-to/send-transactions/revert-reason.md).
By default, the `eth_call` error response includes the [revert reason](../../../private-networks/how-to/send-transactions/revert-reason.md).
#### Parameters
Expand Down Expand Up @@ -2080,7 +2080,7 @@ Returns an estimate of the gas required for a transaction to complete. The estim
The `eth_estimateGas` call does not send a transaction. You must call [`eth_sendRawTransaction`](#eth_sendrawtransaction) to execute the transaction.
If revert reason is enabled with [`--revert-reason-enabled`](../cli/options.md#revert-reason-enabled), the `eth_estimateGas` error response includes the [revert reason](../../../private-networks/how-to/send-transactions/revert-reason.md).
By default, the `eth_estimateGas` error response includes the [revert reason](../../../private-networks/how-to/send-transactions/revert-reason.md).
#### Parameters
Expand Down

0 comments on commit c8248c6

Please sign in to comment.