Skip to content

Commit

Permalink
tendermint: fix waitForCommit to avoid empty proof error at `ProveS…
Browse files Browse the repository at this point in the history
…tate`

Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Oct 16, 2023
1 parent e73877c commit 17b6fcd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chains/tendermint/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ func (c *Chain) waitForCommit(txHash string) (*coretypes.ResultTx, error) {
return retry.Unrecoverable(err)
}
}
// In a tendermint chain, when the latest height of the chain is N+1,
// proofs of states updated up to height N are available.
// In order to make the proof of the state updated by a tx available just after `sendMsgs`,
// `waitForCommit` must wait until the latest height is greater than the tx height.
if height, err := c.LatestHeight(); err != nil {
return fmt.Errorf("failed to obtain latest height: %v", err)
} else if height.GetRevisionHeight() <= uint64(resTx.Height) {
return fmt.Errorf("latest_height(%v) is less than or equal to tx_height(%v) yet", height, resTx.Height)
}
return nil
}, retry.Attempts(maxRetry), retry.Delay(retryInterval), rtyErr); err != nil {
return resTx, fmt.Errorf("failed to make sure that tx is committed: %v", err)
Expand Down

0 comments on commit 17b6fcd

Please sign in to comment.