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

Refactors testnetify and remove last localOsmosis Dockerfile #2795

Merged
merged 10 commits into from
Sep 22, 2022

Conversation

niccoloraspa
Copy link
Member

@niccoloraspa niccoloraspa commented Sep 20, 2022

What is the purpose of the change

As per the title, this PR:

  1. refactors the testnetify scripts
  2. removes the localOsmosis Dockerfile

Main changes:

  • Give code a better structure
  • Create a CLI tool with multiple arguments
  • Decouple the testnetify process from the osmosisd binary. All the needed addresses are now expected as input.
  • Reuse the main Dockerfile to avoid creating a dedicated one
  • Significant speedup was obtained by:
    • reading/writing from disk only at the beginning/end
    • Replace the sed_inplace with the replace function that works in-memory
    • IBC module pruning
  • Run the testnetify.py at docker run time and not at docker build time

Brief Changelog

  1. Refactor testnetify scripts
  2. Remove the localOsmosis Dockerfile

Testing and Verifying

I have updated the documentation that can be followed to test the process.

Main parts:

  1. Copy state_export.json in tests/localosmosis/state_export/state_export.json
  2. localnet-build-state-export
  3. localnet-start-state-export

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@niccoloraspa niccoloraspa requested a review from a team September 20, 2022 11:08
@github-actions github-actions bot added C:docs Improvements or additions to documentation T:build labels Sep 20, 2022
@niccoloraspa
Copy link
Member Author

niccoloraspa commented Sep 20, 2022

A good way to review changes and understand the new flow is to go to top-down:

  1. Inspect docker-compose.yaml
  2. Inspect start.sh
  3. Inspect testnetify.py

Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

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

Awesome job with this!! Its really awesome to see something that is actually understandable compared to the previous testnetify script. Would like to discuss some of these points and then do another review before merging if possible!

tests/localosmosis/state_export/scripts/testnetify.py Outdated Show resolved Hide resolved
tests/localosmosis/state_export/scripts/testnetify.py Outdated Show resolved Hide resolved
tests/localosmosis/state_export/scripts/testnetify.py Outdated Show resolved Hide resolved
localnet-remove-state-export:
@docker-compose -f tests/localosmosis/mainnet_state/docker-compose-state-export.yml down
rm -rf $(PWD)/tests/localosmosis/state_export/.osmosisd
Copy link
Member

@czarcas7ic czarcas7ic Sep 20, 2022

Choose a reason for hiding this comment

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

Are we utilizing a .osmosisd folder within the repo itself to retain data? If so, we should change this to utilize the .osmosisd folder located in the home directory.

Copy link
Member Author

@niccoloraspa niccoloraspa Sep 20, 2022

Choose a reason for hiding this comment

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

Yes, we're using a .osmosisd folder within the repo.
Same behavior of regular localOsmosis.

Should we change both?
TBH I prefer keeping it inside the repo but it's not a problem changing it.

Copy link
Member

Choose a reason for hiding this comment

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

Can we change this on both? From personal experience (today actually), I was confused where it was pulling the data from and had to remake a testnet instead of upgrading it. With the knowledge I have now I realize I could have done the following:

  1. Move the .osmosisd repo to the home folder
  2. Checkout v12
  3. Move the .osmosisd repo back to the in repo location

This seems like a hassle when we could just keep it using .osmosisd. What are your thoughts though? Totally down to keep it this way if there is a good reason!

Copy link
Member Author

@niccoloraspa niccoloraspa Sep 21, 2022

Choose a reason for hiding this comment

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

The osmosis home makes more sense, to be honest.
Using the .osmosisd folder within the repo was done for simplicity.

The initialization step of both localOsmosis setups (modifying the various tomls and genesis) runs only if no .osmosisd/config folder it's found: https://github.com/osmosis-labs/osmosis/blob/main/tests/localosmosis/scripts/setup.sh#L87

The check allows the possibility to stop/restart and restart the chain without repeating the initialization step as well as persisting the data.

