-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Lower maximum transaction gas limit #92
Comments
Do you mean it should:
|
It should reject the transaction. The first option is not possible in my opinion. |
I had been toying with a similar idea and have been playing with an inplementation in the past. I'll try to dig it up or reimplement (shouldn't be too difficult) and see if I can get some benchmarks done :-) |
An option would be to modify the block gas adjustment scheme to not only have a "min gas" but also a "max gas". |
I am already changing the interpreter to throw an OutOfGas exception if the gas limit , the memory limit, or the calculations are >=263. This of course violates the spec, but saves a lot of calculation. It is also a practical impossibility to get anywhere near those limits in the real world. Unfortunately, my code fails tests that push the inputs past those limits anyway. The spec should put hard limits on gas and memory -- they can always be changed later as hardware advances. I agree that 263 -1 is a good limit so far as being practically impossible to approach and fast to compute. |
we could add a few more caps as well
|
I think |
Using "implementation defined" can in theory lead to consensus failure? If so, there should never be any limitations that are implementation defined? |
@larspensjo no. E.g. minimum gas price is user / implementation defined. Transactions with the gas price lower that the minimum are rejected / not mined. |
I see, thanks! |
The program counter is another one. Just noticed this in the Go code
And the C++ interpreter is using a uint64_t as well. Not much sense using a counter for more memory than you can physically address. I'm not sure if testing catches this. |
2^256-1 = |
@wanderer, I used following caps in EVMJIT successfully:
I think there are some test cases that use gas price bigger than 64 bits. I can give up this one as gas price seems not to be on critical path (rarely used in contracts). Never considered using 128-bit integers, wanted to keep the type set small. How can we formalize the above? |
For reference: ethereum/EIPs#92
For reference: - ethereum/EIPs#92 - ethereum/EIPs#106
The EVM2.0 design sets out the following limits:
@gcolvin IIRC if |
In RSK (a.k.a Rootstock) we've defined the limit to be about 2^62. The reason is that it is much more efficient to compute several additions to the gas counter and then to check for int64 oveflow than to check for int64 overflow after each, when each added value is known to be well below 2^20. |
Thanks for sharing that, @SergioDemianLerner. Much appreciated! |
@SergioDemianLerner Can you explain why do you need 2 additional bits to do it instead of one? |
There is no need for 2 bits. We use Java that has signed 64-bit integers, so by limiting ourselves to 62 bits we can be sure all operations remain positive, even when they overflow. But we could also check for negative values. For a platform that has 64-bit unsigned arithmetic, limiting the gas to 2^63-1 would be the same. |
I think we use signed int64 and check for negatives (however it is not full C++ compliant). Thanks for sharing that. |
This was somehow agreed on, by limiting block's max gas limit to 2^63-1. But I'm not sure there is any official EIP expressing that. |
This is now covered by https://eips.ethereum.org/EIPS/eip-1985. I propose to close this issue, @chfast. |
Overwiew
Maximum allowed transaction gas limit is 263 - 1.
Specification
Any transaction with the gas limit greater than 263 - 1 should be ignored by a client.
Motivation
Designing Ethereum VM for unrealistic case where amount of gas is greater than 264 is a waste of time.
Allowing the gas counter to fit regular CPU register on 64-bit targets is a big performance win. One more bit is reserved to allow faster overflow detection.
The text was updated successfully, but these errors were encountered: