Skip to content

Commit

Permalink
Where validation of the merkle transaction inclusion proof has failed…
Browse files Browse the repository at this point in the history
…, when the block contains a single transaction and the block header root hash matches the transaction hash itself, accept the transaction as valid.
  • Loading branch information
svenski123 committed Aug 10, 2023
1 parent 344a865 commit 56bb4eb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions helper/query.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package helper

import (
"bytes"
"context"
"encoding/hex"
"fmt"
Expand Down Expand Up @@ -112,6 +113,16 @@ func ValidateTxResult(cliCtx cosmosContext.CLIContext, resTx *ctypes.ResultTx) e
}

err = resTx.Proof.Validate(check.Header.DataHash)

// Accept if only one tx in block and data hash matches tx hash
if err != nil &&
check.Header.NumTxs == 1 &&
bytes.Equal(check.Header.DataHash, resTx.Hash) &&
bytes.Equal(check.Header.DataHash, resTx.Tx.Hash()) &&
resTx.Index == 0 {
err = nil
}

if err != nil {
return err
}
Expand Down

0 comments on commit 56bb4eb

Please sign in to comment.