Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Truffle v4.0.0 - Full Size Snickers 🍫

Compare
Choose a tag to compare
@tcoulter tcoulter released this 31 Oct 18:43
· 16047 commits to develop since this release

Happy Halloween all! 👻 🎃 👾

Part of any good Halloween haul, the full size candy bar is the crème de la crème of goodies to open on Halloween night. Far tastier than candy corn, and wayyyyy bigger than anything fun size, the full size bar is every kid's top score. This Halloween, we're giving you our crunchiest release yet: Truffle 4.0 - Full Size Snickers 🍫

This release includes so many big things we've had to change the structure of our release notes. We'll introduce what's new first, then more specific items towards the end.

Update: Truffle v4.0.1 has been released containing a debugger fix and a new deterministic mnemonic for truffle develop

Introducing the Integrated Solidity Debugger 😈

screenshot 52

That's right folks. With Truffle 4.0, you can now debug your Ethereum transactions with full Solidity source code mapping. Debug any transaction. On any chain.*

Debugging an Ethereum transaction is different than debugging a traditional application. On Ethereum, all application state is saved on a world computer and can be introspected at any time. By debugging a transaction, you're really stepping through history rather than executing code in real time.

This gives you a lot of power. Here's a list of everything you can do with the debugger:

  • Debug past transactions like you'd debug a normal application. Step over, step into, step next, it's all there.
  • Debug transactions without code. That's right, you can even inspect transactions that you don't have the code for. You won't see any mapping to Solidity source code, since it's not there, but the debugger will provide you important stack and instruction information to understand what's happening within that transaction.
  • Figure out exactly where your transaction errored (think, throw, revert(), assert(), etc.)
  • Figure out the exact point in which your transaction ran out of gas.
  • Inspect individual instructions and their related stack information.
  • See the address associated with each line of code.

This is a big step for Solidity development. And it's all here, included in Truffle. Check out our new tutorial about how to use the debugger for examples debugging specific contracts.

* Your Ethereum client must support eth_debugTraceTransaction. The latest TestRPC does, as does go-ethereum.

Truffle Develop: Faster Development Cycles 👽

demo-double-develop 1

Most users' first action after installing Truffle is to install the TestRPC. With Truffle 4.0, there's no need: An integrated development blockchain powered by ganache-core now comes standard. And you can get to it with a single command:

$ truffle develop

After firing up truffle develop, not only do you get a development blockchain that comes with zero installation, but you also get a direct line into that blockchain via the console. Type commands like compile and migrate as you would if you were using the console on its own. You can also access your contract abstractions as well, as they're automatically reloaded for you after every command. See our console documentation for more information.

Using truffle develop has some other benefits over running the TestRPC directly:

  • It has a consistent host and port that doesn't conflict with the popular port. It always runs on http://localhost:9545
  • It always has the same network id (4447) so you'll know that's the dev environment when you see that id in your artifacts.
  • It's deterministic, using the same mnemonic and accounts every time: candy maple velvet cake sugar cream honey rich smooth crumble sweet treat candy maple cake sugar pudding cream honey rich smooth crumble sweet treat (please see v4.0.1 release for a correction to this mnemonic). 😃
  • Supports multiple consoles for a single session. See the gif above for an example.

Dry Run: Taking the guesswork out of migrations 🐲

Truffle 4.0 allows you to test your migrations against your production networks before committing real transactions (and real 💲). To do so, just run the following:

$ truffle migrate --dry-run

Under the hood, this feature forks from your chain of choice to create a new sandbox to run your migrations. This sandbox has access to all the code, addresses, accounts and balances as the old chain, with all new transactions occurring within the sandbox. This means you can test upgrading those complex upgradable contracts before actually upgrading them.

Truffle Test: Faster Test Cycles & Better CI 👹

Truffle now comes with a test blockchain environment baked in when you run truffle test. Not only is this great for your development process -- you no need longer need to download an install a separate blockchain -- but it's also great for continuous integration: truffle becomes the only application your CI needs to get your automated test environment up and running.

Caveat: For backwards compatibility, if you have an existing Truffle project with a development or test network specified in your truffle.js file, Truffle will use those networks instead of this new built-in blockchain. To take full advantage of this feature, remove or rename the development and test networks from your truffle.js file. If you're just using the TestRPC for development, consider using the new truffle develop instead!

Solidity Optimizer now Off by Default 🤖

For increased security, we've now made the Solidity optimizer opt-in, meaning it's off by default. This ensures your binaries are created exactly how you want, with your own self-configured optimizer settings. Having user-specified optimizer settings also makes the path to contract verification more clear.

To opt back into the optimizer, check out our documentation for an example.

⚠️ Warning: Changing the optimizer settings (and turning off the optimizer) will affect the binary size and gas costs of your contracts. In some instances, this may cause your contracts to exceed the block gas limit, meaning your contracts can't be deployed without further configuration. If you run into gas issues as a result of this change, we recommend either changing the optimizer settings to something better suited to your contracts, or splitting up your contracts into multiple pieces that can be deployed individually.

Other Improvements, Features and Bug Fixes 💀

  • New solc! Now with v0.4.18. We've also removed our own Solidity parser in favor of using solc's. This means you now get new Solidity features, faster.
  • The Solidity compiler version is now included in the contract artifacts, to help support contract verification truffle-compile #29
  • You now have more Truffle Boxes to choose from (with more to come!)
  • Speaking of boxes, truffle init now creates a bare Truffle project. If you'd like a specific example, try a box instead!
  • Also, we shaved a few seconds off of test runs.

Upgrading to Truffle 4.0 from 3.x

Truffle 4.0 changes the content and structure of contract metadata stored on disk. To get the most out of Truffle 4 right away, perform the following steps:

  1. Install the new version of Truffle

    $ npm install -g truffle
    

    Note: If you run into errors, try uninstalling the old version first. Additionally, if you're on OS X or Linux you may have to use sudo with the above command.

  2. Upgrade truffle-contract to v3.0.0 for any project that uses it (like your frontend) to take advantage of the new artifact format. This should be a drop in replacement.

  3. Run truffle compile --all to auto-upgrade contract artifacts and unlock debugging features.

Note: Because of the changes under the hood, you must recompile all your contracts before you can take advantage of the Truffle debugger.

Big Thanks!

We want to send out a big thank you to all of our users, beta testers and everyone that helps make Truffle possible. If you need help with anything or would just like to chat, come on over to our Gitter channel and drop us a line. Or, if you're feeling spooky, write us a new issue to tell us about any 🐛's you find.

Happy Halloween, and happy coding! 👻