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

Fancy tracer mhs #8

Closed
wants to merge 0 commits into from
Closed

Conversation

holiman
Copy link

@holiman holiman commented Nov 27, 2017

Adds blocknumber, gaslimit to ctx, adds db to result, and implements three tracers:

  • 4bytes.js returns info about ABI calldata (signature and argument length)
  • prestate.js generates a geth genesis from a transaction, for local replay
  • tracefunc.js returns data suitable for evmdis disassembly, to get intelligent traces. Original version by @Arachnid

@holiman holiman requested a review from karalabe as a code owner November 27, 2017 10:13
@@ -354,6 +354,10 @@ func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode,
jst.log["depth"] = depth
jst.log["account"] = contract.Address()

//A bit of a hack - should be placed in CaptureStart/CaptureEnd, but there's no evm in those methods
jst.ctx["blocknumber"] = env.BlockNumber.Uint64()
jst.ctx["gasLimit"] = env.GasLimit
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nicer approach imho would be to add this once to ctx. I.e. place something like this at the top of this function:

if pc == 0 {
	jst.ctx["block"] = env.BlockNumber.Uint64()
}

Also please note, the gasLimit is already part of the context and it's called gas.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If pc can be 0 multiple times (unsure how subcalls work with regard to pc), we can add an inited bool field to jst which will be set to true when entering this method for the first time so we only set the block number once.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... though, I did mean block gas limit, but transaction gas limit works aswell in my particular usecase.

Yes, pc can be 0 multiple times

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(even without subcalls, since the first opcode can be jumpdest)

@karalabe
Copy link
Owner

I've cherry picked these commits to fix some minor things.

@karalabe karalabe closed this Nov 27, 2017
@holiman holiman deleted the fancy-tracer-mhs branch November 27, 2017 14:53
karalabe pushed a commit that referenced this pull request Dec 10, 2018
* added tests for new abi encoding features (#4)

* added tests from bytes32[][] and string[]

* added offset to other types

* formatting

* Abi/dynamic types (#5)

* Revert "Abi/dynamic types (#5)" (#6)

This reverts commit dabca31.

* Abi/dynamic types (#7)

* some cleanup

* Apply suggestions from code review

apply suggestions

Co-Authored-By: vedhavyas <vedhavyas.singareddi@gmail.com>

* added better formatting (#8)

* review chnages

* better comments
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.

2 participants