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

Incomplete gas calculation for LOG opcodes #404

Closed
pinkiebell opened this issue Dec 7, 2018 · 8 comments
Closed

Incomplete gas calculation for LOG opcodes #404

pinkiebell opened this issue Dec 7, 2018 · 8 comments

Comments

@pinkiebell
Copy link
Contributor

Right now, all LOG operations are consuming 375 of gas.
We should adhere to spec. from the yellow paper:

Glog 375 Partial payment for a LOG operation.
Glogdata 8 Paid for each byte in a LOG operation’s data.
Glogtopic 375 Paid for each topic of a LOG operation.
@holgerd77
Copy link
Member

Could you link to the parts in the code where this is calculated + where the gas price is defined for reference?

@pinkiebell
Copy link
Contributor Author

Base cost is defined here: https://github.com/ethereumjs/ethereumjs-vm/blob/master/lib/opcodes.js#L144

I think that needs custom handling for example in:
https://github.com/ethereumjs/ethereumjs-vm/blob/master/lib/runCode.js#L190

@holgerd77
Copy link
Member

Also was this gas calculation mechanism like this from the beginning or did it change along one of the hardforks?

@axic
Copy link
Member

axic commented Dec 7, 2018

@pinkiebell
Copy link
Contributor Author

@holgerd77
Oh, I don't know. I was looking at the BYZANTIUM VERSION 12779ac - 2018-11-2725 version.

@axic I'm taking a dive. Maybe it doesn't work because I push stack elements in the 'step' event? 😅

@pinkiebell
Copy link
Contributor Author

Hmm, sorry for the noise. The gas calculation seems fine.
However

  gas: <BN: fffffffffb77>,
  return: <Buffer >,
  gasUsed: <BN: 488> }

gasUsed seems to be wrong (thats for LOG2)
should be 1160

@axic
Copy link
Member

axic commented Dec 7, 2018

I think that is misleading again, because likely it displays it as base-16. 0x488 (hex) = 1160 (decimal)

@pinkiebell
Copy link
Contributor Author

@axic 😅 Thanks! Late night error from my side.

I think the issue can be closed 👍

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

No branches or pull requests

4 participants