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

World metadatas no uploaded after fail #2096

Open
notV4l opened this issue Jun 21, 2024 · 16 comments
Open

World metadatas no uploaded after fail #2096

notV4l opened this issue Jun 21, 2024 · 16 comments
Labels
bug Something isn't working good first issue Good for newcomers sozo
Milestone

Comments

@notV4l
Copy link
Collaborator

notV4l commented Jun 21, 2024

Describe the bug
World metadatas are only uploaded once, at world creation.
If an error occurs on first deployement before uploading metadatas, no metadatas will be uploaded for dojo::world::world
Moreover there is no easy way to update world metadatas

To Reproduce
with dojo starter, start a migration and cancel after base & world contract has been deployed
relaunch migration

Additional context
0.7.2

@notV4l notV4l added bug Something isn't working sozo labels Jun 21, 2024
@glihm glihm changed the title [sozo] world metadatas World metadatas no uploaded after fail Jun 22, 2024
@lambda-0x lambda-0x self-assigned this Jun 24, 2024
@lambda-0x
Copy link
Collaborator

related: #2079

#2079 (comment)

@glihm
Copy link
Collaborator

glihm commented Aug 13, 2024

Closed in #2203.

@glihm glihm closed this as completed Aug 13, 2024
@lambda-0x lambda-0x removed their assignment Aug 14, 2024
@lambda-0x lambda-0x added the good first issue Good for newcomers label Aug 14, 2024
@lambda-0x
Copy link
Collaborator

@glihm this was initially the part of the linked PR, but which the new approach we took of fetching it from onchain this would have not been fixed in the same PR.

although this is less likely to happen so we can probably add a flag to force upload metadata

@lambda-0x lambda-0x reopened this Aug 14, 2024
@AshokGorana
Copy link

Can i try this ?

@lambda-0x
Copy link
Collaborator

sure @AshokGorana, but first can you describe how you plan to address this issue?

@Tushar4059x
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i want to start me open source journey and i thinks it'd be a great place for me.... can i please get this issue?

@prabhash2511
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm an IT student persuing final year

@jaikumar9
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i'm a blockchain developer from 2022 and here is my github profile - https://github.com/jaikumar9

How I plan on tackling this issue

Allow metadata updates after deployment with an admin function.

@Tushar4059x
Copy link

Tushar4059x commented Aug 29, 2024

@lambda-0x can i try this issue?

@CollinsC1O
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

love to work on this

@Constantine234
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Python programmer and also a Cairo programmer also I am pleased to say my skills can be of great value in this project thank you

How I plan on tackling this issue

I will approach this project by using the knowledge I have on Cairo and as a lover of games I will be of great assistance

@masulhasan
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I come from a programming and web development background having worked on various client-based projects and freelanced on People Per Hour and contributed to open-source initiatives. I have also worked with responsive and stateful websites and applications which included careful migration and deployment processes. My work in mortgages has reinforced my problem-solving skills which are aimed towards reliability and long term solutions of the system. This is the way why I think I can use both of these relevant aspects for analyzing the bug in Dojo’s world metadata handling and making sure that such things don’t happen again.

How I plan on tackling this issue

First I would investigate why metadata is only uploaded once and not updated on subsequent deployments if errors occur. To do this:

Reproduce the Bug: I would follow the steps (initiating and canceling the migration after base and world contracts have been deployed) and look at the logs and contract states to see where metadata handling fails.

Fix Metadata Upload Logic: I would refactor the metadata upload process so it’s not tied to the world creation phase. Instead I would make sure metadata can be uploaded or updated at any point post creation. This could mean:

Implementing a retry mechanism for metadata upload failures during deployment.

Adding the ability to update world metadata after initial deployment, perhaps by introducing a separate function or migration step for metadata updates.

Test Thoroughly: After the fix I would write comprehensive tests to simulate various deployment failures (e.g. server crashes, network issues) to make sure the metadata upload mechanism is robust.

Optimize and Document: Finally I would document this new process clearly and make sure any future contributors or users of the platform can update metadata without having to redeploy the entire world contract.

@thesledge04
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Given your scenario and the nature of the bug, my background in Python, data handling, and logical problem-solving could be helpful in diagnosing and resolving this issue. Specifically:

Programming Experience: I could assist in crafting solutions for ensuring metadata is always uploaded, either by retrying failed uploads or allowing manual updates.
Debugging & Error Handling: Experience with debugging and error handling could be used to identify and resolve the error during deployment, ensuring that metadata is not skipped.
System Design: Understanding of system architectures can help propose ways to allow post-deployment metadata updates or a retry mechanism in case of failure.

