Skip to content

Commit

Permalink
fix: gensis import export of modules (#3437)
Browse files Browse the repository at this point in the history
* fix: gensis import export of modules

* ci: add v prefix to version

* test: fix tests

* fix: minor
  • Loading branch information
snobbee authored Dec 15, 2023
1 parent 0698422 commit 191a7e4
Show file tree
Hide file tree
Showing 43 changed files with 4,071 additions and 2,508 deletions.
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Name=sifchain
- -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger
tags:
Expand All @@ -41,7 +41,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Name=sifchain
- -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger
tags:
Expand All @@ -62,7 +62,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Name=sifchain
- -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger
tags:
Expand All @@ -83,7 +83,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Name=sifchain
- -X github.com/cosmos/cosmos-sdk/version.ServerName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.ClientName=sifnoded
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=ledger
tags:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CHAINNET ?= betanet
CHAINNET ?= mainnet
BINARY ?= sifnoded
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin
NOW = $(shell date +'%Y-%m-%d_%T')
COMMIT := $(shell git log -1 --format='%H')
VERSION := $(shell cat version)
VERSION := $(shell git describe --match 'v*' --abbrev=8 --tags | sed 's/-g/-/' | sed 's/-[0-9]*-/-/')
IMAGE_TAG ?= latest
HTTPS_GIT := https://github.com/sifchain/sifnode.git
DOCKER ?= docker
Expand Down
8 changes: 8 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"net/http"
"os"
"strings"

"github.com/cosmos/cosmos-sdk/x/authz"

Expand Down Expand Up @@ -266,7 +267,14 @@ func NewSifAppWithBlacklist(
interfaceRegistry := encodingConfig.InterfaceRegistry
bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)

// FIXME: This adjustment enables the version command to function correctly with the existing version of Sifnode.
// It's intended as a short-term measure and should be eliminated following the planned overhaul of the version command.
if !strings.HasPrefix(version.Version, "v") {
version.Version = "v" + version.Version
}
bApp.SetVersion(version.Version)

bApp.SetInterfaceRegistry(interfaceRegistry)
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey,
Expand Down
11 changes: 5 additions & 6 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
m "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const releaseVersion = "1.3.1-beta"

func SetupHandlers(app *SifchainApp) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm m.VersionMap) (m.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + releaseVersion)
app.UpgradeKeeper.SetUpgradeHandler(version.Version, func(ctx sdk.Context, _ types.Plan, vm m.VersionMap) (m.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + version.Version)

return app.mm.RunMigrations(ctx, app.configurator, vm)
})
Expand All @@ -20,9 +19,9 @@ func SetupHandlers(app *SifchainApp) {
if err != nil {
panic(err)
}
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == version.Version && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{},
// Added: []string{},
}
// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
Expand Down
10 changes: 8 additions & 2 deletions proto/sifnode/clp/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ import "sifnode/clp/v1/types.proto";
import "sifnode/clp/v1/rewards_bucket.proto";

// GenesisState - all clp state that must be provided at genesis
// TODO: Add parameters to Genesis state ,such as minimum liquidity required to
// create a pool
message GenesisState {
sifnode.clp.v1.Params params = 1 [ (gogoproto.nullable) = false ];
repeated string address_whitelist = 2;
repeated sifnode.clp.v1.Pool pool_list = 3;
repeated sifnode.clp.v1.LiquidityProvider liquidity_providers = 4;
repeated RewardsBucket rewards_bucket_list = 5 [(gogoproto.nullable) = false];
sifnode.clp.v1.RewardParams reward_params = 6 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.PmtpParams pmtp_params = 7 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.PmtpEpoch pmtp_epoch = 8 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.PmtpRateParams pmtp_rate_params = 9 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.LiquidityProtectionParams liquidity_protection_params = 10 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.LiquidityProtectionRateParams liquidity_protection_rate_params = 11 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.SwapFeeParams swap_fee_params = 12 [ (gogoproto.nullable) = false ];
sifnode.clp.v1.ProviderDistributionParams provider_distribution_params = 13 [ (gogoproto.nullable) = false ];
}
15 changes: 15 additions & 0 deletions proto/sifnode/ethbridge/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package sifnode.ethbridge.v1;

import "gogoproto/gogo.proto";
import "sifnode/ethbridge/v1/types.proto";

option go_package = "github.com/Sifchain/sifnode/x/ethbridge/types";

// GenesisState for ethbridge
message GenesisState {
string ceth_receive_account = 1;
repeated string peggy_tokens = 2;
repeated string blacklist = 3;
Pause pause = 4;
}
6 changes: 0 additions & 6 deletions proto/sifnode/ethbridge/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ enum ClaimType {
CLAIM_TYPE_LOCK = 2;
}

