Comments (1)
It is feasible as it turns out that whatever we were using nightly it’s already in stable. It was a matter of adding feature flags to the contract API to hide #![feature(...)]
etc.
The issues though:
Using stable rust by default with #![no_std]as we do currently doesn’t work as alloc_error_handler is required - but alloc_error_handler is a nightly feature. So if you want to write a smart contract with no_std you need a nightly compiler.
Building with stdlib enabled by default increases gas cost and all the test contracts grow in size (approx ~200KB extra for all contracts combined). The overhead is likely from the panic behavior from rust’s runtime compiled into wasm. I.e. overflow checks, stdlib’s panic handler with stack unwinding, etc. We don’t need all that under wasm.
I was able to use stable rust with std enabled on all contracts by disabling most if not all rust’s runtime checks with an extra cargo profile. This is what smart contract devs should use as well and we should update our reference contracts to do this:
[profile.release-smart-contracts]
inherits = "release"
codegen-units = 1
opt-level = "s"
lto = true
debug = false
panic = "abort"
overflow-checks = true
With the above settings, I was able to have stable rust, stdlib enabled, with the same size and same gas cost as the current dev with nightly:
# stable, with default release build flags (initial attempt; bad)
$ wc -c target/wasm32-unknown-unknown/release/*.wasm | grep total
6099831 total
# stable, stdlib with extra compiler flags
$ wc -c target/wasm32-unknown-unknown/release/*.wasm | grep total
4800659 total
# dev, nightly, the baseline
$ wc -c target/wasm32-unknown-unknown/release/*.wasm | grep total
4800659 total
What’s left are the feature flags we want to add to the contract API crate. In my experiment, I added the std
feature always enabled, nightly
flag, and the wee_alloc
flag in my experiment. By default, std is on and it also enables wee_alloc
. For convenience, I have a no_std
flag that enables a nightly flag (as raised above it’s for #![feature(...)
and alloc_error_handler
).
from casper-node.
Related Issues (20)
- Extend RPC tests to include Commit_Purge API
- More specific logging configuration in test environment HOT 1
- Overhaul networking component metrics
- Add TrackingMap to make Arc/Weaks used more robust HOT 1
- Global State Update Tool needs to prune
- Investigate the existing upgrade tests and find which are to be retained HOT 5
- Remove its03 and it11 from the commit tests runs HOT 1
- "Monkey Trap" on staging 1_5_2
- [block extensibility] Merge feat-data-extensibility to feat-2.0
- Higher layer unit tests for Juliet
- Reduce or remove usage of fuses in favor of dropping JulietClient
- Fix/ensure multi-frame message are cancelled properly
- Fix validator broadcast efficiency in feat-1.6 HOT 1
- Second VM: calling contracts HOT 1
- Second VM: call stack
- Contract Level Events Discovery
- cherry pick the last commits to address 4215
- Align the changes to rewards made for "private chain" and for "2.0"
- Fix chain_get_block_transfers RPC so that it returns an empty array of transfers instead of null if the block didn’t have any transfers.
- update self documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casper-node.