How I plan on tackling this issue

Identify Where the Issue Occurs:
The first thing to do is pinpoint exactly where in the deployment process the failure occurs. This requires reviewing:

The logic handling the uploading of metadata.
The point in the process where errors or cancellations can lead to incomplete deployments.
Questions to consider:

When exactly is the metadata uploaded in the flow?
Is there any checkpoint or transaction rollback when deployment fails?
What error message is thrown when deployment is canceled?
2. Implement Transactional Metadata Upload:
A robust deployment process should ensure metadata is uploaded only when the world creation is successful. To achieve this, I would:

Ensure the metadata upload is transactional. This means if the deployment fails or is canceled, any action related to metadata upload would be rolled back. This could be done by:
Moving metadata upload to a later stage of deployment (after the world contract is confirmed as deployed).
Guaranteeing consistency: Use an event-based approach or a flag in the contract to signal if the metadata has been successfully uploaded.
3. Error Handling and Retry Mechanism:
Add error handling and a retry mechanism for metadata uploads. If the initial deployment is interrupted:

Catch deployment errors: When the deployment process is canceled or fails, catch these errors and:
Log the failure state (including whether the metadata was uploaded or not).
Prompt the user to retry the metadata upload upon re-running the migration.
Automatic Retry: Implement an automatic retry process that, upon detecting incomplete metadata, triggers a new attempt to upload it without restarting the entire world creation process.
Example:
try:
deploy_world()
upload_metadata()
except DeploymentError:
log("Deployment failed. Retrying metadata upload.")
retry_metadata_upload()
4. Create a Metadata Update Mechanism:
Since there is no easy way to update world metadata, a feature should be introduced that allows this after the world has been created.

Manual Update API/Functionality: Implement a manual method (either through CLI, smart contract functions, or a dedicated update tool) to allow users to upload or update metadata at any point after the world is deployed.

Versioning: Consider adding versioning or timestamps to metadata updates so that any updated information is traceable.
Security: Ensure that only authorized parties (e.g., world owners) can make these updates to avoid malicious changes.
Example:

def update_metadata(world_id, new_metadata):
if authorized_user:
world_metadata[world_id] = new_metadata
log("Metadata updated successfully.")
else:
log("Unauthorized access.")
5. Post-Deployment Checks:
Implement a post-deployment validation step that verifies if the metadata has been uploaded correctly. If metadata is missing or incomplete, prompt the user with options to fix the issue before concluding the process.

Verification: After the contracts are deployed, check if metadata exists for the world.
Prompt for Re-upload: If not, ask the user if they want to retry the metadata upload.
6. Unit Tests and Migrations Validation:
Once the fix is in place, write unit tests and conduct end-to-end testing of the entire migration process to ensure:

The metadata is uploaded properly in all cases (success, failure, or cancellation).
Retrying works as expected when errors occur.
Example Solution Flow:
Deploy base and world contracts.
Upload metadata (only if deployment is successful).
If unsuccessful, allow retry without redeploying the entire contract.
In case of failure: Catch the failure, log it, and prompt for manual or automatic retry.
Introduce metadata update functionality to handle cases where metadata changes are needed after world creation.

@vic-Gray
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a back-end developer with strong experience in systems architecture, databases, and cloud infrastructure. I specialize in frameworks like NestJS and database management systems such as PostgreSQL, which enable me to design reliable and scalable backend services. Additionally, I am proficient in TypeScript, which strengthens my ability to handle complex codebases with a clear focus on typing and structure.

My background enables me to understand issues related to deployment processes and system upgrades. Given my experience, I can identify bottlenecks in software deployments, data synchronization problems, and architectural pitfalls. This skill set would allow me to analyze and resolve bugs like the metadata upload issue in your system.

How I plan on tackling this issue

Analyze and Debug the Existing Code: My first step would be to examine the existing deployment logic related to the dojo::world::world metadatas. I would review how and when the metadatas are triggered for upload and investigate if they are tied to specific conditions during world creation.

Implement a Retry Mechanism: Since the issue occurs when the initial deployment fails, I would introduce a retry mechanism that allows metadata uploads to re-attempt in case of errors. This could be done by adding error-handling mechanisms that ensure metadata upload is retried after failure rather than abandoned.

Add Metadata Update Functionality: I would introduce a separate function or API endpoint allowing updates to metadatas after initial world creation. This would allow administrators or developers to manually update world metadata whenever required, resolving the problem of immutability.

