Skip to content

Commit

Permalink
Merge pull request #462 from KiraCore/release/v0.3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
asmodat authored Apr 27, 2023
2 parents c631347 + 8257445 commit 7cb442f
Show file tree
Hide file tree
Showing 46 changed files with 11,709 additions and 2,367 deletions.
9 changes: 7 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Features:

- Implement layer2 v1 with dapp creation, executors/verifiers management, session management
- Add CLI commands and unit tests on layer2 v1 features
- 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
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var (
baskettypes.ModuleName: {authtypes.Minter, authtypes.Burner},
multistakingtypes.ModuleName: {authtypes.Burner},
collectivestypes.ModuleName: nil,
layer2types.ModuleName: nil,
layer2types.ModuleName: {authtypes.Minter, authtypes.Burner},
recoverytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

Expand Down Expand Up @@ -296,6 +296,7 @@ func NewInitApp(
app.Layer2Keeper = layer2keeper.NewKeeper(
keys[collectivestypes.StoreKey], appCodec,
app.BankKeeper,
app.CustomStakingKeeper,
app.CustomGovKeeper,
app.SpendingKeeper,
)
Expand Down
31 changes: 25 additions & 6 deletions proto/kira/gov/network_properties.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ enum NetworkProperty {
MAX_PROPOSAL_CHECKSUM_SIZE = 45 [(gogoproto.enumvalue_customname) = "MaxProposalChecksumSize"]; // maximum poll checksum size
MIN_DAPP_BOND = 46 [(gogoproto.enumvalue_customname) = "MinDappBond"]; // default 1’000’000 KEX
MAX_DAPP_BOND = 47 [(gogoproto.enumvalue_customname) = "MaxDappBond"]; // default 10’000’000 KEX
DAPP_BOND_DURATION = 48 [(gogoproto.enumvalue_customname) = "DappBondDuration"]; // default 7d - 604800s
DAPP_VERIFIER_BOND = 49 [(gogoproto.enumvalue_customname) = "DappVerifierBond"]; // percentage of lp token supply to be put to be the verifier of the dapp by default 0.1%
DAPP_AUTO_DENOUNCE_TIME = 50 [(gogoproto.enumvalue_customname) = "DappAutoDenounceTime"]; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx`
DAPP_LIQUIDATION_THRESHOLD = 48 [(gogoproto.enumvalue_customname) = "DappLiquidationThreshold"]; // default 100’000 KEX
DAPP_LIQUIDATION_PERIOD = 49 [(gogoproto.enumvalue_customname) = "DappLiquidationPeriod"]; // default 2419200, ~28d
DAPP_BOND_DURATION = 50 [(gogoproto.enumvalue_customname) = "DappBondDuration"]; // default 7d - 604800s
DAPP_VERIFIER_BOND = 51 [(gogoproto.enumvalue_customname) = "DappVerifierBond"]; // percentage of lp token supply to be put to be the verifier of the dapp by default 0.1%
DAPP_AUTO_DENOUNCE_TIME = 52 [(gogoproto.enumvalue_customname) = "DappAutoDenounceTime"]; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx`
DAPP_MISCHANCE_RANK_DECREASE_AMOUNT = 53 [(gogoproto.enumvalue_customname) = "DappMischanceRankDecreaseAmount"];
DAPP_MAX_MISCHANCE = 54 [(gogoproto.enumvalue_customname) = "DappMaxMischance"];
DAPP_INACTIVE_RANK_DECREASE_PERCENT = 55 [(gogoproto.enumvalue_customname) = "DappInactiveRankDecreasePercent"];
DAPP_POOL_SLIPPAGE_DEFAULT = 56 [(gogoproto.enumvalue_customname) = "DappPoolSlippageDefault"];
MINTING_FT_FEE = 57 [ (gogoproto.enumvalue_customname) = "MintingFtFee" ];
MINTING_NFT_FEE = 58 [ (gogoproto.enumvalue_customname) = "MintingNftFee" ];
}

message NetworkPropertyValue {
Expand Down Expand Up @@ -142,10 +150,21 @@ message NetworkProperties {
uint64 max_proposal_checksum_size = 46; // maximum checksum size in the proposal
uint64 min_dapp_bond = 47; // default 1’000’000 KEX
uint64 max_dapp_bond = 48; // default 10’000’000 KEX
uint64 dapp_bond_duration = 49; // default 7d - 604800s
string dapp_verifier_bond = 50 [
uint64 dapp_liquidation_threshold = 49; // default 100’000 KEX
uint64 dapp_liquidation_period = 50; // default 2419200, ~28d
uint64 dapp_bond_duration = 51; // default 7d - 604800s
string dapp_verifier_bond = 52 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
]; // percentage of lp token supply to be put to be the verifier of the dapp by default 0.1%
uint64 dapp_auto_denounce_time = 51; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx`
uint64 dapp_auto_denounce_time = 53; // in seconds (default 60), time the dapp leader allowed to send `execute-dapp-tx`
uint64 dapp_mischance_rank_decrease_amount = 54;
uint64 dapp_max_mischance = 55;
uint64 dapp_inactive_rank_decrease_percent = 56;
string dapp_pool_slippage_default = 57 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
]; // default 0.1, that is 10%
uint64 minting_ft_fee = 58; // default 100’000’000’000 ukex - 100k KEX
uint64 minting_nft_fee = 59; // default 100’000’000’000 ukex - 100k KEX
}
1 change: 1 addition & 0 deletions proto/kira/layer2/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "kira/layer2/layer2.proto";
message GenesisState {
// dapps registered on the module
repeated Dapp dapps = 1 [ (gogoproto.nullable) = false ];
BridgeRegistrar bridge = 2 [ (gogoproto.nullable) = false ];
}

// https://www.notion.so/kira-network/KIP-84-Layer-2-90379a918a3a4394908d814c7455fbdb
134 changes: 132 additions & 2 deletions proto/kira/layer2/layer2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package kira.layer2;
option go_package = "github.com/KiraCore/sekai/x/layer2/types";
option (gogoproto.equal_all) = true;

import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

Expand Down Expand Up @@ -81,6 +82,14 @@ message Dapp {
uint64 vote_quorum = 19; // percentage - default: 51%, collective-specific % of owner accounts that must vote YES or NO for any of the collective proposals to be valid
uint64 vote_period = 20; // seconds - default: 600s, period of time in seconds that any of the collective proposals must last before passing or being rejected
uint64 vote_enactment = 21; // seconds - default: 300s, period of time that must pass before any of the collective proposals is enacted
uint64 liquidation_start = 22; // liquidation start time
string pool_fee = 23 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
]; // default 1% swap, deposits, redemptions
string team_reserve = 24; // team multisig
uint64 premint_time = 25; // timestamp for premint
bool post_mint_paid = 26; // flag to show post mint paid or not
}

message UserDappBond {
Expand Down Expand Up @@ -117,7 +126,10 @@ message DappOperator {
OperatorStatus status = 6;
int64 rank = 7;
int64 streak = 8;
string bonded_lp_amount = 9 [
int64 mischance = 9;
int64 verified_sessions = 10;
int64 missed_sessions = 11;
string bonded_lp_amount = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
Expand Down Expand Up @@ -148,6 +160,7 @@ message DappSession {
string status_hash = 3;
SessionStatus status = 4;
string gateway = 5;
repeated google.protobuf.Any onchain_messages = 6; // dapp mints, xam creations, xam accepts
}

message DappSessionApproval {
Expand All @@ -161,4 +174,121 @@ message ExecutionRegistrar {
DappSession prev_session = 2; // a session that was completed and caused changes to the blockchain
DappSession curr_session = 3; // a session that is currently ongoing or was just finalized but is NOT a part of the changes applied to the blockchain state
DappSession next_session = 4; // a session that is about to begin after the current session ended
}
}

// To signal that dApp expects SEKAI to execute something, a tx as escaped JSON string must be placed in the `xam` field and `dst` set to `0`.
// Users MUST NOT be allowed to set `xam` by sending `transfer-dapp-tx` with `dst == 0`, this can only be done by the applications themselves
// and included as part of `xamdata`.
// Applications also are NOT allowed to send tx on behalf of other tx, meaning that ABR must interpret all tx with `dst == 0`
// as execution requests as long as `xam` is NOT an empty string.
// The only difference between user tx and application tx should be that the application tx will not have a signature.

message BridgeRegistrarHelper {
uint64 next_user = 1; // default 1, defines what should be the next index of the user or application account
uint64 next_xam = 2; // default 1, defines what should be the next cross-application transaction id - xid
uint64 next_token = 3; // default 2, defines what should be the next token denom identifier
}

message BridgeRegistrar {
BridgeRegistrarHelper helper = 1; // contains next values for user, xam, token
repeated BridgeAccount accounts = 2 [ (gogoproto.nullable) = false ]; // used only on genesis export
repeated BridgeToken tokens = 3 [ (gogoproto.nullable) = false ]; // used only on genesis export
repeated XAM xams = 4 [ (gogoproto.nullable) = false ]; // used only on genesis export
}

message BridgeBalance {
uint64 bridge_token_index = 1;
string amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message BridgeAccount {
uint64 index = 1;
string address = 2;
string dapp_name = 3; // set to app name if app account
repeated BridgeBalance balances = 4 [ (gogoproto.nullable) = false ];
}

message BridgeToken {
uint64 index = 1;
string denom = 2;
}

message XAMRequest {
repeated BridgeBalance amounts = 1 [ (gogoproto.nullable) = false ];; // coin amount - { "333333": "222222" } to send 222222 ubtc
uint64 source_dapp = 2; // source app
uint64 source_account = 3; // source beneficiary
uint64 dest_dapp = 4; // destination app
uint64 dest_beneficiary = 5; // destination beneficiary
string xam = 6; // string with message (optional)
}

message XAMResponse {
uint64 xid = 1;
uint64 irc = 2; // Internal error or response code
uint64 src = 3; // Source application error or response code
uint64 drc = 4; // Destination application error or response code
uint64 irm = 5; // Internal response message
uint64 srm = 6; // Source response message
uint64 drm = 7; // Destination response message
}

message XAM {
uint64 req_time = 1;
XAMRequest req = 2 [ (gogoproto.nullable) = false ];
XAMResponse res = 3 [ (gogoproto.nullable) = false ];
}

// Application Bridge Registrar Structure Example
// {
// "next_index": <uint64>, // default 1, defines what should be the next index of the user or application account
// "next_xam": <uint64>, // default 1, defines what should be the next cross-application transaction id - xid
// "next_token": <uint64>, // default 2, defines what should be the next token denom identifier
// "users": { // mapping of uint256 identifiers to addresses, value '0' MUST be reserved
// "1":"kiraXXX...XXX",
// "2":"kiraYYY...YYY",
// ...
// },
// "apps": { // mapping of uint64 identifiers to apps dApp, value '0' MUST be reserved
// "1045": "kiraMMM...MMM",
// ...
// },
// "tokens": { // mapping of denom to identifiers, index 1 is reserved for KEX
// "1": "ukex",
// "2": "<denom>", ...
// }
// "balances": { // user or application account balances
// "<kiraXXX...XXX>": { // explicit account address
// "index": <uint64>, // index as defined as in the users or apps array
// "deposits": {
// "<denom>": { // dictionary mapping denom to applications by <index> and the corresponding amount locked to that dApp
// "<index>": "<uint256>", ...
// }, ...
// }
// }, { ... }, ...
// },
// "xams": { // cross application messages
// "<kiraXXX...XXX>": [ // list of transactions originating from specific kira address (user or application)
// {
// "xid": <uint64>, // iterative, unique cross-application message identifier
// "val": { // dictionary of tokens <uint64> and corresponding ammounts <uint256> to be transferred (if any)
// "<uint64>": "<uint256>", ...
// },
// "time": <uint32>, // unix timestamp of the block when the transfer/withdrawl/message was sent
// "src": <uint64>, // source APPlication of funds FROM which application index funds should be moved, if set to 0 implies deposit to ABR
// "acc": <uint64>, // ACCount index FROM which funds should be sent
// "dst": <uint64>, // APPlication TO which funds should be transferred, if set to 0 implies withdrawl from ABR back to KIRA bank module
// "ben": <uint64>, // beneficiary/destination account to which funds must be sent
// "irc": <uint16>, // Internal error or response code
// "src": <uint16>, // Source application error or response code
// "drc": <uint16>, // Destination application error or response code
// "xam": "<string>", // Cross-application message
// "irm": "<string>", // Internal response message
// "srm": "<string>", // Source response message
// "drm": "<string>" // Destination response message
// }, { ... }, ...
// ]
// }
// }
36 changes: 36 additions & 0 deletions proto/kira/layer2/mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";
package kira.layer2;

option go_package = "github.com/KiraCore/sekai/x/layer2/types";
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

message TokenInfo {
string token_type = 1; // Token Type / Compatibility (can NOT be changed or owner defined)
string denom = 2; // full denom, e.g. ap_kirabridge_btc or class identifier (can NOT be changed)
string name = 3; // full name, eg. Bitcoin, (can only be changed by the proposal-upsert-alias)
string symbol = 4; // symbnol, eg. KEX, BTC, (can only be changed by the proposal-upsert-alias)
string icon = 5; // url 256 chars max, (can be changed by owner or proposal-upsert-alias)
string description = 6; // 512 chars max, (can be changed by owner or proposal-upsert-alias)
string website = 7; // url 256 chars max, (can be changed by owner or proposal-upsert-alias)
string social = 8; // url 256 chars max, (can be changed by owner or proposal-upsert-alias)
uint64 decimals = 9; // min 0, max 255, (can NOT be changed)
string cap = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
]; // maximum supply that can be issued, max 2^256 - 1, (can NOT be INCREASED or decreased below current circulatin supply)
string supply = 11 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
]; // current circulating supply can NOT be more then CAP
uint64 holders = 12;
string fee = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
]; // cost of minting 10^decimals per X ukex, can only increase (can be changed by owner only)
string owner = 14; // owner address or "" if noone should be able to modify most important properties
string metadata = 15; // metadata url or CID
string hash = 16; // hexadecimal metadata checksum
}
13 changes: 9 additions & 4 deletions proto/kira/layer2/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "kira/layer2/layer2.proto";
import "kira/layer2/mint.proto";

option go_package = "github.com/KiraCore/sekai/x/layer2/types";

Expand All @@ -22,7 +23,7 @@ service Query {
}
// query XAMs’ records by either account address, account index, xid or
// transaction hash in which cross-app transaction was added to the ABR.
rpc TransferDapp(QueryTransferDappRequest) returns (QueryTransferDappResponse) {
rpc TransferDapps(QueryTransferDappsRequest) returns (QueryTransferDappsResponse) {
option (google.api.http).get = "/kira/layer2/transfer_dapp";
}
// query list of all token denoms on the network including those created in
Expand All @@ -48,8 +49,12 @@ message QueryAllDappsResponse {
repeated Dapp dapps = 1 [ (gogoproto.nullable) = false ];
}

message QueryTransferDappRequest {}
message QueryTransferDappResponse {}
message QueryTransferDappsRequest {}
message QueryTransferDappsResponse {
repeated XAM XAMs = 1 [ (gogoproto.nullable) = false ];
}

message QueryGlobalTokensRequest {}
message QueryGlobalTokensResponse {}
message QueryGlobalTokensResponse {
repeated TokenInfo tokens = 1 [ (gogoproto.nullable) = false ];
}
Loading

0 comments on commit 7cb442f

Please sign in to comment.