Post
Share your knowledge.
Gas-Efficient Hierarchical Data Storage
What’s the recommended pattern for gas-efficient storage of complex hierarchical data (e.g., identity trees) in Sui using Move structs?
- Sui
- Architecture
- SDKs and Developer Tools
- NFT Ecosystem
- Move
Answers
1I think the most scalable pattern is to use intermediate claim tickets instead of direct locking during migration. Instead of moving the asset directly across shards, the source shard burns the asset and issues a ClaimCap that is only redeemable once on the destination shard. This avoids object contention, because the source asset is permanently invalidated.
Here’s a Move pattern I’ve used:
module cross_shard::bridge {
struct ClaimCap has key {
id: UID,
asset_type: vector<u8>,
amount: u64,
receiver: address,
}
// Source shard burns asset and issues ClaimCap
public entry fun export_asset(asset: Coin<SUI>, receiver: address, ctx: &mut TxContext): ClaimCap {
let amount = coin::value(&asset);
coin::burn(asset);
ClaimCap { id: object::new(ctx), asset_type: b"SUI", amount, receiver }
}
// Destination shard redeems ClaimCap
public entry fun import_asset(cap: ClaimCap, ctx: &mut TxContext): Coin<SUI> {
let coin = coin::mint<SUI>(cap.amount, ctx);
object::delete(cap);
coin
}
}
This way, migration doesn’t block or hold cross-shard locks. Each shard processes its part independently, but consistency is guaranteed since the ClaimCap can’t be reused.
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