Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update protos to IBC-Go v5.0.0 and Cosmos SDK v0.46.1 #24

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
![Rust Stable][rustc-image]
![Rust 1.56.1+][rustc-version]

Rust crate for interacting with Cosmos SDK
[IBC structs](https://github.com/cosmos/ibc-go/tree/main/proto/ibc).
Rust crate for interacting with Cosmos SDK [IBC structs](https://github.com/cosmos/ibc-go/tree/main/proto/ibc).

[Documentation][docs-link]

## Requirements

- Rust 1.56.1+
- `make`, `curl`
- Cosmos SDK (downloaded automatically if you are using `make`)
- [Buf CLI](https://buf.build/product/cli/)

## License

Copyright © 2021 Informal Systems
Copyright © 2022 Informal Systems

Licensed under the Apache License, Version 2.0 (the "License");
you may not use the files in this repository except in compliance with the License.
Expand Down
37 changes: 23 additions & 14 deletions scripts/sync-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ COSMOS_SDK_GIT="${COSMOS_SDK_GIT:-$CACHE_PATH/cosmos/cosmos-sdk.git}"
IBC_GO_GIT="${IBC_GO_GIT:-$CACHE_PATH/ibc-go.git}"


COSMOS_SDK_COMMIT="$(cat proto/src/COSMOS_SDK_COMMIT)"
IBC_GO_COMMIT="$(cat proto/src/IBC_GO_COMMIT)"
COSMOS_SDK_COMMIT="$(cat src/COSMOS_SDK_COMMIT)"
IBC_GO_COMMIT="$(cat src/IBC_GO_COMMIT)"

echo "COSMOS_SDK_COMMIT: $COSMOS_SDK_COMMIT"
echo "IBC_GO_COMMIT: $IBC_GO_COMMIT"
Expand All @@ -38,9 +38,9 @@ echo "IBC_GO_COMMIT: $IBC_GO_COMMIT"

if [[ "$COSMOS_SDK_COMMIT" =~ ^[a-zA-Z0-9]{40}$ ]]
then
SDK_COMMIT_OPTION="--sdk-commit"
SDK_COMMIT_OPTION="--sdk-commit"
else
SDK_COMMIT_OPTION="--sdk-tag"
SDK_COMMIT_OPTION="--sdk-tag"
fi

# If the git directories does not exist, clone them as
Expand All @@ -49,18 +49,18 @@ fi

if [[ ! -e "$COSMOS_SDK_GIT" ]]
then
echo "Cloning cosmos-sdk source code to as bare git repository to $COSMOS_SDK_GIT"
git clone --mirror https://github.com/cosmos/cosmos-sdk.git "$COSMOS_SDK_GIT"
echo "Cloning cosmos-sdk source code to as bare git repository to $COSMOS_SDK_GIT"
git clone --mirror https://github.com/cosmos/cosmos-sdk.git "$COSMOS_SDK_GIT"
else
echo "Using existing cosmos-sdk bare git repository at $COSMOS_SDK_GIT"
echo "Using existing cosmos-sdk bare git repository at $COSMOS_SDK_GIT"
fi

if [[ ! -e "$IBC_GO_GIT" ]]
then
echo "Cloning ibc-go source code to as bare git repository to $IBC_GO_GIT"
git clone --mirror https://github.com/cosmos/ibc-go.git "$IBC_GO_GIT"
echo "Cloning ibc-go source code to as bare git repository to $IBC_GO_GIT"
git clone --mirror https://github.com/cosmos/ibc-go.git "$IBC_GO_GIT"
else
echo "Using existing ibc-go bare git repository at $IBC_GO_GIT"
echo "Using existing ibc-go bare git repository at $IBC_GO_GIT"
fi

# Update the repositories using git fetch. This is so that
Expand All @@ -87,6 +87,10 @@ git checkout "$COSMOS_SDK_COMMIT"
# proto-compiler uses the branch name as the commit
# output. Otherwise it will just output HEAD
git checkout -b "$COSMOS_SDK_COMMIT"

cd proto
buf mod update
buf export -v -o ../proto-include
popd

IBC_GO_DIR=$(mktemp -d /tmp/ibc-go-XXXXXXXX)
Expand All @@ -95,16 +99,19 @@ pushd "$IBC_GO_DIR"
git clone "$IBC_GO_GIT" .
git checkout "$IBC_GO_COMMIT"
git checkout -b "$IBC_GO_COMMIT"

cd proto
buf export -v -o ../proto-include
popd

# Remove the existing generated protobuf files
# so that the newly generated code does not
# contain removed files.

rm -rf proto/src/prost
mkdir -p proto/src/prost
rm -rf src/prost
mkdir -p src/prost

cd proto-compiler
cd tools/proto-compiler

cargo build --locked

Expand All @@ -113,7 +120,9 @@ cargo build --locked
# and once for no-std version with --build-tonic set to false

cargo run --locked -- compile \
--sdk "$COSMOS_SDK_DIR" --ibc "$IBC_GO_DIR" --out ../proto/src/prost
--sdk "$COSMOS_SDK_DIR/proto-include" \
--ibc "$IBC_GO_DIR/proto-include" \
--out ../../src/prost

# Remove the temporary checkouts of the repositories

Expand Down
2 changes: 1 addition & 1 deletion src/COSMOS_SDK_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f2d94445c0f5f52cf5ed999b81048b575de94964
252c6736161e51342bb7dd6af984082a2b064742
2 changes: 1 addition & 1 deletion src/IBC_GO_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
efda07d984a65ad4099fc6d9c82f71a28d66a411
ed56c0b7bf64f44fb9e87ad2756bea1d6ca6ce54
Loading