Skip to content

Commit

Permalink
Merge pull request #676 from lavanet/CNS-remove-ignite-dep
Browse files Browse the repository at this point in the history
CNSremove ignite dep
  • Loading branch information
Yaroms authored Aug 8, 2023
2 parents 0143678 + d029565 commit 759908a
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 94 deletions.
60 changes: 18 additions & 42 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: 1.20.5

# Install Ignite
- name: ignite install
run: git clone --depth 1 --branch v0.26.1 https://github.com/ignite/cli && cd cli && make install
# run: curl https://get.ignite.com/cli! | bash
- name: ignite version
run: ignite version
# - name: starport install
# run: curl https://get.starport.network/starport@v0.19.2! | bash
# - name: starport version
# run: starport version

# Setup Paths
- name: home
Expand All @@ -48,21 +37,20 @@ jobs:
- name: ls -l
run: ls -l

# Pre-build with ignite
- name: ignite build
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_minutes: 20
command: ignite chain build -v
# Pre-build
- name: lavad build
run: make install

######################################################
### Run Lava E2E Tests IGNITE VERSION:0.22.1
### Run Lava E2E Tests
######################################################
- name: Run Lava E2E Tests IGNITE VERSION:0.22.1 -timeout 1200s
- name: Run Lava E2E Tests -timeout 1200s
run: go test ./testutil/e2e/ -run ^TestLavaProtocol$ -v -timeout 1200s # 20mins

- name: tail -n 300 Lavad Logs
if: always()
run: tail -n 300 testutil/e2e/protocolLogs/00_StartLava.log

- name: Stake Lava All Logs
if: always()
run: cat testutil/e2e/protocolLogs/01_stakeLava.log
Expand Down Expand Up @@ -139,17 +127,6 @@ jobs:
with:
go-version: 1.20.5

# Install Ignite
- name: ignite install
run: git clone --depth 1 --branch v0.26.1 https://github.com/ignite/cli && cd cli && make install
# run: curl https://get.ignite.com/cli! | bash
- name: ignite version
run: ignite version
# - name: starport install
# run: curl https://get.starport.network/starport@v0.19.2! | bash
# - name: starport version
# run: starport version

# Setup Paths
- name: home
run: pwd && ls -l
Expand All @@ -174,14 +151,9 @@ jobs:
- name: ls -l
run: ls -l

# Pre-build with ignite
- name: ignite build
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_minutes: 20
command: ignite chain build -v
# Pre-build
- name: lavad build
run: make install

# Install Node.js
- name: Setup Node.js environment
Expand All @@ -197,11 +169,15 @@ jobs:
npm run build
######################################################
### Run Lava E2E Tests IGNITE VERSION:0.22.1
### Run Lava E2E Tests
######################################################
- name: Run Lava E2E Tests IGNITE VERSION:0.22.1 -timeout 1200s
- name: Run Lava E2E Tests -timeout 1200s
run: go test ./testutil/e2e/ -run ^TestLavaSDK -v -timeout 1200s # 20mins

- name: tail -n 300 Lavad Logs
if: always()
run: tail -n 300 testutil/e2e/sdkLogs/00_StartLava.log

- name: Stake Lava All Logs
if: always()
run: cat testutil/e2e/sdkLogs/01_stakeLava.log
Expand Down
44 changes: 44 additions & 0 deletions scripts/genesis/prepare_genesis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3

import json
import toml

# Specify the file path, field to edit, and new value
path = '/home/user/.lava/config/'
genesis = 'genesis.json'
config = 'config.toml'

# Load the JSON file
with open(path + genesis, 'r') as file:
data = json.load(file)

data["app_state"]["gov"]["deposit_params"]["min_deposit"][0]["denom"] = "ulava"
data["app_state"]["gov"]["deposit_params"]["min_deposit"][0]["amount"] = "10000000"
data["app_state"]["gov"]["voting_params"]["voting_period"] = "3s"
data["app_state"]["mint"]["params"]["mint_denom"] = "ulava"
data["app_state"]["staking"]["params"]["bond_denom"] = "ulava"
data["app_state"]["crisis"]["constant_fee"]["denom"] = "ulava"

# Save the changes back to the JSON file
with open(path + genesis, 'w') as file:
json.dump(data, file, indent=4)



