Setting block timestamp not reflecting timestamp inside Fuel VM

I’m running into the same problem @buddy-brontosaurus had here:

I can use the SDK to set block timestamps, and this works normally if I query from Rust using provider.get_blocks.

However, when I call the following code in my Sway contract:

    fn get_time() -> u64 {
        timestamp()
    }

…it returns the current time, (4611686020106380522), not the custom time that I tried to specify.

3 Likes

FWIW I never found a resolution. I just created a helper timestamp method on Sway and called those from the rust sdk.
The other option is mocking your own timestamps

2 Likes

Bump
Would be highly appreciated if sb could clarify whether setting a custom timestamp is now possible or not.

3 Likes

yes , its slow respond website

Hey, sorry this passed our radar. There was a problem with the way fuel-core handled block production, that was fixed here.
Progress on integrating this upstream change in the SDK is tracked here, it should be out soon.

1 Like

The fix was part of https://github.com/FuelLabs/fuels-rs/pull/950, and you can find a proper example since docs: show example of block time travel by iqdecay · Pull Request #985 · FuelLabs/fuels-rs · GitHub.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.