NoshonNetworks / landver

Onchain Land Management
https://landver.vercel.app/
MIT License
7 stars 25 forks source link

Implement Land ID Generation System #84

Closed fishonamos closed 2 weeks ago

fishonamos commented 2 weeks ago

Currently, our land registry system uses block timestamps to generate land IDs, which can be problematic due to potential collisions and predictability. We need to implement a more robust and secure method for generating unique land IDs.

Task: Develop and implement a new system for generating unique land IDs that doesn't rely on block timestamps.

The new system should be:

• Collision-resistant • Unpredictable • Scalable for a large number of land parcels • Suggested Approach:

Some options to consider: • Keccak256 hash of multiple inputs (e.g., owner address, location, current block number) • Incremental counter combined with a random element • UUID-like generation adapted for smart contract use • Implement the chosen method in the LandRegistry contract: • Create a new function for ID generation • Update the register_land function to use the new ID generation method • Ensure the new method is gas-efficient • Update any related functions or storage variables that depend on the land ID • Implement a migration strategy for existing land parcels (if applicable) • Update tests to reflect the new ID generation system

Definition of Done:

• A new land ID generation system is implemented and integrated into the LandRegistry contract • The new system demonstrably produces unique, unpredictable IDs • All existing functionality using land IDs is updated and working correctly • Comprehensive tests are written to verify the new ID generation system • The generated IDs are not easily predictable based on public information • All existing tests pass with the new implementation • New tests specifically for ID generation are added and passing

PoulavBhowmick03 commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a Starknet Wolf. I am a software engineer at Invisible Studios, and a blockchain engineer with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet, Ethereum, Stellar ecosystem.

How I plan on tackling this issue

To solve this issue, I plan to implement a new unique land ID generation system by utilizing a combination of Keccak256 hashing and an incremental counter. This approach will ensure collision resistance, unpredictability, and scalability. Specifically, I will generate land IDs by hashing together the owner address, the land location, and a unique incremental counter value. This hash will serve as the land ID, ensuring both uniqueness and security by making the IDs difficult to predict. I will create a new generate_land_id function to encapsulate this logic and update the register_land function to use the new system. The counter will increment with each registration, providing scalability while avoiding collisions. Additionally, I will ensure that the method is gas-efficient by minimizing the inputs to the Keccak256 hash. Any related functions or storage variables that depend on land IDs will be updated accordingly. I will also write a migration strategy to handle any existing land parcels, and update the test suite to verify the correctness of the new ID generation system. Finally, I will ensure that the solution is thoroughly tested with comprehensive test cases to validate uniqueness, unpredictability, and functionality of the new land ID system.

CollinsC1O commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello can I work on this

SoarinSkySagar commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

GM @fishonamos, I am Sagar Rana, a smart contract developer and full stack engineer. I have 3 years of experience building robust full stack applications and over a year of writing smart contracts. You can see my projects and contributions to some major repos on my GitHub profile. The tech stack I use mainly includes Solidity, Rust, Cairo and Typescript. I am also contributing to the Starknet and Rust ecosystems and building on Cairo and Rust languages. I am interested in contributing to projects like this to learn more about these technologies and help make these projects better. Please assign me as I would be really glad to be a contributor in this project! :)

How I plan on tackling this issue

ETA: 1 Day

JoE11-y commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Joseph a blockchain developer with over four years in blockchain and backend development, I’ve worked across different ecosystems, handling everything from smart contract design to on-chain interactions and protocol integration. I focus on building secure, scalable, and reliable blockchain applications, managing both on-chain and off-chain infrastructure.

How I plan on tackling this issue

Begin by studying the codebase to ensure design consistency, then proceed to work on the task.

  1. Study current codebase design
  2. Leverage all provided resources within the issue to get a better grasp of the task at hand.
  3. Implement the task.
  4. Add tests to make sure the changes are working and no adverse effects
  5. And lastly optimize
blessingbytes commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello i'm a frontend and blockchain developer, pls i will love to work on it. thank you

How I plan on tackling this issue

ShantelPeters commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have extensive experience in blockchain development, focusing on smart contract design and implementation. My background includes working with Ethereum and StarkNet, where I have developed systems that require secure and efficient data management, including NFT and land registry solutions. I have a strong understanding of cryptographic techniques, gas optimization strategies, and testing methodologies. This experience equips me to design and implement a robust and secure land ID genera

How I plan on tackling this issue

I would first analyze the requirements for generating unique land IDs that are collision-resistant and unpredictable. To achieve this, I would consider several options, including using a Keccak256 hash of multiple inputs (such as the owner's address, land location, and a random nonce), implementing an incremental counter combined with a random element, or adopting a UUID-like generation approach tailored for smart contracts.

Once I select the most appropriate method, I would implement a new function in the LandRegistry contract to handle the ID generation. This function would ensure that the generated IDs are unique and unpredictable, avoiding reliance on block timestamps. I would also update the register_land function to utilize this new ID generation method, ensuring that the change integrates seamlessly with existing functionality.

To ensure gas efficiency, I would profile the implementation and optimize any resource-intensive operations. If applicable, I would devise a migration strategy for existing land parcels to transition them to the new ID system without disrupting current operations.

I would also update any related functions or storage variables that depend on land IDs to ensure they are compatible with the new system. Comprehensive tests would be developed to verify the new ID generation system, checking that it produces unique and unpredictable IDs based on public information. I would ensure that all existing tests pass with the new implementation and add new tests specifically targeting the ID generation logic.

By following this structured approach, I will ensure that the new land ID generation system is robust, scalable, and seamlessly integrated into the existing LandRegistry contract.

nickgore commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I'm data analyst / SC dev. For last half a year i ve been participating in development of DeFi products on Starknet, thus i have quite extensive hands on experience with Cairo. I would love to contribute to this issue or tackle something more challenging.

How I plan on tackling this issue

I propose to use keccak256 hash func with owner address, block number and random input. Random input will be generated with Linear congruential generator and will ensure unpredictibility of new ids. Combination of several inputs (unique among them) makes collision mathematically impossible.. 256 bit output space insures practivally unlimited number of unique IDs. Approach uses fixed number of operations, doesnot loop through existing IDs, storage operations are single writes, thus we have constant time gas cost.

Step:

  1. implemnet LCG function

  2. implement id generation function utilising LCG function mentioned above

  3. modify register_land function so it uses new id generator function

  4. add assert for collision in register_land

  5. Migration is up for discussion, as we can keep old ids as they are(typewise no issue here) and continue with new ids. Or migration can be done with custom owner-only migration function that would map old ids into new ones. Map of legacy id to new id can be saved in storage as BE or BO might be dependent on it.

  6. Test coverage includes: tests for LCG func, id generator func, add test case for fn register_land that would panic in case of collision.

ETA 3 days

suhas-sensei commented 2 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i am a python dev and i would like to work on this.

SoarinSkySagar commented 2 weeks ago

GM @fishonamos, this issue is ready to be closed by #99, please review the PR for any changes!