# Step 1: Read the contents of the .toml file
with open(path + config, 'r') as file:
data = toml.load(file)

# Step 2: Modify the content as required
data["consensus"]["timeout_propose"] = "1s"
data["consensus"]["timeout_propose_delta"] = "500ms"
data["consensus"]["timeout_prevote"] = "1s"
data["consensus"]["timeout_prevote_delta"] = "500ms"
data["consensus"]["timeout_propose"] = "1s"
data["consensus"]["timeout_precommit"] = "500ms"
data["consensus"]["timeout_precommit_delta"] = "1s"
data["consensus"]["timeout_commit"] = "1s"

# Step 3: Write the updated content back to the .toml file
with open(path + config, 'w') as file:
toml.dump(data, file)
54 changes: 54 additions & 0 deletions scripts/init_chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# make install

rm -rf ~/.lava
lavad init validator

lavad config broadcast-mode block
lavad config keyring-backend test

# Specify the file path, field to edit, and new value
path="$HOME/.lava/config/"
genesis='genesis.json'
config='config.toml'
app='app.toml'

# Edit genesis file
data=$(cat "$path$genesis" \
| jq '.app_state.gov.deposit_params.min_deposit[0].denom = "ulava"' \
| jq '.app_state.gov.deposit_params.min_deposit[0].amount = "10000000"' \
| jq '.app_state.gov.voting_params.voting_period = "3s"' \
| jq '.app_state.mint.params.mint_denom = "ulava"' \
| jq '.app_state.staking.params.bond_denom = "ulava"' \
| jq '.app_state.crisis.constant_fee.denom = "ulava"' \
)

echo -n "$data" > "$path$genesis"

# Edit conflict.toml file
sed -i "$path$config" \
-e 's/timeout_propose = .*/timeout_propose = "1s"/' \
-e 's/timeout_propose_delta = .*/timeout_propose_delta = "500ms"/' \
-e 's/timeout_prevote = .*/timeout_prevote = "1s"/' \
-e 's/timeout_prevote_delta = .*/timeout_prevote_delta = "500ms"/' \
-e 's/timeout_precommit = .*/timeout_precommit = "500ms"/' \
-e 's/timeout_precommit_delta = .*/timeout_precommit_delta = "1s"/' \
-e 's/timeout_commit = .*/timeout_commit = "1s"/' \
-e 's/skip_timeout_commit = .*/skip_timeout_commit = false/'

# Edit app.toml file
sed -i "$path$app" \
-e 's/enable = .*/enable = true/'


# Add users
users=("alice" "bob" "user1" "user2" "user3" "user4" "servicer1" "servicer2" "servicer3" "servicer4" "servicer5" "servicer6" "servicer7" "servicer8" "servicer9" "servicer10")

for user in "${users[@]}"; do
lavad keys add "$user"
lavad add-genesis-account "$user" 50000000000000ulava
done

lavad gentx alice 100000000000ulava --chain-id lava
lavad collect-gentxs
lavad start
15 changes: 8 additions & 7 deletions testutil/e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Lava E2E

Run all our E2E using the following command (from the root)

```
yarn --cwd ./ecosystem/lava-sdk/ build
go test ./testutil/e2e/ -v -timeout 1200s
```

If you wish you can also run E2E tests independently:

