Skip to content

Commit

Permalink
Halt per hostZone (#606)
Browse files Browse the repository at this point in the history
Co-authored-by: antstalepresh <36045227+antstalepresh@users.noreply.github.com>
Co-authored-by: sampocs <sam.pochyly@gmail.com>
Co-authored-by: sampocs <sam@stridelabs.co>
Co-authored-by: antstalepresh <stalepresh121@outlook.com>
Co-authored-by: Aidan Salzmann <aidan@stridelabs.co>
Co-authored-by: riley-stride <104941670+riley-stride@users.noreply.github.com>
Co-authored-by: Riley Edmunds <riley@stridelabs.co>
  • Loading branch information
8 people committed Mar 9, 2023
1 parent 5ff42a9 commit 616b150
Show file tree
Hide file tree
Showing 32 changed files with 1,040 additions and 375 deletions.
1 change: 1 addition & 0 deletions app/app.go
Expand Up @@ -531,6 +531,7 @@ func NewStrideApp(
app.RecordsKeeper,
app.StakingKeeper,
app.IcacallbacksKeeper,
app.RatelimitKeeper,
)
app.StakeibcKeeper = *stakeibcKeeper.SetHooks(
stakeibcmoduletypes.NewMultiStakeIBCHooks(app.ClaimKeeper.Hooks()),
Expand Down
15 changes: 0 additions & 15 deletions dockernet/tests/integration_tests.bats
Expand Up @@ -235,18 +235,3 @@ setup_file() {
redemption_rate_increased=$(( $(FLOOR $(DECMUL $redemption_rate $MULT)) > $(FLOOR $(DECMUL 1.00000000000000000 $MULT))))
assert_equal "$redemption_rate_increased" "1"
}

@test "[INTEGRATION-BASIC-$CHAIN_NAME] revenue accrued, and clear-balance works" {
# confirm the fee account has accrued revenue
fee_ica_balance=$($HOST_MAIN_CMD q bank balances $(GET_ICA_ADDR $HOST_CHAIN_ID fee) --denom $HOST_DENOM | GETBAL)
fee_ica_balance_positive=$(($fee_ica_balance > 0))
assert_equal "$fee_ica_balance_positive" "1"

# call clear balance (with amount = 1)
$STRIDE_MAIN_CMD tx stakeibc clear-balance $HOST_CHAIN_ID 1 $HOST_TRANSFER_CHANNEL --from $STRIDE_ADMIN_ACCT -y
WAIT_FOR_BLOCK $STRIDE_LOGS 8

# check that balance went to revenue account
fee_stride_balance=$($STRIDE_MAIN_CMD q bank balances $STRIDE_FEE_ADDRESS --denom $HOST_IBC_DENOM | GETBAL)
assert_equal "$fee_stride_balance" "1"
}
13 changes: 12 additions & 1 deletion proto/stride/stakeibc/host_zone.proto
Expand Up @@ -8,7 +8,7 @@ import "cosmos_proto/cosmos.proto";

option go_package = "github.com/Stride-Labs/stride/v6/x/stakeibc/types";

// next id: 19
// next id: 22
message HostZone {
string chain_id = 1;
string connection_id = 2;
Expand Down Expand Up @@ -44,5 +44,16 @@ message HostZone {
(gogoproto.nullable) = false
];
string address = 18 [ (gogoproto.moretags) = "yaml:\"address\"" ];
bool halted = 19;
string min_redemption_rate = 20 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string max_redemption_rate = 21 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
reserved 15;
}
4 changes: 2 additions & 2 deletions proto/stride/stakeibc/params.proto
Expand Up @@ -29,8 +29,8 @@ message Params {
uint64 ibc_timeout_blocks = 11;
uint64 fee_transfer_timeout_nanos = 12;
uint64 max_stake_ica_calls_per_epoch = 13;
uint64 safety_min_redemption_rate_threshold = 14;
uint64 safety_max_redemption_rate_threshold = 15;
uint64 default_min_redemption_rate_threshold = 14;
uint64 default_max_redemption_rate_threshold = 15;
uint64 ibc_transfer_timeout_nanos = 16;
uint64 safety_num_validators = 17;
uint64 safety_max_slash_percent = 18;
Expand Down
12 changes: 11 additions & 1 deletion proto/stride/stakeibc/tx.proto
Expand Up @@ -64,7 +64,7 @@ message MsgRedeemStake {

message MsgRedeemStakeResponse {}

// next: 13
// next: 15
message MsgRegisterHostZone {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Expand All @@ -78,6 +78,16 @@ message MsgRegisterHostZone {
[ (gogoproto.moretags) = "yaml:\"transfer_channel_id\"" ];
uint64 unbonding_frequency = 11
[ (gogoproto.moretags) = "yaml:\"unbonding_frequency\"" ];
string min_redemption_rate = 13 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string max_redemption_rate = 14 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

message MsgRegisterHostZoneResponse {}
Expand Down
43 changes: 25 additions & 18 deletions readme-docs/md/stakeibc_README.md
Expand Up @@ -7,19 +7,21 @@ category: 6392913957c533007128548e
# The StakeIBC Module

The StakeIBC Module contains Stride's main app logic:

- it exposes core liquid staking entry points to the user (liquid staking and redeeming)
- it executes automated beginBlocker and endBlocker logic to stake funds on relevant host zones using Interchain Accounts
- it executes automated beginBlocker and endBlocker logic to stake funds on relevant host zones using Interchain Accounts
- it handles registering new host zones and adjusting host zone validator sets and weights
- it defines Stride's core data structures (e.g. hostZone)
- it defines all the callbacks used when issuing Interchain Account logic
- it defines all the callbacks used when issuing Interchain Account logic

Nearly all of Stride's functionality is built using interchain accounts (ICAs), which are a new functionality in Cosmos, and a critical component of IBC. ICAs allow accounts on Zone A to be controlled by Zone B. ICAs communicate with one another using Interchain Queries (ICQs), which involve Zone A querying Zone B for relevant information.
Nearly all of Stride's functionality is built using interchain accounts (ICAs), which are a new functionality in Cosmos, and a critical component of IBC. ICAs allow accounts on Zone A to be controlled by Zone B. ICAs communicate with one another using Interchain Queries (ICQs), which involve Zone A querying Zone B for relevant information.

Two Zones communicate via a connection and channel. All communications between the Controller Zone (the chain that is querying) and the Host Zone (the chain that is being queried) is done through a dedicated IBC channel between the two chains, which is opened the first time the two chains interact.

For context, ICS standards define that each channel is associated with a particular connection, and a connection may have any number of associated channels.

## Params

```
DepositInterval (default uint64 = 1)
DelegateInterval (default uint64 = 1)
Expand All @@ -29,11 +31,11 @@ RedemptionRateInterval (default uint64 = 1)
StrideCommission (default uint64 = 10)
ValidatorRebalancingThreshold (default uint64 = 100)
ICATimeoutNanos(default uint64 = 600000000000)
BufferSize (default uint64 = 5)
BufferSize (default uint64 = 5)
IbcTimeoutBlocks (default uint64 = 300)
FeeTransferTimeoutNanos (default uint64 = 1800000000000
SafetyMinRedemptionRateThreshold (default uint64 = 90)
SafetyMaxRedemptionRateThreshold (default uint64 = 150)
DefaultMinRedemptionRateThreshold (default uint64 = 90)
DefaultMaxRedemptionRateThreshold (default uint64 = 150)
MaxStakeICACallsPerEpoch (default uint64 = 100)
IBCTransferTimeoutNanos (default uint64 = 1800000000000)
SafetyNumValidators (default uint64 = 35)
Expand All @@ -56,30 +58,35 @@ SafetyNumValidators (default uint64 = 35)
## State

Callbacks
- `SplitDelegation`
- `DelegateCallback`
- `ClaimCallback`
- `ReinvestCallback`
- `UndelegateCallback`
- `RedemptionCallback`
- `Rebalancing`
- `RebalanceCallback`

- `SplitDelegation`
- `DelegateCallback`
- `ClaimCallback`
- `ReinvestCallback`
- `UndelegateCallback`
- `RedemptionCallback`
- `Rebalancing`
- `RebalanceCallback`

HostZone

- `HostZone`
- `ICAAccount`
- `MinValidatorRequirements`

Host Zone Validators

- `Validator`
- `ValidatorExchangeRate`

Misc

- `GenesisState`
- `EpochTracker`
- `Delegation`

Governance

- `AddValidatorProposal`

## Queries
Expand Down Expand Up @@ -107,14 +114,14 @@ Governance

`stakeibc` module emits the following events:

Type: Attribute Key &rarr; Attribute Value
--------------------------------------------------
## Type: Attribute Key &rarr; Attribute Value

registerHostZone: module &rarr; stakeibc
registerHostZone: connectionId &rarr; connectionId
registerHostZone: chainId &rarr; chainId
submitHostZoneUnbonding: hostZone &rarr; chainId
submitHostZoneUnbonding: hostZone &rarr; chainId
submitHostZoneUnbonding: newAmountUnbonding &rarr; totalAmtToUnbond
stakeExistingDepositsOnHostZone: hostZone &rarr; chainId
stakeExistingDepositsOnHostZone: newAmountStaked &rarr; amount
onAckPacket (IBC): module &rarr; moduleName
onAckPacket (IBC): module &rarr; moduleName
onAckPacket (IBC): ack &rarr; ackInfo

0 comments on commit 616b150

Please sign in to comment.