// PKGPATH: gno.land/r/aib/main package main import ( "time" "gno.land/p/aib/ibc/lightclient/tendermint" tmtesting "gno.land/p/aib/ibc/lightclient/tendermint/testing" "gno.land/p/aib/ibc/types" "gno.land/r/aib/ibc/core" ) // UpdateClient with valid misbehaviour: // header1.height == header2.height && header1.Hash != header2.hash func main(cur realm) { // CreateClient and RegisterCounterparty var ( chainID = "atomone-1" height = uint64(2) clientState = tmtesting.NewClientState(chainID, types.NewHeight(1, height)) apphash = tmtesting.Hash("apphash-2") // priv=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A== val1 = tendermint.NewValidator("9DIBYr64rywKO3Kk6+743xDHcEU=", "VMpO0RzmZu4OMVvsniYdeO/2eP+h1xeoAcHBTZC7Gfw=", 10) // priv=nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== val2 = tendermint.NewValidator("y+naL3ubs9q1bXrY9+uRxY9c+J8=", "NeGV1CqewGUTpH5SxVRfkgYOMCVX84MyCslqtw9Ouvo=", 10) trustedValset = tendermint.NewValset(val1, val2) consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash()) ) clientID := core.CreateClient(cross(cur), clientState, consensusState) core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2") // Build valid misbehavior var header1, header2 *tendermint.MsgHeader // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -chainid=atomone-1 -header-time-shift=0 -height=4 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-4") valset = tendermint.NewValset(val1, val2) commitTimestamp = tmtesting.ToTime("2025-09-25T07:55:57.306746166Z") newHeight = uint64(4) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(0)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x2e\xba\x21\xb0\x2f\xd2\x85\xb9\xef\x82\x68\xdc\xef\xd1\xd1\x12\x70\x88\x94\x10\x7e\x4d\x49\xac\x46\x3d\x86\xe2\xf2\xae\x38\xb4\xa5\xab\x0c\xc1\x8f\x8a\x59\xda\x36\x17\x01\xe4\x16\x49\xbf\x03\x86\xf0\x31\x3f\x30\x37\x9e\x47\x28\x72\x3b\x0c\x89\xb9\x94\x05"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\x67\xcc\xc6\xc4\x20\xa0\xcb\x36\xaf\x33\x5c\xf8\xe4\xad\x47\x49\x38\x9d\x9e\xa3\x7c\xe6\x88\x81\x62\x51\x7f\xcc\xa5\x92\x0d\x98\xe9\xbe\x71\x2d\x22\xcd\x41\x30\x28\x83\x03\xcb\xf5\xd7\x28\xde\x7b\x92\x85\x9e\xa6\xe5\xde\x50\x89\x2d\x2b\xc5\x9d\x9a\x33\x00"), }, } ) header1 = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) } // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -apphash-seed=apphash-other -chainid=atomone-1 -header-time-shift=0 -height=4 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-other") valset = tendermint.NewValset(val1, val2) commitTimestamp = tmtesting.ToTime("2025-09-25T07:55:57.306746166Z") newHeight = uint64(4) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(0)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\xe8\x4a\xd3\x9a\x59\xf7\x95\xa4\xdc\x49\xb6\xac\x31\x29\x40\x35\x9d\x04\x06\xc1\x8e\xd1\x0e\xe9\x9f\xd3\x03\xcc\xd6\xb8\x9a\xb7\xa6\xca\xb8\xf6\xe5\xcb\x7e\x55\x14\xa2\x76\xa7\x96\x3f\x70\xed\x38\x8b\x53\x96\x15\xf0\x27\x23\xbc\xb6\x56\xc0\x11\x00\x5a\x05"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\xf2\xfe\x16\xb2\xdc\xe4\x19\x5c\x24\x79\x3f\x88\x84\x5a\x5a\xee\x9c\x62\x99\x60\x0f\x3d\x36\xaa\x14\x83\x21\x4c\xe5\x95\xe6\xad\x73\xd0\x7d\xfb\x0f\x04\x44\xe4\xd7\x2e\x57\xa1\x60\x8b\xfa\x0d\x42\x93\x97\x55\x25\x6e\x87\x92\x1c\x9b\xc1\xdf\x37\xed\xd8\x0f"), }, } ) header2 = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) } msg := &tendermint.Misbehaviour{ Header1: header1, Header2: header2, } core.UpdateClient(cross(cur), clientID, msg) println("----------- assert render clients") println(core.Render("clients")) println("----------- assert render clients/07-tendermint-1/consensus_states") println(core.Render("clients/" + clientID + "/consensus_states")) } // Output: // ----------- assert render clients // {"items":[{"id":"07-tendermint-1","type":"07-tendermint","creator":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","status":"Frozen","counterparty_client_id":"07-tendermint-2","counterparty_merke_prefix":["iavlStoreKey","prefix2"],"client_state":{"chain_id":"atomone-1","latest_height":{"revision_number":1,"revision_height":2},"frozen_height":{"revision_number":0,"revision_height":1},"trust_level":{"numerator":1,"denominator":3},"trusting_period":3600,"unbonding_period":10800,"max_clock_drift":3600,"upgrade_path":[]},"last_consensus_state":{"height":{"revision_number":1,"revision_height":2},"timestamp":1234567890,"root":"YAdxKyKDg+tUQc5Dli2fYkJ2imznqbJ+UDfQ7y0QNlM=","next_validators_hash":"cmlnaEh97r8fwZo58weAGWc3eqq+T3xXT9C88GVXRUc="}}],"page":1,"total":1} // ----------- assert render clients/07-tendermint-1/consensus_states // {"items":[{"height":{"revision_number":1,"revision_height":2},"timestamp":1234567890,"root":"YAdxKyKDg+tUQc5Dli2fYkJ2imznqbJ+UDfQ7y0QNlM=","next_validators_hash":"cmlnaEh97r8fwZo58weAGWc3eqq+T3xXT9C88GVXRUc="}],"page":1,"total":1} // Events: // [ // { // "type": "create_client", // "attrs": [ // { // "key": "client_id", // "value": "07-tendermint-1" // }, // { // "key": "client_type", // "value": "07-tendermint" // }, // { // "key": "consensus_heights", // "value": "1/2" // } // ], // "pkg_path": "gno.land/r/aib/ibc/core" // }, // { // "type": "client_misbehaviour", // "attrs": [ // { // "key": "client_id", // "value": "07-tendermint-1" // }, // { // "key": "client_type", // "value": "07-tendermint" // } // ], // "pkg_path": "gno.land/r/aib/ibc/core" // } // ]