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

test: add regen-sandbox docker setup #1550

Merged
merged 26 commits into from
Nov 15, 2022
Merged

Conversation

clevinson
Copy link
Member

@clevinson clevinson commented Oct 15, 2022

Description

This container (and bootstrapping scripts) is intended to aid with end-to-end testing of client libraries, applications, manual local network tests, and other scenarios where you want to be able to quickly bootstrap a single node regen network.

We could potentially be publishing versioned images of this container as part of our release cycle. And projects like Regen-web and regen-js could pull from those versioned containers for their integration tests.

The hope is to have an easily buildable docker setup for regen-ledger that:

  • bootstraps a network with a basic validator set
  • initializes a set of addresses in a --keyring-backend test keyring from a single mnemonic provided through an env variable
  • is able to be shut down and restarted, with the .regen home directory persisting as a mounted volume by the host of the container
  • allows for a basic set of bash scripts to be written that can run CLI txs to prepopulate datasets into the test network. These scripts can be shared amongst devs and client projects, but do not need to be built as part of the container to be run by the container as part of the bootstrapping process

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@clevinson clevinson requested a review from a team October 15, 2022 00:43
@clevinson clevinson marked this pull request as draft October 15, 2022 00:50
@clevinson clevinson marked this pull request as ready for review October 21, 2022 01:48
@clevinson clevinson requested review from mhagel and wgwz October 21, 2022 01:48
@wgwz
Copy link
Contributor

wgwz commented Oct 25, 2022

i'm seeing this output from the command below, i'm guessing i'm probably doing something wrong:

$ (cd images/regen-sandbox && docker run -v $(pwd):/regen --env REGEN_MNEMONIC='a b c d f g h j k l a q' regen-sandbox:latest)
panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction ({274878092608})

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/types/module.(*Manager).InitGenesis(_, {{0x2ef1cb0, 0x40000da000}, {0x2f03670, 0x40014b6880}, {{0x0, 0x0}, {0x4000d5da30, 0xd}, 0x0, ...}, ...}, ...)
        /go/pkg/mod/github.com/cosmos/[email protected]/types/module/module.go:336 +0x180
github.com/regen-network/regen-ledger/v4/app.(*RegenApp).InitChainer(_, {{0x2ef1cb0, 0x40000da000}, {0x2f03670, 0x40014b6880}, {{0x0, 0x0}, {0x4000d5da30, 0xd}, 0x0, ...}, ...}, ...)
        /work/app/app.go:623 +0x1d4
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).InitChain(0x4000176540, {{0x568de62, 0xedae9efdb, 0x0}, {0x4000d5da30, 0xd}, 0x400002c120, {0x4400aa8, 0x0, 0x0}, ...})
        /go/pkg/mod/github.com/cosmos/[email protected]/baseapp/abci.go:70 +0x310
github.com/tendermint/tendermint/abci/client.(*localClient).InitChainSync(0x4001020f00, {{0x568de62, 0xedae9efdb, 0x0}, {0x4000d5da30, 0xd}, 0x400002c120, {0x4400aa8, 0x0, 0x0}, ...})
        /go/pkg/mod/github.com/tendermint/[email protected]/abci/client/local_client.go:272 +0x194
github.com/tendermint/tendermint/proxy.(*appConnConsensus).InitChainSync(0x40001ca3f0?, {{0x568de62, 0xedae9efdb, 0x0}, {0x4000d5da30, 0xd}, 0x400002c120, {0x4400aa8, 0x0, 0x0}, ...})
        /go/pkg/mod/github.com/tendermint/[email protected]/proxy/app_conn.go:77 +0x84
github.com/tendermint/tendermint/consensus.(*Handshaker).ReplayBlocks(_, {{{0xb, 0x0}, {0x2ec1380, 0x8}}, {0x4000d5da30, 0xd}, 0x1, 0x0, {{0x0, ...}, ...}, ...}, ...)
        /go/pkg/mod/github.com/tendermint/[email protected]/consensus/replay.go:319 +0xac8
github.com/tendermint/tendermint/consensus.(*Handshaker).Handshake(0x4000cef950, {0x2f03fb0, 0x4000d529c0})
        /go/pkg/mod/github.com/tendermint/[email protected]/consensus/replay.go:268 +0x3a8
github.com/tendermint/tendermint/node.doHandshake({_, _}, {{{0xb, 0x0}, {0x2ec1380, 0x8}}, {0x4000d5da30, 0xd}, 0x1, 0x0, ...}, ...)
        /go/pkg/mod/github.com/tendermint/[email protected]/node/node.go:330 +0x120
github.com/tendermint/tendermint/node.NewNode(0x4001058dc0, {0x2eeaca0, 0x400155dea0}, 0x4000149250, {0x2ecc0f8, 0x40004faff0}, 0x2ecbbb8?, 0x4001550ea0?, 0x4000149c60, {0x2ef2d88, ...}, ...)
        /go/pkg/mod/github.com/tendermint/[email protected]/node/node.go:778 +0x3fc
github.com/cosmos/cosmos-sdk/server.startInProcess(_, {{0x0, 0x0, 0x0}, {0x2f16090, 0x4001531b30}, 0x0, {0x4001507750, 0xd}, {0x2f107d8, ...}, ...}, ...)
        /go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:311 +0x5f4
