embark/packages/embark-deployment
Pascal Precht d76a82a30a fix(@embark/deployment): don't over estimate gas when running tests against non-simulator nodes
When running tests against non-simulated blockchain nodes, even for simplex
Smart Contracts, deployment transactions would exceed the block gas limit.

E.g. running `embark blockchain` in one process and `embark test --node embark`
in another, inside our demo application, will throw an error when Embark attempts
to deploy its `SimpleStorage`:

```
Compiling contracts
Compilation done

[SimpleStorage]: error deploying =SimpleStorage= due to error: Returned error: exceeds block gas limit
Error deploying contracts. Please fix errors to continue.
Error deploying contracts. Please fix errors to continue.
terminating due to error
Error deploying contracts. Please fix errors to continue.
```

The reason for that is because in https://github.com/embark-framework/embark/pull/1650, we've introduced a static
gas estimation for Smart Contract deployment that is just right below Ganache's
maximum gas limit of `6721975`, since Ganache tends to underestimate gas for
complex Smart Contracts due to its [low base fee](8ad1ab29de/lib/utils/gasEstimation.js (L33-L39)).

The static gas estimation would apply any time we're in a test context, but we
didn't take into account the case where tests are executed against nodes
other than the simulated environment.

As mentioned in the comments in the linked PR:

> If this is not spec'ed at all, I wonder what complications it could cause when
> at some point we maybe switch to not using Ganache anymore for tests, or even
> the user itself (which I think is a reasonable thing to do).

This causes the error described above because we easily reach the block gas limit
with just two Smart Contracts and Embark already deploys a few Smart Contracts for
ENS.

So basically what we want is to use the static gas estimation when we know
the node we're connecting to is Ganache. In all other cases we can rely on the
standardized gas estimation offered by the node.
2019-07-05 14:15:12 +02:00
..
src fix(@embark/deployment): don't over estimate gas when running tests against non-simulator nodes 2019-07-05 14:15:12 +02:00
.npmrc refactor(@embark/deployment): move deployment module into own package 2019-05-06 11:38:03 +02:00
CHANGELOG.md chore(release): 4.1.0-beta.4 2019-06-27 14:23:32 -05:00
README.md refactor(@embark/deployment): move deployment module into own package 2019-05-06 11:38:03 +02:00
package.json chore(release): 4.1.0-beta.4 2019-06-27 14:23:32 -05:00
tsconfig.json refactor(@embark/deployment): move deployment module into own package 2019-05-06 11:38:03 +02:00
tslint.json refactor(@embark/deployment): move deployment module into own package 2019-05-06 11:38:03 +02:00

README.md

embark-deployment

Deployment APIs for Embark

Visit embark.status.im to get started with Embark.