1. Lava Protocol E2:
Expand All @@ -22,6 +15,14 @@ yarn --cwd ./ecosystem/lava-sdk/ build
go test ./testutil/e2e/ -run ^TestLavaSDK -v -timeout 1200s
```

Run all our E2E using the following command (from the root) - NOT STABLE

```
yarn --cwd ./ecosystem/lava-sdk/ build
go test ./testutil/e2e/ -v -timeout 1200s
```


This E2E performs the steps below to test if the system is working as expected.

1. Start lava in developer mode (equivalent to running the command "ignite chain serve" ).
Expand Down
54 changes: 12 additions & 42 deletions testutil/e2e/protocolE2E.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
Expand All @@ -27,9 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ignite/cli/ignite/config"
"github.com/ignite/cli/ignite/pkg/cache"
"github.com/ignite/cli/ignite/services/chain"
"github.com/lavanet/lava/utils"
epochStorageTypes "github.com/lavanet/lava/x/epochstorage/types"
pairingTypes "github.com/lavanet/lava/x/pairing/types"
Expand Down Expand Up @@ -160,34 +156,12 @@ func (lt *lavaTest) listenCmdCommand(cmd *exec.Cmd, panicReason string, function
}

func (lt *lavaTest) startLava(ctx context.Context) {
defer lt.wg.Done() // Decrements the counter when the goroutine completes.
command := "./scripts/init_chain.sh"
logName := "00_StartLava"
funcName := "startLava"

// We will need to wait for this thread to finish so add wait group
lt.wg.Add(1)

absPath, err := filepath.Abs(".")
if err != nil {
panic(err)
}

c, err := chain.New(absPath)
if err != nil {
panic(err)
}
cacheRootDir, err := config.DirPath()
if err != nil {
panic(err)
}

storage, err := cache.NewStorage(filepath.Join(cacheRootDir, "ignite_cache.db"))
if err != nil {
panic(err)
}

err = c.Serve(ctx, storage, chain.ServeForceReset())
if err != nil && err != context.Canceled {
panic(err)
}
lt.execCommand(ctx, funcName, logName, command, true)
utils.LavaFormatInfo(funcName + " OK")
}

func (lt *lavaTest) checkLava(timeout time.Duration) {
Expand Down Expand Up @@ -784,6 +758,9 @@ func (lt *lavaTest) saveLogs() {
lines := strings.Split(logBuffer.String(), "\n")
errorLines := []string{}
for _, line := range lines {
if fileName == "00_StartLava" { // TODO remove this and solve the errors
break
}
if strings.Contains(line, " ERR ") {
isAllowedError := false
for errorSubstring := range allowedErrors {
Expand Down Expand Up @@ -1097,16 +1074,15 @@ func runProtocolE2E(timeout time.Duration) {

utils.LavaFormatInfo("Starting Lava")

lavaContext, cancelLava := context.WithCancel(context.Background())
go lt.startLava(lavaContext)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

go lt.startLava(ctx)
lt.checkLava(timeout)
utils.LavaFormatInfo("Starting Lava OK")
lt.compileLavaProtocol()
utils.LavaFormatInfo("Compiling Protocol OK")

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

utils.LavaFormatInfo("Staking Lava")
lt.stakeLava(ctx)

Expand Down Expand Up @@ -1213,10 +1189,4 @@ func runProtocolE2E(timeout time.Duration) {
lt.checkQoS()

lt.finishTestSuccessfully()

// Cancel lava network using context
cancelLava()

// Wait for all processes to be done
lt.wg.Wait()
}
2 changes: 1 addition & 1 deletion testutil/e2e/sdk/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func RunSDKTests(ctx context.Context, grpcConn *grpc.ClientConn, privateKey stri
cmd.Env = append(cmd.Env, "BADGE_PROJECT_ID="+"alice")

// Set the environment variable for badge server address
cmd.Env = append(cmd.Env, "BADGE_SERVER_ADDR="+"http://localhost:8080")
cmd.Env = append(cmd.Env, "BADGE_SERVER_ADDR="+"http://localhost:7070")

// Set the environment variable for badge server address
cmd.Env = append(cmd.Env, "PAIRING_LIST="+"testutil/e2e/sdk/pairingList.json")
Expand Down
4 changes: 2 additions & 2 deletions testutil/e2e/sdkE2E.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func (lt *lavaTest) startBadgeServer(ctx context.Context, privateKey string, pub
panic(err)
}

command := fmt.Sprintf("%s badgegenerator --grpc-url=127.0.0.1:9090 --log_level=debug --chain-id lava", lt.protocolPath)
command := fmt.Sprintf("%s badgegenerator --port=7070 --grpc-url=127.0.0.1:9090 --log_level=debug --chain-id lava", lt.protocolPath)
logName := "01_BadgeServer"
funcName := "startBadgeServer"
lt.execCommandWithRetry(ctx, funcName, logName, command)

lt.checkBadgeServerResponsive(ctx, "127.0.0.1:8080", time.Minute)
lt.checkBadgeServerResponsive(ctx, "127.0.0.1:7070", time.Minute)
}

// exportUserPublicKey exports public key from specific user
Expand Down

0 comments on commit 759908a

Please sign in to comment.