// 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 after the next // 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 4 at duration+6 (so older than height 5) // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -chainid=atomone-1 -header-time-shift=6 -height=4 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-4") // 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(4) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(6)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x7e\x5f\x1b\x68\x12\x02\x85\x0f\xee\x1d\x1c\x89\x68\xce\x2b\xb8\x88\xd7\x66\xbb\x95\xea\x18\x8f\x63\x4f\x81\x7b\x1c\xde\x64\xf2\x5f\x58\x6d\xdf\x0f\xee\xfd\x36\xff\xbf\x53\xa6\x5f\xb1\x43\xc8\x6e\xab\x1e\xf4\x10\xde\xeb\x11\xa6\xd9\xb4\x8e\x17\xaf\x58\x07"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\x2c\x7c\x13\xd8\x67\x5e\xdb\x77\xc9\xd1\x1a\x5b\x4f\x61\x09\xb6\xd5\x9a\x99\x13\x7b\xbc\xd3\x6a\x0f\x1c\x99\x7c\xaf\xb6\xb2\x5f\x78\xe0\x5b\x78\xf5\xd9\xe9\xa6\x42\xd7\xd7\x97\xb9\x8f\xb8\xaf\x23\x35\x3f\x65\x9a\xd7\x3a\x3f\x74\x7a\x08\x23\x2a\x3f\x41\x0d"), }, } 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"}