-
Notifications
You must be signed in to change notification settings - Fork 21.5k
core/tracing: state journal wrapper #30441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8659e68
b4e0174
f670a7f
cf873c3
365b715
aac4024
dbe5f83
b87c4fe
702a42f
c915bed
838fc25
1cc58cf
3c58155
501f302
1a64297
1862333
6650000
d9de74e
d2ba76f
a2ca5f8
85a85d0
2754b41
92337d8
36b4194
efed5a6
ea92ef4
fbd1d19
0f005af
5e4d6b8
4d2fb0e
b37f2ac
a0f7cd6
87582a4
6e4d14c
553f023
be93d72
1dda30d
4acea3b
018df6b
60b2222
6c56ea5
f4cf2a5
7fb2688
3228063
95b82cf
de48d55
9cae376
bf51dde
459c50f
831524a
6f5e74b
bca2e2c
8a2230e
59a5022
4ba05e9
2795c0e
51720dc
4787f31
8a44029
eaacae4
93432fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,14 @@ | |
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| // Package tracing defines hooks for 'live tracing' of block processing and transaction | ||
| // execution. Here we define the low-level [Hooks] object that carries hooks which are | ||
| // invoked by the go-ethereum core at various points in the state transition. | ||
| // | ||
| // To create a tracer that can be invoked with Geth, you need to register it using | ||
| // [github.com/ethereum/go-ethereum/eth/tracers.LiveDirectory.Register]. | ||
| // | ||
| // See https://geth.ethereum.org/docs/developers/evm-tracing/live-tracing for a tutorial. | ||
| package tracing | ||
|
|
||
| import ( | ||
|
|
@@ -163,6 +171,9 @@ type ( | |
| // NonceChangeHook is called when the nonce of an account changes. | ||
| NonceChangeHook = func(addr common.Address, prev, new uint64) | ||
|
|
||
| // NonceChangeHookV2 is called when the nonce of an account changes. | ||
| NonceChangeHookV2 = func(addr common.Address, prev, new uint64, reason NonceChangeReason) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have chosen this naming scheme explicitly. The intent is communicating which version of the hook is the newest one. When we introduce a new hook version, the old one becomes deprecated and will eventually be unsupported. Also, if we were to introduce another revision of this hook, would it be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the old one is removed, you can remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot rename the function because it is a stable, user-exposed API. If we could just change it, we wouldn't go through the trouble of having multiple versions of the hook. |
||
|
|
||
| // CodeChangeHook is called when the code of an account changes. | ||
| CodeChangeHook = func(addr common.Address, prevCodeHash common.Hash, prevCode []byte, codeHash common.Hash, code []byte) | ||
|
|
||
|
|
@@ -171,6 +182,9 @@ type ( | |
|
|
||
| // LogHook is called when a log is emitted. | ||
| LogHook = func(log *types.Log) | ||
|
|
||
| // BlockHashReadHook is called when EVM reads the blockhash of a block. | ||
| BlockHashReadHook = func(blockNumber uint64, hash common.Hash) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use-case is to have access to the headers of hashes that are accessed by the EVM. Alternative would be if we added a GetHeaderByHash method somewhere. But getting the hash from OnOpcode is also tricky since the hash will be put on the stack after OnOpcode is invoked. |
||
| ) | ||
|
|
||
| type Hooks struct { | ||
|
|
@@ -195,9 +209,12 @@ type Hooks struct { | |
| // State events | ||
| OnBalanceChange BalanceChangeHook | ||
| OnNonceChange NonceChangeHook | ||
| OnNonceChangeV2 NonceChangeHookV2 | ||
| OnCodeChange CodeChangeHook | ||
| OnStorageChange StorageChangeHook | ||
| OnLog LogHook | ||
| // Block hash read | ||
| OnBlockHashRead BlockHashReadHook | ||
| } | ||
|
|
||
| // BalanceChangeReason is used to indicate the reason for a balance change, useful | ||
|
|
@@ -249,6 +266,10 @@ const ( | |
| // account within the same tx (captured at end of tx). | ||
| // Note it doesn't account for a self-destruct which appoints itself as recipient. | ||
| BalanceDecreaseSelfdestructBurn BalanceChangeReason = 14 | ||
|
|
||
| // BalanceChangeRevert is emitted when the balance is reverted back to a previous value due to call failure. | ||
s1na marked this conversation as resolved.
Show resolved
Hide resolved
s1na marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // It is only emitted when the tracer has opted in to use the journaling wrapper (WrapWithJournal). | ||
| BalanceChangeRevert BalanceChangeReason = 15 | ||
| ) | ||
|
|
||
| // GasChangeReason is used to indicate the reason for a gas change, useful | ||
|
|
@@ -321,3 +342,29 @@ const ( | |
| // it will be "manually" tracked by a direct emit of the gas change event. | ||
| GasChangeIgnored GasChangeReason = 0xFF | ||
| ) | ||
|
|
||
| // NonceChangeReason is used to indicate the reason for a nonce change. | ||
| type NonceChangeReason byte | ||
|
|
||
| const ( | ||
| NonceChangeUnspecified NonceChangeReason = 0 | ||
|
|
||
| // NonceChangeGenesis is the nonce allocated to accounts at genesis. | ||
| NonceChangeGenesis NonceChangeReason = 1 | ||
|
|
||
| // NonceChangeEoACall is the nonce change due to an EoA call. | ||
| NonceChangeEoACall NonceChangeReason = 2 | ||
|
|
||
| // NonceChangeContractCreator is the nonce change of an account creating a contract. | ||
| NonceChangeContractCreator NonceChangeReason = 3 | ||
|
|
||
| // NonceChangeNewContract is the nonce change of a newly created contract. | ||
| NonceChangeNewContract NonceChangeReason = 4 | ||
|
|
||
| // NonceChangeTransaction is the nonce change due to a EIP-7702 authorization. | ||
| NonceChangeAuthorization NonceChangeReason = 5 | ||
|
|
||
| // NonceChangeRevert is emitted when the nonce is reverted back to a previous value due to call failure. | ||
| // It is only emitted when the tracer has opted in to use the journaling wrapper (WrapWithJournal). | ||
| NonceChangeRevert NonceChangeReason = 6 | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.