MultiversX Tracker is Live!

gasleft(); Self fullfilling prophecy ?

Etherum Reddit

More / Etherum Reddit 102 Views

Lets say we have a view function which'll use up more than 30m gas and ultimately fail for hitting the ceiling. (out of gas)What if i limited the function to stop if gas is low.

function stuff() public view returns(uint a){

while(a<10000000 && gasleft() > 50000){

a++;

}

}

For now ethereum calculates this function's gas as around 30m and when there's too little left it leaves the loop and doesn't fail.

But i'm wondering if ethereum in future would get smarter and figure out it can just go through this function with 21k gas ?

Is checking gasleft() a self fullfilling prophecy ? is it future proofed ?

PS1: Consider user not entering a manual gaslimit, all done by auto gas estimation

PS2: Correct me if i'm wrong, All my findings are from my own testing. I'm usually wrong :)

PS3: I noticed some ppl doesn't know view or pure functions still use gas so i published this contract to demonstrate.https://goerli.etherscan.io/address/0xb5df66e29157bdac857099a776b2f3a47c57ff10#code

submitted by /u/resilientboy
[link] [comments]
Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments