Releases: OffchainLabs/stylus-sdk-rs
v0.10.0-beta.1
New
- Support for associated types (#255)
- Support for nested structs in return types (#274)
- More conevenient integer functions for storage (#277)
- Support for custom storage slots (#286)
- Ability to use Stylus contracts as libraries, where their interfaces are exposed. This allows them to be called by dependant contracts safely. (#282)
- Allow usage of tuples in return types
Removed
- Removal of deprecated code from previous versions (#259)
- Old inheritance model no longer supported (#280, #281)
Changed
- Update calls / deploys / logs to use new hostio model (#258)
- Additional integration tests (#264, #266)
- Upgrade alloy version (#260)
- More example contracts from Stylus By Example (#272)
- Use alloy::Bytes type instead of our own (#275)
- Improvements to CI (#283)
WIP - Planned for final 0.10.0 release
- Cargo-stylus is moving into the stylus-sdk-rs repo. This change is currently underway, as much of the code has been moved (#288), but there is still some functionality to be added which can be tracked in (#279). This change will make the development and release process easier. This will also expose the stylus-tools repo for calling this functionality programatically, as well as support for workspace projects with multiple contracts (#288, #279)
Full Changelog: v0.8.1...v0.10.0-beta.1
v0.9.0
What's Changed
- Fix formatting by @amsanghi in #222
- Add Stylus constructors by @gligneul in #184
- first pass implementation of trait based inheritance by @rory-ocl in #223
- Fix Cargo Stylus Replay by @gligneul in #225
- Update CHANGELOG.md (main) by @gligneul in #228
- Remove mark_used function to reduce binary size by @gligneul in #235
- Port 0.8.3 changes to main by @gligneul in #231
- add
StorageU96
int alias by @0xNeshi in #234 - Remove the HostIO-caching feature by @gligneul in #237
- Add a README to Stylus Test by @rauljordan in #239
- Be more strict with special function names by @gligneul in #242
- Resolve Audit Feedback Related to TestVM and Fallbacks by @rauljordan in #241
New Contributors
Full Changelog: v0.8.1...v0.9.0
v0.8.4
Full Changelog: v0.8.3...v0.8.4
Issues:
- Cache Invalidation: The cache was not being invalidated correctly if storage types were read before making an external call that modified those storage cells. Subsequent reads would not reflect the updated storage values, returning stale data from before the external call.
- Reentrancy: Occurs when using Solidity and Stylus contracts together. There is a possibility of reentrancy not being properly detected if a combination of reentrant and non-reentrant contracts are used and call into each other. To mitigate the risks of this, we have changed the behavior of external calls from stylus to always flush its cache. The
msg::reentrant()
hostio also may be unreliable, so relying on it for safety should be avoided.
Breaking Changes:
- Storage types no longer implement
Deref
which some contracts may have been using. the.get()
method of each storage type should be used instead.
v0.8.3
Stylus SDK v0.8.2
Stylus SDK v0.8.1
Fixed
- Add Reentrant Feature to Stylus Test When Enabled in SDK: #221
Full Changelog: v0.8.0...v0.8.1
v0.8.0 - Stylus Contract Test Framework!
What's Changed
Version 0.8.0 of the Stylus SDK brings a brand new stylus_test
crate providing a testing framework for all Stylus contracts and storage types. This crate is re-exported through the Stylus SDK under stylus_sdk::testing
when targeting a native architecture. A new Host
trait is defined in an internal stylus_core
crate that defines all the hostio affordances Stylus contracts have. All global hostio invocations, such as stylus_sdk::msg::value()
are now deprecated in favor of invoking hostios through a Host
access available to contracts.
The Stylus #[storage]
proc macro makes a .vm()
method available on all contracts which offers all hostio methods. Moreover, a stylus_sdk::testing
crate implements a test host for use in unit testing:
use stylus_sdk::{alloy_primitives::U256, prelude::*};
#[entrypoint]
#[storage]
pub struct Counter {
number: StorageU256;
}
#[public]
impl Counter {
pub fn number(&self) -> U256 {
self.number.get()
}
pub fn increment(&mut self) {
let number = self.number.get();
self.set_number(number + U256::from(1));
}
}
#[cfg(test)]
mod test {
use super::*;
use stylus_sdk::testing::*;
#[test]
fn test_counter() {
let vm = TestVM::default();
let mut contract = Counter::from(&vm);
assert_eq!(U256::ZERO, contract.number());
contract.increment();
assert_eq!(U256::from(1), contract.number());
}
}
Caveats
- All the code related to cross-contract calls is not yet updated to use the new
Host
trait, meaning it cannot be fully tested via the testing framework. This is because changing calls requires breaking changes, and will be done in the 1.0 release candidate for the SDK in the near future - In order to leverage and unit test contracts with
stylus_test
, contracts must use hostio access via the.vm()
accessor instead of global hostio invocations, which are now deprecated
- [1/5] - Define a Host Trait for the Stylus SDK by @rauljordan in #199
- [2/5] - Define Initial WasmHost Implementation for Wasm Targets by @rauljordan in #200
- [3/5] - Use a Boxed, Dyn Host Trait for Contract Initialization by @rauljordan in #203
- [4/?] - Define Testing VM to Implement the Mock Trait by @rauljordan in #204
- [5/?] - Rename Stylus-Host to Stylus-Core and Make Calls Part of the VM by @rauljordan in #206
- [6/?] - Make Deployment Logic Part of the Host Trait by @rauljordan in #207
- Fix storage bytes set-len when shrinking by @gligneul in #211
- [7] - Deprecate Old Hostios and Improve TestVM Ergonomics by @rauljordan in #209
- Add unit tests to storage bytes by @gligneul in #213
- [8] - Add Missing Methods to Host Trait by @rauljordan in #210
- Reduce Wasm Code Size Impact of Host Trait by @rauljordan in #216
- Add a Powerful Test VM by @rauljordan in #212
- Minimize calls to storage for bytes/string by @gligneul in #217
- Fix examples and doctest by @gligneul in #219
- Make CI fail for clippy warnings by @gligneul in #220
- v0.8.0 Release Candidate by @rauljordan in #218
Full Changelog: v0.7.0...v0.8.0
Stylus SDK v0.7.0
0.7.0 - 2025-02-03
Added
impl From<alloy_primitives::Bytes> for stylus_sdk::Bytes
- Support for integer types from
alloy_primitives
- Fallback/receive functionality for routers created using
#[public]
Changed
- Upgrade alloy dependency to
0.8.14
- Allow struct references within
sol_interface!
macro pub
structs insol_interface!
macro- Refactor of proc macros for better maintainability and testability
Stylus SDK 0.6.0
0.6.0 - 2024-08-30
This release contains bugfixes, some breaking changes, and general updates. This is the recommended release for usage at the time of the Stylus release on Arbitrum mainnet.
Breaking Changes
#[selector(id = ...)]
syntax has been removed to avoid misleading contracts
from being implemented.- Several methods in
RawDeploy
which were not fully implemented yet #[pure]
,#[view]
and#[write]
attributes have been removed in favor of
using arguments to infer state mutability.stylus-sdk
now ships withmini-alloc
enabled by default. This means that
a#[global_allocator]
should not be declared in most cases. If a custom
allocator is still needed themini-alloc
should be disabled (enabled by
default).StorageU1
andStorageI1
types have been removed.
Deprecated
- The
#[external]
macro is now deprecated in favor of#[public]
which
provides the same functionality. - The
#[solidity_storage]
macro is now deprecated in favor of#[storage]
which provides the same functionality.
Changed
- Ensure consistency between proc macros when parsing attributes.
- Update
sol_interface!
macro to report errors when using Solidity features
which have not yet been implemented.
Fixed
- Properly encode bytes when calling external contracts.
- Properly encode Bytes and strings in return types.
- Bytes type now works properly in
export-abi
. export-abi
now works for contracts with no functions with returned values.- Off-by-one error when storing strings with length 32.
- Interfaces in
sol_interface!
no longer incorrectly inherit functions from
previous definitions.
Documentation
- Various documentation updates for clarity.
- Cleaned up typos and moved TODOs to the github issue tracker.
Security
- Function signatures which generate the same selector values will now fail
at compile-time to avoid misleading contract calls.
Stylus SDK 0.4.3
This release introduces two quality of life improvements around error handling to the Stylus SDK.
Infallible Methods
External methods may now be infallible. That is, you don't have to write Result
and Ok
unless the code returns an error.
#[external]
impl Counter {
pub fn number(&self) -> U256 {
self.number.get()
}
}
[derive(SolidityError)]
The derive(SolidityError)
macro simplifies the error declaration process.
sol! {
error InsufficientBalance(address from, uint256 have, uint256 want);
error InsufficientAllowance(address owner, address spender, uint256 have, uint256 want);
}
#[derive(SolidityError)]
pub enum Erc20Error {
InsufficientBalance(InsufficientBalance),
InsufficientAllowance(InsufficientAllowance),
}
#[external]
impl Contract {
pub fn fallible_method() -> Result<(), Erc20Error> {
// code that might revert
}
}
The above is abi-compatible with Solidity and will auto-generate interface types.
cargo stylus export-abi
interface IContract {
function fallibleMethod() external;
error InsufficientBalance(address, uint256, uint256);
error InsufficientAllowance(address, address, uint256, uint256);
}