@zuhaibnoor/zigchain-sdk 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/circuit/ChainCircuitApi.d.ts.map +1 -1
- package/dist/circuit/ChainCircuitApi.js.map +1 -1
- package/dist/consensus/ChainConsensusApi.d.ts +5 -0
- package/dist/consensus/ChainConsensusApi.d.ts.map +1 -1
- package/dist/consensus/ChainConsensusApi.js +16 -0
- package/dist/consensus/ChainConsensusApi.js.map +1 -1
- package/dist/consensus/types.d.ts +55 -0
- package/dist/consensus/types.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.d.ts.map +1 -1
- package/dist/dex/ChainDexApi.js.map +1 -1
- package/dist/distribution/ChainDistributionApi.d.ts.map +1 -1
- package/dist/distribution/ChainDistributionApi.js +0 -1
- package/dist/distribution/ChainDistributionApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/staking/ChainStakingApi.d.ts +1 -5
- package/dist/staking/ChainStakingApi.d.ts.map +1 -1
- package/dist/staking/ChainStakingApi.js +9 -7
- package/dist/staking/ChainStakingApi.js.map +1 -1
- package/dist/upgrade/ChainUpgradeApi.d.ts.map +1 -1
- package/dist/validator-set/ChainValidator.d.ts +8 -0
- package/dist/validator-set/ChainValidator.d.ts.map +1 -0
- package/dist/validator-set/ChainValidator.js +15 -0
- package/dist/validator-set/ChainValidator.js.map +1 -0
- package/docs/block.md +325 -38
- package/docs/circuit.md +164 -35
- package/docs/consensus.md +600 -0
- package/docs/dex.md +313 -63
- package/docs/distribution.md +664 -93
- package/docs/evidence.md +117 -122
- package/docs/factory.md +308 -62
- package/docs/gov.md +268 -70
- package/docs/ibc/ibcChannel.md +736 -249
- package/docs/ibc/ibcClient.md +608 -139
- package/docs/ibc-transfer.md +349 -90
- package/docs/interchain-accounts.md +151 -48
- package/docs/mint.md +173 -36
- package/docs/runtime.md +81 -42
- package/docs/slashing.md +209 -61
- package/docs/staking.md +534 -411
- package/docs/tokenwrapper.md +221 -64
- package/docs/txs.md +447 -0
- package/docs/upgrade.md +281 -58
- package/docs/validator-set.md +177 -0
- package/package.json +1 -1
- package/docs/comet-validator-set.md +0 -70
package/docs/evidence.md
CHANGED
|
@@ -1,18 +1,53 @@
|
|
|
1
1
|
# Evidence Module
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Evidence is used by the network to **prove validator misbehavior**, such as double-signing or light-client attacks, and is a critical part of the **slashing and security mechanism** in Cosmos-SDK–based chains like ZigChain.
|
|
3
|
+
## What is the Evidence Module?
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
The **Evidence module** is responsible for handling **cryptographic proof of validator misbehavior** on ZigChain.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
* List all submitted evidence (paginated)
|
|
7
|
+
It allows the chain to objectively verify faults such as:
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
* Double-signing (signing two different blocks at the same height)
|
|
10
|
+
* Or other consensus rule violations
|
|
11
|
+
|
|
12
|
+
Once verified, this evidence is forwarded to the **Slashing module**, which may:
|
|
13
|
+
|
|
14
|
+
* Slash validator stake
|
|
15
|
+
* Jail the validator
|
|
16
|
+
* Tombstone the validator (permanent ban)
|
|
17
|
+
|
|
18
|
+
This module is part of ZigChain’s **core security layer**.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Important Terminology
|
|
23
|
+
|
|
24
|
+
### Evidence
|
|
25
|
+
|
|
26
|
+
**Evidence** is a cryptographic proof that a validator violated consensus rules.
|
|
27
|
+
|
|
28
|
+
It contains enough data for the blockchain to independently verify the misbehavior without trusting any party.
|
|
29
|
+
|
|
30
|
+
Evidence is:
|
|
31
|
+
|
|
32
|
+
* Public
|
|
33
|
+
* Immutable once accepted
|
|
34
|
+
* Automatically processed by the chain
|
|
12
35
|
|
|
13
36
|
---
|
|
14
37
|
|
|
15
|
-
|
|
38
|
+
### Evidence Hash
|
|
39
|
+
|
|
40
|
+
Each evidence record has a **unique hash** that identifies it on-chain.
|
|
41
|
+
|
|
42
|
+
This hash is used to query a specific evidence record via:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
zigchaind query evidence evidence <hash>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Setup
|
|
16
51
|
|
|
17
52
|
```ts
|
|
18
53
|
import {
|
|
@@ -27,30 +62,39 @@ const evidenceApi = new ChainEvidenceApi(endpoints)
|
|
|
27
62
|
|
|
28
63
|
---
|
|
29
64
|
|
|
30
|
-
|
|
65
|
+
# 1️⃣ fetchEvidence
|
|
66
|
+
|
|
67
|
+
## Method
|
|
31
68
|
|
|
32
69
|
```ts
|
|
33
70
|
async fetchEvidence(hash: string)
|
|
34
71
|
```
|
|
35
72
|
|
|
36
|
-
|
|
73
|
+
## CLI Equivalent
|
|
37
74
|
|
|
38
75
|
```bash
|
|
39
76
|
zigchaind query evidence evidence <hash>
|
|
40
77
|
```
|
|
41
78
|
|
|
42
|
-
|
|
79
|
+
## Description
|
|
43
80
|
|
|
44
81
|
Fetches a **single evidence record** using its unique evidence hash.
|
|
45
|
-
This is useful when you already know an evidence hash (for example, from logs, explorers, or governance discussions) and want to inspect the exact misbehavior details.
|
|
46
82
|
|
|
47
|
-
|
|
83
|
+
This is useful when:
|
|
48
84
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
85
|
+
* You obtained a hash from logs or an explorer
|
|
86
|
+
* You are auditing a slashing event
|
|
87
|
+
* You are investigating validator misbehavior
|
|
52
88
|
|
|
53
|
-
|
|
89
|
+
If the hash does not exist, the chain will return an error.
|
|
90
|
+
|
|
91
|
+
## Parameters
|
|
92
|
+
|
|
93
|
+
| Name | Type | Description |
|
|
94
|
+
| ---- | ------ | ------------------------------------------- |
|
|
95
|
+
| hash | string | Unique hash identifying the evidence record |
|
|
96
|
+
|
|
97
|
+
## Usage Example
|
|
54
98
|
|
|
55
99
|
```ts
|
|
56
100
|
const evidence = await evidenceApi.fetchEvidence(
|
|
@@ -60,140 +104,91 @@ const evidence = await evidenceApi.fetchEvidence(
|
|
|
60
104
|
console.dir(evidence, { depth: null })
|
|
61
105
|
```
|
|
62
106
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* Inspect a **specific validator misbehavior**
|
|
66
|
-
* Debug or audit slashing events
|
|
67
|
-
* Explorer or monitoring tools
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## `fetchAllEvidence`
|
|
107
|
+
## Response Structure
|
|
72
108
|
|
|
73
109
|
```ts
|
|
74
|
-
|
|
110
|
+
{
|
|
111
|
+
evidence: {
|
|
112
|
+
type_url: string
|
|
113
|
+
value: any
|
|
114
|
+
}
|
|
115
|
+
}
|
|
75
116
|
```
|
|
76
117
|
|
|
77
|
-
|
|
118
|
+
### `evidence`
|
|
78
119
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
120
|
+
| Field | Description |
|
|
121
|
+
----------|------------|
|
|
122
|
+
| `type_url` | Identifies the evidence type (e.g., duplicate vote) |
|
|
123
|
+
| `value` | Evidence-specific structure (depends on type) |
|
|
82
124
|
|
|
83
|
-
|
|
125
|
+
## When to Use
|
|
84
126
|
|
|
85
|
-
|
|
86
|
-
|
|
127
|
+
* Debugging validator slashing
|
|
128
|
+
* Explorer implementations
|
|
129
|
+
* Governance/security monitoring
|
|
130
|
+
* Auditing historical faults
|
|
87
131
|
|
|
88
|
-
|
|
132
|
+
---
|
|
89
133
|
|
|
90
|
-
|
|
91
|
-
* Security dashboards
|
|
92
|
-
* Chain analytics tools
|
|
134
|
+
# 2️⃣ fetchAllEvidence
|
|
93
135
|
|
|
94
|
-
|
|
136
|
+
## Method
|
|
95
137
|
|
|
96
138
|
```ts
|
|
97
|
-
|
|
98
|
-
console.dir(allEvidence, { depth: null })
|
|
139
|
+
async fetchAllEvidence()
|
|
99
140
|
```
|
|
100
141
|
|
|
101
|
-
|
|
142
|
+
## CLI Equivalent
|
|
102
143
|
|
|
103
|
-
|
|
104
|
-
|
|
144
|
+
```bash
|
|
145
|
+
zigchaind query evidence list
|
|
146
|
+
```
|
|
105
147
|
|
|
106
|
-
|
|
148
|
+
## Description
|
|
107
149
|
|
|
108
|
-
|
|
150
|
+
Returns **all submitted evidence records** currently stored on-chain.
|
|
109
151
|
|
|
110
|
-
|
|
152
|
+
On ZigChain testnet, this typically returns:
|
|
111
153
|
|
|
112
|
-
```
|
|
154
|
+
```json
|
|
113
155
|
{
|
|
114
|
-
|
|
115
|
-
|
|
156
|
+
"evidence": [],
|
|
157
|
+
"pagination": {
|
|
158
|
+
"next_key": null,
|
|
159
|
+
"total": "0"
|
|
160
|
+
}
|
|
116
161
|
}
|
|
117
162
|
```
|
|
118
163
|
|
|
119
|
-
|
|
120
|
-
* `value` → Evidence-specific data (structure depends on evidence type)
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Summary Table
|
|
125
|
-
|
|
126
|
-
| Function | CLI Command | Purpose |
|
|
127
|
-
| ------------------ | ------------------------------------------ | -------------------------------- |
|
|
128
|
-
| `fetchEvidence` | `zigchaind query evidence evidence <hash>` | Query a specific evidence record |
|
|
129
|
-
| `fetchAllEvidence` | `zigchaind query evidence list` | List all submitted evidence |
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## How Evidence Works
|
|
134
|
-
|
|
135
|
-
### Who Submits Evidence?
|
|
136
|
-
|
|
137
|
-
Evidence is **not submitted by regular users**.
|
|
164
|
+
This simply means no validator misbehavior has been recorded.
|
|
138
165
|
|
|
139
|
-
|
|
166
|
+
## Parameters
|
|
140
167
|
|
|
141
|
-
|
|
142
|
-
* **Full nodes** that detect misbehavior
|
|
143
|
-
* **Light clients** (for light-client attack proofs)
|
|
144
|
-
|
|
145
|
-
In most cases, evidence is **automatically generated and broadcast** by the blockchain software when a validator’s misbehavior is detected.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
### What Does Evidence Contain?
|
|
150
|
-
|
|
151
|
-
Evidence is a **cryptographic proof** of validator misbehavior.
|
|
152
|
-
It contains enough information for the blockchain to **verify the fault without trust**.
|
|
153
|
-
|
|
154
|
-
Depending on the evidence type, it may include:
|
|
155
|
-
|
|
156
|
-
* Validator consensus address
|
|
157
|
-
* Block height at which misbehavior occurred
|
|
158
|
-
* Conflicting block headers or signatures
|
|
159
|
-
* Timestamp of the infraction
|
|
160
|
-
* Power (stake) of the validator at that time
|
|
161
|
-
|
|
162
|
-
Once verified, this evidence can trigger **slashing**, **jailing**, or **tombstoning** of the validator.
|
|
163
|
-
|
|
164
|
-
---
|
|
168
|
+
None.
|
|
165
169
|
|
|
166
|
-
|
|
170
|
+
## Usage Example
|
|
167
171
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
* **Light Client Attack Evidence**
|
|
174
|
-
Proof of malicious behavior aimed at misleading light clients.
|
|
175
|
-
|
|
176
|
-
Each evidence type is identified by its `type_url` field in the response.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
### Why Evidence Is Important
|
|
181
|
-
|
|
182
|
-
The Evidence module ensures:
|
|
183
|
-
|
|
184
|
-
* **Network security** through objective proof
|
|
185
|
-
* **Automatic punishment** without human intervention
|
|
186
|
-
* **Trustless verification** of validator behavior
|
|
187
|
-
|
|
188
|
-
Because evidence is cryptographically verifiable, it **cannot be faked or disputed** once accepted by the chain.
|
|
189
|
-
|
|
190
|
-
---
|
|
172
|
+
```ts
|
|
173
|
+
const allEvidence = await evidenceApi.fetchAllEvidence()
|
|
174
|
+
console.dir(allEvidence, { depth: null })
|
|
175
|
+
```
|
|
191
176
|
|
|
192
|
-
|
|
177
|
+
## Response Structure
|
|
193
178
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
179
|
+
```ts
|
|
180
|
+
{
|
|
181
|
+
evidence: Evidence[]
|
|
182
|
+
pagination: {
|
|
183
|
+
next_key: string | null
|
|
184
|
+
total: string
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
198
188
|
|
|
189
|
+
## When to Use
|
|
199
190
|
|
|
191
|
+
* Building blockchain explorers
|
|
192
|
+
* Monitoring validator behavior
|
|
193
|
+
* Security dashboards
|
|
194
|
+
---
|