Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation failed with status: BACKWARD_INCOMPATIBLE_MODULE_UPDATE\nExecution failed with message: Module Update Failure #1028

Open
makimakiver opened this issue Jan 29, 2025 · 3 comments

Comments

@makimakiver
Copy link

what should I do with this such an error? I always have the error when I wanted to deploy my smart contracts.

Image

here is the event module:

`module movement::event{
use std::debug::print;
use std::signer::address_of;
use 0x1::event;

struct GlobalData has key, drop {
    value: u64
}

#[event]
struct EventChangeValue has drop, store {
    value: u64,
    executor: address
}

#[event]
struct EventChangeValueV2 has drop, store {
    value: u64,
    executor: address,
    new_field: bool
}

const EResourceNotExist: u64 = 33;
const ENotEqual: u64 = 10;

public fun new_global(signer: &signer, value: u64) {
    let data = GlobalData {
        value: value
    } ;
    move_to(signer, data);
}

public fun check_global_storage_exists(addr: address): bool {
    exists<GlobalData>(addr)
}

#[view]
public fun get_value_from_global_storage(addr: address): u64 acquires GlobalData {
    if (!check_global_storage_exists(addr)) {
        abort EResourceNotExist
    };
    let value_reference = borrow_global<GlobalData>(addr);
    print(&value_reference.value);
    value_reference.value
}

public entry fun remove_resource_from_global_storage(account: &signer) acquires GlobalData {
    let rev = move_from<GlobalData>(address_of(account));
}

public entry fun change_value_from_global_storage(signer: &signer, value: u64) acquires GlobalData {
    let addr = address_of(signer);
    if (!check_global_storage_exists(addr)) {
        abort EResourceNotExist
    };

    let value_reference = &mut borrow_global_mut<GlobalData>(addr).value;
    *value_reference = *value_reference + value;
    event::emit(EventChangeValueV2 {
        value,
        executor: addr,
        new_field: true
    });
}

#[test(account = @default)]
fun test_new_global(account: &signer) {
    new_global(account, 10);
}

#[test(account = @default)]
fun test_change_value_global(account: &signer) acquires GlobalData {
    new_global(account, 10);
    change_value_from_global_storage(account, 10); // value should be equal 20
    let value = get_value_from_global_storage(address_of(account));
    assert!(value == 20, ENotEqual);
    // remove resource
    remove_resource_from_global_storage(account);
    assert!(!check_global_storage_exists(address_of(account)), EResourceNotExist);
}

}
`

@0xmovses
Copy link
Contributor

What command are you running and what version of the movement CLI are you on?

@makimakiver
Copy link
Author

I ran "movement move publish"
the version of CLI is "aptos 3.5.0" I got it by typing "movement -V"

@0xmovses
Copy link
Contributor

Ok @Rahat-ch could you try to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants