MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.18k stars 11.19k forks source link

Namespace collision between packages' dependencies #20112

Open Oni-giri opened 6 days ago

Oni-giri commented 6 days ago

Steps to Reproduce Issue

Consider an empty project with the following Move.toml:

[package]
name = "test"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move

[dependencies]
Sui = { override = true, git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
ScallopProtocol = { git = "https://github.com/scallop-io/sui-lending-protocol.git", subdir = "contracts/protocol", rev = "mainnet" }
lending_core = { git = "https://github.com/naviprotocol/protocol-interface.git", subdir = "lending_core", rev = "main" }

Expected Result

Everything compiles

Actual Result

Calling sui move build will return the following error:

Failed to build Move modules: Processing dependency 'lending_core' of 'test'

Caused by:
    Conflicting assignments for address 'math': '0x0' and '0x66aa3335901ce7e04b85ed6597ee42d4b479f7110bf98e8ebd474fa32a0027e1'..

Remarks

Note that removing ScallopProtocol or lending_core (Navi Finance) will compile fine.

The issue here is likely that both protocols use their own math dependency :

Given that both libraries are not overlapping, we can't try to override it.

System Information

tzakian commented 5 days ago

Hi there!

This is a problem due to Scallop and Navi exposing two different named addresses with the same name. This should be able to be resolved using the addr_subst form in the Move.toml which can be used to rename the math named address on either or both of the packages that bring the math address into scope. Give this a shot and it should work:

[package]
name = "test"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move

[dependencies]
Sui = { override = true, git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
ScallopProtocol = { git = "https://github.com/scallop-io/sui-lending-protocol.git", subdir = "contracts/protocol", rev = "mainnet", addr_subst = {"scallop_math" = "math" } }
lending_core = { git = "https://github.com/naviprotocol/protocol-interface.git", subdir = "lending_core", rev = "main", addr_susbst = {"lending_math" = "math" } }