Search Apps Documentation Source Content File Folder Download Copy Actions Download

zz_recover_client_example_filetest.gno

1.53 Kb · 39 lines
 1// PKGPATH: gno.land/r/aib/main
 2package main
 3
 4import (
 5	"gno.land/r/aib/ibc/core"
 6)
 7
 8func main(cur realm) {
 9	// Bootstrap so the test caller is the admin (RecoverClient is
10	// admin-gated; in production this is the deployer or, eventually,
11	// govDAO).
12	core.SetAdmin(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
13
14	// RecoverClient revives a Frozen or Expired subject client by copying
15	// state from a healthy substitute that tracks the same counterparty.
16	// Admin-gated. See recover-client.md for the full flow.
17	//
18	// Preconditions (panic otherwise):
19	//   - caller is the admin
20	//   - subject and substitute IDs differ
21	//   - both clients exist and have the same `typ` (e.g. 07-tendermint)
22	//   - subject.Status() ∈ {Frozen, Expired}
23	//   - substitute.Status() == Active
24	//   - their ClientStates match on TrustLevel, UnbondingPeriod,
25	//     MaxClockDrift, ProofSpecs, UpgradePath
26	//
27	// On success, ChainID / LatestHeight / TrustingPeriod from the
28	// substitute are copied into the subject, FrozenHeight is reset, and
29	// the substitute's consensus state at its LatestHeight is stored in
30	// the subject. Packet commitments, receipts, acks, sequence counters
31	// and counterparty registration on the subject are untouched.
32	subjectClientID := "07-tendermint-1"    // XXX update — Frozen/Expired client to revive
33	substituteClientID := "07-tendermint-2" // XXX update — healthy client tracking the same chain
34
35	core.RecoverClient(cross(cur), subjectClientID, substituteClientID)
36}
37
38// Error:
39// subject client 07-tendermint-1 not found