Skip to content

Commit

Permalink
feat(v0.50.2): Finish full ICS integration, E2E, Documentation (#143)
Browse files Browse the repository at this point in the history
* all test but PFM (not tested, just syntactically correct)

* fixes

* golang:1.22-alpine

* go 1.22.3

* keep ictest-basic on removal of staking

* feat: UI consensus selector (#145)

* consensus selector

* fix: e2e with new consensus

* fix: POA being removed when selected due to POS parent

* fix dev templates

* fix interchaintest setup logic with ICS

* fix: wasm.NewAppModule being removed when using ICS

* remove duplicate interchain-security feature

* ict: fc.FormatGoFile

* touchup replacements

* fix: wassm app module not being fully removed

* debugging: debugErrorFile on failed generate

* matrix generator

* matrix gen, v0.50.2

* mod tidy on new chain

* fix: secondary chain config values in `setup.go`

* simplify ics e2e

* nit: `rm -rf` generated matrix dirs

* poa: numPOAVals int test & ratelimit test delete

* tf `EnableCommunityPoolFeeFunding` remove if no staking (ICS) to burn fees instead

* tf(TokenFactoryCreateDenom): increase gas limit

* nicely show transfer channel errors

* documentation & localchain-1

* add default chain as a GH config

* fix(docs): relative link
  • Loading branch information
Reecepbcups authored May 30, 2024
1 parent c697428 commit a2c523f
Show file tree
Hide file tree
Showing 37 changed files with 907 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '1.21'
go-version: '1.22.3'

- name: Clean up dist directory
run: rm -rf dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
description: 'The command which runs the chain via the shell'

env:
GO_VERSION: 1.21.9
GO_VERSION: 1.22.3
JQ_VERSION: '1.7'
JQ_FORCE: false

Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/spawn-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.21.9
GO_VERSION: 1.22.3
JQ_VERSION: '1.7'
JQ_FORCE: false

Expand Down Expand Up @@ -50,14 +50,22 @@ jobs:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: Normal Staking
spawn-create-cmd: ./spawn new mychain --bypass-prompt --bech32=roll --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --disable=ics
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="local-1" BLOCK_TIME="2000ms" CLEAN=true sh scripts/test_node.sh &
id: Proof of Stake
spawn-create-cmd: ./spawn new mychain --consensus=proof-of-stake --bypass-prompt --bech32=prefix --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="localchain-1" BLOCK_TIME="2000ms" CLEAN=true sh scripts/test_node.sh &

proof-of-authority:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: Proof of Authority
spawn-create-cmd: ./spawn new mychain --consensus=proof-of-authority --bypass-prompt --bech32=cosmos --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="localchain-1" BLOCK_TIME="2000ms" CLEAN=true sh scripts/test_node.sh &

normal-ics:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: ICS
spawn-create-cmd: ./spawn new mychain --bin=appd --bypass-prompt --bech32=roll --no-git --org=rollchains-org --denom=uroll --debug
start-chain-cmd: HOME_DIR="~/.icsnetwork" CHAIN_ID="local-2" CLEAN=true BLOCK_TIME="500ms" sh scripts/test_ics_node.sh &
id: ICS - Cosmos Hub
spawn-create-cmd: ./spawn new mychain --consensus=ics --bin=appd --bypass-prompt --bech32=roll --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.icsnetwork" CHAIN_ID="localchain-2" CLEAN=true BLOCK_TIME="2000ms" sh scripts/test_ics_node.sh &
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
cancel-in-progress: true

env:
GO_VERSION: 1.21.0
GO_VERSION: 1.22.3

jobs:
build:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ bin/spawn
dist/

myproject/
mychain/
*.log

debugging/
scripts/matrix.sh
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ help: Makefile

# ---- Developer Templates ----
template-staking: install
spawn new myproject --debug --bech32=cosmos --bin=appd --disable=ics,poa
spawn new myproject --consensus=proof-of-stake --debug --bech32=cosmos --bin=appd --bypass-prompt

template-poa: install
spawn new myproject --debug --no-git --bin=rolld --bech32=roll --denom=uroll --disable=ics
spawn new myproject --consensus=proof-of-authority --debug --no-git --bin=rolld --bech32=roll --denom=uroll --bypass-prompt

template-ics: install
spawn new myproject --debug --no-git --bin=rolld --bech32=roll --denom=uroll --disable=globalfee,cosmwasm,wasm-lc,ignite,ibc-packetforward
spawn new myproject --consensus=interchain-security --debug --no-git --bin=rolld --bech32=roll --denom=uroll --bypass-prompt


.DEFAULT_GOAL := install
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://github.com/rollchains/spawn/assets/31943163/ecc21ce4-c42c-4ff2-8e73-897c

## Requirements

- [`go 1.21+`](https://go.dev/doc/install)
- [`go 1.22+`](https://go.dev/doc/install)
- [`Docker`](https://docs.docker.com/get-docker/)

[MacOS + Ubuntu Setup](./docs/SYSTEM_SETUP.md)
Expand All @@ -39,7 +39,7 @@ In this tutorial, we'll create and interact with a new Cosmos-SDK blockchain cal
```shell
git clone https://github.com/rollchains/spawn.git
cd spawn
git checkout v0.50.1
git checkout v0.50.2
make install
```

Expand All @@ -49,10 +49,11 @@ make install
GITHUB_USERNAME=rollchains

spawn new rollchain \
--consensus=proof-of-authority `# proof-of-authority,proof-of-stake,interchain-security` \
--bech32=roll `# the prefix for addresses` \
--denom=uroll `# the coin denomination to create` \
--bin=rolld `# the name of the binary` \
--disabled=cosmwasm,globalfee `# disable features. [proof-of-authority,tokenfactory,globalfee,packetforward,cosmwasm,wasm-lc,ignite]` \
--disabled=cosmwasm,globalfee `# disable features. [tokenfactory,globalfee,ibc-packetforward,ibc-ratelimit,cosmwasm,wasm-light-client,ignite-cli]` \
--org=${GITHUB_USERNAME} `# the github username or organization to use for the module imports`
```

Expand All @@ -63,7 +64,11 @@ spawn new rollchain \
```shell
cd rollchain

# Starts an API at http://127.0.0.1:8080 by default to view endpoints.
# Starts 2 networks for the IBC testnet at http://127.0.0.1:8080.
# - Builds the docker image of your chain
# - Launches a testnet with IBC automatically connected and relayed
#
# Note: you can run a single node, non IBC testnet, with `make sh-testnet`.
make testnet
```

Expand All @@ -74,7 +79,7 @@ make testnet
rolld keys list

# send a transaction from one account to another
rolld tx bank send acc0 $(rolld keys show acc1 -a) 1337uroll --chain-id=chainid-1
rolld tx bank send acc0 $(rolld keys show acc1 -a) 1337uroll --chain-id=localchain-1

# enter "y" to confirm the transaction
# then query your balances tfor proof the transaction executed successfully
Expand All @@ -85,17 +90,17 @@ rolld q bank balances $(rolld keys show acc1 -a)

```shell
# submit a cross chain transfer from acc0 to the other address
rolld tx ibc-transfer transfer transfer channel-0 cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr 7uroll --from=acc0 --chain-id=chainid-1 --yes
rolld tx ibc-transfer transfer transfer channel-0 cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr 7uroll --from=acc0 --chain-id=localchain-1 --yes

# Query the other side to confirm it went through
sleep 10

# Interact with the other chain without having to install the cosmos binary
# - Endpoints found at: GET http://127.0.0.1:8080/info
local-ic interact localcosmos-1 query 'bank balances cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr'
local-ic interact localcosmos-1 query 'bank balances cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr' --api-endpoint=http://127.0.0.1:8080
```

6. Push your new chain to a new repository
6. Push your new chain to a github repository

```shell
# Create a new repository on GitHub from the gh cli
Expand Down
82 changes: 68 additions & 14 deletions cmd/spawn/new_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,29 @@ var (
// SupportedFeatures is a list of all features that can be toggled.
// - UI: uses the IsSelected
// - CLI: all are enabled by default. Must opt out.
SupportedFeatures = items{
{ID: "proof-of-authority", IsSelected: true, Details: "Proof-of-Authority consensus algorithm (permissioned network)"},

ConsensusFeatures = items{
// Consensus (only 1 per app)
{ID: "proof-of-authority", IsSelected: true, IsConsensus: true, Details: "Proof-of-Authority consensus algorithm (permissioned network)"},
{ID: "proof-of-stake", IsSelected: false, IsConsensus: true, Details: "Proof-of-Stake consensus algorithm (permissionless network)"},
{ID: "interchain-security", IsSelected: false, IsConsensus: true, Details: "Cosmos Hub Interchain Security"},
// {ID: "ics-ethos", IsSelected: false, IsConsensus: true, Details: "Interchain-Security with Ethos ETH restaking"},
}

SupportedFeatures = append(ConsensusFeatures, items{
{ID: "tokenfactory", IsSelected: true, Details: "Native token minting, sending, and burning on the chain"},
{ID: "globalfee", IsSelected: true, Details: "Static minimum fee(s) for all transactions, controlled by governance"},
{ID: "ibc-packetforward", IsSelected: true, Details: "Packet forwarding"},
{ID: "ibc-ratelimit", IsSelected: false, Details: "Thresholds for outflow as a percent of total channel value"},
{ID: "cosmwasm", IsSelected: false, Details: "Cosmos smart contracts"},
{ID: "wasm-light-client", IsSelected: false, Details: "08 Wasm Light Client"},
{ID: "interchain-security", IsSelected: false, Details: "Cosmos Interchain Security"},
{ID: "ignite-cli", IsSelected: false, Details: "Ignite-CLI Support"},
}
}...)

// parentDeps is a list of modules that are disabled if a parent module is disabled.
// i.e. Without staking, POA is not possible as it depends on staking.
parentDeps = map[string][]string{
spawn.Staking: {spawn.POA},
spawn.POS: {spawn.POA},
}
)

Expand All @@ -40,35 +47,44 @@ const (
FlagTokenDenom = "denom"
FlagGithubOrg = "org"
FlagDisabled = "disable"
FlagConsensus = "consensus"
FlagNoGit = "skip-git"
FlagBypassPrompt = "bypass-prompt"
)

func init() {
features := make([]string, len(SupportedFeatures))
for idx, feat := range SupportedFeatures {
features[idx] = feat.ID
features := make([]string, 0)
consensus := make([]string, 0)

for _, feat := range SupportedFeatures {
if feat.IsConsensus {
consensus = append(consensus, feat.ID)
} else {
features = append(features, feat.ID)
}
}

newChain.Flags().String(FlagWalletPrefix, "cosmos", "chain bech32 wallet prefix")
newChain.Flags().StringP(FlagBinDaemon, "b", "simd", "binary name")
newChain.Flags().String(FlagGithubOrg, "rollchains", "github organization")
newChain.Flags().String(FlagTokenDenom, "token", "bank token denomination")
newChain.Flags().StringSlice(FlagDisabled, []string{}, strings.Join(features, ","))
newChain.Flags().String(FlagConsensus, "", strings.Join(consensus, ",")) // we default to POA later if not set
newChain.Flags().Bool(FlagDebugging, false, "enable debugging")
newChain.Flags().Bool(FlagNoGit, false, "ignore git init")
newChain.Flags().Bool(FlagBypassPrompt, false, "bypass UI prompt")

newChain.Flags().SetNormalizeFunc(normalizeWhitelistVarRun)
}

var newChain = &cobra.Command{
Use: "new-chain [project-name]",
Short: "Create a new project",
Example: fmt.Sprintf(
` - spawn new rollchain --%s=cosmos --%s=simd --%s=token
- spawn new rollchain --%s=tokenfactory,poa,globalfee`,
FlagWalletPrefix, FlagBinDaemon, FlagTokenDenom, FlagDisabled,
` - spawn new rollchain --consensus=proof-of-stake --%s=cosmos --%s=simd --%s=token --org=abcde
- spawn new rollchain --consensus=proof-of-authority --%s=tokenfactory,globalfee
- spawn new rollchain --consensus=interchain-security --%s=cosmwasm --%s
- spawn new rollchain --%s`,
FlagWalletPrefix, FlagBinDaemon, FlagTokenDenom, FlagDisabled, FlagDisabled, FlagNoGit, FlagBypassPrompt,
),
Args: cobra.ExactArgs(1),
Aliases: []string{"new", "init", "create"},
Expand All @@ -84,20 +100,58 @@ var newChain = &cobra.Command{
denom, _ := cmd.Flags().GetString(FlagTokenDenom)
ignoreGitInit, _ := cmd.Flags().GetBool(FlagNoGit)
githubOrg, _ := cmd.Flags().GetString(FlagGithubOrg)
consensus, _ := cmd.Flags().GetString(FlagConsensus)

// Show a UI if the user did not specific to bypass it, or if nothing is disabled.
bypassPrompt, _ := cmd.Flags().GetBool(FlagBypassPrompt)

// Show a UI to select the consensus algorithm (POS, POA, ICS) if a custom one was not specified.
if !bypassPrompt {
if len(consensus) == 0 {
text := "Consensus Selector (( enter to toggle ))"
items, err := selectItems(text, 0, SupportedFeatures, false, true, true)
if err != nil {
logger.Error("Error selecting consensus", "err", err)
return
}
consensus = items.String()
}
}
consensus = spawn.AliasName(consensus)
logger.Debug("Consensus selected", "consensus", consensus)

// Disable all consensus algorithms except the one selected.
disabledConsensus := make([]string, 0)
for _, feat := range ConsensusFeatures {
name := spawn.AliasName(feat.ID)
if name != consensus {
// if consensus is proof-of-authority, allow proof of stake
if consensus == spawn.POA && name == spawn.POS {
continue
}

disabledConsensus = append(disabledConsensus, name)
}
}
logger.Debug("Disabled Consensuses", "disabled", disabledConsensus, "using", consensus)

// Disable all features not selected
// Show a UI if the user did not specific to bypass it, or if nothing is disabled.
if len(disabled) == 0 && !bypassPrompt {
items, err := selectItems(0, SupportedFeatures, true)
text := "Feature Selector (( enter to toggle ))"
items, err := selectItems(text, 0, SupportedFeatures, true, false, false)
if err != nil {
logger.Error("Error selecting disabled", "err", err)
return
}
disabled = items.NOTSlice()

}

disabled = append(disabled, disabledConsensus...)
disabled = spawn.NormalizeDisabledNames(disabled, parentDeps)

logger.Debug("Disabled features", "features", disabled)

cfg := &spawn.NewChainConfig{
ProjectName: projName,
Bech32Prefix: walletPrefix,
Expand Down
3 changes: 2 additions & 1 deletion cmd/spawn/new_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestDisabledGeneration(t *testing.T) {

allButStaking := make([]string, 0, len(spawn.AllFeatures)-1)
for _, f := range spawn.AllFeatures {
if f != spawn.Staking {
if f != spawn.POS {
allButStaking = append(allButStaking, f)
}
}
Expand Down Expand Up @@ -75,6 +75,7 @@ func TestDisabledGeneration(t *testing.T) {
}

for _, c := range disabledCases {
c := c
name := "spawnunittest" + c.Name
dc := c.Disabled

Expand Down
Loading

0 comments on commit a2c523f

Please sign in to comment.