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

params, core/vm: Istanbul EIP-1108 gas costs implementation #19904

Merged
merged 3 commits into from
Aug 6, 2019

Conversation

Shadowfiend
Copy link
Contributor

@Shadowfiend Shadowfiend commented Jul 31, 2019

This PR implements the gas cost adjustments in EIP-1108. Commit messages outline how this is done; currently the Istanbul block is nil in all cases, and precompiles are not hooked up to the tracer isPrecompiled check. It's not immediately clear where Istanbul should be switched to “on” before the relevant block, basically, so this PR adds the plumbing and switching on it, but doesn't activate it anywhere.

Opening this a touch early as to see whether this direction makes sense (it is based it on feedback from last year's #17644 from @ngrinkevich), or if there's a different approach worth pursuing.

@karalabe
Copy link
Member

There's a fairly significant PR pending from @holiman that reorganizes stuff a bit around fork handling and EIPs. Please wait until that's merged, this will need to be reworked on top. #19735

@karalabe
Copy link
Member

Although I think there's fairly little overlap.

@Shadowfiend
Copy link
Contributor Author

Ah! Thanks for pointing that out, I must have missed it when I rummaged to see if there was anything fork-related for Istanbul (maybe because it was at a higher level). I'll spend some cycles looking at it as well and see how it might affect my approach here.

@holiman
Copy link
Contributor

holiman commented Jul 31, 2019

In my PR, what I've done for those cases that change value over time, is the opposite of what you did in this PR.
Example:

	// EXP has a dynamic portion depending on the size of the exponent
	ExpByteFrontier uint64 = 10 // was set to 10 in Frontier
	ExpByteEIP158   uint64 = 50 // was raised to 50 during Eip158 (Spurious Dragon)

So instead of having preIstanbulXX and XX, I'd prefer <validFromFork>XXX , so byzantiumBn256AddGas (where it was introduced) and istanbulBn256AddGas

@Shadowfiend
Copy link
Contributor Author

Mmm, fair. I took this approach because it seemed like it would be easier over the long term to understand what the “current” value was... But of course the value doesn’t become current until the hardfork.

I’ll make that change, thanks!

@Shadowfiend
Copy link
Contributor Author

Ok, I have a rebased version here that swaps to the *<fork> naming and uses configParams. I'll push it once #19735 is merged!

@karalabe
Copy link
Member

karalabe commented Aug 5, 2019

Please rebase

@Shadowfiend Shadowfiend force-pushed the istanbul-eip-1108-gas-costs branch 2 times, most recently from c57c836 to ea7b4df Compare August 5, 2019 23:27
IstanbulBlock, used to determine if the config IsIstanbul, is currently
left nil until an actual block is chosen.
Old gas costs for elliptic curve operations are given the PreIstanbul
prefix, while current gas costs retain the unprefixed names. The actual
precompile implementations are the same, so they are factored out into
common functions that are called by the pre-Istanbul and current
precompile structs. Finally, an Istanbul precompile list is added that
references the new precompile structs, which in turn reference the new
gas costs.
@Shadowfiend
Copy link
Contributor Author

Ok, rebased. Had a few tripups with conflicts, sorry. Let me know what you think!

@karalabe karalabe mentioned this pull request Aug 6, 2019
10 tasks
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

I've pushed a tiny commit on top to move the declared fork field in the chain config to it's correct chronological position. I also reordered the bn256 precompile cost constants to follow Martin's previous scheme (it it easier to understand the changes if they are enumerated one after the other vs. in fork batches).

Thank you very much for the PR, clean and elegant. LGTM

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@karalabe karalabe merged commit beff5fa into ethereum:master Aug 6, 2019
@karalabe karalabe added this to the 1.9.2 milestone Aug 6, 2019
@Shadowfiend
Copy link
Contributor Author

Thanks y’all, and thanks for the tweaks @karalabe... Definitely got my fork ordering mixed up 🤦‍♂️

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.

None yet

3 participants