// 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 fails new consensus state timestamp is before the previous // consensus state. 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") // Add height 5 at duration+5 // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -chainid=atomone-1 -header-time-shift=5 -height=5 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-5") // 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) valset = tendermint.NewValset(val1, val2) commitTimestamp = tmtesting.ToTime("2025-09-25T07:55:57.306746166Z") newHeight = uint64(5) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(5)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x84\x70\x8b\xba\x3d\x32\xd2\xb9\xed\xcd\x3c\x36\x1e\xc0\xf4\xc1\x93\x20\x2e\xc7\xfe\x6a\x9f\xdf\xe7\x21\x47\x9e\xe6\x42\xb8\x23\x56\xd5\x51\xa0\x67\x83\x74\x13\xb3\xb1\xcd\x3f\x71\xd5\x51\x76\xce\xbe\x0f\x24\x02\x04\x98\xc8\xc1\xce\x4c\xfb\x04\x02\xbf\x04"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\x2f\xdb\x5e\xdd\xec\xd2\x1a\x8f\xd6\x7f\x56\xcb\x87\x00\x1e\x0b\x1b\xbb\xa6\xcc\xb7\x2e\x87\xca\x59\x4f\x00\xa2\xf1\xd1\xef\xe8\xc5\x29\x43\xba\x0e\xeb\xed\x35\x23\x12\xdb\x1e\x21\x6f\xcb\xd3\xe7\x00\xce\xcd\x0e\x9c\x45\xad\xb6\xae\xe2\x96\x07\xe8\x4b\x0b"), }, } msgHeader = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) ) core.UpdateClient(cross(cur), clientID, msgHeader) } // Add height 6 at duration+4 (so younger than height 5) // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -chainid=atomone-1 -header-time-shift=4 -height=6 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-6") // 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) valset = tendermint.NewValset(val1, val2) commitTimestamp = tmtesting.ToTime("2025-09-25T07:55:57.306746166Z") newHeight = uint64(6) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(4)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x35\xa1\x03\x5d\xf9\x9d\xd0\x6f\x9c\x4f\xcc\xea\xd2\x8f\xcb\x0c\x2c\x80\xce\xe9\x8d\x67\xd2\x39\x35\x86\xcd\x42\xe7\xf1\xb2\xee\xdb\xcb\xf6\xf2\x72\x46\xe5\xaf\x82\x3f\x71\x80\xcf\x67\xee\xe2\xc2\x2f\x12\x26\xa0\x71\x1f\x19\xf3\x12\x9d\x4b\x2b\x67\xd0\x0c"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\xf1\xad\xcb\x25\x02\x38\xc6\xf5\x05\x3c\x77\x16\x9b\xe7\xcc\x19\xc9\x98\x27\xd6\xf0\x14\xf1\xd0\xdb\xdb\x94\x8c\x69\x5c\x20\x93\x4c\xdb\xe6\x19\xc7\x65\x8a\x3a\xfa\xd5\xe8\x99\xb4\x0b\xaa\xef\xf3\x51\xd1\x9f\x1a\x4c\x5c\x05\x1e\xec\xc8\x50\x1f\x63\x6c\x05"), }, } msgHeader = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) ) core.UpdateClient(cross(cur), clientID, msgHeader) } println("----------- assert render client status") println(core.Render("clients/" + clientID + "/status")) // client should be frozen } // Output: // ----------- assert render client status // {"status":"Frozen"}