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

Restructured and cleaned up folder and added upgrade handler #7

Merged
merged 10 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=cronos \
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=genesis \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(BINARY_NAME) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
Expand Down
88 changes: 16 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,35 @@
# GenesisL1 blockchain
<h1 align="center">
GenesisL1 Mainnet (Cronos fork)
</h1>

<p align="center">
<img src="https://github.com/zenodeapp/genesisL1/assets/108588903/be368fa2-a154-48a6-b04b-8eb452b02033" alt="GenesisL1" width="150" height="150"/>
</p>

<p align="center">
Cosmos SDK v0.46.15
Chain ID <b>genesis_29-2</b>
</p>

<p align="center">
<i>Source code fork of cronos and ethermint.</i>
A source code fork of <b>Cronos</b> and <b>Ethermint</b>
</p>

## Node requirements

- 300GB+ good hard drive disk
- 8GB+ RAM (if necessary it will use at max 150GB from hard drive as swap, see below)
- 4 CPU Threads
- Good Internet Connection

## **Script**

### Overview

`genesisd.sh` is available in the root folder of the repository. Running `sh genesisd.sh` gives an overview of what the script is capable of.

```
Usage: genesisd.sh <command> [moniker]
<command> should be either 'upgrade' or 'init'

Options:
--crisis-skip Makes sure that genesisd starts with the --x-crisis-skip-assert-invariants flag (default: false)
--skip-state-download Skips downloading the genesis.json file, only do this if you're certain to have the correct state file already (default: false)
--reset-priv-val-state Resets data/priv_validator_state.json file [UNSAFE] (default: false)
--no-service This prevents the genesisd service from being made (default: false)
--no-start This prevents the genesisd service from starting at the end of the script (default: false)
```

### Usage

- **Initialization (new validators; generates a new key)**

`sh genesisd.sh init $YOUR_NEW_NODE_NAME`

- **Upgrading (existing validators; you already have an existing .genesisd folder and configuration)**

`sh genesisd.sh upgrade`

_--if you want a different node name you could use `sh genesisd.sh upgrade $YOUR_NEW_NODE_NAME`_

_--more detailed guides for specific upgrades could be found in the [\/genesisd_docs](genesisd_docs/)-folder_
<br>

<p align="center">
☕ <i>node init/upgrade time is 30-60min or a few tea cups...</i>
Cosmos SDK <b>v0.46.15</b>
</p>

---

### Information
> [!IMPORTANT]
> **For Full-Node Syncing**
>
> If you wish to sync a full node, then you'll have to follow the instructions in the `genesis-evmos` repository first before continuing. This for we were an Evmos-fork before we made the decision to hard fork to Cronos.

#### Swap

Initializing a node uses quite a bit of memory. The script therefore automatically creates virtual memory (swap) to compensate for the amount it requires to start the node. Currently the script is set to automatically calculate how much RAM + Swap is available. Then, whether the user has enough disk space, creates additional swap to have a total of 150GB available RAM + Swap (Example: if 32GB RAM is unused and 30GB of swap is free, an additional swap of 88GB will be created). These swapfiles are formatted as `genesisd_swapfile_{number}` and are made persistent across reboots by adding a line to the `etc/fstab` file. See the bonus scripts for more info on how to properly add or remove them.

#### Backups

If a `.genesisd` folder already exists, the script will back this up to a folder formatted as `.genesisd_backup_{date_time}`. This is a unique name based on the system's current time. Therefore running the script multiple times will continue to create new backup folders.

Since our state file is large this would mean that it will be around ~14GB every time a backup is made. Make sure to remove older backup folders if you plan on running the script more often (testing purposes for instance). They're hidden folders in the root folder; use `cd ~` then `ls -a` to see them.

## **Other (bonus) scripts**

There are some extra scripts in the `genesisd_scripts` folder, which could be useful later down the line.

### Swap scripts

Since the node requires quite some memory usage, swapfiles are created when you run the genesisd.sh script. To alter these swap files we've included scripts to quickly add or remove genesisd_swapfiles.

