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

feat(sozo): output block number after successful migration #717

Merged
merged 5 commits into from
Aug 11, 2023

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Aug 6, 2023

Fixes: #687

print block number in stdout

@lambda-0x lambda-0x marked this pull request as ready for review August 7, 2023 17:27
@tarrencev tarrencev requested a review from kariy August 7, 2023 20:58
Copy link
Member

@kariy kariy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe outputting the block number is so that torii can start syncing from when the World contract is deployed, instead of starting from block 0.

This would not output the block of when the World is deployed though but instead the block of when the migration is finished.

@lambda-0x
Copy link
Contributor Author

thats what i thought earlier, but world is redeployed for any kind of migration so afaik torii just needs the last world deployment block to get all info it needs.

@kariy
Copy link
Member

kariy commented Aug 8, 2023

but world is redeployed for any kind of migration

World will not be redeployed on component/system updates. It will only migrate the changed components/systems.

so afaik torii just needs the last world deployment block to get all info it needs.

that would skip the prev blocks, no? torii still need to process components/systems registration events but this would only output the block where we finish the migration and the components/systems registration might've been done in prev blocks, which then it would skip.

@lambda-0x
Copy link
Contributor Author

lambda-0x commented Aug 8, 2023

World will not be redeployed on component/system updates. It will only migrate the changed components/systems.

oh, i saw WorldContract::new so i thought it means new deployment.

that would skip the prev blocks, no? torii still need to process components/systems registration events but this would only output the block where we finish the migration and the components/systems registration might've been done in prev blocks, which then it would skip.

hmm so is the linked issue asking for block number at which the first deployment happened? but that means we would return the same block_number for all migrations which i don't think is very useful.

i think we basically need to prune blocks to only process ones that have relevant state now, for that would returning min(deployed_block_height(all_dojo_contract)) work? (not sure how to get this value though, any pointers would be helpful if this needs to be implemented)

i am not sure how torii works so i need more context on what needs to be done here

CC: @broody @kariy

@broody
Copy link
Collaborator

broody commented Aug 8, 2023

hmm so is the linked issue asking for block number at which the first deployment happened? but that means we would return the same block_number for all migrations which i don't think is very useful.

Yeah, as kairy mentioned, torii would use the block from where the world is first deployed so it can process registration events and create component/system specific db tables.

So I think two scenarios - If sozo migrate causes incremental update, deployed block would remain the same. If we force new deployment with sozo migrate —name diff_name then block number reflects where new world contract is deployed.

@lambda-0x
Copy link
Contributor Author

lambda-0x commented Aug 9, 2023

okay i have updated it to return block number only when world contract is migrated.

Because there isn't a good way to store the block_number returned in subsequent runs we don't print block_number when world is not migrated. but if we need it after we start storing this value in manifest file we can print it everytime.

@lambda-0x lambda-0x requested a review from kariy August 9, 2023 12:55
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@kariy kariy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
@kariy kariy merged commit 2338b50 into dojoengine:main Aug 11, 2023
@lambda-0x lambda-0x deleted the fix-687 branch August 11, 2023 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Sozo] Output block # after successful migration
3 participants