Skip to content

Commit

Permalink
Merge branch 'main' into feat/ibc-eureka
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein authored Nov 20, 2024
2 parents fe6a6dc + ae3dffb commit 798b892
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/release-tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ versions of ibc-go to guarantee that no regression is introduced -->
- [ ] In `docs/versions.json`.
- [ ] Rename `docs/versioned_sidebars/version-vx.y.z-sidebars.json`
- [ ] Rename `docs/versioned_docs/version-vx.y.z`
- [ ] Update the [compatibility test matrices](https://github.com/cosmos/ibc-go/tree/main/.github/compatibility-test-matrices):
- [ ] Ensure annotations on tests are correct as per the [compatibility test tool](../../scripts/compatibility.md):
- Add the new release.
- Remove any tags that might not be recommended anymore.
- [ ] Update the manual [e2e `simd`](https://github.com/cosmos/ibc-go/blob/main/.github/workflows/e2e-manual-simd.yaml) test workflow:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
if: ${{ inputs.build-and-push-docker-image }}
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }}

Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
if: ${{ inputs.build-and-push-docker-image-wasm }}
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME_WASM }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }}

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
})
}

// compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal:skip
// compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal:skip:true
func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulSubmitGovProposal() {
s.testMsgSendTxSuccessfulGovProposal(channeltypes.ORDERED)
}

// compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal_UnorderedChannel:skip
// compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal_UnorderedChannel:skip:true
func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulSubmitGovProposal_UnorderedChannel() {
s.testMsgSendTxSuccessfulGovProposal(channeltypes.UNORDERED)
}
Expand Down
15 changes: 0 additions & 15 deletions modules/core/23-commitment/types/bench_test.go

This file was deleted.