// GenesisState for ethbridge
message GenesisState {
string ceth_receive_account = 1;
repeated string peggy_tokens = 2;
}

message Pause {
bool is_paused = 1;
}
14 changes: 14 additions & 0 deletions proto/sifnode/margin/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package sifnode.margin.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/Sifchain/sifnode/x/margin/types";

import "sifnode/margin/v1/params.proto";
import "sifnode/margin/v1/types.proto";

message GenesisState {
Params params = 1;
repeated MTP mtp_list = 2;
}
65 changes: 65 additions & 0 deletions proto/sifnode/margin/v1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
syntax = "proto3";
package sifnode.margin.v1;
import "gogoproto/gogo.proto";

option go_package = "github.com/Sifchain/sifnode/x/margin/types";

message Params {
string leverage_max = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_max = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_min = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_increase = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_decrease = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string health_gain_factor = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
int64 epoch_length = 7;
repeated string pools = 8;
string removal_queue_threshold = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 max_open_positions = 11;
string pool_open_threshold = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string force_close_fund_percentage = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string force_close_fund_address = 14;
string incremental_interest_payment_fund_percentage = 15 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string incremental_interest_payment_fund_address = 16;
string sq_modifier = 17 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string safety_factor = 18 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
repeated string closed_pools = 19;
bool incremental_interest_payment_enabled = 20;
bool whitelisting_enabled = 21;
bool rowan_collateral_enabled = 22;
}
1 change: 1 addition & 0 deletions proto/sifnode/margin/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "sifnode/margin/v1/types.proto";
import "sifnode/margin/v1/params.proto";

option go_package = "github.com/Sifchain/sifnode/x/margin/types";

Expand Down
1 change: 1 addition & 0 deletions proto/sifnode/margin/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sifnode.margin.v1;

import "gogoproto/gogo.proto";
import "sifnode/margin/v1/types.proto";
import "sifnode/margin/v1/params.proto";

option go_package = "github.com/Sifchain/sifnode/x/margin/types";

Expand Down
62 changes: 0 additions & 62 deletions proto/sifnode/margin/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,6 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/Sifchain/sifnode/x/margin/types";

message GenesisState { Params params = 1; }

message Params {
string leverage_max = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_max = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_min = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_increase = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string interest_rate_decrease = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string health_gain_factor = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
int64 epoch_length = 7;
repeated string pools = 8;
string removal_queue_threshold = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 max_open_positions = 11;
string pool_open_threshold = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string force_close_fund_percentage = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string force_close_fund_address = 14;
string incremental_interest_payment_fund_percentage = 15 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string incremental_interest_payment_fund_address = 16;
string sq_modifier = 17 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string safety_factor = 18 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
repeated string closed_pools = 19;
bool incremental_interest_payment_enabled = 20;
bool whitelisting_enabled = 21;
bool rowan_collateral_enabled = 22;
}

enum Position {
UNSPECIFIED = 0;
LONG = 1;
Expand Down
13 changes: 13 additions & 0 deletions proto/sifnode/oracle/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package sifnode.oracle.v1;

import "gogoproto/gogo.proto";
import "sifnode/oracle/v1/types.proto";

option go_package = "github.com/Sifchain/sifnode/x/oracle/types";

message GenesisState {
repeated string address_whitelist = 1;
string admin_address = 2;
repeated DBProphecy prophecies = 3;
}
6 changes: 0 additions & 6 deletions proto/sifnode/oracle/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/Sifchain/sifnode/x/oracle/types";

message GenesisState {
repeated string address_whitelist = 1;
string admin_address = 2;
repeated DBProphecy prophecies = 3;
}

// Claim contains an arbitrary claim with arbitrary content made by a given
// validator
message Claim {
Expand Down
11 changes: 11 additions & 0 deletions proto/sifnode/tokenregistry/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package sifnode.tokenregistry.v1;

import "gogoproto/gogo.proto";
import "sifnode/tokenregistry/v1/types.proto";

option go_package = "github.com/Sifchain/sifnode/x/tokenregistry/types";

message GenesisState {
Registry registry = 2;
}
4 changes: 0 additions & 4 deletions proto/sifnode/tokenregistry/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/Sifchain/sifnode/x/tokenregistry/types";

message GenesisState {
Registry registry = 2;
}

message Registry { repeated RegistryEntry entries = 1; }

enum Permission {
Expand Down
5 changes: 0 additions & 5 deletions scripts/chain-initiator/download-and-run-version.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ func downloadAndRunVersion(binaryPathOrURL string, skipDownload bool) (path stri
}
version = versionMatches[0]

// Remove the "v" prefix if present
if strings.HasPrefix(version, "v") {
version = strings.TrimPrefix(version, "v")
}

// Set the binary path based on the version
path = "/tmp/sifnoded-" + version

Expand Down
Loading

0 comments on commit 191a7e4

Please sign in to comment.