mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
docs/trace: add state/block overrides
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
c8f937f61e
commit
b0f2cdbc9c
2 changed files with 41 additions and 9 deletions
|
|
@ -498,7 +498,18 @@ Returns:
|
|||
|
||||
## State overrides {#state-overrides}
|
||||
|
||||
It is possible to give temporary state modifications to Geth in order to simulate the effects of `eth_call`. 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.
|
||||
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`. The state of the account.
|
||||
- `stateDiff`: `map[common.Hash]common.Hash`. The diff of the account.
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -508,6 +519,19 @@ 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 block header's fields to simulate the effects of `eth_call` or `debug_traceCall`, we support the following block header fields to override:
|
||||
|
||||
- `number`: `hexdecimal`. The block number.
|
||||
- `difficulty`: `hexdecimal`. The block hash.
|
||||
- `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}
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -579,11 +579,11 @@ References:
|
|||
|
||||
### debug_traceCall
|
||||
|
||||
The `debug_traceCall` method lets you run an `eth_call` within the context of the given block execution using the final state of parent block as the base. The first argument (just as in `eth_call`) is a [transaction object](/docs/interacting-with-geth/rpc/objects#transaction-call-object). The block can be specified either by hash or by number as the second argument. The trace can be configured similar to `debug_traceTransaction`, see [TraceConfig](#traceconfig). The method returns the same output as `debug_traceTransaction`.
|
||||
The `debug_traceCall` method lets you run an `eth_call` within the context of the given block execution using the final state of parent block as the base. The first argument (just as in `eth_call`) is a [transaction object](/docs/interacting-with-geth/rpc/objects#transaction-call-object). The block can be specified either by hash or by number as the second argument. The trace can be configured similar to `debug_traceTransaction`, see [TraceCallConfig](#tracecallconfig). The method returns the same output as `debug_traceTransaction`.
|
||||
|
||||
| Client | Method invocation |
|
||||
| :-----: | --------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Go | `debug.TraceCall(args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (*ExecutionResult, error)` |
|
||||
| :-----: | ------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Go | `debug.TraceCall(args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (*ExecutionResult, error)` |
|
||||
| Console | `debug.traceCall(object, blockNrOrHash, [options])` |
|
||||
| RPC | `{"method": "debug_traceCall", "params": [object, blockNrOrHash, {}]}` |
|
||||
|
||||
|
|
@ -629,7 +629,7 @@ It is possible to supply 'overrides' for both state-data (accounts/storage) and
|
|||
},
|
||||
"latest",
|
||||
{
|
||||
"blockoverrides": {"number": "0x50"}
|
||||
"blockOverrides": {"number": "0x50"}
|
||||
})
|
||||
{
|
||||
failed: false,
|
||||
|
|
@ -690,7 +690,7 @@ In addition to the hash of the transaction you may give it a secondary _optional
|
|||
- `tracer`: `STRING`. Name for built-in tracer or Javascript expression. See below for more details.
|
||||
- `timeout`: `STRING`. Overrides the default timeout of 5 seconds for each transaction tracing, valid values are described [here](https://golang.org/pkg/time/#ParseDuration).
|
||||
- `reexec`: `UINT64`. The number of blocks the tracer is willing to go back and re-execute to produce missing historical state necessary to run a specific trace. (default is 128).
|
||||
- `tracerConfig`: Config for the specified `tracer`. For example see callTracer's [config](/docs/developers/evm-tracing/built-in-tracers#config).
|
||||
- `tracerConfig`: Config for the specified `tracer`. For example see [callTracer's config](/docs/developers/evm-tracing/built-in-tracers#call-tracer-config).
|
||||
|
||||
Geth comes with a bundle of [built-in tracers](/docs/developers/evm-tracing/built-in-tracers), each providing various data about a transaction. This method defaults to the [struct logger](/docs/developers/evm-tracing/built-in-tracers#structopcode-logger). The `tracer` field of the second parameter can be set to use any of the other tracers. Alternatively a [custom tracer](/docs/developers/evm-tracing/custom-tracer) can be implemented in either Go or Javascript.
|
||||
|
||||
|
|
@ -730,6 +730,14 @@ Geth comes with a bundle of [built-in tracers](/docs/developers/evm-tracing/buil
|
|||
}]
|
||||
```
|
||||
|
||||
#### TraceCallConfig
|
||||
|
||||
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.
|
||||
- `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.
|
||||
- `txIndex`: `NUMBER`. If set, the state at the the given transaction index will be used to tracing (default = the last transaction index in the block).
|
||||
|
||||
### debug_verbosity
|
||||
|
||||
Sets the logging verbosity ceiling. Log messages with level up to and including the given level will be printed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue