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: local dev environment #1554

Merged
merged 5 commits into from May 21, 2022
Merged

feat: local dev environment #1554

merged 5 commits into from May 21, 2022

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented May 21, 2022

What is the purpose of the change

As it stands, it is not simple to quickly test a change in a local dev environment. This introduces a modified LocalOsmosis that is lightweight and makes it very easy to spin up a local net to test your changes. The docker image also creates a new genesis on build, preventing any issues that have arose in the past from hardcoded genesis files.

The basic process is as follows:

  1. Make your local changes
  2. Run make localnet-build
  3. Run make localnet-start. Your local network has now started. Query it with your local daemon (i.e osmosisd status)
  4. Run make localnet-keys to add all 10 keys to your keyring
  5. Run make localnet-remove to remove all block data

Testing and Verifying

This code was tested locally in an arm64 environment

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? yes
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? yes

@czarcas7ic czarcas7ic requested a review from a team May 21, 2022 02:34
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2022

Codecov Report

Merging #1554 (44a820a) into main (16007fb) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1554   +/-   ##
=======================================
  Coverage   19.47%   19.47%           
=======================================
  Files         242      242           
  Lines       32258    32258           
=======================================
  Hits         6282     6282           
  Misses      24822    24822           
  Partials     1154     1154           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16007fb...44a820a. Read the comment docs.

tests/localosmosis/Dockerfile Outdated Show resolved Hide resolved
tests/localosmosis/Dockerfile Outdated Show resolved Hide resolved
tests/localosmosis/keys.sh Outdated Show resolved Hide resolved
tests/localosmosis/keys.sh Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
tests/localosmosis/Dockerfile Outdated Show resolved Hide resolved
tests/localosmosis/setup.sh Outdated Show resolved Hide resolved
&& apk add jq \
&& rm -rf /var/cache/apk/*
RUN chmod +x /setup.sh
RUN /setup.sh
Copy link
Member

Choose a reason for hiding this comment

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

One little improvement could be not to run this script during the docker build phase but running as an entrypoint script of the docker container.

In this way we can avoid rebuilding the image if we want to modify a parameter of the genesis.
Building takes 1-2 mins while running the script should be in the order of seconds

The way to do that would be to modifying the Dockerfile like this:

...
WORKDIR $HOME
RUN apk update \
 && apk add jq \
 && rm -rf /var/cache/apk/*
RUN chmod +x /setup.sh

# Remove the RUN /setup

EXPOSE 26656
EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["/setup.sh"]
CMD ["osmosisd", "start"]

And in the setup.sh:

#!/usr/bin/env sh
set -eu

<STANDARD CONTENT>

exec "$@" 

The exec part will execute the CMD part of the Dockerfile after is has executed the script

Copy link
Member Author

Choose a reason for hiding this comment

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

The only problem with this is the user would be recreating the genesis process on every start right? This process should only be done once at compilation time I think, and if the user wanted to modify a genesis param, they are probably better off recompiling anyway right?

Copy link
Member

@niccoloraspa niccoloraspa left a comment

Choose a reason for hiding this comment

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

LGTM! Nice stuff! It's going to be very useful!

I added some improvements here and there.
As always, take what you like.

I'm approving the PR as it's working as it is.

@czarcas7ic
Copy link
Member Author

@nikever @p0mvn thanks so much for the review, both had awesome suggestions that I ended up implementing

@czarcas7ic czarcas7ic merged commit f5472e0 into main May 21, 2022
@czarcas7ic czarcas7ic deleted the adam/dev-env branch May 21, 2022 16:10
@czarcas7ic czarcas7ic added the A:backport/v9.x Do not use. backport patches to v9.x branch label May 22, 2022
mergify bot pushed a commit that referenced this pull request May 22, 2022
* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog

(cherry picked from commit f5472e0)
czarcas7ic added a commit that referenced this pull request May 22, 2022
* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog

(cherry picked from commit f5472e0)

Co-authored-by: Adam Tucker <adamleetucker@outlook.com>
@czarcas7ic czarcas7ic added the A:backport/v8.x backport patches to v8.x branch label Jun 2, 2022
mergify bot pushed a commit that referenced this pull request Jun 2, 2022
* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog

(cherry picked from commit f5472e0)

# Conflicts:
#	CHANGELOG.md
#	Makefile
czarcas7ic added a commit that referenced this pull request Jun 2, 2022
* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog
czarcas7ic added a commit that referenced this pull request Jun 2, 2022
* feat: local dev environment (#1554)

* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog

(cherry picked from commit f5472e0)

# Conflicts:
#	CHANGELOG.md
#	Makefile

* feat: local dev environment (#1554)

* localosmosis

* extract docker runs to script

* change ubuntu to alpine

* nicco suggestions

* update changelog

* Update CHANGELOG.md

Co-authored-by: Adam Tucker <adamleetucker@outlook.com>
Co-authored-by: Adam Tucker <adam@osmosis.team>
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v8.x backport patches to v8.x branch A:backport/v9.x Do not use. backport patches to v9.x branch
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants