-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Use eth_getEstimate
to get the gas limit for Optimistic Ethereum
#4217
Comments
Hi @qbzzt thanks for bringing this up! Truffle estimates gas and the default What do you think about setting the gasMultiplier on a per-contract basis? This should address the issues in tests and anywhere else the contract is used. It would look something like this:
This would override the default multiplier. If I remember right, MetaMask upped their multiplier to 1.5 and that was enough, though we could play around with the right number. We don't have an easy way to set this at the configuration level though that might be something we can do in the future. Let me know what you think, thanks! |
I think this is sufficient for deployments to Optimistic Kovan, where the gas is essentially free. Would you be OK if I documented this (after you do it, of course) and left a note that it would probably be best to use a different system for deploying for the production network when you get to it? We charge |
Hi @qbzzt I'd really like to help make it feasible to deploy from Truffle to the production chain! Why do you charge |
If we can't do an automatic call to
Either is possible, but neither is great developer experience. It might be better to just create a web page where people can use a wallet to deploy their code. |
Hi @qbzzt sorry for the delay! I will do a deeper dive into this issue this week to see what we can do on our side. When you say an automatic call to I think I'm a bit confused about how gas for a deployment to Optimistic L2 is calculated -- you say |
@fainashalts , no problem. I prefer late answers to hurried ones.
We need to account for gas cost of L1 for the storage. That is the main cost of the transaction, and contract creation transactions require a lot of storage (one byte for each byte of the code, at least). Here is what happens currently:
What I want is to have a step between b and c that runs |
Hi @qbzzt, Just wanted to provide an update -- I discovered that we use a hard-coded default gas when one is not provided, which is definitely not ideal, regardless of the chain or layer involved. I am working to find the best way to change this that addresses all the places where this default is currently used. In the meantime, I got to thinking -- when I deploy to the Optimistic L2 from Truffle, I am using web3 to get certain information from the chain. I think web3 basically assumes I'm just talking to the L1, but you all have a fork of the When I estimate gas on an optimistic chain, what exactly am I getting back? I am just wondering if I should be treating this gas estimate the same way as I do the Ethereum one or if I should be trying to inject the context of which chain I am on into this estimation (my initial impulse was not to inject context at this stage and just treat the estimate the same way). Would love to know your thoughts/findings on this! |
I don't think we use a fork of |
Sorry @qbzzt, I am pretty sure I saw a fork of I can ask the node I am connected to for the gas using
The reason I got to thinking about this is that when I hit the L2 node with an |
Sorry I didn't answer it. When you ask for a gas estimate it gives you the equation in https://community.optimism.io/docs/developers/fees.html#encoding-sequencer-transaction-costs. It's fairly involved, which is why it's best to just rely on
You mean when you try to then send a transaction with that
|
Hi @qbzzt! My apologies, it looks like I originally misunderstood what you were asking for here. To be clear, you are requesting that we change the way we get the For the sake of absolute clarity, in Truffle land:
We check for the Re-reading our correspondence I see you meant you'd like us to use the |
IIRC in Optimism each transaction is its own block, so the two figures are really the same. Sorry I wasn't clear on what I meant earlier. |
Here's where I am now. I'm trying to use
When I try to run
|
Hi @qbzzt thanks for keeping me updated! Yes, I get the exceeds blockLimit error as well when setting I just tried it and I do see this error using Neither of these errors happen when tested against regular Kovan and regular Ethereum mainnet, so my thought is that there is a mismatch somewhere in Truffle's communication with Optimism. Is this document up to date? https://community.optimism.io/docs/protocol/evm-comparison.html I want to be sure that whatever changes we make are consistent with how things are done on Ethereum as well, since ideally devs shouldn't have to get in the weeds on this sort of thing when developing for either chain. A couple of us over at the Truffle team will be meeting about the entire gas/gasPrice/gasLimit/blockLimit flow next week, and we may be reworking it to be more straightforward. In that conversation, I'll be sure we consider the Optimism needs and try to address everything we've talked about here. Any additional info you'd like to provide for that in the meantime would be appreciated! |
It's accurate for right now. We are working on an upgrade that will change some things (https://community.optimism.io/docs/developers/l2/deploy.html#key-info), but I don't think it will affect the gas issue. PSThank you for representing us. |
It looks like our October update will remove this problem, so this is not a big priority for us. |
Oh, interesting @qbzzt! Would you mind telling/showing me what changes will be made that will address this? I want to be sure anything we change won't mess it up. :) |
Of course not. We're going to do two things:
The disadvantage is that unless we can get wallets to change their UI they'll report a wrong gas price for the transaction. The advantage, though, is that we'll be back to using the normal Ethereum method so 3rd party tools, such as Truffle, will work without modification. |
Hi @qbzzt I will be making some changes to the way we do gas estimation to ensure this sort of thing doesn't happen again. Thank you for pointing out the issue as it led to a deeper dive for me into Truffle's gas estimation flow that was really useful and informative. I will let you know when the changes are live. In the meantime, I believe if you set |
Thank you. I'll try it, probably tomorrow (it's 7pm here and I'm taking
babies to sleep)
…On Thu, Aug 26, 2021 at 6:52 PM Faina Shalts ***@***.***> wrote:
Hi @qbzzt <https://github.com/qbzzt> I will be making some changes to the
way we do gas estimation to ensure this sort of thing doesn't happen again.
Thank you for pointing out the issue as it led to a deeper dive for me into
Truffle's gas estimation flow that was really useful and informative. I
will let you know when the changes are live.
In the meantime, I believe if you set gas: 0 in the network configuration
in truffle-config.ovm.js that will force Truffle to do the gas estimation
we want. Let me know if that helps for now!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4217 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADBCGGIKP43PHJ7SXWPEA3DT63HUHANCNFSM5BNU3RKQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
It doesn't. ori@Oris-MacBook-Pro dapp % truffle console --config truffle-config.ovm.js --network optimistic_kovan
truffle(optimistic_kovan)> x = await SimpleStorage.new()
Uncaught:
{
code: -32000,
message: 'invalid transaction: exceeds block gas limit'
}
truffle(optimistic_kovan)> When my optimistic_kovan: {
network_id: 69,
chain_id: 69,
gasPrice: 15000000,
gas: 0,
provider: function() {
return new HDWalletProvider(kovanMnemonic, "https://optimism-kovan.infura.io/v3/"+ infuraKey, 0, 1);
}
}, |
Ah interesting! Setting |
Thank you. Sorry this is turning into a time sink for you.
…On Fri, Aug 27, 2021 at 6:35 PM Faina Shalts ***@***.***> wrote:
Ah interesting! Setting gas: 0 forces a gas estimation from the Truffle
side the way the code currently is. This means there is an additional issue
to sort out once that happens. I'll try to dig in further next week and see
what this may be about. Thanks for checking!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4217 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADBCGGNPNGKBVP62CNEPNTDT7AONDANCNFSM5BNU3RKQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
This isnt resolved |
Issue
In Optimistic Ethereum we use
eth_getEstimate
from the server to return an estimate of the cost of a transaction. We do this because the cost of a transaction is not primarily the cost of execution, but the cost of L1 storage. See https://community.optimism.io/docs/developers/fees.html#fees-for-sequencer-transactions.This clashes with Truffle's standard algorithm of looking at the gas cost of a transaction internally and setting gasLimit to a multiple of that value. This causes a failure when attempting to deploy a contract or run a test on Optimistic Kovan (running with the internal development node is not an issue).
Steps to Reproduce
In an empty directory, run
Create a
.env
file with this content:Test the sample dapp:
Results
Without anything else the migration fails with:
We can fix this problem by editing
migrations/1_deploy_contracts.js
to:But then we get this error:
We can also fix this error by modifying the code to specify a gas limit in
test/simplestorage.js
. However, manuallyspecifying a gas limit in every transaction in every test is bad user experience.
The text was updated successfully, but these errors were encountered: