17
17
import score .Context ;
18
18
import score .DictDB ;
19
19
import score .annotation .External ;
20
+ import score .annotation .Optional ;
20
21
21
22
import java .math .BigInteger ;
22
23
import java .util .Arrays ;
@@ -120,7 +121,6 @@ public Map<String, byte[]> updateClient(String clientId, byte[] clientMessageByt
120
121
onlyHandler ();
121
122
ibc .lightclients .tendermint .v1 .Header tmHeader = ibc .lightclients .tendermint .v1 .Header .decode (clientMessageBytes );
122
123
boolean conflictingHeader = false ;
123
-
124
124
// Check if the Client store already has a consensus state for the header's
125
125
// height
126
126
// If the consensus state exists, and it matches the header then we return early
@@ -153,7 +153,8 @@ public Map<String, byte[]> updateClient(String clientId, byte[] clientMessageByt
153
153
// Header is different from existing consensus state and also valid, so freeze
154
154
// the client and return
155
155
if (conflictingHeader ) {
156
- clientState .setFrozenHeight (newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight ()));
156
+ BigInteger revision = getRevisionNumber (tmHeader .getSignedHeader ().getHeader ().getChainId ());
157
+ clientState .setFrozenHeight (newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight (), revision ));
157
158
encodedClientState = clientState .encode ();
158
159
clientStates .set (clientId , encodedClientState );
159
160
@@ -168,12 +169,13 @@ public Map<String, byte[]> updateClient(String clientId, byte[] clientMessageByt
168
169
"clientStateCommitment" , IBCCommitment .keccak256 (encodedClientState ),
169
170
"consensusStateCommitment" , IBCCommitment .keccak256 (encodedConsensusState ),
170
171
"height" ,
171
- newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight ()).encode ());
172
+ newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight (), revision ).encode ());
172
173
}
173
174
174
175
// update the consensus state from a new header and set processed time metadata
175
176
if (tmHeader .getSignedHeader ().getHeader ().getHeight ().compareTo (clientState .getLatestHeight ().getRevisionHeight ()) > 0 ) {
176
- clientState .setLatestHeight (newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight ()));
177
+ BigInteger revision = getRevisionNumber (tmHeader .getSignedHeader ().getHeader ().getChainId ());
178
+ clientState .setLatestHeight (newHeight (tmHeader .getSignedHeader ().getHeader ().getHeight (), revision ));
177
179
encodedClientState = clientState .encode ();
178
180
clientStates .set (clientId , encodedClientState );
179
181
}
0 commit comments