- **Adding swap** `sh swap_add.sh <amount_of_swap_in_gb>`

Example: sh swap_add.sh 50 will create a new genesisd_swapfile that is 50GB in size in '/'.

- **Removing swap** `sh swap_remove.sh <filename>`

Example: sh swap_remove.sh /genesisd_swapfile_2 turns off swapfile genesisd_swapfile_2, removes the related line in '/etc/fstab' and deletes /genesisd_swapfile_2.
## Node requirements

- **Removing all swaps** `sh swap_remove_all.sh`
- 300GB+ good hard drive disk
- 8GB+ RAM
- 4 CPU Threads
- Good Internet Connection

This will turn off all genesis swapfiles, removes all related lines in '/etc/fstab' and deletes all /genesisd_swapfiles
## Instructions
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func init() {
panic(err)
}

DefaultNodeHome = filepath.Join(userHomeDir, "."+Name+"d")
DefaultNodeHome = filepath.Join(userHomeDir, "."+Name)
sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1000000000000000000)
}

Expand Down
38 changes: 8 additions & 30 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,30 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
)

func (app *App) RegisterUpgradeHandlers(experimental bool) {
upgradeHandlerV1 := func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// upgrade handlers
planName := "plan_cronos"
planHandler := func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
m, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return m, err
}
// clear extra_eips from evm parameters
// Ref: https://github.com/crypto-org-chain/cronos/issues/755
params := app.EvmKeeper.GetParams(ctx)
params.ExtraEIPs = []int64{}
evmParams := app.EvmKeeper.GetParams(ctx)
evmParams.ExtraEIPs = []int64{}

// fix the incorrect value on testnet parameters
zero := sdkmath.ZeroInt()
params.ChainConfig.LondonBlock = &zero
evmParams.ChainConfig.LondonBlock = &zero

app.EvmKeeper.SetParams(ctx, params)
app.EvmKeeper.SetParams(ctx, evmParams)
return m, nil
}
// `v1.0.0` upgrade plan will clear the `extra_eips` parameters, and upgrade ibc-go to v5.2.0.
planName := "v1.0.0"
app.UpgradeKeeper.SetUpgradeHandler(planName, upgradeHandlerV1)
// "v1.0.0-testnet3-2" is another coordinated upgrade on testnet3 to upgrade ibc-go to "v5.2.0".
planNameTestnet3 := "v1.0.0-testnet3-2"
app.UpgradeKeeper.SetUpgradeHandler(planNameTestnet3, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

gravityPlanName := "v0.8.0-gravity-alpha3"
if experimental {
app.UpgradeKeeper.SetUpgradeHandler(gravityPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})
}
app.UpgradeKeeper.SetUpgradeHandler(planName, planHandler)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand All @@ -57,15 +44,6 @@ func (app *App) RegisterUpgradeHandlers(experimental bool) {
Added: []string{ibcfeetypes.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
if experimental && upgradeInfo.Name == gravityPlanName {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{ibcfeetypes.StoreKey},
Deleted: []string{icacontrollertypes.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
Expand Down
Binary file added assets/L1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 0 additions & 22 deletions assets/cronos.svg

This file was deleted.

Binary file added assets/genesisl1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/whitepaper.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/cronosd/config/prefix_testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import sdk "github.com/cosmos/cosmos-sdk/types"

const (
// Bech32Prefix defines the Bech32 prefix used for Cronos Accounts
Bech32Prefix = "genesis"
Bech32Prefix = "tgenesis"

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = Bech32Prefix
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
proxy_app = "tcp://127.0.0.1:26658"

# A custom human readable name for this node
moniker = ""
moniker = "mygenesismoniker"

# If this node is many blocks behind the tip of the chain, FastSync
# allows them to catchup quickly by downloading blocks in parallel
Expand Down
15 changes: 0 additions & 15 deletions genesisd-crisis.service

This file was deleted.

102 changes: 0 additions & 102 deletions genesisd_docs/UPGRADE_29-2_CRONOS.md

This file was deleted.

Loading
Loading