Post
Share your knowledge.
how to fix BACKWARD_INCOMPATIBLE_MODULE_UPDATE error
Hi, I am trying to upgrade a contract published on testnet. I am just changing the version const value to 2. But while I try to upgrade it i am getting BACKWARD_INCOMPATIBLE_MODULE_UPDATE error.
Here is the error msg:
Error: Dry run failed, could not automatically determine a budget: PackageUpgradeError { upgrade_error: IncompatibleUpgrade } in command 1
at setGasBudget (/Users/simusud/Desktop/new_one/one-sui-smart-contracts/node_modules/@mysten/sui/src/experimental/transports/json-rpc-resolver.ts:69:9)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
[cause]: {
effects: {
messageVersion: 'v1',
status: [Object],
executedEpoch: '770',
gasUsed: [Object],
modifiedAtVersions: [Array],
transactionDigest: 'DJBCDqPmJcUBamvV6eJfQxdZTXL3DT3bsKJ4jzDZ2vwd',
mutated: [Array],
gasObject: [Object],
dependencies: [Array]
},
events: [],
objectChanges: [ [Object], [Object] ],
balanceChanges: [ [Object] ],
input: {
messageVersion: 'v1',
transaction: [Object],
sender: '0xa363fb07f43b034cd8f0bd6b75f15a2855da191191989fbb9b45d5e01ac87b2d',
gasData: [Object]
},
executionErrorSource: 'PartialVMError with status BACKWARD_INCOMPATIBLE_MODULE_UPDATE'
}
}
{ result: '' }
- Sui
Answers
5The BACKWARD_INCOMPATIBLE_MODULE_UPDATE error in Sui typically occurs when your upgraded Move module introduces changes that are not backward-compatible with the previously published version.
Even minor-looking changes, like updating a constant value, can trigger this if the Sui framework determines that the module layout has changed in a way that might break compatibility for clients depending on the old version.
The BACKWARD_INCOMPATIBLE_MODULE_UPDATE error occurs when your Move module changes violate Sui's backward compatibility rules during an upgrade. To fix this, ensure all existing public function signatures, struct layouts, and storage formats remain unchanged when incrementing the version. Check for modifications to public/entry functions, struct fields, or key abilities that might break existing dependencies. Use sui move verify to detect compatibility issues before deploying. If intentional breaking changes are needed, consider deploying a new package instead of upgrading.
The BACKWARD_INCOMPATIBLE_MODULE_UPDATE error means your upgrade breaks backward compatibility. Even changing a const can trigger this if it alters the module's public API or storage layout.
How to Fix:
-
Ensure Compatibility – Avoid:
- Removing/renaming public functions or structs.
- Changing existing struct fields (even private ones).
- Modifying
constvalues used in storage.
-
Test with
sui move verify– Checks upgrade compatibility before publishing. -
If Stuck:
- Publish as a new package (not an upgrade).
- Or keep the old version and deploy a new module.
Root Cause
You're making breaking changes that violate Sui's backward compatibility rules. Even version number changes require strict adherence to upgrade rules.
Quick Fixes
-
Ensure Structural Compatibility:
- Never change existing
public/entryfunction signatures - Never modify existing struct fields (order/type)
- Only add new functions/structs
- Never change existing
-
For Version Bumps:
// Old (v1) const VERSION: u64 = 1; // New (v2) - Add this instead of modifying const VERSION_2: u64 = 2; // Keep old constant -
Required Steps:
# 1. Verify compatibility sui move verify --path <your-package> --against <original-package-id> # 2. Upgrade with explicit compatibility check sui client upgrade --gas-budget 1000000000 --skip-compatibility-check false
Common Pitfalls
- Changing
public/entryfunction parameters - Reordering struct fields
- Removing or modifying existing constants
If Absolutely Necessary
# Force upgrade (not recommended)
sui client upgrade --skip-compatibility-check true
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking616
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction419
- Sui Transaction Failing: Objects Reserved for Another Transaction410