Skip to content
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
1 change: 0 additions & 1 deletion .gitbook/defi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
description: >-
This section helps traders to learn more about trading instruments and start
trading on Injective
icon: coins
---

# DeFi
Expand Down
2 changes: 1 addition & 1 deletion .gitbook/developers-cosmwasm.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
icon: comet

---

# Cosmwasm Developers
Expand Down
2 changes: 1 addition & 1 deletion .gitbook/developers-defi.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
icon: money-bill-transfer

---

# DeFi Developers
Expand Down
2 changes: 1 addition & 1 deletion .gitbook/developers-evm.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
icon: rectangle-code

---

# EVM Developers
Expand Down
2 changes: 1 addition & 1 deletion .gitbook/developers-native.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
icon: microchip

---

# Native Developers
Expand Down
76 changes: 39 additions & 37 deletions .gitbook/developers-native/core/circuit.mdx
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# Circuit
# `x/circuit`

## Concepts

Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use hyphenated "app-specific" as a compound adjective.

When modifying noun phrases with multiple adjectives, use hyphens to join them. Replace "app specific" with "app-specific".

- Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications. 
+ Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app-specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
Circuit Breaker is a module that is meant to avoid a chain needing to halt/shut down in the presence of a vulnerability, instead the module will allow specific messages or all messages to be disabled. When operating a chain, if it is app-specific then a halt of the chain is less detrimental, but if there are applications built on top of the chain then halting is expensive due to the disturbance to applications.
🧰 Tools
🪛 LanguageTool