Testing and Validation: I would thoroughly test this fix by simulating various scenarios such as deployment failures, re-attempted migrations, and metadata updates. This would help ensure that the solution is robust across different environments.

Analyze and Debug the Existing Code: My first step would be to examine the existing deployment logic related to the dojo::world::world metadatas. I would review how and when the metadatas are triggered for upload and investigate if they are tied to specific conditions during world creation.

Implement a Retry Mechanism: Since the issue occurs when the initial deployment fails, I would introduce a retry mechanism that allows metadata uploads to re-attempt in case of errors. This could be done by adding error-handling mechanisms that ensure metadata upload is retried after failure rather than abandoned.

Add Metadata Update Functionality: I would introduce a separate function or API endpoint allowing updates to metadatas after initial world creation. This would allow administrators or developers to manually update world metadata whenever required, resolving the problem of immutability.

Testing and Validation: I would thoroughly test this fix by simulating various scenarios such as deployment failures, re-attempted migrations, and metadata updates. This would help ensure that the solution is robust across different environments.

@Deepak2623
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have over 3 years of experience as a backend developer, with a strong focus on blockchain technology, particularly in smart contract development and deployment. I have previously taught over 400 students about blockchain at Anna University, which has given me a solid foundation in the intricacies of decentralized applications. My expertise includes working with technologies such as Hardhat, Polygon Mumbai, and more recently, Dojo, where I have been involved in smart contract migration, debugging, and optimization. I have also worked across multiple development roles, giving me a holistic view of both technical and architectural challenges within blockchain systems.

How I plan on tackling this issue

Analyze the Deployment Process: I would begin by conducting a thorough analysis of the deployment pipeline for the world contract and metadata. This involves identifying the exact step where metadata upload is triggered and where the process fails when deployment is interrupted. By breaking down the entire flow, I can pinpoint vulnerabilities in the sequence.

Implement Error Handling and Fallbacks: One of the key issues here is that metadata upload is not retried after an initial failure. I would design a more robust error-handling mechanism by implementing automatic retries or checkpoints, ensuring that metadata upload does not happen until the world contract is fully deployed. This would guarantee that an incomplete deployment does not prevent the upload of essential metadata.

Enable Metadata Updates: Given that there's no current mechanism to update metadata, I would extend the contract to include functionality that allows the update of metadata post-deployment. This could be done through an additional function in the smart contract that can be called only when certain conditions are met (e.g., verifying that the initial metadata upload was unsuccessful).

@GradleD
Copy link

GradleD commented Oct 16, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am Full-Stack Web Developer with over 4+ years of experience

How I plan on tackling this issue

To address the issue of world metadata only being uploaded once during world creation in the Dojo framework, and the complications that arise if an error occurs during the initial deployment, follow these steps:
Understanding the Problem
Single Upload Limitation: The metadata for dojo::world::world is only uploaded at the time of world creation. If the deployment fails before this upload, you will not have a way to upload the metadata later.
Difficulty in Updating Metadata: Once the metadata is set, there is no straightforward method to update it, which can lead to issues if changes are needed post-deployment.
Steps to Reproduce the Issue
To reproduce this issue using the Dojo starter project:
Start a migration process.
Cancel it after the base and world contracts have been deployed.
Relaunch the migration to observe that the metadata does not upload again.
Proposed Solutions

  1. Error Handling During Deployment
    Implement robust error handling in your migration scripts to ensure that any errors encountered during deployment are logged and addressed before proceeding. This includes:
    Validation Checks: Before initiating a deployment, validate all necessary parameters and configurations.
    Rollback Mechanism: If an error occurs, ensure that you can roll back to a previous stable state without losing any data.
  2. Manual Metadata Upload
    If you encounter this issue:
    Create a separate script or function that allows for manual uploading of metadata after initial deployment.
    This could involve directly interacting with the smart contract or using an API endpoint designed for this purpose.
  3. Update Mechanism for Metadata
    Develop a mechanism to allow updates to world metadata:
    Consider implementing a function within your smart contract that allows for metadata updates under specific conditions (e.g., only by an admin).
    This function should include checks to ensure that updates are valid and do not compromise the integrity of the world state.
  4. Utilize Middleware Features
    With the introduction of before and after middleware in Dojo 5, leverage these features to manage processes around world creation and metadata uploads:
    Use before middleware to run validation and setup tasks before deploying worlds.
    Use after middleware to handle any cleanup or notifications after deployment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers sozo
Projects
Status: Done
Development

No branches or pull requests