Skip to content

Commit

Permalink
chore: fix lint and markdown (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Omri <[email protected]>
  • Loading branch information
hoangdv2429 and omritoptix authored Apr 17, 2024
1 parent 876ccad commit 83177bb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
with:
version: v1.56.2
skip-cache: true
args: --timeout 5m
15 changes: 8 additions & 7 deletions cmd/rollappd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package cmd
import (
"context"
"fmt"
"net"
"net/http"
"os"
"runtime/pprof"
"strconv"
"time"

berpc "github.com/bcdevtools/block-explorer-rpc-cosmos/be_rpc"
berpcbackend "github.com/bcdevtools/block-explorer-rpc-cosmos/be_rpc/backend"
berpccfg "github.com/bcdevtools/block-explorer-rpc-cosmos/be_rpc/config"
Expand All @@ -13,12 +20,6 @@ import (
raebeapi "github.com/dymensionxyz/rollapp-evm/ra_evm_be_rpc/namespaces/rae"
"github.com/ethereum/go-ethereum/rpc"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
"net"
"net/http"
"os"
"runtime/pprof"
"strconv"
"time"

"github.com/spf13/cobra"
"github.com/tendermint/tendermint/node"
Expand Down Expand Up @@ -525,7 +526,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
idxer,
nil, // external services modifier
func(evmberpcbackend.EvmBackendI) {
berpc.RegisterAPINamespace(raebeapi.DymRollAppEvmBlockExplorerNamespace, func(ctx *server.Context,
_ = berpc.RegisterAPINamespace(raebeapi.DymRollAppEvmBlockExplorerNamespace, func(ctx *server.Context,
_ client.Context,
_ *rpcclient.WSClient,
_ map[string]berpctypes.MessageParser,
Expand Down
2 changes: 0 additions & 2 deletions ra_evm_be_rpc/backend/rollapp_evm_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ func (m *RollAppEvmRequestInterceptor) GetModuleParams(moduleName string) (inter
} else {
params = *sequencersParams
}
break
case "hub-genesis":
hubGenesisParams, errFetch := m.backend.GetHubGenesisModuleParams()
if errFetch != nil {
err = errors.Wrap(errFetch, "failed to get hub genesis params")
} else {
params = *hubGenesisParams
}
break
default:
return m.defaultInterceptor.GetModuleParams(moduleName)
}
Expand Down
62 changes: 49 additions & 13 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#!/bin/bash
tmp=$(mktemp)
EXECUTABLE="rollapp-evm"

set_denom() {
denom=$1
jq --arg denom "$denom" '.app_state.mint.params.mint_denom = $denom' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg denom "$denom" '.app_state.staking.params.bond_denom = $denom' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg denom "$denom" '.app_state.gov.deposit_params.min_deposit[0].denom = $denom' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
local denom=$1
local success=true

jq --arg denom "$denom" '.app_state.evm.params.evm_denom = $denom' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg denom "$denom" '.app_state.claims.params.claims_denom = $denom' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg denom "$denom" '.app_state.mint.params.mint_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" ||
success=false
jq --arg denom "$denom" '.app_state.staking.params.bond_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" ||
success=false
jq --arg denom "$denom" '.app_state.gov.deposit_params.min_deposit[0].denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" ||
success=false
jq --arg denom "$denom" '.app_state.evm.params.evm_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" ||
success=false
jq --arg denom "$denom" '.app_state.claims.params.claims_denom = $denom' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE" ||
success=false

if [ "$success" = false ]; then
echo "An error occurred. Please refer to README.md"
return 1
fi
}

set_EVM_params() {
Expand All @@ -19,7 +31,8 @@ set_EVM_params() {

# ---------------------------- initial parameters ---------------------------- #
# Assuming 1,000,000 tokens
#half is staked
# Half is staked
# set BASE_DENOM to the token denomination
TOKEN_AMOUNT="1000000000000000000000000$BASE_DENOM"
STAKING_AMOUNT="500000000000000000000000$BASE_DENOM"

Expand All @@ -43,7 +56,8 @@ fi
# Verify that a genesis file doesn't exists for the dymension chain
if [ -f "$GENESIS_FILE" ]; then
printf "\n======================================================================================================\n"
echo "A genesis file already exists [$GENESIS_FILE]. building the chain will delete all previous chain data. continue? (y/n)"
echo "A genesis file already exists at $GENESIS_FILE."
echo "Building the chain will delete all previous chain data. Continue? (y/n)"
printf "\n======================================================================================================\n"
read -r answer
if [ "$answer" != "${answer#[Yy]}" ]; then
Expand All @@ -53,29 +67,51 @@ if [ -f "$GENESIS_FILE" ]; then
fi
fi

# Check if MONIKER is set, if not, set a default value
if [ -z "$MONIKER" ]; then
MONIKER="${ROLLAPP_CHAIN_ID}-sequencer" # Default moniker value
fi

# Check if KEY_NAME_ROLLAPP is set, if not, set a default value
if [ -z "$KEY_NAME_ROLLAPP" ]; then
KEY_NAME_ROLLAPP="rol-user" # Default key name value
fi

# ------------------------------- init rollapp ------------------------------- #
"$EXECUTABLE" init "$MONIKER" --chain-id "$ROLLAPP_CHAIN_ID"

# ------------------------------- client config ------------------------------ #
"$EXECUTABLE" config chain-id "$ROLLAPP_CHAIN_ID"

# -------------------------------- app config -------------------------------- #
sed -i'' -e "s/^minimum-gas-prices *= .*/minimum-gas-prices = \"0$BASE_DENOM\"/" "$APP_CONFIG_FILE"
# Detect the operating system
OS=$(uname)

# Modify app.toml minimum-gas-prices using sed command based on the OS
if [ "$OS" = "Darwin" ]; then
# macOS requires an empty string '' after -i to edit in place without backup
sed -i '' "s/^minimum-gas-prices *= .*/minimum-gas-prices = \"0$BASE_DENOM\"/" "$APP_CONFIG_FILE"
else
# Linux directly uses -i for in-place editing without creating a backup
sed -i "s/^minimum-gas-prices *= .*/minimum-gas-prices = \"0$BASE_DENOM\"/" "$APP_CONFIG_FILE"
fi
set_denom "$BASE_DENOM"
set_EVM_params

# --------------------- adding keys and genesis accounts --------------------- #
#local genesis account
# Local genesis account
"$EXECUTABLE" keys add "$KEY_NAME_ROLLAPP" --keyring-backend test
"$EXECUTABLE" add-genesis-account "$KEY_NAME_ROLLAPP" "$TOKEN_AMOUNT" --keyring-backend test

# set sequencer's operator address
# Set sequencer's operator address
operator_address=$("$EXECUTABLE" keys show "$KEY_NAME_ROLLAPP" -a --keyring-backend test --bech val)
jq --arg addr "$operator_address" '.app_state["sequencers"]["genesis_operator_address"] = $addr' "$GENESIS_FILE" >"$tmp" && mv "$tmp" "$GENESIS_FILE"
jq --arg addr "$operator_address" '.app_state["sequencers"]["genesis_operator_address"] = $addr' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"


# Ask if to include a governor on genesis
echo "Do you want to include a governor on genesis? (Y/n) "
read -r answer
if [ ! "$answer" != "${answer#[Nn]}" ]; then
if [ "$answer" != "${answer#[Nn]}" ] ; then
"$EXECUTABLE" gentx "$KEY_NAME_ROLLAPP" "$STAKING_AMOUNT" --chain-id "$ROLLAPP_CHAIN_ID" --keyring-backend test --home "$ROLLAPP_HOME_DIR"
"$EXECUTABLE" collect-gentxs --home "$ROLLAPP_HOME_DIR"
fi
Expand Down

0 comments on commit 83177bb

Please sign in to comment.