// PKGPATH: gno.land/r/aib/main package main import ( "testing" "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 bc trusted header time > now+trustingPeriod 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") // Increase block time ctx := testing.GetContext() ctx.Time = time.Now().Add(clientState.TrustingPeriod / 2) testing.SetContext(ctx) // Update clientID // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -apphash-seed=apphash-3 -chainid=atomone-1 -header-time-shift=30 -height=3 -new-validators=0 -privkeys=8a6cAbQSpDbebmcTEhCMPhhr/SkL/2pizo60yzHRkN9Uyk7RHOZm7g4xW+yeJh147/Z4/6HXF6gBwcFNkLsZ/A==,nWg6ETc62tyxd94lh8fFaQnZKaAW6vlS0L/4lfseJuI14ZXUKp7AZROkflLFVF+SBg4wJVfzgzIKyWq3D066+g== { var ( apphash = tmtesting.Hash("apphash-3") valset = tendermint.NewValset(val1, val2) commitTimestamp = tmtesting.ToTime("2025-09-25T07:55:57.306746166Z") newHeight = uint64(3) newTimestamp = consensusState.Timestamp.Add(time.Minute * time.Duration(30)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x6e\x67\x16\x43\xb9\x51\x74\x78\x24\x83\x57\x8d\x62\x42\x97\x6c\xc7\x41\xcf\x1e\x92\x33\x53\x34\x8f\xe9\xa2\xb5\x76\x6a\xad\xa9\x01\x1f\x90\xd5\x31\x1f\x09\x97\xc2\x90\x90\x2c\x48\x99\x37\x54\x38\xb5\x50\xee\xc0\x99\xaf\x0f\x68\xae\x2b\x17\x21\x59\x3e\x08"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\x43\x20\x1c\xa1\xec\x64\xb4\xe8\x3c\xcb\x66\x80\x7c\x7e\x5b\x31\xdd\x85\x16\xad\x32\x0b\x45\x3a\xf7\xbb\x65\x03\xd8\xcd\x9c\x7b\xdd\x76\x65\xa2\xbb\x45\xe9\x72\x96\x99\x2d\x35\x71\x62\x3c\x0a\x2f\x87\x77\xd2\x60\xb8\x77\xe8\x06\x0d\x24\x96\xae\x5b\xc1\x0f"), }, } msgHeader = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) ) core.UpdateClient(cross(cur), clientID, msgHeader) } // Increase block time again, now the initial trusted header is expired. ctx.Time = time.Now().Add(clientState.TrustingPeriod / 2) testing.SetContext(ctx) // Perform an other update which references the initial trusted height which // is now older than TrustingPeriod. // NOTE we need to reference a height that is not the latest height to // trigger this error, otherwise we would get an other error: the client // expired error. // NOTE code generated by: // go run -C ./cmd/gen-block-signatures . -apphash-seed=apphash-4 -chainid=atomone-1 -header-time-shift=60 -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(60)) nextValset = tendermint.NewValset(val1, val2) trustedHeight = clientState.LatestHeight signatures = []tendermint.CommitSig{ { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[0].Address, Timestamp: commitTimestamp, Signature: []byte("\x62\x9a\x39\xdd\x10\x62\x30\xd9\x3e\xd1\x34\xe6\x12\x9a\x58\x68\x19\xbb\x2d\x9c\xe1\x84\xbf\xab\x91\x0f\xf9\xfa\x6e\xa7\xe9\x30\xde\x2e\xde\xd3\xed\x5e\xf4\x7a\xf3\xae\xfb\x7c\x0f\xc1\xb2\x9d\x06\xa3\x05\x62\x2f\x06\xdb\x68\x0c\xc3\xd3\xfc\xed\x94\x42\x05"), }, { BlockIDFlag: tendermint.BlockIDFlagCommit, ValidatorAddress: valset.Validators[1].Address, Timestamp: commitTimestamp, Signature: []byte("\x35\x6b\x6a\xbd\xf5\x14\x9c\xad\xd1\xef\xd6\x37\x97\xb8\x0b\x92\x4b\x48\xd5\x11\x50\xb4\xd0\x0e\x6e\xac\x9d\x98\x1c\xb3\x9e\x71\x6c\x73\x28\x72\x75\x62\xb6\x5a\x15\x60\x71\x6b\x75\x55\x02\x5d\xd9\xd7\xcc\xc1\x05\xef\xf5\xfe\x95\x5f\xbc\x89\x93\x70\x64\x04"), }, } msgHeader = tmtesting.NewMsgHeader( chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset, signatures, ) ) core.UpdateClient(cross(cur), clientID, msgHeader) } } // Error: // header 2 has expired at 2009-02-14 00:31:30 +0000 UTC (now: 2009-02-14 00:31:30 +0000 UTC)