[grammar] ~5-~5: Use a hyphen to join words.
Context: ...ed. When operating a chain, if it is app specific then a halt of the chain is les...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In .gitbook/developers-native/core/circuit.mdx around line 5, the phrase "app
specific" is used as a compound adjective; replace it with the hyphenated form
"app-specific" to conform to compound-adjective style (i.e., change "if it is
app specific then" to "if it is app-specific then").


Circuit Breaker works with the idea that an address or set of addresses have the right to block messages from being executed and/or included in the mempool. Any address with a permission is able to reset the circuit breaker for the message.
Circuit Breaker works with the idea that an address or set of addresses have the right to block messages from being executed and/or included in the mempool. Any address with a permission is able to reset the circuit breaker for the message.

The transactions are checked and can be rejected at two points:

* In `CircuitBreakerDecorator` [ante handler](https://docs.cosmos.network/main/learn/advanced/baseapp#antehandler):

```go
```go reference
https://github.com/cosmos/cosmos-sdk/blob/x/circuit/v0.1.0/x/circuit/ante/circuit.go#L27-L41
```
```

* With a [message router check](https://docs.cosmos.network/main/learn/advanced/baseapp#msg-service-router):

```go
```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.50.1/baseapp/msg_service_router.go#L104-L115
```
```

:::note\
The `CircuitBreakerDecorator` works for most use cases, but [does not check the inner messages of a transaction](https://docs.cosmos.network/main/learn/beginner/tx-lifecycle#antehandler). This some transactions (such as `x/authz` transactions or some `x/gov` transactions) may pass the ante handler. **This does not affect the circuit breaker** as the message router check will still fail the transaction.\
This tradeoff is to avoid introducing more dependencies in the `x/circuit` module. Chains can re-define the `CircuitBreakerDecorator` to check for inner messages if they wish to do so.\
:::note
The `CircuitBreakerDecorator` works for most use cases, but [does not check the inner messages of a transaction](https://docs.cosmos.network/main/learn/beginner/tx-lifecycle#antehandler). This some transactions (such as `x/authz` transactions or some `x/gov` transactions) may pass the ante handler. **This does not affect the circuit breaker** as the message router check will still fail the transaction.
This tradeoff is to avoid introducing more dependencies in the `x/circuit` module. Chains can re-define the `CircuitBreakerDecorator` to check for inner messages if they wish to do so.
:::

## State

### Accounts

* AccountPermissions `0x1 | account_address -> ProtocolBuffer(CircuitBreakerPermissions)`
* AccountPermissions `0x1 | account_address -> ProtocolBuffer(CircuitBreakerPermissions)`

```go
type level int32
Expand Down Expand Up @@ -57,15 +57,16 @@ type Access struct {
}
```


### Disable List

List of type urls that are disabled.

* DisableList `0x2 | msg_type_url -> []byte{}`
* DisableList `0x2 | msg_type_url -> []byte{}` {/* - should this be stored in json to skip encoding and decoding each block, does it matter? */}

## State Transitions

### Authorize
### Authorize

Authorize, is called by the module authority (default governance module account) or any account with `LEVEL_SUPER_ADMIN` to give permission to disable/enable messages to another account. There are three levels of permissions that can be granted. `LEVEL_SOME_MSGS` limits the number of messages that can be disabled. `LEVEL_ALL_MSGS` permits all messages to be disabled. `LEVEL_SUPER_ADMIN` allows an account to take all circuit breaker actions including authorizing and deauthorizing other accounts.

Expand Down Expand Up @@ -98,7 +99,7 @@ Reset is called by an authorized account to enable execution for a specific msgU

### MsgAuthorizeCircuitBreaker

```protobuf
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L25-L75
```

Expand All @@ -108,7 +109,7 @@ This message is expected to fail if:

### MsgTripCircuitBreaker

```protobuf
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L77-L93
```

Expand All @@ -118,51 +119,52 @@ This message is expected to fail if:

### MsgResetCircuitBreaker

```protobuf
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/circuit/v1/tx.proto#L95-109
```

This message is expected to fail if:

* if the type url is not disabled

## Events - list and describe event tags
## Events - list and describe event tags

The circuit module emits the following events:

### Message Events

#### MsgAuthorizeCircuitBreaker

| Type | Attribute Key | Attribute Value |
| ------- | ------------- | --------------------------- |
| string | granter | {granterAddress} |
| string | grantee | {granteeAddress} |
| string | permission | {granteePermissions} |
| message | module | circuit |
| message | action | authorize\_circuit\_breaker |
| Type | Attribute Key | Attribute Value |
|---------|---------------|---------------------------|
| string | granter | `{granterAddress}` |
| string | grantee | `{granteeAddress}` |
| string | permission | `{granteePermissions}` |
| message | module | `circuit` |
| message | action | `authorize_circuit_breaker` |

#### MsgTripCircuitBreaker

| Type | Attribute Key | Attribute Value |
| --------- | ------------- | ---------------------- |
| string | authority | {authorityAddress} |
| \[]string | msg\_urls | \[]string{msg\_urls} |
| message | module | circuit |
| message | action | trip\_circuit\_breaker |
| Type | Attribute Key | Attribute Value |
|----------|---------------|--------------------|
| string | authority | `{authorityAddress}` |
| []string | msg_urls | `[]string{msg_urls}` |
| message | module | `circuit` |
| message | action | `trip_circuit_breaker` |

#### ResetCircuitBreaker

| Type | Attribute Key | Attribute Value |
| --------- | ------------- | ----------------------- |
| string | authority | {authorityAddress} |
| \[]string | msg\_urls | \[]string{msg\_urls} |
| message | module | circuit |
| message | action | reset\_circuit\_breaker |
| Type | Attribute Key | Attribute Value |
|----------|---------------|--------------------|
| string | authority | `{authorityAddress}` |
| []string | msg_urls | `[]string{msg_urls}` |
| message | module | `circuit` |
| message | action | `reset_circuit_breaker` |


## Keys - list of key prefixes used by the circuit module

* `AccountPermissionPrefix` - `0x01`
* `DisableListPrefix` - `0x02`
* `DisableListPrefix` - `0x02`

## Client - list and describe CLI commands and gRPC and REST endpoints
58 changes: 29 additions & 29 deletions .gitbook/developers-native/core/crisis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@
sidebar_position: 1
---

# Crisis
# `x/crisis`

## Overview

The crisis module halts the blockchain under the circumstance that a blockchain\
invariant is broken. Invariants can be registered with the application during the\
The crisis module halts the blockchain under the circumstance that a blockchain
invariant is broken. Invariants can be registered with the application during the
application initialization process.

## Contents

* [State](./#state)
* [Messages](./#messages)
* [Events](./#events)
* [Parameters](./#parameters)
* [Client](./#client)
* [CLI](./#cli)
* [State](#state)
* [Messages](#messages)
* [Events](#events)
* [Parameters](#parameters)
* [Client](#client)
* [CLI](#cli)

## State

### ConstantFee

Due to the anticipated large gas cost requirement to verify an invariant (and\
potential to exceed the maximum allowable block gas limit) a constant fee is\
used instead of the standard gas consumption method. The constant fee is\
intended to be larger than the anticipated gas cost of running the invariant\
Due to the anticipated large gas cost requirement to verify an invariant (and
potential to exceed the maximum allowable block gas limit) a constant fee is
used instead of the standard gas consumption method. The constant fee is
intended to be larger than the anticipated gas cost of running the invariant
with the standard gas consumption method.

The ConstantFee param is stored in the module params state with the prefix of `0x01`,\
The ConstantFee param is stored in the module params state with the prefix of `0x01`,
it can be updated with governance or the address with authority.

* Params: `mint/params -> legacy_amino(sdk.Coin)`

## Messages

In this section we describe the processing of the crisis messages and the\
In this section we describe the processing of the crisis messages and the
corresponding updates to the state.

### MsgVerifyInvariant

Blockchain invariants can be checked using the `MsgVerifyInvariant` message.

```protobuf
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/crisis/v1beta1/tx.proto#L26-L42
```

Expand All @@ -52,10 +52,10 @@ This message is expected to fail if:
* the sender does not have enough coins for the constant fee
* the invariant route is not registered

This message checks the invariant provided, and if the invariant is broken it\
panics, halting the blockchain. If the invariant is broken, the constant fee is\
never deducted as the transaction is never committed to a block (equivalent to\
being refunded). However, if the invariant is not broken, the constant fee will\
This message checks the invariant provided, and if the invariant is broken it
panics, halting the blockchain. If the invariant is broken, the constant fee is
never deducted as the transaction is never committed to a block (equivalent to
being refunded). However, if the invariant is not broken, the constant fee will
not be refunded.

## Events
Expand All @@ -66,20 +66,20 @@ The crisis module emits the following events:

#### MsgVerifyInvariance

| Type | Attribute Key | Attribute Value |
| --------- | ------------- | ----------------- |
| invariant | route | {invariantRoute} |
| message | module | crisis |
| message | action | verify\_invariant |
| message | sender | {senderAddress} |
| Type | Attribute Key | Attribute Value |
|-----------|---------------|------------------|
| invariant | route | `{invariantRoute}` |
| message | module | `crisis` |
| message | action | `verify_invariant` |
| message | sender | `{senderAddress}` |

## Parameters

The crisis module contains the following parameters:

| Key | Type | Example |
| ----------- | ------------- | --------------------------------- |
| ConstantFee | object (coin) | {"denom":"uatom","amount":"1000"} |
|-------------|---------------|-----------------------------------|
| ConstantFee | object (coin) | `{"denom":"uatom","amount":"1000"}` |

## Client

Expand All @@ -95,7 +95,7 @@ The `tx` commands allow users to interact with the `crisis` module.
simd tx crisis --help
```

**invariant-broken**
##### invariant-broken

The `invariant-broken` command submits proof when an invariant was broken to halt the chain

Expand Down
Loading