65 changes: 20 additions & 45 deletions modules/core/23-commitment/types/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package types
import (
"bytes"

"github.com/cosmos/gogoproto/proto"
ics23 "github.com/cosmos/ics23/go"

errorsmod "cosmossdk.io/errors"

cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"

"github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)
Expand Down Expand Up @@ -86,19 +83,16 @@ func ApplyPrefix(prefix exported.Prefix, path v2.MerklePath) (v2.MerklePath, err
// VerifyMembership verifies the membership of a merkle proof against the given root, path, and value.
// Note that the path is expected as []string{<store key of module>, <key corresponding to requested value>}.
func (proof MerkleProof) VerifyMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path, value []byte) error {
if err := proof.validateVerificationArgs(specs, root); err != nil {
return err
}

// VerifyMembership specific argument validation
mpath, ok := path.(v2.MerklePath)
if !ok {
return errorsmod.Wrapf(ErrInvalidProof, "path %v is not of type MerklePath", path)
}
if len(mpath.KeyPath) != len(specs) {
return errorsmod.Wrapf(ErrInvalidProof, "path length %d not same as proof %d",
len(mpath.KeyPath), len(specs))

if err := validateVerificationArgs(proof, mpath, specs, root); err != nil {
return err
}

// VerifyMembership specific argument validation
if len(value) == 0 {
return errorsmod.Wrap(ErrInvalidProof, "empty value in membership proof")
}
Expand All @@ -112,17 +106,13 @@ func (proof MerkleProof) VerifyMembership(specs []*ics23.ProofSpec, root exporte
// VerifyNonMembership verifies a chained proof where the absence of a given path is proven
// at the lowest subtree and then each subtree's inclusion is proved up to the final root.
func (proof MerkleProof) VerifyNonMembership(specs []*ics23.ProofSpec, root exported.Root, path exported.Path) error {
if err := proof.validateVerificationArgs(specs, root); err != nil {
return err
}

// VerifyNonMembership specific argument validation
mpath, ok := path.(v2.MerklePath)
if !ok {
return errorsmod.Wrapf(ErrInvalidProof, "path %v is not of type MerkleProof", path)
}
if len(mpath.KeyPath) != len(specs) {
return errorsmod.Wrapf(ErrInvalidProof, "path length %d not same as proof %d", len(mpath.KeyPath), len(specs))

if err := validateVerificationArgs(proof, mpath, specs, root); err != nil {
return err
}

// VerifyNonMembership will verify the absence of key in lowest subtree, and then chain inclusion proofs
Expand Down Expand Up @@ -198,40 +188,25 @@ func verifyChainedMembershipProof(root []byte, specs []*ics23.ProofSpec, proofs
return nil
}

// blankMerkleProof and blankProofOps will be used to compare against their zero values,
// and are declared as globals to avoid having to unnecessarily re-allocate on every comparison.
var (
blankMerkleProof = &MerkleProof{}
blankProofOps = &cmtcrypto.ProofOps{}
)

// Empty returns true if the root is empty
func (proof *MerkleProof) Empty() bool {
return proof == nil || proto.Equal(proof, blankMerkleProof) || proto.Equal(proof, blankProofOps)
}

// ValidateBasic checks if the proof is empty.
func (proof MerkleProof) ValidateBasic() error {
if proof.Empty() {
return ErrInvalidProof
}
return nil
}

// validateVerificationArgs verifies the proof arguments are valid
func (proof MerkleProof) validateVerificationArgs(specs []*ics23.ProofSpec, root exported.Root) error {
if proof.Empty() {
return errorsmod.Wrap(ErrInvalidMerkleProof, "proof cannot be empty")
// validateVerificationArgs verifies the proof arguments are valid.
// The merkle path and merkle proof contain a list of keys and their proofs
// which correspond to individual trees. The length of these keys and their proofs
// must equal the length of the given specs. All arguments must be non-empty.
func validateVerificationArgs(proof MerkleProof, path v2.MerklePath, specs []*ics23.ProofSpec, root exported.Root) error {
if proof.GetProofs() == nil {
return errorsmod.Wrap(ErrInvalidMerkleProof, "proof must not be empty")
}

if root == nil || root.Empty() {
return errorsmod.Wrap(ErrInvalidMerkleProof, "root cannot be empty")
}

if len(specs) != len(proof.Proofs) {
return errorsmod.Wrapf(ErrInvalidMerkleProof,
"length of specs: %d not equal to length of proof: %d",
len(specs), len(proof.Proofs))
return errorsmod.Wrapf(ErrInvalidMerkleProof, "length of specs: %d not equal to length of proof: %d", len(specs), len(proof.Proofs))
}

if len(path.KeyPath) != len(specs) {
return errorsmod.Wrapf(ErrInvalidProof, "path length %d not same as proof %d", len(path.KeyPath), len(specs))
}

for i, spec := range specs {
Expand Down
5 changes: 0 additions & 5 deletions modules/core/23-commitment/types/merkle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ func (suite *MerkleTestSuite) TestVerifyMembership() {
proof, err := types.ConvertProofs(res.ProofOps)
require.NoError(suite.T(), err)

suite.Require().NoError(proof.ValidateBasic())
suite.Require().Error(types.MerkleProof{}.ValidateBasic())

cases := []struct {
name string
root []byte
Expand Down Expand Up @@ -93,8 +90,6 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() {
proof, err := types.ConvertProofs(res.ProofOps)
require.NoError(suite.T(), err)

suite.Require().NoError(proof.ValidateBasic())

cases := []struct {
name string
root []byte
Expand Down
2 changes: 1 addition & 1 deletion scripts/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ The following annotations are supported:
|-------------------------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| from_version | v7.4.0 | Tests should only run if a semver comparison is greater than or equal to this version. Generally this will just be the minimum supported version of ibc-go | // compatibility:from_version:v7.4.0 |
| TEST_NAME:from_versions | v8.4.0,v8.5.0,v9.0.0 | For some tests, they should only be run against a specific release line. This annotation is test case specific, and ensures the test case is run based on the major and minor versions specified. If a version is provided to the tool, and a matching major minor version is not listed, the test will be skipped. | // compatibility:TestScheduleIBCUpgrade_Succeeds:from_versions: v8.4.0,v8.5.0,v9.0.0 |
| TEST_NAME:skip | skip | A flag to ensure that this test is not included in the compatibility tests at all. | // compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal:skip |
| TEST_NAME:skip | true | A flag to ensure that this test is not included in the compatibility tests at all. | // compatibility:TestMsgSendTx_SuccessfulSubmitGovProposal:skip:true |

> Note: if additional control is required, the script can be modified to support additional annotations.
2 changes: 1 addition & 1 deletion scripts/generate-compatibility-json.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _test_should_be_run(test_name: str, version: str, file_fields: Dict) -> bool
"""

# the test has been explicitly marked to be skipped for compatibility tests.
if file_fields.get(f"{test_name}:{SKIP}") is not None:
if file_fields.get(f"{test_name}:{SKIP}") == "true":
return False

test_semver_version = parse_version(version)
Expand Down

0 comments on commit 798b892

Please sign in to comment.