Skip to content

Releases: OffchainLabs/stylus-sdk-rs

v0.10.0-beta.1

15 Aug 19:31
6111e94
Compare
Choose a tag to compare
v0.10.0-beta.1 Pre-release
Pre-release

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

20 May 17:37
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.8.1...v0.9.0

v0.8.4

09 Apr 19:30
Compare
Choose a tag to compare

Full Changelog: v0.8.3...v0.8.4

Issues:

  1. 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.
  2. 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

18 Mar 15:03
a8cf156
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.8.2...v0.8.3

Stylus SDK v0.8.2

11 Mar 21:16
v0.8.2
5da9bdd
Compare
Choose a tag to compare

0.8.2 - 2025-03-11

Fixed

  • Fix cargo stylus replay #226

Stylus SDK v0.8.1

21 Feb 15:44
5ab4881
Compare
Choose a tag to compare

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!

12 Feb 18:53
eeccda9
Compare
Choose a tag to compare

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

Full Changelog: v0.7.0...v0.8.0

Stylus SDK v0.7.0

03 Feb 21:15
d1bd030
Compare
Choose a tag to compare

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 in sol_interface! macro
  • Refactor of proc macros for better maintainability and testability

Stylus SDK 0.6.0

03 Sep 16:15
4d5a9e5
Compare
Choose a tag to compare

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 with mini-alloc enabled by default. This means that
    a #[global_allocator] should not be declared in most cases. If a custom
    allocator is still needed the mini-alloc should be disabled (enabled by
    default).
  • StorageU1 and StorageI1 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

23 Feb 19:22
bf26cb5
Compare
Choose a tag to compare

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);
}