If we want to use the .osmosisd folder in the home, we need to handle the first run of the script ensuring that the ~/.osmosisd folder is empty otherwise the init phase won't run

@niccoloraspa
Copy link
Member Author

Implemented some changes and addressed the other points

@czarcas7ic
Copy link
Member

Side note, does args.verbose default to True? If not I think it should imo.

Only question remaining is discussion on .osmosisd folder, other than that everything else looks good to go!

@niccoloraspa
Copy link
Member Author

Side note, does args.verbose default to True? If not I think it should imo.

Only question remaining is discussion on .osmosisd folder, other than that everything else looks good to go!

verbose defaults to false

@czarcas7ic
Copy link
Member

@niccoloraspa do you agree that verbose should default to true? Also, would you like to just merge this as is and address the .osmosisd issue in a subsequent PR or do you want to do this in this PR? I'll approve now so you can decide whatever works best for you!

@niccoloraspa
Copy link
Member Author

@niccoloraspa do you agree that verbose should default to true? Also, would you like to just merge this as is and address the .osmosisd issue in a subsequent PR or do you want to do this in this PR? I'll approve now so you can decide whatever works best for you!

No strong preference, I'm happy with verbose output as a default.
I will invert the logic and rename the -v, --verbose flag to -q, --quiet to make the output less verbose if needed.

@czarcas7ic
Copy link
Member

As discussed, merging this, then fixing/merging #2813. From there we can make a fix for utilizing the home folder

@czarcas7ic czarcas7ic merged commit 3fa5450 into main Sep 22, 2022
@czarcas7ic czarcas7ic deleted the feat/refactor-testnetify branch September 22, 2022 17:24
@czarcas7ic czarcas7ic added the A:backport/v12.x backport patches to v12.x branch label Sep 22, 2022
mergify bot pushed a commit that referenced this pull request Sep 22, 2022
* Refactor testnetify and remove Dockerfile

* Manually replace new validator public key

* Improve output formatting

* Bug fixes

* Add ACCOUNT_PUBKEY and ACCOUNT_ADDRESS input

* Add environment variables as input and config folder check

* Update docs, Makefile and rename folder

* Modify CLI arguments

* Update docker-compose.yaml defaults and print updated values

* Invert printing logic replacing verbose with quiet

(cherry picked from commit 3fa5450)

# Conflicts:
#	tests/localosmosis/README.md
@czarcas7ic czarcas7ic added the A:backport/v11.x backport patches to v11.x branch label Sep 22, 2022
mergify bot pushed a commit that referenced this pull request Sep 22, 2022
* Refactor testnetify and remove Dockerfile

* Manually replace new validator public key

* Improve output formatting

* Bug fixes

* Add ACCOUNT_PUBKEY and ACCOUNT_ADDRESS input

* Add environment variables as input and config folder check

* Update docs, Makefile and rename folder

* Modify CLI arguments

* Update docker-compose.yaml defaults and print updated values

* Invert printing logic replacing verbose with quiet

(cherry picked from commit 3fa5450)

# Conflicts:
#	tests/localosmosis/README.md
czarcas7ic added a commit that referenced this pull request Sep 22, 2022
…#2795) (#2822)

* Refactors testnetify and remove last localOsmosis Dockerfile (#2795)

* Refactor testnetify and remove Dockerfile

* Manually replace new validator public key

* Improve output formatting

* Bug fixes

* Add ACCOUNT_PUBKEY and ACCOUNT_ADDRESS input

* Add environment variables as input and config folder check

* Update docs, Makefile and rename folder

* Modify CLI arguments

* Update docker-compose.yaml defaults and print updated values

* Invert printing logic replacing verbose with quiet

(cherry picked from commit 3fa5450)

# Conflicts:
#	tests/localosmosis/README.md

* fix md conflicts

Co-authored-by: Niccolo Raspa <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v11.x backport patches to v11.x branch A:backport/v12.x backport patches to v12.x branch C:docs Improvements or additions to documentation T:build
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants