Skip to content
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

Merged
merged 2 commits into from
Oct 18, 2024
Merged

rpcdaemon: Split ComputeTxEnv #12325

merged 2 commits into from
Oct 18, 2024

Conversation

shohamc1
Copy link
Member

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.

turbo/transactions/tracing.go Show resolved Hide resolved
@@ -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) {
Copy link
Collaborator

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


// 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) {
Copy link
Collaborator

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.

Copy link
Member Author

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.

turbo/transactions/tracing.go Outdated Show resolved Hide resolved
@@ -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)
Copy link
Collaborator

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)

@AskAlexSharov AskAlexSharov added this to the 3.0.0-alpha6 milestone Oct 16, 2024
@shohamc1 shohamc1 enabled auto-merge (squash) October 18, 2024 03:52
@shohamc1 shohamc1 merged commit ea2ca63 into main Oct 18, 2024
11 checks passed
@shohamc1 shohamc1 deleted the shohamc1/better-ibs branch October 18, 2024 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants