mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
fix state/block override refs
This commit is contained in:
parent
2f5d60e550
commit
5e729fd005
4 changed files with 29 additions and 70 deletions
|
|
@ -497,42 +497,6 @@ Returns:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## State overrides {#state-overrides}
|
|
||||||
|
|
||||||
It is possible to give temporary state modifications to Geth in order to simulate the effects of `eth_call` or `debug_traceCall`. For example, some new bytecode could be deployed to some address _temporarily just for the duration of the execution_ and then a transaction interacting with that address can be traced. This can be used for scenario testing or determining the outcome of some hypothetical transaction before executing for real.
|
|
||||||
|
|
||||||
Available state overrides are:
|
|
||||||
|
|
||||||
- `nonce`: `hexdecimal`. The nonce of the account.
|
|
||||||
- `code`: `string`. The bytecode of the account.
|
|
||||||
- `balance`: `hexdecimal`. The balance of the account in Wei.
|
|
||||||
- `state`: `map[common.Hash]common.Hash`. Clear all storage slots of the account and insert the ones given in the dictionary.
|
|
||||||
- `stateDiff`: `map[common.Hash]common.Hash`. Update the given storage slots with new values.
|
|
||||||
|
|
||||||
Note, `state` and `stateDiff` can't be specified at the same time. If `state` is
|
|
||||||
set, message execution will only use the data in the given state. Otherwise if `statDiff` is set, all diff will be applied first and then execute the call.
|
|
||||||
|
|
||||||
To do this, the tracer is written as normal, but the parameter `stateOverrides` is passed an address and some bytecode.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var code = //contract bytecode
|
|
||||||
var tracer = //tracer name
|
|
||||||
debug.traceCall({from: , to: , input: }, 'latest', {stateOverrides: {'0x...': {code: code}}, tracer: tracer})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Block overrides {#block-overrides}
|
|
||||||
|
|
||||||
Similar to [State overrides](#state-overrides), it is also possible to override some of the execution's block context to simulate the effects of `eth_call` or `debug_traceCall`, we support the following override options:
|
|
||||||
|
|
||||||
- `number`: `hexdecimal`. The block number.
|
|
||||||
- `difficulty`: `hexdecimal`. The block difficulty.
|
|
||||||
- `time`: `hexdecimal`. The block timestamp.
|
|
||||||
- `gasLimit`: `hexdecimal`. The block gas limit.
|
|
||||||
- `coinbase`: `common.Address`. The block coinbase.
|
|
||||||
- `random`: `common.Hash`. The block PREVRANDAO.
|
|
||||||
- `baseFee`: `hexdecimal`. The block base fee.
|
|
||||||
- `blobBaseFee`: `hexdecimal`. The block blob base fee.
|
|
||||||
|
|
||||||
## Summary {#summary}
|
## Summary {#summary}
|
||||||
|
|
||||||
This page showed how to use the tracers that come bundled with Geth. There are a set written in Go and a set written in Javascript. They are invoked by passing their names when calling an API method. State overrides can be used in combination with tracers to examine precisely what the EVM will do in some hypothetical scenarios.
|
This page showed how to use the tracers that come bundled with Geth. There are a set written in Go and a set written in Javascript. They are invoked by passing their names when calling an API method. State overrides can be used in combination with tracers to examine precisely what the EVM will do in some hypothetical scenarios.
|
||||||
|
|
|
||||||
|
|
@ -591,8 +591,8 @@ The `debug_traceCall` method lets you run an `eth_call` within the context of th
|
||||||
|
|
||||||
TraceCallConfig is a superset of [TraceConfig](#traceconfig), providing additional arguments in addition to those provided by [TraceConfig](#traceconfig):
|
TraceCallConfig is a superset of [TraceConfig](#traceconfig), providing additional arguments in addition to those provided by [TraceConfig](#traceconfig):
|
||||||
|
|
||||||
- `stateOverrides`: `StateOverride`. Overrides for the state data (accounts/storage) for the call, see [StateOverride](/docs/developers/evm-tracing/built-in-tracers#state-overrides) for more details.
|
- `stateOverrides`: `StateOverride`. Overrides for the state data (accounts/storage) for the call, see [StateOverride](/docs/interacting-with-geth/rpc/objects#state-override-set) for more details.
|
||||||
- `blockOverrides`: `BlockOverrides`. Overrides for the block data (number, timestamp etc) for the call, see [BlockOverrides](/docs/developers/evm-tracing/built-in-tracers#block-overrides) for more details.
|
- `blockOverrides`: `BlockOverrides`. Overrides for the block data (number, timestamp etc) for the call, see [BlockOverrides](/docs/interacting-with-geth/rpc/objects#block-overrides) for more details.
|
||||||
- `txIndex`: `NUMBER`. If set, the state at the given transaction index will be used to tracing (default = the last transaction index in the block).
|
- `txIndex`: `NUMBER`. If set, the state at the given transaction index will be used to tracing (default = the last transaction index in the block).
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
|
||||||
|
|
@ -28,25 +28,7 @@ The `eth_simulate` payload structure:
|
||||||
| `stateOverrides` | `StateOverrides` | State overrides can be used to replace existing blockchain state with new state. |
|
| `stateOverrides` | `StateOverrides` | State overrides can be used to replace existing blockchain state with new state. |
|
||||||
| `calls` | `GenericCallTransaction[]` | An aray of transaction call objects. Please see [Transaction Call Object](/docs/interacting-with-geth/rpc/objects#transaction-call-object) for details. |
|
| `calls` | `GenericCallTransaction[]` | An aray of transaction call objects. Please see [Transaction Call Object](/docs/interacting-with-geth/rpc/objects#transaction-call-object) for details. |
|
||||||
|
|
||||||
The `BlockOverrides` object is as follows:
|
The optional `BlockOverrides` object modifies the context in which the transactions of that given block are executed. Refer to [Block overrides](/docs/interacting-with-geth/rpc/objects#block-overrides) for a list of modifiable fields. When overriding multiple blocks, block numbers must increment. Skipping numbers is allowed and skipped blocks are included in the response. When overriding time across multiple blocks, time need to be increasing. If time is not specified, it's incremented by one for each block.
|
||||||
| Field | Type | Description |
|
|
||||||
| :-------------- | :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `number` | `uint64` | Block number. When overriding multiple blocks, block numbers must increment. Skipping numbers is allowed and skipped blocks are included in the response. |
|
|
||||||
| `prevRandao` | `uint256` | The previous value of randomness beacon |
|
|
||||||
| `time` | `uint64` | When overriding time across multiple blocks, time need to be increasing. If time is not specified, it's incremented by one for each block. |
|
|
||||||
| `gasLimit` | `uint64` | Gas limit |
|
|
||||||
| `feeRecipient` | `address` | Fee recipient (also known as coinbase) |
|
|
||||||
| `withdrawals` | `Withdrawals` | Withdrawals made by validators |
|
|
||||||
| `baseFeePerGas` | `uint256` | Base fee per unit of gas |
|
|
||||||
| `blobBaseFee` | `uint64` | Base fee per unit of blob gas |
|
|
||||||
|
|
||||||
The object `withdrawals` is an array of withdrawal objects:
|
|
||||||
| Field | Type | Description |
|
|
||||||
| :--------------- | :-------- | :-------------- |
|
|
||||||
| `index` | `uint64` | index |
|
|
||||||
| `validatorIndex` | `uint64` | validator index |
|
|
||||||
| `address` | `address` | address |
|
|
||||||
| `amount` | `uint64` | amount |
|
|
||||||
|
|
||||||
The StateOverrides is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing each block. Please see [State Override Set](/docs/interacting-with-geth/rpc/objects#state-override-set) for details.
|
The StateOverrides is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing each block. Please see [State Override Set](/docs/interacting-with-geth/rpc/objects#state-override-set) for details.
|
||||||
|
|
||||||
|
|
@ -238,18 +220,7 @@ The _state override set_ is an optional address-to-state mapping, where each ent
|
||||||
|
|
||||||
4. `Object` - Block override set
|
4. `Object` - Block override set
|
||||||
|
|
||||||
The fields of this optional object customize the block as part of which the call is simulated. The object contains the following fields:
|
The _block override set_ is an optional object with the purpose of modifying the context in which the call is executed. Refer to [Block overrides](/docs/interacting-with-geth/rpc/objects#block-overrides) for a rundown of the fields.
|
||||||
|
|
||||||
| Field | Type | Bytes | Optional | Description |
|
|
||||||
|---------------|----------|-------|----------|----------------------------------------------------------|
|
|
||||||
| `number` | Quantity | <32 | Yes | Fake block number |
|
|
||||||
| `difficulty` | Quantity | <32 | Yes | Fake difficulty. Note post-merge difficulty should be 0. |
|
|
||||||
| `time` | Quantity | <8 | Yes | Fake block timestamp |
|
|
||||||
| `gasLimit` | Quantity | <8 | Yes | Block gas capacity |
|
|
||||||
| `coinbase` | String | 20 | Yes | Block fee recipient |
|
|
||||||
| `random` | Binary | 32 | Yes | Fake PrevRandao value |
|
|
||||||
| `baseFee` | Quantity | <32 | Yes | Block base fee (see EIP-1559) |
|
|
||||||
| `blobBaseFee` | Quantity | <32 | Yes | Block blob base fee (see EIP-4844) |
|
|
||||||
|
|
||||||
|
|
||||||
**Response:**
|
**Response:**
|
||||||
|
|
|
||||||
|
|
@ -111,3 +111,27 @@ The goal of the _state override set_ is manyfold:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Block overrides
|
||||||
|
|
||||||
|
The fields of this object customize the block as part of which a call is simulated. This object can be passed to eth_call, eth_simulateV1 as well as debug_traceCall methods and contains the following fields:
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
| :-------------- | :------------ | :----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `number` | `uint64` | Block number. |
|
||||||
|
| `prevRandao` | `uint256` | The previous value of randomness beacon. |
|
||||||
|
| `time` | `uint64` | Block timestamp. |
|
||||||
|
| `gasLimit` | `uint64` | Gas limit. |
|
||||||
|
| `feeRecipient` | `address` | Fee recipient (also known as coinbase). |
|
||||||
|
| `withdrawals` | `Withdrawals` | Withdrawals made by validators. |
|
||||||
|
| `baseFeePerGas` | `uint256` | Base fee per unit of gas (see EIP-1559). |
|
||||||
|
| `blobBaseFee` | `uint64` | Base fee per unit of blob gas (see EIP-4844). |
|
||||||
|
|
||||||
|
The object `withdrawals` is an array of withdrawal objects:
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
| :--------------- | :-------- | :-------------- |
|
||||||
|
| `index` | `uint64` | index |
|
||||||
|
| `validatorIndex` | `uint64` | validator index |
|
||||||
|
| `address` | `address` | address |
|
||||||
|
| `amount` | `uint64` | amount |
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue