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

Native call tracer (block mode) does not have a way to populate txHash #24655

Closed
evanzbitgo opened this issue Apr 6, 2022 · 5 comments · Fixed by #24679
Closed

Native call tracer (block mode) does not have a way to populate txHash #24655

evanzbitgo opened this issue Apr 6, 2022 · 5 comments · Fixed by #24679
Assignees

Comments

@evanzbitgo
Copy link

evanzbitgo commented Apr 6, 2022

Rationale

Why should this feature exist?
When tracing a block with call tracer, we need to know the txHash of each transaction. Unfortunately, we have no way to populate that txHash even with custom tracer.

What are the use-cases?
We need have a reliable way to map a txHash to its traces. Without this feature, we have to rely on the transaction order within the block which does not give us a strong confidence of correctness.

Implementation

Do you have ideas regarding the implementation of this feature?
We need to add txHash into TxContext struct

Are you willing to implement this feature?
Yes

@karalabe
Copy link
Member

karalabe commented Apr 7, 2022

The trace order must be the same as the transaction order in the block. Why would it be different?

@holiman
Copy link
Contributor

holiman commented Apr 7, 2022

We already have this for js-tracers, via the constructor. It would be pretty easy to modify this function, in native/tracers.go

// lookup returns a tracer, if one can be matched to the given name.
func lookup(name string, ctx *tracers.Context) (tracers.Tracer, error) {
	if ctors == nil {
		ctors = make(map[string]func() tracers.Tracer)
	}
	if ctor, ok := ctors[name]; ok {
		return ctor(), nil
	}
	return nil, errors.New("no tracer found")
}

to also pass the ctx to the constructor for the native tracer. The ctx contains the txindex and txhash. cc @s1na

@s1na s1na self-assigned this Apr 7, 2022
@evanzbitgo
Copy link
Author

The trace order must be the same as the transaction order in the block. Why would it be different?

Better to be built in Geth, in case of unforeseen situations such as missing txns and two lists do not exactly match

@s1na
Copy link
Contributor

s1na commented Apr 13, 2022

Now custom native tracers have access to txHash and blockHash but those are not added to the default call tracer. Feel free to open a PR if you need that too.

@evanzbitgo
Copy link
Author

Now custom native tracers have access to txHash and blockHash but those are not added to the default call tracer. Feel free to open a PR if you need that too.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants