-
Notifications
You must be signed in to change notification settings - Fork 14
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
Always use estimateGas when computing forgeOrg gas #349
Conversation
lib/wrappers/daoCreator.ts
Outdated
controllerAddress, | ||
options.tokenCap]; | ||
|
||
// always use estimateGas or will fail when using non-universal controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"or will fail when using non-universal controller ? why ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added explanation to the comment in the code.
gasLimits.js
Outdated
@@ -10,34 +10,16 @@ const arcForgeOrgGasLimit = require("./arcConstants.js").ARC_GAS_LIMIT; | |||
const gasLimitsConfig = | |||
{ | |||
/** | |||
* The gas limit used by Arc to forge a DAO with foundersInGasLimitArc founders | |||
* and to `new` GenesisProtocol. | |||
* The gas limit used by Arc to `new` GenesisProtocol. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not clear.please clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified in the comment in the code.
gasLimits.js
Outdated
/** | ||
* How many founders are already accounted-for in the gaslimit from Arc | ||
*/ | ||
"foundersInGasLimitArc": 3, | ||
/** | ||
* Gas limit sufficient (though not necessarily optimal) for all other transactions | ||
* besides creating DAOs | ||
*/ | ||
"gasLimit_runtime": 4543760, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this number is calculated ? from where it is taken ?
gasLimits.js
Outdated
@@ -15,7 +15,8 @@ const gasLimitsConfig = | |||
"gasLimit_arc": arcForgeOrgGasLimit, | |||
/** | |||
* Gas limit sufficient (though not necessarily optimal) for all other transactions | |||
* besides creating DAOs. This is taken from the default that truffle puts in truffle.js. | |||
* besides creating DAOs and instantiating a new GenesisProtocol. | |||
* This is taken from the default that truffle puts in truffle.js. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you choose to use truffle default values ? why do we care about truffle default value ?
how did truffle choose this value ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code that uses this may not be required. It is very old code that actually predates me, and has never, that I recall, been questioned. I will test with it removed and report back.
BTW I am also looking into removing the other setting, gasLimit_arc
, a task which is proving to be tricky, but with both of those settings gone we could completely remove some code including the dependency on the Arc test/constants.js file.
@orenyodfat I have removed arcConstants.js and gasLimits.js, so there is no longer a dependency on gas numbers from Arc. The default gas limit used by truffle is now stored in defaults.json as a global configuration setting. It is required for certain operations to succeed with enough gas. I have updated the description in this PR to include all of the recent changes. |
@@ -4,6 +4,7 @@ | |||
"cacheContractWrappers": true, | |||
"logLevel": 9, | |||
"estimateGas": false, | |||
"defaultGasLimit": 4543760, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this value and not other (e.g 4543759) ?
Is there a good reason for that except that "truffle use that" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason except that it works for both Arc and Arc.js automated tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets find out the reason or set it to max gas limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same reason Arc is using it. I don't see how it makes sense to raise it to the max, as that is wasteful. It would only make sense to lower it to a minimum value that still works. Since Arc tests cover more contract API use cases than Arc.js, I think it would be best to find that minimum value in Arc.
const web3 = await Utils.getWeb3(); | ||
|
||
const maxGasLimit = await computeMaxGasLimit(web3); | ||
const maxGasLimit = await UtilsInternal.computeMaxGasLimit(); | ||
|
||
if (currentNetwork === "Ganache") { | ||
return maxGasLimit; // because who cares with ganache and we can't get good estimates from it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gas estimation for Ganache should be the same as other networks.
In general, we should strive to execute same arc.js code regardless that networks it is connected to.(as possible as can be done).
This line should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ganache returns gas estimates that are not sufficient. At the time I wrote this code I spent a lot of time on this issue. I just now gave it another try, but encountered the same result. I am in the process of moving to truffle 5.0 and web3 1.0 -- maybe something will change then, I can retry when I have things working enough to test.
I think this may be a case requiring network-specific code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a known ganache issue ? If it is please add a link to this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is one: trufflesuite/ganache#151
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add a link to that on the code ?
lib/contractWrapperBase.ts
Outdated
@@ -321,9 +319,9 @@ export abstract class ContractWrapperBase implements IContractWrapper { | |||
let error; | |||
|
|||
const gasPriceComputer = ConfigService.get("gasPriceAdjustment") as GasPriceAdjustor; | |||
const web3 = await Utils.getWeb3(); | |||
|
|||
if (gasPriceComputer && !web3Params.gasPrice) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gasPriceComputer -> gasPriceComputed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -53,7 +53,7 @@ export const arcJsDeployer = ( | |||
console.log(`Deploying schemes to ${network}`); | |||
|
|||
const DAOToken = await Utils.requireContract("DAOToken"); | |||
const gasLimit = await computeMaxGasLimit(web3); | |||
const gasLimit = await UtilsInternal.computeMaxGasLimit(); | |||
const gasPrice = 10000000000; // 10 Gwei |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const gasPrice = 10000000000; // 10 Gwei ?
from where this come from ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was your suggestion when we were doing the last complete migration to mainnet and were having issues with the mining taking too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script doubles that in a few specific cases where it doesn't suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix 10 Gwei is a workaround.
please set the appropriate gas price needed.
You can read that from eth gas station ...(alchemy done that)
https://github.com/daostack/alchemy/blob/dev/src/index.tsx#L21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking of that too. Would you mind waiting on this until I have Truffle 5 working? As you know, they have lots of migration changes and I'd like to code this in the context of those changes. I'm doing the work right now of upgrading to Truffle 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please open an issue for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
6c4aff5
to
9a8abe4
Compare
9a8abe4
to
de8dc44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open an issues for all open issues on this pr
Resolves: #342
forgeOrg
andGenesisProtocol.new
, regardless of the "estimateGas" configuration settingDAO.new
.new
operations.