Canister does not rollback when trap occured

When i use call_with_payment128 in canister。This problem occurs when http calls or creates canister and cycles above 0
The state before call did not rollback when trap occured。
The pseudo code is as follows,Change state from 0 to 1 :

state = 1

When the trap occurs, the status still changes to 1 and the rollback does not occur.

Read: Avoid traps after await


What you described is expected. When there’s an inter-canister call which you await on, there are two separate message executions. The first one ends when the message is enqueued and if it’s successful the state changes will be committed. The second message execution happens when your canister handles the response from the inter-canister call. If you panic! on the callback, then only the changes made by the callback handler will be rolled back (i.e. in the same message execution).