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

SDI changes #111

Merged
merged 9 commits into from
Jul 18, 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 .github/workflows/build-ci-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build CI multiplatform

on:
push:
branches: [ develop, '**-release' ]
branches: [ develop, '**-release', 'feat/sdi-changes' ]
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
Expand Down
97 changes: 58 additions & 39 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,35 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"

"swisstronik/x/evm"
"swisstronik/x/feemarket"

"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
"github.com/cosmos/cosmos-sdk/x/group"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"

simappparams "cosmossdk.io/simapp/params"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store/streaming"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
Expand All @@ -54,6 +47,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand All @@ -74,7 +70,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/cosmos/cosmos-sdk/x/group"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
Expand Down Expand Up @@ -114,36 +110,30 @@ import (
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

vestingmodule "swisstronik/x/vesting"
vestingmodulekeeper "swisstronik/x/vesting/keeper"
vestingmoduletypes "swisstronik/x/vesting/types"

compliancemodule "swisstronik/x/compliance"
compliancemoduleclient "swisstronik/x/compliance/client"
compliancemodulekeeper "swisstronik/x/compliance/keeper"
compliancemoduletypes "swisstronik/x/compliance/types"

evmante "swisstronik/app/ante"
"swisstronik/app/upgrades/v1_0_3"
"swisstronik/docs"
"swisstronik/encoding"

simappparams "cosmossdk.io/simapp/params"

evmante "swisstronik/app/ante"
"swisstronik/ethereum/eip712"
srvflags "swisstronik/server/flags"
evmcommontypes "swisstronik/types"
compliancemodule "swisstronik/x/compliance"
compliancemoduleclient "swisstronik/x/compliance/client"
compliancemodulekeeper "swisstronik/x/compliance/keeper"
compliancemoduletypes "swisstronik/x/compliance/types"
"swisstronik/x/evm"
evmkeeper "swisstronik/x/evm/keeper"
evmtypes "swisstronik/x/evm/types"
"swisstronik/x/feemarket"
feemarketkeeper "swisstronik/x/feemarket/keeper"
feemarkettypes "swisstronik/x/feemarket/types"

"swisstronik/ethereum/eip712"

"github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
vestingmodule "swisstronik/x/vesting"
vestingmodulekeeper "swisstronik/x/vesting/keeper"
vestingmoduletypes "swisstronik/x/vesting/types"
)

const (
Expand Down Expand Up @@ -803,7 +793,7 @@ func New(
app.setAnteHandler(encodingConfig.TxConfig, maxGasWanted)
app.setPostHandler()
app.SetEndBlocker(app.EndBlocker)
SetupHandlers(app, app.EvmKeeper, app.IBCKeeper.ClientKeeper, app.ParamsKeeper, appCodec)
app.setupUpgradeHandlers()

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -1068,6 +1058,35 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
return paramsKeeper
}

func (app *App) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
v1_0_3.UpgradeName,
v1_0_3.CreateUpgradeHandler(
app.mm, app.configurator,
),
)

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
// This will read that value, and execute the preparations for the upgrade.
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

if upgradeInfo.Name == v1_0_3.UpgradeName {
// 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,
// so that new stores start with the correct version (the current height of chain),
// instead the default which is the latest version that store last committed i.e 0 for new stores.
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storetypes.StoreUpgrades{}))
}
}

// SimulationManager implements runtime.AppI
func (*App) SimulationManager() *module.SimulationManager {
panic("unimplemented")
Expand Down
153 changes: 0 additions & 153 deletions app/setup_handler.go

This file was deleted.

5 changes: 5 additions & 0 deletions app/upgrades/v1_0_3/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v1_0_3

const (
UpgradeName = "v1.0.3"
)
24 changes: 24 additions & 0 deletions app/upgrades/v1_0_3/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package v1_0_3

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info("Upgrade complete")
return vm, err
}
}
3 changes: 3 additions & 0 deletions proto/swisstronik/compliance/entities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ message OperatorDetails {
message IssuerDetails {
// Allows to easily understand
// what entity can be associated with issuer address.
// Issuer name
string name = 1;
// Basic issuer description
string description = 2;
Expand All @@ -49,6 +50,8 @@ message IssuerDetails {
string logo = 4;
// Legal entity name
string legalEntity = 5;
// Issuer creator who created current issuer
string creator = 6;
}

message AddressDetails {
Expand Down
4 changes: 2 additions & 2 deletions proto/swisstronik/compliance/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ option go_package = "swisstronik/x/compliance/types";
// GenesisState defines the compliance module's genesis state.
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];
repeated IssuerGenesisAccount issuers = 2;
repeated GenesisIssuerDetails issuerDetails = 2;
deep-quality-dev marked this conversation as resolved.
Show resolved Hide resolved
repeated GenesisAddressDetails addressDetails = 3;
repeated GenesisVerificationDetails verificationDetails = 4;
repeated OperatorDetails operators = 5;
}

message IssuerGenesisAccount {
message GenesisIssuerDetails {
string address = 1;
IssuerDetails details = 2;
}
Expand Down
Loading
Loading