github.com/cosmos/cosmos-sdk/server.StartCmd.func2(0x400105ca00?, {0x40014b7740?, 0x0?, 0x4?})
        /go/pkg/mod/github.com/cosmos/[email protected]/server/start.go:143 +0xd8
github.com/spf13/cobra.(*Command).execute(0x400105ca00, {0x40014b7700, 0x4, 0x4})
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:872 +0x4e8
github.com/spf13/cobra.(*Command).ExecuteC(0x4000bf0000)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:990 +0x360
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:918
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:911
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x113a0?, {0x210bf27, 0x5}, {0x400051fc30, 0xc})
        /go/pkg/mod/github.com/cosmos/[email protected]/server/cmd/execute.go:36 +0x1a8
main.main()
        /work/cmd/regen/main.go:15 +0x48
/usr/bin/bootstrap-solo-network.sh: line 1: kill: (-1) - No such process

images/regen-sandbox/README.md Outdated Show resolved Hide resolved
images/regen-sandbox/README.md Outdated Show resolved Hide resolved
images/regen-sandbox/bootstrap-solo-network.sh Outdated Show resolved Hide resolved
@paul121
Copy link
Contributor

paul121 commented Oct 26, 2022

/usr/bin/bootstrap-solo-network.sh: line 1: kill: (-1) - No such process

@wgwz running docker with the --init flag fixed this for me. https://devops.stackexchange.com/questions/5613/how-to-explicitly-kill-the-process-with-pid-1-from-inside-a-container :

To kill PID 1 you will have to explicitly declare the handler for the SIGTERM signal or, in current versions of Docker, pass the --init flag in the docker run command to instrument tini.

This error happened to me because I set the env variable REGEN_MNEMONIC=word word word without quotes around it. When I ran docker run ... the first time this created and persisted the .regen directory despite there being an errant mnemonic. Fixing my REGEN_MNEMONIC env variable was not enough, I had to rm -r .regen before I tried running the docker image again. We could try and make the script defensive to this situation but it's also an easy fix on the user end.

Copy link
Contributor

@paul121 paul121 left a comment

Choose a reason for hiding this comment

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

This is great!!

One thing I'd like to have is an easy way to run this without persisting the data. I'd like to be able to re-run scripts without rm -r .regen to get fresh state. Right now if you run the data script twice you get an error defining the resolver a second time:

INFO: Defining resolver http://resolver.mydataservice.com
ERROR: (code 24) failed to execute message; message index: 0: a resolver with the same URL and manager already exists: unique key violation

The solution is almost there.. if you don't provide a /regen volume mount then the chain data isn't persisted. But without a /regen volume mount you can't run scripts nor share the keyring-backend directory. Maybe we could make a separate volume mount for config, data and scripts? Although I don't want to make the docker run command too complex

@paul121
Copy link
Contributor

paul121 commented Oct 26, 2022

Or maybe a flag could be passed that is checked at the beginning of bootstrap-solo-network.sh to run regen unsafe-reset-all? REGEN_RESET_STATE=true

@ryanchristo
Copy link
Member

@clevinson are you wanting someone to pick up the changes/improvements on this?

@wgwz wgwz requested a review from blushi November 2, 2022 19:56
@clevinson clevinson requested review from paul121, wgwz and ryanchristo and removed request for paul121 November 10, 2022 17:13
@ryanchristo
Copy link
Member

We could potentially be publishing versioned images of this container as part of our release cycle. And projects like Regen-web and regen-js could pull from those versioned containers for their integration tests.

👍

Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Tested the following:

  • successfully spun up with setting mnemonic
  • successfully spun up without setting mnemonic
  • successfully spun up with existing home directory
  • successfully spun up overwriting home directory
  • successfully spun up with specific setup scripts

All minor suggestions/questions but before approving:

  • bridge is not listed as a setup option in the readme
  • running bridge and ecocredit together produces inaccurate logs

images/regen-sandbox/Dockerfile Outdated Show resolved Hide resolved
images/regen-sandbox/Dockerfile Outdated Show resolved Hide resolved
images/regen-sandbox/README.md Outdated Show resolved Hide resolved
images/regen-sandbox/README.md Outdated Show resolved Hide resolved
images/regen-sandbox/setup/bridge.sh Outdated Show resolved Hide resolved
@clevinson
Copy link
Member Author

@ryanchristo addressed your comments and ready for another review. Thanks!

@clevinson clevinson requested review from ryanchristo and paul121 and removed request for paul121 November 15, 2022 05:42
Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

The scripts have been removed from the pull request:

INFO: Initializing state from './setup/ecocredit.sh'
/usr/bin/bootstrap.sh: line 124: ./setup/ecocredit.sh: No such file or directory

Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Nvm on the last comment, just need to update the example command.

images/regen-sandbox/README.md Outdated Show resolved Hide resolved
Co-authored-by: Ryan Christoffersen <[email protected]>
@clevinson clevinson enabled auto-merge (squash) November 15, 2022 20:07
@clevinson clevinson disabled auto-merge November 15, 2022 20:07
@ryanchristo ryanchristo merged commit 3ee3aa3 into main Nov 15, 2022
@ryanchristo ryanchristo deleted the clev/add-docker-sandbox branch November 15, 2022 20:53
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.

6 participants