Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
fix: remove unnecessary height assertion (#116)
Browse files Browse the repository at this point in the history
* fix: remove unnecessary assertion

* imp: added exec report

* fix: e2e
  • Loading branch information
srdtrk authored Oct 14, 2024
1 parent 35b504c commit 3d6c5d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
9 changes: 0 additions & 9 deletions contracts/src/SP1ICS07Tendermint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ contract SP1ICS07Tendermint is
private
returns (uint256)
{
if (proofHeight.revisionNumber != clientState.latestHeight.revisionNumber) {
revert ProofHeightMismatch(
proofHeight.revisionNumber,
proofHeight.revisionHeight,
clientState.latestHeight.revisionNumber,
clientState.latestHeight.revisionHeight
);
}

SP1MembershipProof memory proof = abi.decode(proofBytes, (SP1MembershipProof));
if (proof.sp1Proof.vKey != MEMBERSHIP_PROGRAM_VKEY) {
revert VerificationKeyMismatch(MEMBERSHIP_PROGRAM_VKEY, proof.sp1Proof.vKey);
Expand Down
26 changes: 23 additions & 3 deletions e2e/interchaintestv8/operator/operator.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package operator

import (
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"os/exec"
"strconv"
Expand Down Expand Up @@ -63,7 +65,7 @@ func StartOperator(args ...string) error {
func UpdateClientAndMembershipProof(trusted_height, target_height uint64, paths string, args ...string) (*sp1ics07tendermint.IICS02ClientMsgsHeight, []byte, error) {
args = append([]string{"fixtures", "update-client-and-membership", "--trusted-block", strconv.FormatUint(trusted_height, 10), "--target-block", strconv.FormatUint(target_height, 10), "--key-paths", paths}, args...)

output, err := exec.Command("target/release/operator", args...).CombinedOutput()
output, err := execOperatorCommand(exec.Command("target/release/operator", args...))
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -133,9 +135,9 @@ func MisbehaviourProof(cdc codec.Codec, misbehaviour tmclient.Misbehaviour, writ
defer os.Remove(misbehaviourFileName)

args = append([]string{"fixtures", "misbehaviour", "--misbehaviour-path", misbehaviourFileName}, args...)
output, err := exec.Command("target/release/operator", args...).CombinedOutput()
output, err := execOperatorCommand(exec.Command("target/release/operator", args...))
if err != nil {
return nil, fmt.Errorf("operator misbehaviour failed: %w, output: %s", err, output)
return nil, err
}

// eliminate non-json characters
Expand Down Expand Up @@ -306,3 +308,21 @@ func marshalMisbehaviour(cdc codec.Codec, misbehaviour tmclient.Misbehaviour) ([

return json.Marshal(jsonIntermediary)
}

func execOperatorCommand(c *exec.Cmd) ([]byte, error) {
var outBuf bytes.Buffer

// Create a MultiWriter to write to both os.Stdout and the buffer
multiWriter := io.MultiWriter(os.Stdout, &outBuf)

// Set the command's stdout and stderror to the MultiWriter
c.Stdout = multiWriter
c.Stderr = multiWriter

// Run the command
if err := c.Run(); err != nil {
return nil, fmt.Errorf("operator command '%s' failed: %s", strings.Join(c.Args, " "), outBuf.String())
}

return outBuf.Bytes(), nil
}

0 comments on commit 3d6c5d4

Please sign in to comment.