mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
core/tracing: add code change reason type
This commit is contained in:
parent
3aeccadd04
commit
7a85fc1d1d
2 changed files with 61 additions and 0 deletions
29
core/tracing/gen_code_change_reason_stringer.go
Normal file
29
core/tracing/gen_code_change_reason_stringer.go
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Code generated by "stringer -type=CodeChangeReason -trimprefix=CodeChange -output gen_code_change_reason_stringer.go"; DO NOT EDIT.
|
||||||
|
|
||||||
|
package tracing
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
|
func _() {
|
||||||
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||||
|
// Re-run the stringer command to generate them again.
|
||||||
|
var x [1]struct{}
|
||||||
|
_ = x[CodeChangeUnspecified-0]
|
||||||
|
_ = x[CodeChangeContractCreation-1]
|
||||||
|
_ = x[CodeChangeGenesis-2]
|
||||||
|
_ = x[CodeChangeAuthorization-3]
|
||||||
|
_ = x[CodeChangeAuthorizationClear-4]
|
||||||
|
_ = x[CodeChangeSelfDestruct-5]
|
||||||
|
_ = x[CodeChangeRevert-6]
|
||||||
|
}
|
||||||
|
|
||||||
|
const _CodeChangeReason_name = "UnspecifiedContractCreationGenesisAuthorizationAuthorizationClearSelfDestructRevert"
|
||||||
|
|
||||||
|
var _CodeChangeReason_index = [...]uint8{0, 11, 27, 34, 47, 65, 77, 83}
|
||||||
|
|
||||||
|
func (i CodeChangeReason) String() string {
|
||||||
|
if i >= CodeChangeReason(len(_CodeChangeReason_index)-1) {
|
||||||
|
return "CodeChangeReason(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
|
}
|
||||||
|
return _CodeChangeReason_name[_CodeChangeReason_index[i]:_CodeChangeReason_index[i+1]]
|
||||||
|
}
|
||||||
|
|
@ -177,6 +177,9 @@ type (
|
||||||
// CodeChangeHook is called when the code of an account changes.
|
// 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)
|
CodeChangeHook = func(addr common.Address, prevCodeHash common.Hash, prevCode []byte, codeHash common.Hash, code []byte)
|
||||||
|
|
||||||
|
// CodeChangeHookV2 is called when the code of an account changes.
|
||||||
|
CodeChangeHookV2 = func(addr common.Address, prevCodeHash common.Hash, prevCode []byte, codeHash common.Hash, code []byte, reason CodeChangeReason)
|
||||||
|
|
||||||
// StorageChangeHook is called when the storage of an account changes.
|
// StorageChangeHook is called when the storage of an account changes.
|
||||||
StorageChangeHook = func(addr common.Address, slot common.Hash, prev, new common.Hash)
|
StorageChangeHook = func(addr common.Address, slot common.Hash, prev, new common.Hash)
|
||||||
|
|
||||||
|
|
@ -211,6 +214,7 @@ type Hooks struct {
|
||||||
OnNonceChange NonceChangeHook
|
OnNonceChange NonceChangeHook
|
||||||
OnNonceChangeV2 NonceChangeHookV2
|
OnNonceChangeV2 NonceChangeHookV2
|
||||||
OnCodeChange CodeChangeHook
|
OnCodeChange CodeChangeHook
|
||||||
|
OnCodeChangeV2 CodeChangeHookV2
|
||||||
OnStorageChange StorageChangeHook
|
OnStorageChange StorageChangeHook
|
||||||
OnLog LogHook
|
OnLog LogHook
|
||||||
// Block hash read
|
// Block hash read
|
||||||
|
|
@ -372,3 +376,31 @@ const (
|
||||||
// It is only emitted when the tracer has opted in to use the journaling wrapper (WrapWithJournal).
|
// It is only emitted when the tracer has opted in to use the journaling wrapper (WrapWithJournal).
|
||||||
NonceChangeRevert NonceChangeReason = 6
|
NonceChangeRevert NonceChangeReason = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CodeChangeReason is used to indicate the reason for a code change.
|
||||||
|
type CodeChangeReason byte
|
||||||
|
|
||||||
|
//go:generate go run golang.org/x/tools/cmd/stringer -type=CodeChangeReason -trimprefix=CodeChange -output gen_code_change_reason_stringer.go
|
||||||
|
|
||||||
|
const (
|
||||||
|
CodeChangeUnspecified CodeChangeReason = 0
|
||||||
|
|
||||||
|
// CodeChangeContractCreation is when a new contract is deployed via CREATE/CREATE2 operations.
|
||||||
|
CodeChangeContractCreation CodeChangeReason = 1
|
||||||
|
|
||||||
|
// CodeChangeGenesis is when contract code is set during blockchain genesis or initial setup.
|
||||||
|
CodeChangeGenesis CodeChangeReason = 2
|
||||||
|
|
||||||
|
// CodeChangeAuthorization is when code is set via EIP-7702 Set Code Authorization.
|
||||||
|
CodeChangeAuthorization CodeChangeReason = 3
|
||||||
|
|
||||||
|
// CodeChangeAuthorizationClear is when EIP-7702 delegation is cleared by setting to zero address.
|
||||||
|
CodeChangeAuthorizationClear CodeChangeReason = 4
|
||||||
|
|
||||||
|
// CodeChangeSelfDestruct is when contract code is cleared due to self-destruct.
|
||||||
|
CodeChangeSelfDestruct CodeChangeReason = 5
|
||||||
|
|
||||||
|
// CodeChangeRevert is emitted when the code 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).
|
||||||
|
CodeChangeRevert CodeChangeReason = 6
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue