-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
8659e68
core/tracing: add vm context to system call hook
s1na b4e0174
core/tracing: add GetCodeHash to statedb interface
s1na f670a7f
core/tracing: emit state change events for journal reverts
s1na cf873c3
core/tracing: add hook for reverted out blocks
s1na 365b715
log selfdestructs balance revert
s1na aac4024
Add state read hooks
s1na dbe5f83
add tracing journal
s1na b87c4fe
update changelog
s1na 702a42f
fix indent
s1na c915bed
add block hash read hook
s1na 838fc25
resolve merge conflict
s1na 1cc58cf
fix code and nonce param order
s1na 3c58155
update test
s1na 501f302
pass-through non-journaled hooks
s1na 1a64297
missed two hooks
s1na 1862333
fix journal cur rev Id
s1na 6650000
add note on balanceChangeRevert reason
s1na d9de74e
refactor WrapWithJournal to use reflection
s1na d2ba76f
add license to journal_test
s1na a2ca5f8
add desc for revert change reason
s1na 85a85d0
add OnSystemCallStartV2
s1na 2754b41
drop OnReorg
s1na 92337d8
rm newline
s1na 36b4194
Merge branch 'master' into tracing/v1.1
s1na efed5a6
fix OnTxEnd
s1na ea92ef4
Merge branch 'master' into tracing/v1.1
s1na fbd1d19
fix pre-post block process fns
s1na 0f005af
mv read hooks to statedb_hooked
s1na 5e4d6b8
add whitespace
s1na 4d2fb0e
update changelog
s1na b37f2ac
Merge branch 'master' into tracing/v1.1
s1na a0f7cd6
Add test for all underlying hooks being called
s1na 87582a4
Merge branch 'master' into tracing/v1.1
s1na 6e4d14c
resolve merge conflict
s1na 553f023
handle creation nonce in journal
s1na be93d72
Merge branch 'master' into tracing/v1.1
s1na 1dda30d
Merge branch 'master' into tracing/v1.1
s1na 4acea3b
rm OnCodeSizeRead
s1na 018df6b
rm onreorg type
s1na 60b2222
wrapper func for OnSystemCallStart
s1na 6c56ea5
update changelog
s1na f4cf2a5
Merge branch 'master' into tracing/v1.1
s1na 7fb2688
run go generate
s1na 3228063
rm read hooks
s1na 95b82cf
lint issue
s1na de48d55
fix changelog
s1na 9cae376
un-expose hooks copy
s1na bf51dde
Merge branch 'master' into tracing/v1.1
s1na 459c50f
refactor copy
s1na 831524a
Merge branch 'master' into tracing/v1.1
fjl 6f5e74b
Use nonce reason in journal
s1na bca2e2c
resolve conflict
s1na 8a2230e
resolve conflict
s1na 59a5022
fix test
s1na 4ba05e9
core/tracing: add logging in journal test
fjl 2795c0e
core/tracing: simplify journal implementation
fjl 51720dc
core/tracing: further improve journal tests
fjl 4787f31
core/tracing: remove Hooks.copy
fjl 8a44029
core/tracing: add note about WrapWithJournal in comments
fjl eaacae4
core/tracing: add a package-level doc comment
fjl 93432fc
license year
s1na File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ type StateDB interface { | |
| GetBalance(common.Address) *uint256.Int | ||
| GetNonce(common.Address) uint64 | ||
| GetCode(common.Address) []byte | ||
| GetCodeHash(common.Address) common.Hash | ||
| GetState(common.Address, common.Hash) common.Hash | ||
| Exist(common.Address) bool | ||
| GetRefund() uint64 | ||
|
|
@@ -133,6 +134,9 @@ type ( | |
| // GenesisBlockHook is called when the genesis block is being processed. | ||
| GenesisBlockHook = func(genesis *types.Block, alloc types.GenesisAlloc) | ||
|
|
||
| // ReorgHook is called when a segment of the chain is reverted. | ||
| ReorgHook = func(reverted []*types.Block) | ||
|
|
||
| // OnSystemCallStartHook is called when a system call is about to be executed. Today, | ||
| // this hook is invoked when the EIP-4788 system call is about to be executed to set the | ||
| // beacon block root. | ||
|
|
@@ -142,7 +146,7 @@ type ( | |
| // | ||
| // Note that system call happens outside normal transaction execution, so the `OnTxStart/OnTxEnd` hooks | ||
| // will not be invoked. | ||
| OnSystemCallStartHook = func() | ||
| OnSystemCallStartHook = func(vm *VMContext) | ||
|
|
||
| // OnSystemCallEndHook is called when a system call has finished executing. Today, | ||
| // this hook is invoked when the EIP-4788 system call is about to be executed to set the | ||
|
|
@@ -167,6 +171,24 @@ type ( | |
|
|
||
| // LogHook is called when a log is emitted. | ||
| LogHook = func(log *types.Log) | ||
|
|
||
| // BalanceReadHook is called when EVM reads the balance of an account. | ||
| BalanceReadHook = func(addr common.Address, bal *big.Int) | ||
|
|
||
| // NonceReadHook is called when EVM reads the nonce of an account. | ||
| NonceReadHook = func(addr common.Address, nonce uint64) | ||
|
|
||
| // CodeReadHook is called when EVM reads the code of an account. | ||
| CodeReadHook = func(addr common.Address, code []byte) | ||
|
||
|
|
||
| // CodeSizeReadHook is called when EVM reads the code size of an account. | ||
| CodeSizeReadHook = func(addr common.Address, size int) | ||
|
|
||
| // CodeHashReadHook is called when EVM reads the code hash of an account. | ||
| CodeHashReadHook = func(addr common.Address, hash common.Hash) | ||
|
|
||
| // StorageReadHook is called when EVM reads a storage slot of an account. | ||
| StorageReadHook = func(addr common.Address, slot, value common.Hash) | ||
| ) | ||
|
|
||
| type Hooks struct { | ||
|
|
@@ -185,6 +207,7 @@ type Hooks struct { | |
| OnBlockEnd BlockEndHook | ||
| OnSkippedBlock SkippedBlockHook | ||
| OnGenesisBlock GenesisBlockHook | ||
| OnReorg ReorgHook | ||
| OnSystemCallStart OnSystemCallStartHook | ||
| OnSystemCallEnd OnSystemCallEndHook | ||
| // State events | ||
|
|
@@ -193,6 +216,13 @@ type Hooks struct { | |
| OnCodeChange CodeChangeHook | ||
| OnStorageChange StorageChangeHook | ||
| OnLog LogHook | ||
| // State reads | ||
| OnBalanceRead BalanceReadHook | ||
| OnNonceRead NonceReadHook | ||
|
||
| OnCodeRead CodeReadHook | ||
| OnCodeSizeRead CodeSizeReadHook | ||
| OnCodeHashRead CodeHashReadHook | ||
| OnStorageRead StorageReadHook | ||
| } | ||
|
|
||
| // BalanceChangeReason is used to indicate the reason for a balance change, useful | ||
|
|
@@ -244,6 +274,9 @@ 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
|
||
| BalanceChangeRevert BalanceChangeReason = 15 | ||
| ) | ||
|
|
||
| // GasChangeReason is used to indicate the reason for a gas change, useful | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consensus was to drop Reorg hook for now because it's not clear what the best API would be. We can shit the rest and then iterate on this one with whoever wants to use it before comitting.