-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rpcdaemon: Split ComputeTxEnv #12325
Conversation
@@ -83,13 +85,13 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ | |||
msg, _ := txn.AsMessage(*signer, block.BaseFee(), rules) | |||
if msg.FeeCap().IsZero() && engine != nil { | |||
syscall := func(contract libcommon.Address, data []byte) ([]byte, error) { |
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.
this closure is same for all txs
turbo/transactions/tracing.go
Outdated
|
||
// ComputeTxContext returns the execution environment of a certain transaction. | ||
func ComputeTxContext(blockContext evmtypes.BlockContext, statedb *state.IntraBlockState, engine consensus.EngineReader, block *types.Block, cfg *chain.Config, txIndex int) (core.Message, evmtypes.TxContext, error) { |
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.
if you don't need *types.Block
then pls use *types.Header
- because in Erigon3 many RPC API's are executing individual transactions (instead of whole block) - and for that API's no much reason to read whole block
from DB.
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.
I think for this set of RPCs we read the whole block anyways since we need the header in addition to the transaction. This change would need refactoring the RPC code which is out of the scope of this PR, which is aiming to get state sync transaction tracing working.
@@ -83,13 +85,13 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ | |||
msg, _ := txn.AsMessage(*signer, block.BaseFee(), rules) | |||
if msg.FeeCap().IsZero() && engine != nil { | |||
syscall := func(contract libcommon.Address, data []byte) ([]byte, error) { | |||
return core.SysCallContract(contract, data, cfg, statedb, header, engine, true /* constCall */) | |||
return core.SysCallContract(contract, data, cfg, statedb, block.HeaderNoCopy(), engine, true /* constCall */) | |||
} | |||
msg.SetIsFree(engine.IsServiceTransaction(msg.From(), syscall)) | |||
} | |||
|
|||
TxContext := core.NewEVMTxContext(msg) |
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.
NewEVMTxContext
returns non-pointer types - then no much profit in creating intermediate variable (it will copy anyway)
A follow up to #12316, instead of relaxing conditions on
ComputeTxEnv
which may cause unintended edge cases, we split the function into two smaller, well-defined functions. When tracing state sync events, we do not care about generating TxContext so we can skip validation surrounding it.