Skip to content

Commit

Permalink
Custody module double address protection
Browse files Browse the repository at this point in the history
  • Loading branch information
kobs30 committed May 1, 2023
2 parents 187e751 + 7cb442f commit a7acde3
Show file tree
Hide file tree
Showing 249 changed files with 67,322 additions and 15,946 deletions.
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# sekai

KIRA Relay Chain

## Quick setup from Github
Expand Down Expand Up @@ -67,59 +68,110 @@ TOOLS_VERSION="v0.0.12.4" && mkdir -p /usr/keys && FILE_NAME="bash-utils.sh" &&
```sh
sh env.sh
```

# Get version info

[scripts/commands/version.sh](scripts/commands/version.sh)

# Adding more validators

[scripts/commands/adding-validators.sh](scripts/commands/adding-validators.sh)

## Set ChangeTxFee permission

[scripts/commands/set-permission.sh](scripts/commands/set-permission.sh)

## Set network properties

[scripts/commands/set-network-properties.sh](scripts/commands/set-network-properties.sh)

## Set Execution Fee

[scripts/commands/set-execution-fee.sh](scripts/commands/set-execution-fee.sh)

## Upsert token rates

[scripts/commands/upsert-token-rates.sh](scripts/commands/upsert-token-rates.sh)

## Upsert token alias

[scripts/commands/upsert-token-alias.sh](scripts/commands/upsert-token-alias.sh)

# Fee payment in foreign currency

[scripts/commands/foreign-fee-payments.sh](scripts/commands/foreign-fee-payments.sh)

# Fee payment in foreign currency returning failure - execution fee in foreign currency

[scripts/commands/foreign-fee-payments-failure-return.sh](scripts/commands/foreign-fee-payments-failure-return.sh)

## Query permission of an address

[scripts/commands/query-permission.sh](scripts/commands/query-permission.sh)

## Query network properties

[scripts/commands/query-network-properties.sh](scripts/commands/query-network-properties.sh)

## Query execution fee

[scripts/commands/query-execution-fee.sh](scripts/commands/query-execution-fee.sh)

# Query token alias

[scripts/commands/query-token-alias.sh](scripts/commands/query-token-alias.sh)

# Query token rate

[scripts/commands/query-token-rate.sh](scripts/commands/query-token-rate.sh)

# Query validator account

[scripts/commands/query-validator.sh](scripts/commands/query-validator.sh)

# Query for current frozen / unfronzen tokens

**Notes**: these values are valid only when specific network property is enabled
[scripts/commands/query-frozen-token.sh](scripts/commands/query-frozen-token.sh)

# Query poor network messages

[scripts/commands/query-poor-network-messages.sh](scripts/commands/query-poor-network-messages.sh)

# Query signing infos per validator's consensus address

[scripts/commands/query-signing-infos.sh](scripts/commands/query-signing-infos.sh)

# Common commands for governance process

[scripts/commands/governance/common.sh](scripts/commands/governance/common.sh)

### Set permission via governance process

[scripts/commands/governance/assign-permission.sh](scripts/commands/governance/assign-permission.sh)

## Upsert token alias via governance process

[scripts/commands/governance/upsert-token-alias.sh](scripts/commands/governance/upsert-token-alias.sh)

## Upsert token rates via governance process

[scripts/commands/governance/upsert-token-rates.sh](scripts/commands/governance/upsert-token-rates.sh)

# Commands for poor network management via governance process

[scripts/commands/governance/poor-network-messages.sh](scripts/commands/governance/poor-network-messages.sh)

# Freeze / unfreeze tokens via governance process

[scripts/commands/governance/token-freeze.sh](scripts/commands/governance/token-freeze.sh)

# Set network property proposal via governance process

[scripts/commands/governance/set-network-property.sh](scripts/commands/governance/set-network-property.sh)

# Set application upgrade proposal via governance process

[scripts/commands/governance/upgrade-plan.sh](scripts/commands/governance/upgrade-plan.sh)

Export the status of chain before halt (should kill the daemon process at the time of genesis export)
Expand All @@ -134,12 +186,14 @@ At each time of upgrade, genesis upgrade command will be built and infra could r
Note: state export command is not exporting the upgrade plan and if all validators run with exported genesis with the previous binary, consensus failure won't happen.

# Identity registrar

[scripts/commands/identity-registrar.sh](scripts/commands/identity-registrar.sh)

# Unjail via governance process

Modify genesis json to have jailed validator for Unjail testing
Add jailed validator key to kms.

```sh
sekaid keys add jailed_validator --keyring-backend=test --home=$HOME/.sekaid --recover
"dish rather zoo connect cross inhale security utility occur spell price cute one catalog coconut sort shuffle palm crop surface label foster slender inherit"
Expand All @@ -156,5 +210,6 @@ In order to manually generate new genesis file when the hard fork is activated,
3. Replace current upgrade plan in the app_state.upgrade with next plan and set next plan to null

Using a command it can be done in this way.

1. sekaid export > exported-genesis.json
2. sekaid new-genesis-from-exported exported-genesis.json new-genesis.json
2. sekaid new-genesis-from-exported exported-genesis.json new-genesis.json --json-minimize=true
11 changes: 7 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Features:

- update validator fee share from int to dec
- move commission rewards from validator object to multistaking pool
- Update fields from int to decimal for inactive_rank_decrease_percent,…
- convert slash percentage from int to decimal
- Dapp operator performance counter
- LP token return on verifier exit
- Liquidation for dapp when fall below threshold
- Swap, redeem, convert on lp tokens
- Bridge registrar
- Minting feature
- Add CLI commands and unit tests
1 change: 1 addition & 0 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ func (suite *AnteTestSuite) TestPoorNetworkManagementDecorator() {
sdk.ZeroDec(),
sdk.ZeroInt(),
false,
false,
),
}
return msgs, privs[0:1], accNums[0:1], []uint64{0}, sdk.NewCoins(sdk.NewInt64Coin("ukex", 100))
Expand Down
63 changes: 54 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ import (
customgov "github.com/KiraCore/sekai/x/gov"
customgovkeeper "github.com/KiraCore/sekai/x/gov/keeper"
govtypes "github.com/KiraCore/sekai/x/gov/types"
"github.com/KiraCore/sekai/x/layer2"
layer2keeper "github.com/KiraCore/sekai/x/layer2/keeper"
layer2types "github.com/KiraCore/sekai/x/layer2/types"
"github.com/KiraCore/sekai/x/multistaking"
multistakingkeeper "github.com/KiraCore/sekai/x/multistaking/keeper"
multistakingtypes "github.com/KiraCore/sekai/x/multistaking/types"
recovery "github.com/KiraCore/sekai/x/recovery"
recoverykeeper "github.com/KiraCore/sekai/x/recovery/keeper"
recoverytypes "github.com/KiraCore/sekai/x/recovery/types"
customslashing "github.com/KiraCore/sekai/x/slashing"
customslashingkeeper "github.com/KiraCore/sekai/x/slashing/keeper"
slashingtypes "github.com/KiraCore/sekai/x/slashing/types"
Expand Down Expand Up @@ -104,6 +110,7 @@ var (
params.AppModuleBasic{},
upgrade.AppModuleBasic{},
customslashing.AppModuleBasic{},
recovery.AppModuleBasic{},
customstaking.AppModuleBasic{},
customgov.AppModuleBasic{},
spending.AppModuleBasic{},
Expand All @@ -116,6 +123,7 @@ var (
custody.AppModuleBasic{},
multistaking.AppModuleBasic{},
collectives.AppModuleBasic{},
layer2.AppModuleBasic{},
)

// module account permissions
Expand All @@ -128,6 +136,8 @@ var (
baskettypes.ModuleName: {authtypes.Minter, authtypes.Burner},
multistakingtypes.ModuleName: {authtypes.Burner},
collectivestypes.ModuleName: nil,
layer2types.ModuleName: {authtypes.Minter, authtypes.Burner},
recoverytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -158,6 +168,7 @@ type SekaiApp struct {
CustomGovKeeper customgovkeeper.Keeper
CustomStakingKeeper customstakingkeeper.Keeper
CustomSlashingKeeper customslashingkeeper.Keeper
RecoveryKeeper recoverykeeper.Keeper
TokensKeeper tokenskeeper.Keeper
FeeProcessingKeeper feeprocessingkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
Expand All @@ -167,6 +178,7 @@ type SekaiApp struct {
BasketKeeper basketkeeper.Keeper
MultiStakingKeeper multistakingkeeper.Keeper
CollectivesKeeper collectiveskeeper.Keeper
Layer2Keeper layer2keeper.Keeper

// Module Manager
mm *module.Manager
Expand Down Expand Up @@ -205,6 +217,7 @@ func NewInitApp(
banktypes.StoreKey,
paramstypes.StoreKey,
upgradetypes.StoreKey,
recoverytypes.ModuleName,
slashingtypes.ModuleName,
stakingtypes.ModuleName,
govtypes.ModuleName,
Expand All @@ -218,6 +231,7 @@ func NewInitApp(
evidencetypes.StoreKey,
custodytypes.StoreKey,
collectivestypes.ModuleName,
layer2types.ModuleName,
)
tKeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)

Expand Down Expand Up @@ -258,17 +272,10 @@ func NewInitApp(
app.GetSubspace(slashingtypes.ModuleName),
)
app.SpendingKeeper = spendingkeeper.NewKeeper(keys[spendingtypes.ModuleName], appCodec, app.BankKeeper, app.CustomGovKeeper)
app.UbiKeeper = ubikeeper.NewKeeper(keys[ubitypes.ModuleName], appCodec, app.BankKeeper, app.SpendingKeeper)
// NOTE: customStakingKeeper above is passed by reference, so that it will contain these hooks
app.CustomStakingKeeper = *customStakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.CustomSlashingKeeper.Hooks()),
)
app.DistrKeeper = distributorkeeper.NewKeeper(
keys[distributortypes.ModuleName], appCodec,
app.AccountKeeper, app.BankKeeper,
app.CustomStakingKeeper, app.CustomGovKeeper,
app.MultiStakingKeeper)
app.MultiStakingKeeper.SetDistrKeeper(app.DistrKeeper)

app.BasketKeeper = basketkeeper.NewKeeper(
keys[baskettypes.ModuleName], appCodec,
Expand All @@ -286,6 +293,14 @@ func NewInitApp(
app.SpendingKeeper,
)

app.Layer2Keeper = layer2keeper.NewKeeper(
keys[collectivestypes.StoreKey], appCodec,
app.BankKeeper,
app.CustomStakingKeeper,
app.CustomGovKeeper,
app.SpendingKeeper,
)

app.UpgradeKeeper = upgradekeeper.NewKeeper(keys[upgradetypes.StoreKey], appCodec, app.CustomStakingKeeper)

// app.upgradeKeeper.SetUpgradeHandler(
Expand All @@ -303,6 +318,27 @@ func NewInitApp(

app.CustodyKeeper = custodykeeper.NewKeeper(keys[custodytypes.StoreKey], appCodec, app.CustomGovKeeper, app.BankKeeper)

app.RecoveryKeeper = recoverykeeper.NewKeeper(
appCodec,
keys[slashingtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
&customStakingKeeper,
app.CustomGovKeeper,
app.MultiStakingKeeper,
app.CollectivesKeeper,
app.SpendingKeeper,
app.CustodyKeeper,
)

app.DistrKeeper = distributorkeeper.NewKeeper(
keys[distributortypes.ModuleName], appCodec,
app.AccountKeeper, app.BankKeeper,
app.CustomStakingKeeper, app.CustomGovKeeper,
app.MultiStakingKeeper, app.RecoveryKeeper)
app.MultiStakingKeeper.SetDistrKeeper(app.DistrKeeper)
app.UbiKeeper = ubikeeper.NewKeeper(keys[ubitypes.ModuleName], appCodec, app.BankKeeper, app.SpendingKeeper, app.DistrKeeper)

proposalRouter := govtypes.NewProposalRouter(
[]govtypes.ProposalHandler{
customgov.NewApplyWhitelistAccountPermissionProposalHandler(app.CustomGovKeeper),
Expand Down Expand Up @@ -342,6 +378,8 @@ func NewInitApp(
collectives.NewApplyCollectiveSendDonationProposalHandler(app.CollectivesKeeper),
collectives.NewApplyCollectiveUpdateProposalHandler(app.CollectivesKeeper),
collectives.NewApplyCollectiveRemoveProposalHandler(app.CollectivesKeeper),
layer2.NewApplyJoinDappProposalHandler(app.Layer2Keeper),
layer2.NewApplyUpsertDappProposalHandler(app.Layer2Keeper),
})

app.CustomGovKeeper.SetProposalRouter(proposalRouter)
Expand All @@ -360,6 +398,7 @@ func NewInitApp(
upgrade.NewAppModule(app.UpgradeKeeper, app.CustomGovKeeper),
params.NewAppModule(app.ParamsKeeper),
customslashing.NewAppModule(appCodec, app.CustomSlashingKeeper, app.AccountKeeper, app.BankKeeper, app.CustomStakingKeeper),
recovery.NewAppModule(appCodec, app.RecoveryKeeper, app.AccountKeeper, app.CustomStakingKeeper),
customstaking.NewAppModule(app.CustomStakingKeeper, app.CustomGovKeeper),
multistaking.NewAppModule(app.MultiStakingKeeper, app.BankKeeper, app.CustomGovKeeper, app.CustomStakingKeeper),
customgov.NewAppModule(app.CustomGovKeeper),
Expand All @@ -372,6 +411,7 @@ func NewInitApp(
evidence.NewAppModule(app.EvidenceKeeper),
custody.NewAppModule(app.CustodyKeeper, app.CustomGovKeeper, app.BankKeeper),
collectives.NewAppModule(app.CollectivesKeeper),
layer2.NewAppModule(app.Layer2Keeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -380,26 +420,28 @@ func NewInitApp(
app.mm.SetOrderBeginBlockers(
genutiltypes.ModuleName, paramstypes.ModuleName, govtypes.ModuleName, tokenstypes.ModuleName,
authtypes.ModuleName, feeprocessingtypes.ModuleName, banktypes.ModuleName,
upgradetypes.ModuleName, slashingtypes.ModuleName,
upgradetypes.ModuleName, slashingtypes.ModuleName, recoverytypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName,
spendingtypes.ModuleName, ubitypes.ModuleName,
distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName,
baskettypes.ModuleName,
distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName,
baskettypes.ModuleName,
collectivestypes.ModuleName,
layer2types.ModuleName,
)
app.mm.SetOrderEndBlockers(
banktypes.ModuleName, upgradetypes.ModuleName, tokenstypes.ModuleName,
evidencetypes.ModuleName, genutiltypes.ModuleName, paramstypes.ModuleName,
slashingtypes.ModuleName, authtypes.ModuleName,
slashingtypes.ModuleName, authtypes.ModuleName, recoverytypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
feeprocessingtypes.ModuleName,
spendingtypes.ModuleName, ubitypes.ModuleName,
distributortypes.ModuleName, multistakingtypes.ModuleName, custodytypes.ModuleName,
baskettypes.ModuleName,
collectivestypes.ModuleName,
layer2types.ModuleName,
)

// NOTE: The genutils moodule must occur after staking so that pools are
Expand All @@ -413,6 +455,7 @@ func NewInitApp(
govtypes.ModuleName, // staking module is using the moniker identity registrar and gov module should be initialized before
stakingtypes.ModuleName,
slashingtypes.ModuleName,
recoverytypes.ModuleName,
tokenstypes.ModuleName,
feeprocessingtypes.ModuleName,
genutiltypes.ModuleName,
Expand All @@ -426,6 +469,7 @@ func NewInitApp(
multistakingtypes.ModuleName,
baskettypes.ModuleName,
collectivestypes.ModuleName,
layer2types.ModuleName,
)

app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
Expand All @@ -442,6 +486,7 @@ func NewInitApp(
auth.NewAppModule(appCodec, app.AccountKeeper, simulation.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
customslashing.NewAppModule(appCodec, app.CustomSlashingKeeper, app.AccountKeeper, app.BankKeeper, app.CustomStakingKeeper),
recovery.NewAppModule(appCodec, app.RecoveryKeeper, app.AccountKeeper, app.CustomStakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
)
Expand Down
Loading

0 comments on commit a7acde3

Please sign in to comment.