When transaction within the migration depends on deployer's address (e.g. ownership transfer) then dry run fails.
Try to transfer ownership as part of the migration.
The same set of accounts is used in the dry run as well as during the actual migration.
Similar issue here:
https://github.com/trufflesuite/truffle/issues/1612#issuecomment-459273927
I notice also the use of network names as [network]-fork can really mess up the logic if you have network-dependent logic.
Add skipDryRun: true in your network config. That should help.
Example:
development: {
skipDryRun: true,
host: "127.0.0.1",
port: 7545,
network_id: "*" // match any network
},
@zulhfreelancer Sure, it's easy to "skip" the problem, but it doesn't solve the problem with dry run.
Hey @MichalZalecki, do you have a specific example that I can take a look at to reproduce the problem?
+1
To reproduce the issue, try to deploy a simple erc20 and call the transfer function from deployer address.
Skipping dry run works.
@seesemichaelj Is this related to the problem you were referencing the other day? Can you tag this if it is when you open a PR?
@eggplantzzz ya I believe it's caused by the same bug. Will do!
@seesemichaelj Did you do something related to this issue?
Nope, it hit the back burner
@seesemichaelj Do you have more information about this issue that you could link here?
This is what @nicholasjpaterno wrote on our other repo about the issue:
To add more background info, echoing @seesemichaelj's comments on this issue for solidarity:
web3.eth.getAccounts() with an infura provider returns an empty array, causing https://github.com/trufflesuite/truffle/blob/develop/packages/environment/environment.js#L46 to send an empty array to ganache as what accounts are unlocked, causing https://github.com/trufflesuite/ganache-core/blob/283cbeca1cf9f9c598845a00baaa331afc621596/lib/statemanager.js#L327 to be triggered and errors
Proposed Solution:
https://github.com/trufflesuite/truffle/blob/develop/packages/environment/environment.js#L46
thoughts on making it something more like
const options = {
fork: config.provider,
gasLimit: block.gasLimit
};
if (accounts.length > 0) {
options.unlocked_accounts = accounts;
}
config.networks[forkedNetwork] = {
network_id: config.network_id,
provider: Ganache.provider(options),
from: config.from,
gas: upstreamConfig.gas,
gasPrice: upstreamConfig.gasPrice
};
@davidmurdoch @nicholasjpaterno we can fix this inside Truffle as proposed above, but y'all really should make Ganache accept an empty array :)
@gnidan, are you suggesting unlocked_accounts: [] should unlock _all_ accounts instead of no accounts?
This is a discussion that should be on the https://github.com/trufflesuite/ganache-core repo, but the UX would indicate that unlocked_accounts: [] should unlock no accounts rather than all accounts, which I would argue that the proposed change in Truffle would need to happen as that's not the desired outcome of this scenario
Closing this as I believe it is fixed! Get back to me if you think this is still an issue and we'll re-open. Thanks!