MyGit

v0.48.0

FuelLabs/fuels-rs

版本发布时间: 2023-09-12 04:51:22

FuelLabs/fuels-rs最新发布版本:v0.61.0(2024-05-10 12:13:19)

What's Changed

New Contributors

Full Changelog: https://github.com/FuelLabs/fuels-rs/compare/v0.47.0...v0.48.0

Breaking changes and new features

Predicate gas estimation fix

Recently, we've had an issue with estimating gas in predicates. This release fixes it but introduces some small API changes: calculate_base_amount_with_fee() now returns an Option<64>. We also went from fn fee_checked_from_tx(&self, params: &ConsensusParameters) -> Option<TransactionFee>; to fn fee_checked_from_tx(&self, params: &ConsensusParameters) -> Result<Option<TransactionFee>>;

Storage slots autoload

Automatic Loading of Storage Slots: Storage slots are now autoloaded by default to simplify and optimize the integration process. Should you wish to opt-out, an option is readily available.

When the StorageConfiguration indicates that autoload should be enabled, Contract::load_from will attempt to find the storage slots file within the same directory as the contract binary. This ensures a seamless experience without needing additional configuration in typical setups.

Enhancements related to this feature:

Guided Error Handling: The SDK will generate an error if the storage slots file is missing. In this scenario, you will be given guidance to source the required file or deactivate the autoload feature to help the user.

Priority Configuration: Users can still manually configure storage slots in StorageConfiguration. This manual configuration will precede the default settings autoloaded from the storage slots file.

Bug Fix: Rectified an error exposed by the autoload feature. Previously, the system did not properly account for storage slots during the computation of the heap data offset for predicates. This has now been addressed.

Breaking Changes:

Updated Storage Configuration Interface: As you know, modifications have been made to the storage configuration interface. Please review the documentation to understand these changes and adjust your setups accordingly.

Behavioural Adjustments with Autoloading: Since storage slots are now autoloaded by default, some users may notice differences in system behaviour. Assessing this feature in your context is important to ensure it aligns with your project's requirements.

This is how the usage around storage slots look like:

#[tokio::test]
async fn storage_slots_override() -> Result<()> {
    {
        // ANCHOR: storage_slots_override
        use fuels::{programs::contract::Contract, tx::StorageSlot};
        let slot_override = StorageSlot::new([1; 32].into(), [2; 32].into());
        let storage_config =
            StorageConfiguration::default().add_slot_overrides([slot_override]);

        let load_config =
            LoadConfiguration::default().with_storage_configuration(storage_config);
        let _: Result<Contract> = Contract::load_from("...", load_config);
        // ANCHOR_END: storage_slots_override
    }

    {
        // ANCHOR: storage_slots_disable_autoload
        use fuels::programs::contract::Contract;
        let storage_config = StorageConfiguration::default().with_autoload(false);

        let load_config =
            LoadConfiguration::default().with_storage_configuration(storage_config);
        let _: Result<Contract> = Contract::load_from("...", load_config);
        // ANCHOR_END: storage_slots_disable_autoload
    }

    Ok(())
}

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-09-12发行的版本