-
Notifications
You must be signed in to change notification settings - Fork 21.9k
eth/catalyst: add initial OpenTelemetry tracing for newPayload #33521
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 17 commits
3ca7721
1c17380
4b13763
b616d63
2c270e2
282e2db
5731ca5
402d36d
0d2fc33
646be76
3a6ff92
65b6b78
adb8e8f
e68c5b2
fee1233
2d6a0e8
c2c24ea
453061f
ec5f992
dd6f692
2cdb9ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| package core | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "math/big" | ||
|
|
||
|
|
@@ -27,6 +28,7 @@ import ( | |
| "github.com/ethereum/go-ethereum/core/types" | ||
| "github.com/ethereum/go-ethereum/core/vm" | ||
| "github.com/ethereum/go-ethereum/crypto" | ||
| "github.com/ethereum/go-ethereum/internal/telemetry" | ||
| "github.com/ethereum/go-ethereum/params" | ||
| ) | ||
|
|
||
|
|
@@ -57,7 +59,7 @@ func (p *StateProcessor) chainConfig() *params.ChainConfig { | |
| // Process returns the receipts and logs accumulated during the process and | ||
| // returns the amount of gas that was used in the process. If any of the | ||
| // transactions failed to execute due to insufficient gas it will return an error. | ||
| func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (*ProcessResult, error) { | ||
| func (p *StateProcessor) Process(ctx context.Context, block *types.Block, statedb *state.StateDB, cfg vm.Config) (*ProcessResult, error) { | ||
| var ( | ||
| config = p.chainConfig() | ||
| receipts types.Receipts | ||
|
|
@@ -101,18 +103,42 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg | |
| return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) | ||
| } | ||
| statedb.SetTxContext(tx.Hash(), i) | ||
|
|
||
| _, _, spanEnd := telemetry.StartSpan(ctx, "core.ApplyTransactionWithEVM", | ||
| telemetry.StringAttribute("tx.hash", tx.Hash().Hex()), | ||
| telemetry.Int64Attribute("tx.index", int64(i)), | ||
| ) | ||
| receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, context.Time, tx, usedGas, evm) | ||
| spanEnd(&err) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) | ||
| } | ||
| receipts = append(receipts, receipt) | ||
| allLogs = append(allLogs, receipt.Logs...) | ||
| } | ||
| requests, err := postExecution(ctx, config, block, allLogs, evm) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) | ||
| p.chain.Engine().Finalize(p.chain, header, tracingStateDB, block.Body()) | ||
|
|
||
| return &ProcessResult{ | ||
| Receipts: receipts, | ||
| Requests: requests, | ||
| Logs: allLogs, | ||
| GasUsed: *usedGas, | ||
| }, nil | ||
| } | ||
|
|
||
| // postExecution processes the post-execution system calls if Prague is enabled. | ||
| func postExecution(ctx context.Context, config *params.ChainConfig, block *types.Block, allLogs []*types.Log, evm *vm.EVM) (requests [][]byte, err error) { | ||
| _, _, spanEnd := telemetry.StartSpan(ctx, "core.postExecution") | ||
| defer spanEnd(&err) | ||
|
|
||
| // Read requests if Prague is enabled. | ||
| var requests [][]byte | ||
| if config.IsPrague(block.Number(), block.Time()) { | ||
| requests = [][]byte{} | ||
| var requests [][]byte | ||
| // EIP-6110 | ||
| if err := ParseDepositLogs(&requests, allLogs, config); err != nil { | ||
| return nil, fmt.Errorf("failed to parse deposit logs: %w", err) | ||
|
|
@@ -127,15 +153,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg | |
| } | ||
| } | ||
|
||
|
|
||
| // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) | ||
| p.chain.Engine().Finalize(p.chain, header, tracingStateDB, block.Body()) | ||
|
|
||
| return &ProcessResult{ | ||
| Receipts: receipts, | ||
| Requests: requests, | ||
| Logs: allLogs, | ||
| GasUsed: *usedGas, | ||
| }, nil | ||
| return requests, nil | ||
| } | ||
|
|
||
| // ApplyTransactionWithEVM attempts to apply a transaction to the given state database | ||
|
|
||
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.
@fjl This is the line that breaks blockchain tests. For some reason, it is expected to return a non-nil requests list post-prague if there are no requests.
Seems to do with the hash of a
nilrequests not matching that of an empty one.